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

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

Issue 2980973002: config_service: Fixed multiple ajax requests in the front page while the page determines whether a … (Closed)
Patch Set: Nit: formatting of if statement 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="../../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
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 21 matching lines...) Expand all
83 </template> 82 </template>
84 </template> 83 </template>
85 </template> 84 </template>
86 </div> 85 </div>
87 </template> 86 </template>
88 <script> 87 <script>
89 Polymer({ 88 Polymer({
90 is: 'front-page', 89 is: 'front-page',
91 90
92 properties: { 91 properties: {
92 auth_headers: {
93 type: Object,
94 value: () => null,
95 observer: '_fetchConfigs'
96 },
97
93 configSetList: { 98 configSetList: {
94 type: Array, 99 type: Array,
95 value: () => [] 100 value: () => []
96 }, 101 },
97 102
98 isLoading: { 103 isLoading: {
99 type: Boolean, 104 type: Boolean,
100 value: true 105 value: true
101 }, 106 },
102 107
103 query: { 108 query: {
104 type: String, 109 type: String,
105 observer: '_updateSearchResults' 110 observer: '_updateSearchResults'
106 }, 111 },
107 112
108 searchResults: { 113 searchResults: {
109 type: Array, 114 type: Array,
110 value: () => [] 115 value: () => []
116 },
117
118 user: {
119 type: Object,
120 value: () => null,
121 notify: true,
122 observer: '_fetchConfigs'
111 } 123 }
112 }, 124 },
113 125
126 _fetchConfigs: function() {
127 if (this.initialized && this.user) {
128 if (this.user.getBasicProfile()) {
129 if (this.auth_headers) {
130 this.isLoading = true;
131 this.$.requestConfigs.generateRequest();
132 }
133 } else {
134 this.isLoading = true;
135 this.$.requestConfigs.generateRequest();
136 }
137 }
138 },
139
114 _formatName: function(name) { 140 _formatName: function(name) {
115 var tempName = name.substring(name.indexOf("/") + 1); 141 var tempName = name.substring(name.indexOf("/") + 1);
116 return tempName.includes("/") ? 142 return tempName.includes("/") ?
117 tempName.substring(0, tempName.indexOf("/")) : tempName; 143 tempName.substring(0, tempName.indexOf("/")) : tempName;
118 }, 144 },
119 145
120 _getLastImportAttempt: function(lastImportAttempt) { 146 _getLastImportAttempt: function(lastImportAttempt) {
121 if (lastImportAttempt) { 147 if (lastImportAttempt) {
122 return lastImportAttempt; 148 return lastImportAttempt;
123 } else { 149 } else {
(...skipping 22 matching lines...) Expand all
146 var tempResults = this.configSetList.filter(e => e.config_set.includes(t his.query)); 172 var tempResults = this.configSetList.filter(e => e.config_set.includes(t his.query));
147 tempResults.sort(function(a, b) { 173 tempResults.sort(function(a, b) {
148 return this._formatName(a.config_set).localeCompare(this._formatName(b .config_set)); 174 return this._formatName(a.config_set).localeCompare(this._formatName(b .config_set));
149 }.bind(this)); 175 }.bind(this));
150 this.searchResults = tempResults; 176 this.searchResults = tempResults;
151 }, 177 },
152 178
153 }); 179 });
154 </script> 180 </script>
155 </dom-module> 181 </dom-module>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698