| <!-- |
| The common.js file must be included before this file. |
| |
| This in an HTML Import-able file that contains the definition |
| of the following elements: |
| |
| <tree-status-sk> |
| |
| This element occasionally polls the tree, displaying the status and exposing |
| the active roles (sherrif, wrangler, robocop, trooper) through various |
| properties. |
| |
| To use this file import it: |
| |
| <link href="/res/imp/tree-status-sk.html" rel="import" /> |
| |
| Usage: |
| |
| <tree-status-sk></tree-status-sk> |
| |
| Properties: |
| // input |
| reload: How often (in seconds) to reload the tree status. |
| |
| // output |
| sheriff: Who is the current sheriff |
| wrangler: Who is the current gpu wrangler |
| robocop: Who is the current android robocop |
| trooper: Who is the current infra trooper |
| --> |
| <link rel="import" href="/res/imp/bower_components/iron-ajax/iron-ajax.html"> |
| |
| <link rel="import" href="/res/common/imp/timer-sk.html"> |
| |
| <dom-module id="tree-status-sk"> |
| <template> |
| <style> |
| a { |
| color: inherit; |
| } |
| #container { |
| text-align: center; |
| width: 100%; |
| } |
| span.nowrap { |
| white-space: nowrap; |
| } |
| </style> |
| <iron-ajax |
| id="status" |
| auto url="https://skia-tree-status.appspot.com/banner-status" |
| params='{"format":"json"}' |
| handle-as="json" |
| last-response="{{_bannerStatus}}"> |
| </iron-ajax> |
| <iron-ajax |
| id="sheriff" |
| auto url="https://skia-tree-status.appspot.com/current-sheriff" |
| params='{"format":"json"}' |
| handle-as="json" |
| last-response="{{_sheriffStatus}}"> |
| </iron-ajax> |
| <iron-ajax id="wrangler" |
| auto url="https://skia-tree-status.appspot.com/current-gpu-sheriff" |
| params='{"format":"json"}' |
| handle-as="json" |
| last-response="{{_wranglerStatus}}"> |
| </iron-ajax> |
| <iron-ajax id="robocop" |
| auto url="https://skia-tree-status.appspot.com/current-robocop" |
| params='{"format":"json"}' |
| handle-as="json" |
| last-response="{{_robocopStatus}}"> |
| </iron-ajax> |
| <iron-ajax id="trooper" |
| auto url="https://skia-tree-status.appspot.com/current-trooper" |
| params='{"format":"json"}' |
| handle-as="json" |
| last-response="{{_trooperStatus}}"> |
| </iron-ajax> |
| <timer-sk period="[[reload]]" on-trigger="_reload"></timer-sk> |
| <div id="container"> |
| <span><a href="https://skia-tree-status.appspot.com" target="_blank">{{_message}}</a></span> |
| <span class="nowrap"> |
| [{{_author}} |
| {{_timeSince}} ago] |
| </span> |
| </div> |
| </template> |
| <script> |
| Polymer({ |
| is:"tree-status-sk", |
| |
| properties: { |
| // input |
| reload: { |
| type: Number, |
| value: 60, |
| }, |
| |
| // output |
| open: { |
| type: String, |
| computed: "_getStatus(_bannerStatus)", |
| notify: true, |
| }, |
| sheriff: { |
| type: String, |
| computed: "_getName(_sheriffStatus)", |
| notify: true, |
| }, |
| wrangler: { |
| type: String, |
| computed: "_getName(_wranglerStatus)", |
| notify: true, |
| }, |
| robocop: { |
| type: String, |
| computed: "_getName(_robocopStatus)", |
| notify: true, |
| }, |
| trooper: { |
| type: String, |
| computed: "_getName(_trooperStatus)", |
| notify: true, |
| }, |
| |
| //private |
| _message: { |
| type: String, |
| computed: "_getMessage(_bannerStatus)", |
| }, |
| _author: { |
| type: String, |
| computed: "_getName(_bannerStatus)", |
| }, |
| _timeSince: { |
| type: String, |
| computed: "_getTime(_bannerStatus)", |
| }, |
| |
| _bannerStatus: { |
| type: Object |
| }, |
| _sheriffStatus: { |
| type: Object |
| }, |
| _wranglerStatus: { |
| type: Object |
| }, |
| _robocopStatus: { |
| type: Object |
| }, |
| _trooperStatus: { |
| type: Object |
| }, |
| }, |
| |
| _getMessage: function(status) { |
| if (!status || !status.message) { |
| return "(loading)"; |
| } |
| return status.message; |
| }, |
| |
| _getName: function(status) { |
| if (!status || !status.username) { |
| return "(loading)"; |
| } |
| return status.username.split("@")[0]; |
| }, |
| |
| _getStatus: function(status) { |
| if (!status || !status.general_state) { |
| return "open"; |
| } |
| return status.general_state; |
| }, |
| |
| _getTime: function(status) { |
| if (!status || !status.date) { |
| return "eons"; |
| } |
| return sk.human.diffDate(status.date + " UTC"); |
| }, |
| |
| _reload: function() { |
| this.$.status.generateRequest(); |
| this.$.robocop.generateRequest(); |
| this.$.trooper.generateRequest(); |
| this.$.wrangler.generateRequest(); |
| this.$.sheriff.generateRequest(); |
| }, |
| |
| }); |
| </script> |
| |
| </dom-module> |