remove bindata, update name, add new bootstrap + mithril
[arvados.git] / services / boot / js / index.js
index 5915b9249ee0ec2e2f7dc2db2cb6fd24a81dd9e4..9e8452fe793f0e95623a819aea0a82e650f40663 100644 (file)
@@ -1,2 +1,50 @@
 // application entry point
+window.jQuery = require('jquery')
+window.Tether = require('tether')
+require('bootstrap')
 require('./example.js')
+var m = require('mithril')
+var Stream = require('mithril/stream')
+
+var checklist = [
+    {
+        name: 'arvados-boot web gui',
+        api: null,
+        lastCheck: (new Date()).valueOf(),
+        error: Stream(null),
+        response: Stream('ok'),
+    },
+    {
+        name: 'arvados-boot web backend',
+        api: '/api/ping',
+    },
+    {
+        name: 'arvados-boot fail canary',
+        api: '/api/error',
+    },
+]
+
+checklist.map(function(check) {
+    if (!check.api) return
+    if (!check.response) check.response = Stream()
+    if (!check.error) check.error = Stream()
+    m.request({method: 'GET', url: check.api}).then(check.response).catch(check.error)
+})
+
+var Home = {
+    view: function(vnode) {
+        return m('.panel', checklist.map(function(check) {
+            return m('div.alert',
+                     {class: (!check.response() || check.error()) ? 'alert-danger' : 'alert-success'}, 
+                     [
+                         check.name,
+                         ': ',
+                         JSON.stringify(check.response()),
+                     ])
+        }))
+    }
+}
+
+m.route(document.getElementById('app'), '/', {
+    '/': Home,
+})