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

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

Issue 2959833002: config_service: add last import validation and tests (Closed)
Patch Set: Add tests to front-page and config-set page. 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="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/paper-item/paper-item.html"> 9 <link rel="import" href="../../bower_components/paper-item/paper-item.html">
10 <link rel="import" href="../../bower_components/polymer/polymer.html"> 10 <link rel="import" href="../../bower_components/polymer/polymer.html">
11 <link rel="import" href="../../bower_components/iron-icons/maps-icons.html">
11 12
12 <dom-module id="config-set"> 13 <dom-module id="config-set">
13 <template> 14 <template>
14 <style> 15 <style>
15 .category { 16 .category {
16 font-size: 100%; 17 font-size: 100%;
17 font-family: sans-serif; 18 font-family: sans-serif;
18 } 19 }
19 20
20 .center { 21 .center {
21 width: 27%; 22 width: 27%;
22 margin: auto; 23 margin: auto;
23 text-align: left; 24 text-align: left;
24 } 25 }
25 26
26 .name { 27 .name {
27 font-size: 200%; 28 font-size: 200%;
28 font-family: sans-serif; 29 font-family: sans-serif;
29 } 30 }
30 31
31 .title { 32 .title {
32 padding-bottom: 1%; 33 padding-bottom: 1%;
33 padding-top: 5%; 34 padding-top: 5%;
34 } 35 }
35 </style> 36 </style>
36 37
37 <iron-ajax 38 <iron-ajax
38 auto 39 auto
39 id="requestConfigs" 40 id="requestConfigs"
40 url="/_ah/api/config/v1/config-sets?config_set=[[category]]%2F[[name]]&i nclude_files=true" 41 url="/_ah/api/config/v1/config-sets?config_set=[[category]]%2F[[name]][[ route.path]]&include_files=true&include_last_import_attempt=true"
41 handle-as="json" 42 handle-as="json"
42 on-response="_onGotConfigFiles"> 43 on-response="_onGotConfigFiles">
43 </iron-ajax> 44 </iron-ajax>
44 45
45 <div class="center title"> 46 <div class="center title">
46 <div class="name">[[name]][[route.path]]</div> 47 <div class="name">[[name]][[route.path]]
47 <div class="category">[[_formatCategory(category)]]</div> 48 <template is="dom-if" if="[[_not(isLoading)]]">
49 <template is="dom-if" if="[[lastImportAttempt.success]]">
50 <iron-icon icon="icons:check-circle"></iron-icon>
51 </template>
52 <template is="dom-if" if="[[_not(lastImportAttempt.success)]]">
53 <iron-icon icon="icons:warning"></iron-icon>
54 </template>
55 </template>
56 </div>
57 <div class="category">
58 [[_formatCategory(category)]] <br>
59 <template is="dom-if" if="[[_not(isLoading)]]">
60 <template is="dom-if" if="[[_not(lastImportAttempt.success)]]">
61 Last import attempt failed: [[lastImportAttempt.message]]
62 </template>
63 </template>
64 </div>
48 </div> 65 </div>
49 66
50 <template is="dom-if" if="[[isLoading]]"> 67 <template is="dom-if" if="[[isLoading]]">
51 <div class="center">Fetching config files...</div> 68 <div class="center">Fetching config files...</div>
52 </template> 69 </template>
53 <template is="dom-if" if="[[_not(isLoading)]]"> 70 <template is="dom-if" if="[[_not(isLoading)]]">
54 <template is="dom-repeat" items="[[files]]" as="file"> 71 <template is="dom-if" if="[[_isEmpty(files)]]">
55 <config-file-card 72 <div class="center" style="font-family: sans-serif;">
56 name="[[file.path]]" link="[[location]]/[[file.path]]"> 73 No config files found.
57 </config-file-card> 74 </div>
75 </template>
76 <template is="dom-if" if="[[_not(_isEmpty(files))]]">
77 <template is="dom-repeat" items="[[files]]" as="file">
78 <config-file-card
79 name="[[file.path]]" link="[[location]]/[[file.path]]">
80 </config-file-card>
81 </template>
58 </template> 82 </template>
59 </template> 83 </template>
60 </template> 84 </template>
61 <script> 85 <script>
62 Polymer({ 86 Polymer({
63 is: "config-set", 87 is: "config-set",
64 88
65 properties: { 89 properties: {
90
91 frontPageIsActive: {
92 type: Boolean,
93 observer: '_frontPageIsActive'
94 },
95
66 category: { 96 category: {
67 type: String 97 type: String
68 }, 98 },
69 99
70 files: { 100 files: {
71 type: Array 101 type: Array
72 }, 102 },
73 103
74 isLoading: { 104 isLoading: {
75 type: Boolean, 105 type: Boolean,
76 value: true 106 value: true
77 }, 107 },
78 108
109 lastImportAttempt: {
110 type: Object
111 },
112
79 location: { 113 location: {
80 type: String 114 type: String
81 }, 115 },
82 116
83 name: { 117 name: {
84 type: String 118 type: String
85 } 119 }
86 }, 120 },
87 121
122 _frontPageIsActive: function() {
123 if (this.frontPageIsActive === false) {
124 this.isLoading = true;
125 this.$.requestConfigs.generateRequest();
126 }
127 },
128
129 _isEmpty: function(list) {
130 return list.length === 0;
131 },
132
88 _formatCategory: function(category) { 133 _formatCategory: function(category) {
89 if (category === "projects") return "Project"; 134 if (category === "projects") return "Project";
90 if (category === "services") return "Service"; 135 if (category === "services") return "Service";
91 }, 136 },
92 137
93 _not: function(b) { 138 _not: function(b) {
94 return !b; 139 return !b;
95 }, 140 },
96 141
97 _onGotConfigFiles: function(event) { 142 _onGotConfigFiles: function(event) {
98 this.files = event.detail.response.config_sets[0].files; 143 this.files = event.detail.response.config_sets[0].files ?
144 event.detail.response.config_sets[0].files : [];
99 this.location = event.detail.response.config_sets[0].location; 145 this.location = event.detail.response.config_sets[0].location;
146 this.lastImportAttempt =
147 event.detail.response.config_sets[0].last_import_attempt;
100 this.isLoading = false; 148 this.isLoading = false;
101 } 149 }
102 }); 150 });
103 </script> 151 </script>
104 </dom-module> 152 </dom-module>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698