Chromium Code Reviews| 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 30 matching lines...) Expand all Loading... | |
| 41 | 41 |
| 42 paper-search-bar { | 42 paper-search-bar { |
| 43 @apply --shadow-elevation-4dp; | 43 @apply --shadow-elevation-4dp; |
| 44 width: 40%; | 44 width: 40%; |
| 45 height: 100%; | 45 height: 100%; |
| 46 margin: auto; | 46 margin: auto; |
| 47 } | 47 } |
| 48 </style> | 48 </style> |
| 49 | 49 |
| 50 <iron-ajax | 50 <iron-ajax |
| 51 auto | |
| 52 id="requestConfigs" | 51 id="requestConfigs" |
| 53 url="/_ah/api/config/v1/config-sets?include_last_import_attempt=true" | 52 url="/_ah/api/config/v1/config-sets?include_last_import_attempt=true" |
| 54 handle-as="json" | 53 handle-as="json" |
| 55 on-response="_onGotConfigSets" | 54 on-response="_onGotConfigSets" |
| 56 headers="[[auth_headers]]"> | 55 headers="[[auth_headers]]"> |
| 57 </iron-ajax> | 56 </iron-ajax> |
| 58 | 57 |
| 59 <div class="search-bar"> | 58 <div class="search-bar"> |
| 60 <paper-search-bar | 59 <paper-search-bar |
| 61 query="{{query}}" | 60 query="{{query}}" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 101 }, | 100 }, |
| 102 | 101 |
| 103 query: { | 102 query: { |
| 104 type: String, | 103 type: String, |
| 105 observer: '_updateSearchResults' | 104 observer: '_updateSearchResults' |
| 106 }, | 105 }, |
| 107 | 106 |
| 108 searchResults: { | 107 searchResults: { |
| 109 type: Array, | 108 type: Array, |
| 110 value: () => [] | 109 value: () => [] |
| 110 }, | |
| 111 | |
| 112 user: { | |
| 113 type: Object, | |
| 114 value: () => null, | |
| 115 notify: true, | |
| 116 observer: '_fetchConfigs' | |
| 111 } | 117 } |
| 112 }, | 118 }, |
| 113 | 119 |
| 120 _fetchConfigs: function() { | |
| 121 // If the google auth API has been initialized, | |
| 122 // and the user is not signed in, then generate the | |
| 123 // ajax request. If the google auth API has been | |
| 124 // initialized, and the user is signed in, we wait for | |
| 125 // the auth headers to be set, and then generate the | |
| 126 // ajax request to get the config sets. | |
| 127 if (this.initialized && this.user) { | |
| 128 if (this.user.getBasicProfile()){ | |
| 129 window.setTimeout(function() { | |
|
Ryan Tseng
2017/07/14 18:52:30
Can we bind to and event where the auth_header bei
| |
| 130 if (this.auth_headers) { | |
| 131 this.isLoading = true; | |
| 132 this.$.requestConfigs.generateRequest(); | |
| 133 } else { | |
| 134 this._fetchConfigs.bind(this); | |
| 135 } | |
| 136 }.bind(this), 50); | |
| 137 } else { | |
| 138 this.isLoading = true; | |
| 139 this.$.requestConfigs.generateRequest(); | |
| 140 } | |
| 141 } | |
| 142 }, | |
| 143 | |
| 114 _formatName: function(name) { | 144 _formatName: function(name) { |
| 115 var tempName = name.substring(name.indexOf("/") + 1); | 145 var tempName = name.substring(name.indexOf("/") + 1); |
| 116 return tempName.includes("/") ? | 146 return tempName.includes("/") ? |
| 117 tempName.substring(0, tempName.indexOf("/")) : tempName; | 147 tempName.substring(0, tempName.indexOf("/")) : tempName; |
| 118 }, | 148 }, |
| 119 | 149 |
| 120 _getLastImportAttempt: function(lastImportAttempt) { | 150 _getLastImportAttempt: function(lastImportAttempt) { |
| 121 if (lastImportAttempt) { | 151 if (lastImportAttempt) { |
| 122 return lastImportAttempt; | 152 return lastImportAttempt; |
| 123 } else { | 153 } else { |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 146 var tempResults = this.configSetList.filter(e => e.config_set.includes(t his.query)); | 176 var tempResults = this.configSetList.filter(e => e.config_set.includes(t his.query)); |
| 147 tempResults.sort(function(a, b) { | 177 tempResults.sort(function(a, b) { |
| 148 return this._formatName(a.config_set).localeCompare(this._formatName(b .config_set)); | 178 return this._formatName(a.config_set).localeCompare(this._formatName(b .config_set)); |
| 149 }.bind(this)); | 179 }.bind(this)); |
| 150 this.searchResults = tempResults; | 180 this.searchResults = tempResults; |
| 151 }, | 181 }, |
| 152 | 182 |
| 153 }); | 183 }); |
| 154 </script> | 184 </script> |
| 155 </dom-module> | 185 </dom-module> |
| OLD | NEW |