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

Side by Side Diff: appengine/config_service/ui/common/common-behaviors.html

Issue 2991013002: config_service: Added revision and timestamp to config-set-cards and config-set pages (Closed)
Patch Set: Nit: forgot to add launch icon to config set page Created 3 years, 4 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 unified diff | Download patch
OLDNEW
(Empty)
1 <!--
2 Copyright 2017 The LUCI Authors. All rights reserved.
3 Use of this source code is governed under the Apache License, Version 2.0
4 that can be found in the LICENSE file.
5
6 It contains the definition of the following Behaviors:
7
8 ConfigUIBehaviors.CommonBehavior
9
10 To use it, include
11 behaviors: [ConfigUIBehaviors.CommonBehavior]
12 in the creation of any Polymer element.
13
14 ConfigUIBehaviors.CommonBehavior contains shared methods to ease
15 templating, such _isEmpty() and _not(), as well as general utility methods
16 such as _formatDate and _getTimestamp.
17 -->
18
19 <script>
20 window.ConfigUIBehaviors = window.ConfigUIBehaviors || {};
21 (function(){
22 // This behavior wraps up all the shared config UI functionality.
23 ConfigUIBehaviors.CommonBehavior = {
Sergey Berezin 2017/07/31 20:21:18 Could you add unittests for these functions?
cwpayton 2017/07/31 23:40:52 Done.
24
25 _formatDate: function(timestamp) {
26 var date = new Date(timestamp / 1000);
27 var month = date.getMonth() + 1;
28 if (month < 10) {
29 month = "0" + month;
30 }
31 var day = date.getDate();
32 if (day < 10) {
33 day = "0" + day;
34 }
35 var hours = date.getHours();
36 if (hours < 10) {
37 hours = "0" + hours;
38 }
39 var minutes = date.getMinutes();
40 if (minutes < 10) {
41 minutes = "0" + minutes;
42 }
43 return month + "/" + day + "/" + date.getFullYear() +
44 " " + hours + ":" + minutes;
Sergey Berezin 2017/07/31 20:21:18 Why not just use date.toString()? In particular, i
cwpayton 2017/07/31 23:40:52 Done.
45 },
46
47 _frontPageIsActive: function() {
48 if (this.frontPageIsActive === false) {
49 this.isLoading = true;
50 if (!this.initialized) {
51 document.addEventListener('fetch-configs', function() {
52 this.$.requestConfigs.generateRequest();
53 }.bind(this));
54 } else {
55 this.$.requestConfigs.generateRequest();
56 }
57 }
58 },
59
60 _getTimestamp: function(lastImportAttempt, revision) {
61 if (lastImportAttempt && lastImportAttempt.success) {
62 return this._formatDate(lastImportAttempt.revision.timestamp);
63 } else if (revision && revision.timestamp) {
64 return this._formatDate(revision.timestamp);
65 } else {
66 return "Not Found"
67 }
68 },
69
70 _getRevision: function(revision) {
71 if (revision) {
72 return revision.id;
73 } else {
74 return "Not Found"
75 }
76 },
77
78 _isEmpty: function(list) {
79 return list.length === 0;
80 },
81
82 _not: function(a) {
83 return !a;
84 },
85 };
86 })();
87 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698