diff options
author | Kazuki Yamaguchi <k@rhe.jp> | 2015-08-02 16:24:59 +0900 |
---|---|---|
committer | Kazuki Yamaguchi <k@rhe.jp> | 2015-08-02 16:24:59 +0900 |
commit | 001ffeb91f3862d16b88f673efd8d095be3c3c71 (patch) | |
tree | f00eacc349cdf84be8eb8a7b4e78dc83bdd088ac /app/assets/javascripts | |
parent | 1a10e04aa84f741eadad4818e74c9328e86f034f (diff) | |
parent | 7a91591b92bfd86aa7c45705027a6be7f7270202 (diff) | |
download | aclog-001ffeb91f3862d16b88f673efd8d095be3c3c71.tar.gz |
Merge branch 'master' of gitlab.rhe.jp:rhenium/aclog
Diffstat (limited to 'app/assets/javascripts')
-rw-r--r-- | app/assets/javascripts/controllers/about.coffee.erb | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/app/assets/javascripts/controllers/about.coffee.erb b/app/assets/javascripts/controllers/about.coffee.erb index 79688e0..b72c0d0 100644 --- a/app/assets/javascripts/controllers/about.coffee.erb +++ b/app/assets/javascripts/controllers/about.coffee.erb @@ -5,3 +5,41 @@ Views.about = node.onclick = (e) -> e.preventDefault() Helpers.openTwitterIntent(node.getAttribute("href")) + status: -> + vm = new Vue + el: "#status" + data: + nodes: {} + active_nodes: [] + inactive_nodes: [] + loading: false + error: null + methods: + uptime: (i) -> + diff = Math.floor(Date.now() / 1000) - this.nodes[i].activated_at + if diff < 5 * 60 + diff.toString() + " seconds" + else if diff < 5 * 60 * 60 + Math.floor(diff / 60).toString() + " minutes" + else if diff < 48 * 60 * 60 + Math.floor(diff / 60 / 60).toString() + " hours" + else + Math.floor(diff / 60 / 60 / 24).toString() + " days" + reload: (e = null) -> + e.preventDefault() if e + return if vm.loading + vm.loading = true + superagent + .get "/i/status.json" + .accept "json" + .end (err, res) -> + json = res.body + vm.loading = false + if json.error + vm.error = json.error + else + vm.error = null + vm.nodes = json.nodes + vm.active_nodes = json.active_nodes + vm.inactive_nodes = json.inactive_nodes + vm.reload() |