| 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="../../bower_components/app-layout/app-layout.html"> | 7 <link rel="import" href="../../bower_components/app-layout/app-layout.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/paper-button/paper-button.html"> | 9 <link rel="import" href="../../bower_components/paper-button/paper-button.html"> |
| 10 <link rel="import" href="../../bower_components/paper-search/paper-search-bar.ht
ml"> | 10 <link rel="import" href="../../bower_components/paper-search/paper-search-bar.ht
ml"> |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 border-width: 2px; | 31 border-width: 2px; |
| 32 width: 40%; | 32 width: 40%; |
| 33 height: 100%; | 33 height: 100%; |
| 34 margin: auto; | 34 margin: auto; |
| 35 } | 35 } |
| 36 </style> | 36 </style> |
| 37 | 37 |
| 38 <iron-ajax | 38 <iron-ajax |
| 39 auto | 39 auto |
| 40 id="requestConfigs" | 40 id="requestConfigs" |
| 41 url="/_ah/api/config/v1/config-sets" | 41 url="/_ah/api/config/v1/config-sets?include_last_import_attempt=true" |
| 42 handle-as="json" | 42 handle-as="json" |
| 43 on-response="_onGotConfigSets" | 43 on-response="_onGotConfigSets" |
| 44 headers="[[auth_headers]]"> | 44 headers="[[auth_headers]]"> |
| 45 </iron-ajax> | 45 </iron-ajax> |
| 46 | 46 |
| 47 <div class="search-bar"> | 47 <div class="search-bar"> |
| 48 <paper-search-bar query="{{query}}"></paper-search-bar> | 48 <paper-search-bar query="{{query}}"></paper-search-bar> |
| 49 </div> | 49 </div> |
| 50 | 50 |
| 51 <div class="config-list"> | 51 <div class="config-list"> |
| 52 <template is="dom-if" if="[[isLoading]]"> | 52 <template is="dom-if" if="[[isLoading]]"> |
| 53 <div class="center">Fetching config sets...</div> | 53 <div class="center">Fetching config sets...</div> |
| 54 </template> | 54 </template> |
| 55 <template is="dom-if" if="[[_not(isLoading)]]"> | 55 <template is="dom-if" if="[[_not(isLoading)]]"> |
| 56 <template is="dom-if" if="[[_isEmpty(searchResults)]]"> | 56 <template is="dom-if" if="[[_isEmpty(searchResults)]]"> |
| 57 <div class="center">No config sets found.</div> | 57 <div class="center">No config sets found.</div> |
| 58 </template> | 58 </template> |
| 59 <template is="dom-if" if="[[_not(_isEmpty(searchResults))]]"> | 59 <template is="dom-if" if="[[_not(_isEmpty(searchResults))]]"> |
| 60 <template is="dom-repeat" items="[[searchResults]]" as="config"> | 60 <template is="dom-repeat" items="[[searchResults]]" as="config"> |
| 61 <config-set-card name="[[config.config_set]]" on-tap="_handleClick">
</config-set-card> | 61 <config-set-card |
| 62 name="[[config.config_set]]" |
| 63 last-import-attempt="[[_getLastImportAttempt(config.last_import_
attempt)]]" |
| 64 on-tap="_handleClick"> |
| 65 </config-set-card> |
| 62 </template> | 66 </template> |
| 63 </template> | 67 </template> |
| 64 </template> | 68 </template> |
| 65 </div> | 69 </div> |
| 66 </template> | 70 </template> |
| 67 | 71 |
| 68 <script> | 72 <script> |
| 69 Polymer({ | 73 Polymer({ |
| 70 is: 'front-page', | 74 is: 'front-page', |
| 71 | 75 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 84 type: String, | 88 type: String, |
| 85 observer: '_updateSearchResults' | 89 observer: '_updateSearchResults' |
| 86 }, | 90 }, |
| 87 | 91 |
| 88 searchResults: { | 92 searchResults: { |
| 89 type: Array, | 93 type: Array, |
| 90 value: () => [] | 94 value: () => [] |
| 91 } | 95 } |
| 92 }, | 96 }, |
| 93 | 97 |
| 98 _getLastImportAttempt: function(lastImportAttempt) { |
| 99 if (lastImportAttempt) { |
| 100 return lastImportAttempt; |
| 101 } else { |
| 102 return null; |
| 103 } |
| 104 }, |
| 105 |
| 94 _isEmpty: function(array) { | 106 _isEmpty: function(array) { |
| 95 return array.length === 0; | 107 return array.length === 0; |
| 96 }, | 108 }, |
| 97 | 109 |
| 98 _onGotConfigSets: function(event) { | 110 _onGotConfigSets: function(event) { |
| 99 this.configSetList = event.detail.response.config_sets; | 111 this.configSetList = event.detail.response.config_sets; |
| 100 this._updateSearchResults(); | 112 this._updateSearchResults(); |
| 101 this.isLoading = false; | 113 this.isLoading = false; |
| 102 }, | 114 }, |
| 103 | 115 |
| 104 _not: function(b) { | 116 _not: function(b) { |
| 105 return !b; | 117 return !b; |
| 106 }, | 118 }, |
| 107 | 119 |
| 108 _updateSearchResults: function() { | 120 _updateSearchResults: function() { |
| 109 this.searchResults = this.configSetList.filter(e => e.config_set.include
s(this.query)); | 121 this.searchResults = this.configSetList.filter(e => e.config_set.include
s(this.query)); |
| 110 }, | 122 }, |
| 111 | 123 |
| 112 _handleClick: function(event) { | 124 _handleClick: function(event) { |
| 113 window.location = window.location.href + event.model.config.config_set; | 125 window.location = window.location.href + event.model.config.config_set; |
| 114 }, | 126 }, |
| 115 | 127 |
| 116 }); | 128 }); |
| 117 </script> | 129 </script> |
| 118 </dom-module> | 130 </dom-module> |
| OLD | NEW |