Chromium Code Reviews| Index: appengine/config_service/ui/src/config-ui/front-page.html |
| diff --git a/appengine/config_service/ui/src/config-ui/front-page.html b/appengine/config_service/ui/src/config-ui/front-page.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..112788e5fdf137b62bda5d4242c519fc0dd5a68f |
| --- /dev/null |
| +++ b/appengine/config_service/ui/src/config-ui/front-page.html |
| @@ -0,0 +1,142 @@ |
| +<!-- |
| + Copyright 2017 The LUCI Authors. All rights reserved. |
| + Use of this source code is governed under the Apache License, Version 2.0 |
| + that can be found in the LICENSE file. |
| +--> |
| + |
| +<link rel="import" href="../../bower_components/app-layout/app-layout.html"> |
| +<link rel="import" href="config-card.html"> |
| +<link rel="import" href="../../bower_components/iron-ajax/iron-ajax.html"> |
| +<link rel="import" href="../../bower_components/paper-button/paper-button.html"> |
| +<link rel="import" href="../../bower_components/paper-search/paper-search-bar.html"> |
| +<link rel="import" href="../../bower_components/polymer/polymer.html"> |
| + |
| +<dom-module id="front-page"> |
| + <template> |
| + <style> |
| + app-toolbar { |
| + background-color: #efefef; |
| + color: #232323; |
| + } |
| + |
| + app-header { |
| + @apply --layout-fixed-top; |
| + } |
| + |
| + .center { |
| + width: 50%; |
| + margin: auto; |
| + text-align: center; |
| + } |
| + |
| + .logo { |
| + height: 100%; |
| + } |
| + |
| + .title { |
| + padding-left: 1%; |
| + font-size: 150%; |
| + font-family: sans-serif; |
| + } |
| + |
| + .search-bar { |
| + padding-top: 7%; |
| + padding-bottom: 2%; |
| + } |
| + |
| + paper-search-bar { |
| + border-style: solid; |
| + border-width: 2px; |
| + width: 40%; |
| + height: 100%; |
| + margin: auto; |
| + } |
| + </style> |
| + |
| + <app-header reveals> |
| + <app-toolbar> |
| + <image class="logo" src="/static/images/chromium.png"/> |
| + <div class="title" main-title>Configuration Service (not fully implemented)</div> |
| + </app-toolbar> |
| + </app-header> |
| + |
| + <iron-ajax |
| + auto |
| + id="requestConfigs" |
| + url="https://luci-config.appspot.com/_ah/api/config/v1/config-sets" |
| + handle-as="json" |
| + on-response="_onGotConfigs"> |
| + </iron-ajax> |
| + |
| + <div class="search-bar"> |
| + <paper-search-bar query="{{query}}"></paper-search-bar> |
| + </div> |
| + |
| + <div class="config-list"> |
| + <template is="dom-if" if="[[isLoading]]"> |
| + <div class="center">Fetching config sets...</div> |
| + </template> |
| + <template is="dom-if" if="[[_not(isLoading)]]"> |
| + <template is="dom-if" if="[[_isEmpty(searchResults)]]"> |
| + <config-card name="No config sets found."></config-card> |
| + </template> |
| + <template is="dom-if" if="[[_not(_isEmpty(searchResults))]]"> |
| + <template is="dom-repeat" items="[[searchResults]]" as="config"> |
| + <config-card name="[[config.config_set]]"></config-card> |
| + </template> |
| + </template> |
| + </template> |
| + </div> |
| + </template> |
| + |
| + <script> |
| + Polymer({ |
| + is: 'front-page', |
| + |
| + properties: { |
| + configList: { |
| + type: Array, |
| + value: [] |
| + }, |
| + |
| + isLoading: { |
| + type: Boolean, |
| + value: true |
| + }, |
| + |
| + query: { |
| + type: String, |
| + observer: '_updateSearchResults' |
| + }, |
| + |
| + searchResults: { |
| + type: Array, |
| + value: () => { return []; } |
| + } |
| + }, |
| + |
| + _isEmpty: function(searchResults) { |
| + return searchResults.length === 0; |
|
nodir
2017/06/13 16:48:22
this function does not actually care if the parame
|
| + }, |
| + |
| + _onGotConfigs: function(event) { |
| + this.configList = event.detail.response.config_sets; |
|
nodir
2017/06/13 16:50:48
I think this is configSetList, not configList. Con
|
| + this._updateSearchResults(); |
| + this.isEmpty = this.searchResults.length === 0; |
| + this.isLoading = false; |
| + }, |
| + |
| + _not: function(bool) { |
| + return (!(bool)); |
| + }, |
| + |
| + _updateSearchResults: function() { |
| + var query = this.query; |
| + this.searchResults = this.configList.filter(function(elem) { |
| + return elem.config_set.includes(query); |
| + }); |
| + this.isEmpty = this.searchResults.length === 0; |
| + } |
| + }); |
| + </script> |
| +</dom-module> |