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

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

Issue 2959833002: config_service: add last import validation and tests (Closed)
Patch Set: Include a bug number for making the element call on-response handler automatically. 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/iron-icons/iron-icons.html">
10 <link rel="import" href="../../bower_components/paper-item/paper-item.html"> 10 <link rel="import" href="../../bower_components/paper-item/paper-item.html">
11 <link rel="import" href="../../bower_components/polymer/polymer.html"> 11 <link rel="import" href="../../bower_components/polymer/polymer.html">
12 <link rel="import" href="../../bower_components/iron-icons/maps-icons.html">
12 13
13 <dom-module id="config-set"> 14 <dom-module id="config-set">
14 <template> 15 <template>
15 <style> 16 <style>
16 .category { 17 .category {
17 font-size: 100%; 18 font-size: 100%;
18 font-family: sans-serif; 19 font-family: sans-serif;
19 } 20 }
20 21
21 .center { 22 .center {
(...skipping 13 matching lines...) Expand all
35 36
36 .title { 37 .title {
37 padding-bottom: 1%; 38 padding-bottom: 1%;
38 padding-top: 5%; 39 padding-top: 5%;
39 } 40 }
40 </style> 41 </style>
41 42
42 <iron-ajax 43 <iron-ajax
43 auto 44 auto
44 id="requestConfigs" 45 id="requestConfigs"
45 url="/_ah/api/config/v1/config-sets?config_set=[[category]]/[[name]][[ro ute.path]]&include_files=true" 46 url="/_ah/api/config/v1/config-sets?config_set=[[category]]%2F[[name]][[ route.path]]&include_files=true&include_last_import_attempt=true"
46 handle-as="json" 47 handle-as="json"
47 on-response="_onGotConfigFiles" 48 on-response="_onGotConfigFiles"
48 headers="[[auth_headers]]"> 49 headers="[[auth_headers]]">
49 </iron-ajax> 50 </iron-ajax>
50 51
51 <iron-ajax 52 <iron-ajax
52 id="refreshConfigs" 53 id="refreshConfigs"
53 url="/_ah/api/config/v1/reimport?config_set=[[category]]/[[name]][[route .path]]" 54 url="/_ah/api/config/v1/reimport?config_set=[[category]]/[[name]][[route .path]]"
54 method="POST" 55 method="POST"
55 handle-as="json" 56 handle-as="json"
56 on-error="_onRefreshError" 57 on-error="_onRefreshError"
57 on-response="_onCompleteRefresh" 58 on-response="_onCompleteRefresh"
58 headers="[[auth_headers]]"> 59 headers="[[auth_headers]]">
59 </iron-ajax> 60 </iron-ajax>
60 61
61 <div class="center title"> 62 <div class="center title">
62 <div class="name"> 63 <div class="name">
63 [[name]][[route.path]] 64 [[name]][[route.path]]
64 <template is="dom-if" if="[[auth_headers]]"> 65 <template is="dom-if" if="[[_not(isLoading)]]">
66 <template is="dom-if" if="[[lastImportAttempt]]">
67 <template is="dom-if" if="[[lastImportAttempt.success]]">
68 <iron-icon id="valid" icon="icons:check-circle"></iron-icon>
69 </template>
70 <template is="dom-if" if="[[_not(lastImportAttempt.success)]]">
71 <iron-icon id="invalid" icon="icons:warning"></iron-icon>
72 </template>
73 </template>
74 <template is="dom-if" if="[[_not(lastImportAttempt)]]">
75 <iron-icon icon="icons:help"></iron-icon>
76 </template>
77 </template>
78 <template is="dom-if" if="[[auth_headers]]">
65 <iron-icon icon="icons:refresh" on-tap="_forceRefresh"></iron-icon> 79 <iron-icon icon="icons:refresh" on-tap="_forceRefresh"></iron-icon>
66 <span id="refreshStatus">[[refreshMessage]]</span> 80 <span id="refreshStatus">[[refreshMessage]]</span>
67 </template> 81 </template>
68 </div> 82 </div>
69 <div class="category">[[_formatCategory(category)]]</div> 83 <div class="category">
84 [[_formatCategory(category)]] <br>
85 <template is="dom-if" if="[[_not(isLoading)]]">
86 <template is="dom-if" if="[[lastImportAttempt]]">
87 <template is="dom-if" if="[[_not(lastImportAttempt.success)]]">
88 Last import attempt failed: [[lastImportAttempt.message]]
89 </template>
90 </template>
91 <template is="dom-if" if="[[_not(lastImportAttempt)]]">
92 Last import attempt info not available.
93 </template>
94 </template>
95 </div>
70 </div> 96 </div>
71 <template is="dom-if" if="[[isRefreshing]]"> 97 <template is="dom-if" if="[[isRefreshing]]">
72 <div class="center">Refreshing config files...</div> 98 <div class="center">Refreshing config files...</div>
73 </template> 99 </template>
74 <template is="dom-if" if="[[!isRefreshing]]"> 100 <template is="dom-if" if="[[_not(isRefreshing)]]">
75 <template is="dom-if" if="[[isLoading]]"> 101 <template is="dom-if" if="[[isLoading]]">
76 <div class="center">Fetching config files...</div> 102 <div class="center">Fetching config files...</div>
77 </template> 103 </template>
78 <template is="dom-if" if="[[!isLoading]]"> 104 <template is="dom-if" if="[[_not(isLoading)]]">
79 <template is="dom-repeat" items="[[files]]" as="file"> 105 <template is="dom-if" if="[[_isEmpty(files)]]">
80 <config-file-card 106 <div class="center" style="font-family: sans-serif;">
81 name="[[file.path]]" link="[[location]]/[[file.path]]"> 107 No config files found.
82 </config-file-card> 108 </div>
109 </template>
110 <template is="dom-if" if="[[_not(_isEmpty(files))]]">
111 <template is="dom-repeat" items="[[files]]" as="file">
112 <config-file-card
113 name="[[file.path]]" link="[[location]]/[[file.path]]">
114 </config-file-card>
115 </template>
83 </template> 116 </template>
84 </template> 117 </template>
85 </template> 118 </template>
86 </template> 119 </template>
87 <script> 120 <script>
88 Polymer({ 121 Polymer({
89 is: "config-set", 122 is: "config-set",
90 123
91 properties: { 124 properties: {
125
126 frontPageIsActive: {
127 type: Boolean,
128 observer: '_frontPageIsActive'
129 },
130
92 category: { 131 category: {
93 type: String 132 type: String
94 }, 133 },
95 134
96 files: { 135 files: {
97 type: Array 136 type: Array
98 }, 137 },
99 138
100 isLoading: { 139 isLoading: {
101 type: Boolean, 140 type: Boolean,
102 value: true 141 value: true
103 }, 142 },
104 143
105 isRefreshing: { 144 isRefreshing: {
106 type: Boolean, 145 type: Boolean,
107 value: false 146 value: false
108 }, 147 },
109 148
149 lastImportAttempt: {
150 type: Object
151 },
152
110 location: { 153 location: {
111 type: String 154 type: String
112 }, 155 },
113 156
114 name: { 157 name: {
115 type: String 158 type: String
116 }, 159 },
117 160
118 refreshMessage: { 161 refreshMessage: {
119 type: String, 162 type: String,
120 value: null 163 value: null
121 } 164 }
122 }, 165 },
123 166
124 _forceRefresh: function() { 167 _forceRefresh: function() {
125 this.refreshMessage = null; 168 this.refreshMessage = null;
126 this.$.refreshConfigs.generateRequest(); 169 this.$.refreshConfigs.generateRequest();
127 this.isRefreshing = true; 170 this.isRefreshing = true;
128 }, 171 },
129 172
173 _frontPageIsActive: function() {
174 if (this.frontPageIsActive === false) {
175 this.isLoading = true;
176 this.$.requestConfigs.generateRequest();
177 }
178 },
179
180 ready: function() {
181 this.isLoading = true;
182 },
183
184 _isEmpty: function(list) {
185 return list.length === 0;
186 },
187
130 _formatCategory: function(category) { 188 _formatCategory: function(category) {
131 if (category === "projects") return "Project"; 189 if (category === "projects") return "Project";
132 if (category === "services") return "Service"; 190 if (category === "services") return "Service";
133 }, 191 },
134 192
135 _onCompleteRefresh: function() { 193 _onCompleteRefresh: function() {
136 this.isRefreshing = false; 194 this.isRefreshing = false;
137 this.refreshMessage = "Refresh successful."; 195 this.refreshMessage = "Refresh successful.";
138 }, 196 },
139 197
198 _not: function(b) {
199 return !b;
200 },
201
140 _onGotConfigFiles: function(event) { 202 _onGotConfigFiles: function(event) {
141 this.files = event.detail.response.config_sets[0].files; 203 this.files = event.detail.response.config_sets[0].files || [];
142 this.location = event.detail.response.config_sets[0].location; 204 this.location = event.detail.response.config_sets[0].location;
205 this.lastImportAttempt =
206 event.detail.response.config_sets[0].last_import_attempt || null;
143 this.isLoading = false; 207 this.isLoading = false;
144 }, 208 },
145 209
146 _onRefreshError: function() { 210 _onRefreshError: function() {
147 this.isRefreshing = false; 211 this.isRefreshing = false;
148 this.refreshMessage = "Error: Files could not be refreshed."; 212 this.refreshMessage = "Error: Files could not be refreshed.";
149 } 213 }
150 }); 214 });
151 </script> 215 </script>
152 </dom-module> 216 </dom-module>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698