| OLD | NEW |
| 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/paper-spinner/paper-spinner.html
"> | 11 <link rel="import" href="../../bower_components/paper-spinner/paper-spinner.html
"> |
| 12 <link rel="import" href="../../bower_components/polymer/polymer.html"> | 12 <link rel="import" href="../../bower_components/polymer/polymer.html"> |
| 13 <link rel="import" href="../../bower_components/iron-icons/maps-icons.html"> | 13 <link rel="import" href="../../bower_components/iron-icons/maps-icons.html"> |
| 14 <link rel="import" href="../../bower_components/paper-tooltip/paper-tooltip.html
"> | 14 <link rel="import" href="../../bower_components/paper-tooltip/paper-tooltip.html
"> |
| 15 | 15 |
| 16 <dom-module id="config-set"> | 16 <dom-module id="config-set"> |
| 17 <template> | 17 <template> |
| 18 <style> | 18 <style> |
| 19 .spinner { | 19 @media only screen and (min-width: 768px) { |
| 20 text-align: center; | 20 .center { |
| 21 width: 550px; |
| 22 } |
| 21 } | 23 } |
| 22 | 24 |
| 23 .category { | 25 .category { |
| 24 font-size: 100%; | 26 font-size: 100%; |
| 25 font-family: sans-serif; | 27 font-family: sans-serif; |
| 26 } | 28 } |
| 27 | 29 |
| 30 .name { |
| 31 font-size: 200%; |
| 32 font-family: sans-serif; |
| 33 word-wrap: break-word; |
| 34 } |
| 35 |
| 28 .center { | 36 .center { |
| 29 width: 20%; | |
| 30 margin: auto; | 37 margin: auto; |
| 31 text-align: left; | 38 text-align: left; |
| 32 } | 39 } |
| 33 | 40 |
| 34 .config-card { | 41 .config-card { |
| 35 padding-bottom: 1%; | 42 padding-bottom: 1%; |
| 36 animation: fadein 1.5s; | 43 animation: fadein 1.5s; |
| 37 } | 44 } |
| 38 | 45 |
| 39 @keyframes fadein { | 46 @keyframes fadein { |
| 40 from {opacity: 0} | 47 from {opacity: 0} |
| 41 to {opacity: 1} | 48 to {opacity: 1} |
| 42 } | 49 } |
| 43 | 50 |
| 44 .name { | |
| 45 font-size: 200%; | |
| 46 font-family: sans-serif; | |
| 47 word-wrap: break-word; | |
| 48 } | |
| 49 | |
| 50 #refreshStatus { font-size: 80%; } | |
| 51 | |
| 52 .title { | 51 .title { |
| 53 padding-bottom: 1%; | 52 padding-bottom: 1%; |
| 54 padding-top: 5%; | 53 padding-top: 5%; |
| 55 } | 54 } |
| 56 | 55 |
| 56 #refreshStatus { font-size: 80%; } |
| 57 |
| 57 .paper-green { color: var(--paper-green-600); } | 58 .paper-green { color: var(--paper-green-600); } |
| 58 | 59 |
| 59 .paper-red { color: var(--paper-red-600); } | 60 .paper-red { color: var(--paper-red-600); } |
| 60 | 61 |
| 61 .paper-grey { color: var(--paper-grey-600); } | 62 .paper-grey { color: var(--paper-grey-600); } |
| 63 |
| 64 .spinner { |
| 65 text-align: center; |
| 66 } |
| 67 |
| 62 </style> | 68 </style> |
| 63 | 69 |
| 64 <iron-ajax | 70 <iron-ajax |
| 65 auto | 71 auto |
| 66 id="requestConfigs" | 72 id="requestConfigs" |
| 67 url="/_ah/api/config/v1/config-sets?config_set=[[category]]/[[name]][[ro
ute.path]]&include_files=true&include_last_import_attempt=true" | 73 url="/_ah/api/config/v1/config-sets?config_set=[[category]]/[[name]][[ro
ute.path]]&include_files=true&include_last_import_attempt=true" |
| 68 handle-as="json" | 74 handle-as="json" |
| 75 on-error="_onRequestError" |
| 69 on-response="_onGotConfigFiles" | 76 on-response="_onGotConfigFiles" |
| 70 headers="[[auth_headers]]"> | 77 headers="[[auth_headers]]"> |
| 71 </iron-ajax> | 78 </iron-ajax> |
| 72 | 79 |
| 73 <iron-ajax | 80 <iron-ajax |
| 74 id="refreshConfigs" | 81 id="refreshConfigs" |
| 75 url="/_ah/api/config/v1/reimport?config_set=[[category]]/[[name]][[route
.path]]" | 82 url="/_ah/api/config/v1/reimport?config_set=[[category]]/[[name]][[route
.path]]" |
| 76 method="POST" | 83 method="POST" |
| 77 handle-as="json" | 84 handle-as="json" |
| 78 on-error="_onRefreshError" | 85 on-error="_onRefreshError" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 Last import succeeded. | 124 Last import succeeded. |
| 118 </template> | 125 </template> |
| 119 </template> | 126 </template> |
| 120 <template is="dom-if" if="[[_not(lastImportAttempt)]]"> | 127 <template is="dom-if" if="[[_not(lastImportAttempt)]]"> |
| 121 Last import attempt info not available. | 128 Last import attempt info not available. |
| 122 </template> | 129 </template> |
| 123 </template> | 130 </template> |
| 124 <p id="refreshStatus">[[refreshMessage]]</p> | 131 <p id="refreshStatus">[[refreshMessage]]</p> |
| 125 </div> | 132 </div> |
| 126 </div> | 133 </div> |
| 127 <template is="dom-if" if="[[isRefreshing]]"> | 134 <template is="dom-if" if="[[_not(errorMessage)]]"> |
| 128 <div class="spinner"> | 135 <template is="dom-if" if="[[isRefreshing]]"> |
| 129 <paper-spinner active></paper-spinner> | |
| 130 </div> | |
| 131 </template> | |
| 132 <template is="dom-if" if="[[_not(isRefreshing)]]"> | |
| 133 <template is="dom-if" if="[[isLoading]]"> | |
| 134 <div class="spinner"> | 136 <div class="spinner"> |
| 135 <paper-spinner active></paper-spinner> | 137 <paper-spinner active></paper-spinner> |
| 136 </div> | 138 </div> |
| 137 </template> | 139 </template> |
| 138 <template is="dom-if" if="[[_not(isLoading)]]"> | 140 <template is="dom-if" if="[[_not(isRefreshing)]]"> |
| 139 <template is="dom-if" if="[[_isEmpty(files)]]"> | 141 <template is="dom-if" if="[[isLoading]]"> |
| 140 <div class="center" style="font-family: sans-serif;"> | 142 <div class="spinner"> |
| 141 No config files found. | 143 <paper-spinner active></paper-spinner> |
| 142 </div> | 144 </div> |
| 143 </template> | 145 </template> |
| 144 <template is="dom-if" if="[[_not(_isEmpty(files))]]"> | 146 <template is="dom-if" if="[[_not(isLoading)]]"> |
| 145 <template is="dom-repeat" items="[[files]]" as="file"> | 147 <template is="dom-if" if="[[_isEmpty(files)]]"> |
| 146 <div class="center config-card"> | 148 <div class="center" style="font-family: sans-serif;"> |
| 147 <config-file-card | 149 No config files found. |
| 148 name="[[file.path]]" link="[[location]]/[[file.path]]"> | |
| 149 </config-file-card> | |
| 150 </div> | 150 </div> |
| 151 </template> | 151 </template> |
| 152 <template is="dom-if" if="[[_not(_isEmpty(files))]]"> |
| 153 <template is="dom-repeat" items="[[files]]" as="file"> |
| 154 <div class="center config-card"> |
| 155 <config-file-card |
| 156 name="[[file.path]]" link="[[location]]/[[file.path]]"> |
| 157 </config-file-card> |
| 158 </div> |
| 159 </template> |
| 160 </template> |
| 152 </template> | 161 </template> |
| 153 </template> | 162 </template> |
| 154 </template> | 163 </template> |
| 164 <template is="dom-if" if="[[errorMessage]]"> |
| 165 <div class="center"> |
| 166 <p>[[errorMessage]]</p> |
| 167 </div> |
| 168 </template> |
| 155 </template> | 169 </template> |
| 156 <script> | 170 <script> |
| 157 Polymer({ | 171 Polymer({ |
| 158 is: "config-set", | 172 is: "config-set", |
| 159 | 173 |
| 160 properties: { | 174 properties: { |
| 161 | 175 |
| 162 frontPageIsActive: { | 176 frontPageIsActive: { |
| 163 type: Boolean, | 177 type: Boolean, |
| 164 observer: '_frontPageIsActive' | 178 observer: '_frontPageIsActive' |
| (...skipping 25 matching lines...) Expand all Loading... |
| 190 type: String | 204 type: String |
| 191 }, | 205 }, |
| 192 | 206 |
| 193 name: { | 207 name: { |
| 194 type: String | 208 type: String |
| 195 }, | 209 }, |
| 196 | 210 |
| 197 refreshMessage: { | 211 refreshMessage: { |
| 198 type: String, | 212 type: String, |
| 199 value: null | 213 value: null |
| 214 }, |
| 215 |
| 216 errorMessage: { |
| 217 type: String, |
| 218 value: null |
| 200 } | 219 } |
| 201 }, | 220 }, |
| 202 | 221 |
| 203 _forceRefresh: function() { | 222 _forceRefresh: function() { |
| 204 this.refreshMessage = null; | 223 this.refreshMessage = null; |
| 205 this.$.refreshConfigs.generateRequest(); | 224 this.$.refreshConfigs.generateRequest(); |
| 206 this.isRefreshing = true; | 225 this.isRefreshing = true; |
| 207 }, | 226 }, |
| 208 | 227 |
| 209 _frontPageIsActive: function() { | 228 _frontPageIsActive: function() { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 235 _not: function(b) { | 254 _not: function(b) { |
| 236 return !b; | 255 return !b; |
| 237 }, | 256 }, |
| 238 | 257 |
| 239 _onGotConfigFiles: function(event) { | 258 _onGotConfigFiles: function(event) { |
| 240 this.files = event.detail.response.config_sets[0].files || []; | 259 this.files = event.detail.response.config_sets[0].files || []; |
| 241 this.location = event.detail.response.config_sets[0].location; | 260 this.location = event.detail.response.config_sets[0].location; |
| 242 this.lastImportAttempt = | 261 this.lastImportAttempt = |
| 243 event.detail.response.config_sets[0].last_import_attempt || null; | 262 event.detail.response.config_sets[0].last_import_attempt || null; |
| 244 this.isLoading = false; | 263 this.isLoading = false; |
| 264 this.errorMessage = null; |
| 245 this.fire('processedConfigFiles'); | 265 this.fire('processedConfigFiles'); |
| 246 }, | 266 }, |
| 247 | 267 |
| 248 _onRefreshError: function() { | 268 _onRefreshError: function() { |
| 249 this.isRefreshing = false; | 269 this.isRefreshing = false; |
| 250 this.refreshMessage = "Error: Files could not be refreshed."; | 270 this.refreshMessage = "Error: Files could not be refreshed."; |
| 251 this.fire('refreshError'); | 271 this.fire('refreshError'); |
| 272 }, |
| 273 |
| 274 _onRequestError: function(event) { |
| 275 var error = parseInt(event.detail.error.message.match(/\d+/g)); |
| 276 this.isLoading = false; |
| 277 if (error === 403) { |
| 278 this.errorMessage = "Authorization required to view this config set. Y
ou " + |
| 279 "need to sign in first."; |
| 280 } else if (error >= 500 && error < 600) { |
| 281 this.errorMessage = "Internal server error."; |
| 282 } else { |
| 283 this.errorMessage = "Error occured. Try again later."; |
| 284 } |
| 285 this.fire('fetchError'); |
| 252 } | 286 } |
| 287 |
| 253 }); | 288 }); |
| 254 </script> | 289 </script> |
| 255 </dom-module> | 290 </dom-module> |
| OLD | NEW |