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

Side by Side Diff: appengine/config_service/ui/src/config-ui/config-set.html

Issue 2971033003: Added force refresh to the config set page. (Closed)
Patch Set: Nit: put css attributes in alphabetical order Created 3 years, 5 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
1 <!-- 1 <!--
2 Copyright 2017 The LUCI Authors. All rights reserved. 2 Copyright 2017 The LUCI Authors. All rights reserved.
3 Use of this source code is governed under the Apache License, Version 2.0 3 Use of this source code is governed under the Apache License, Version 2.0
4 that can be found in the LICENSE file. 4 that can be found in the LICENSE file.
5 --> 5 -->
6 6
7 <link rel="import" href="config-file-card.html"> 7 <link rel="import" href="config-file-card.html">
8 <link rel="import" href="../../bower_components/iron-ajax/iron-ajax.html"> 8 <link rel="import" href="../../bower_components/iron-ajax/iron-ajax.html">
9 <link rel="import" href="../../bower_components/iron-icons/iron-icons.html">
9 <link rel="import" href="../../bower_components/paper-item/paper-item.html"> 10 <link rel="import" href="../../bower_components/paper-item/paper-item.html">
10 <link rel="import" href="../../bower_components/polymer/polymer.html"> 11 <link rel="import" href="../../bower_components/polymer/polymer.html">
11 12
12 <dom-module id="config-set"> 13 <dom-module id="config-set">
13 <template> 14 <template>
14 <style> 15 <style>
15 .category { 16 .category {
16 font-size: 100%; 17 font-size: 100%;
17 font-family: sans-serif; 18 font-family: sans-serif;
18 } 19 }
19 20
20 .center { 21 .center {
21 width: 27%; 22 width: 27%;
22 margin: auto; 23 margin: auto;
23 text-align: left; 24 text-align: left;
24 } 25 }
25 26
26 .name { 27 .name {
27 font-size: 200%; 28 font-size: 200%;
28 font-family: sans-serif; 29 font-family: sans-serif;
29 } 30 }
30 31
32 #refreshStatus {
33 font-size: 35%;
34 }
35
31 .title { 36 .title {
32 padding-bottom: 1%; 37 padding-bottom: 1%;
33 padding-top: 5%; 38 padding-top: 5%;
34 } 39 }
35 </style> 40 </style>
36 41
37 <iron-ajax 42 <iron-ajax
38 auto 43 auto
39 id="requestConfigs" 44 id="requestConfigs"
40 url="/_ah/api/config/v1/config-sets?config_set=[[category]]/[[name]][[ro ute.path]]&include_files=true" 45 url="/_ah/api/config/v1/config-sets?config_set=[[category]]/[[name]][[ro ute.path]]&include_files=true"
41 handle-as="json" 46 handle-as="json"
42 on-response="_onGotConfigFiles" 47 on-response="_onGotConfigFiles"
43 headers="[[auth_headers]]"> 48 headers="[[auth_headers]]">
44 </iron-ajax> 49 </iron-ajax>
45 50
51 <iron-ajax
52 id="refreshConfigs"
53 url="/_ah/api/config/v1/reimport?config_set=[[category]]/[[name]][[route .path]]"
54 method="POST"
55 handle-as="json"
56 on-error="_onRefreshError"
57 on-response="_onCompleteRefresh"
58 headers="[[auth_headers]]">
59 </iron-ajax>
60
46 <div class="center title"> 61 <div class="center title">
47 <div class="name">[[name]][[route.path]]</div> 62 <div class="name">
63 [[name]][[route.path]]
64 <iron-icon icon="icons:refresh" on-tap="_forceRefresh"></iron-icon>
65 <span id="refreshStatus"></span>
66 </div>
48 <div class="category">[[_formatCategory(category)]]</div> 67 <div class="category">[[_formatCategory(category)]]</div>
49 </div> 68 </div>
50 69 <template is="dom-if" if="[[isRefreshing]]">
51 <template is="dom-if" if="[[isLoading]]"> 70 <div class="center">Refreshing config files...</div>
52 <div class="center">Fetching config files...</div>
53 </template> 71 </template>
54 <template is="dom-if" if="[[!isLoading]]"> 72 <template is="dom-if" if="[[!isRefreshing]]">
55 <template is="dom-repeat" items="[[files]]" as="file"> 73 <template is="dom-if" if="[[isLoading]]">
56 <config-file-card 74 <div class="center">Fetching config files...</div>
57 name="[[file.path]]" link="[[location]]/[[file.path]]"> 75 </template>
58 </config-file-card> 76 <template is="dom-if" if="[[!isLoading]]">
77 <template is="dom-repeat" items="[[files]]" as="file">
78 <config-file-card
79 name="[[file.path]]" link="[[location]]/[[file.path]]">
80 </config-file-card>
81 </template>
59 </template> 82 </template>
60 </template> 83 </template>
61 </template> 84 </template>
62 <script> 85 <script>
63 Polymer({ 86 Polymer({
64 is: "config-set", 87 is: "config-set",
65 88
66 properties: { 89 properties: {
67 category: { 90 category: {
68 type: String 91 type: String
69 }, 92 },
70 93
71 files: { 94 files: {
72 type: Array 95 type: Array
73 }, 96 },
74 97
75 isLoading: { 98 isLoading: {
76 type: Boolean, 99 type: Boolean,
77 value: true 100 value: true
78 }, 101 },
79 102
103 isRefreshing: {
104 type: Boolean,
105 value: false
106 },
107
80 location: { 108 location: {
81 type: String 109 type: String
82 }, 110 },
83 111
84 name: { 112 name: {
85 type: String 113 type: String
86 } 114 }
87 }, 115 },
88 116
117 _forceRefresh: function() {
118 this.$.refreshConfigs.generateRequest();
119 this.isRefreshing = true;
120 },
121
89 _formatCategory: function(category) { 122 _formatCategory: function(category) {
90 if (category === "projects") return "Project"; 123 if (category === "projects") return "Project";
91 if (category === "services") return "Service"; 124 if (category === "services") return "Service";
92 }, 125 },
93 126
127 _onCompleteRefresh: function() {
128 this.isRefreshing = false;
129 var status = this.$.refreshStatus;
130 status.innerHTML = "Refresh successful.";
131 setTimeout(function() {
Ryan Tseng 2017/07/05 23:45:02 I don't think we'll need this, error messages shou
cwpayton 2017/07/06 02:03:40 Done.
132 status.innerHTML = "";
133 }, 2000);
134 },
135
94 _onGotConfigFiles: function(event) { 136 _onGotConfigFiles: function(event) {
95 this.files = event.detail.response.config_sets[0].files; 137 this.files = event.detail.response.config_sets[0].files;
96 this.location = event.detail.response.config_sets[0].location; 138 this.location = event.detail.response.config_sets[0].location;
97 this.isLoading = false; 139 this.isLoading = false;
140 },
141
142 _onRefreshError: function() {
143 this.isRefreshing = false;
144 var status = this.$.refreshStatus;
145 status.innerHTML = "Error: Files could not be refreshed.";
146 setTimeout(function() {
147 status.innerHTML = "";
148 }, 2000);
98 } 149 }
99 }); 150 });
100 </script> 151 </script>
101 </dom-module> 152 </dom-module>
OLDNEW
« appengine/config_service/ui/bower.json ('K') | « appengine/config_service/ui/bower.json ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698