Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(538)

Unified Diff: appengine/swarming/elements/res/imp/stats/stats-overview.html

Issue 2367413003: Update Stats element to use new directory layout (Closed) Base URL: git@github.com:luci/luci-py@master
Patch Set: rebase Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: appengine/swarming/elements/res/imp/stats/stats-overview.html
diff --git a/appengine/swarming/elements/res/imp/stats/stats-overview.html b/appengine/swarming/elements/res/imp/stats/stats-overview.html
index ca09ea3b2f8ab8b62d1c125bf4900d0d59024a80..707509eba06894b26382cc7184edc47e39daf9b7 100644
--- a/appengine/swarming/elements/res/imp/stats/stats-overview.html
+++ b/appengine/swarming/elements/res/imp/stats/stats-overview.html
@@ -1,12 +1,14 @@
<!--
-# Copyright 2016 The LUCI Authors. All rights reserved.
-# Use of this source code is governed by the Apache v2.0 license that can be
-# found in the LICENSE file.
+ Copyright 2016 The LUCI Authors. All rights reserved.
+ Use of this source code is governed under the Apache License, Version 2.0
+ that can be found in the LICENSE file.
+
+ For more on Google Charts and the data format, see https://developers.google.com/chart/interactive/docs/datatables_dataviews
-->
-<link rel="import" href="/imp/bower_components/polymer/polymer.html">
-<link rel="import" href="/imp/bower_components/iron-ajax/iron-ajax.html">
-<link rel="import" href="/imp/bower_components/iron-flex-layout/iron-flex-layout-classes.html">
+<link rel="import" href="/res/imp/bower_components/polymer/polymer.html">
+<link rel="import" href="/res/imp/bower_components/iron-ajax/iron-ajax.html">
+<link rel="import" href="/res/imp/bower_components/iron-flex-layout/iron-flex-layout-classes.html">
<link rel="import" href="load-charts-api.html">
<link rel="import" href="partial-line-chart.html">
@@ -58,8 +60,17 @@
is: 'stats-overview',
properties: {
// input
+ // TODO(kjlubick): Update the stats endpoints to use OAuth.
+ auth_headers: {
+ type: Object,
+ }
//output
+ busy: {
+ type: Boolean,
+ value: false,
+ notify: true,
+ },
data_table: {
type: Object,
computed: "_extractData(response,charts_api_loaded)",
@@ -88,6 +99,30 @@
},
_extractData: function (_response, ready) {
+ // Times are coming in like Date(2016,4,13,12,10,0) which is supposed
+ // to be UTC but the browser interprets as browser local time. We fix
+ // the dates to be parsed as UTC and the partial-line-chart will show
+ // times in browser local time.
+ var table = _response.table;
+ // Our data looks like https://developers.google.com/chart/interactive/docs/datesandtimes#dates-and-times-using-the-date-string-representation
+ // i.e.
+ // rows: [
+ // {c: [v: "Date(2016,8,23,14,35,0)", v: ...]}
+ // {c: ... }
+ // ]
+ // and we parse the first part of each datum, the Date.
+ // TODO(kjlubick): Is there a cleaner way to do this server side?
+ table.rows.forEach(function(r) {
+ var time = r.c[0].v;
+ if (time.startsWith && time.startsWith("Date")) {
+ // Remove the Date() wrapper
+ time = time.substring(5, time.length-1);
+ // Split into an array of arguments
+ time = time.split(",");
+ // Parse and store.
+ r.c[0].v = new Date(Date.UTC(...time))
+ }
+ });
return _response.table;
},
});

Powered by Google App Engine
This is Rietveld 408576698