| OLD | NEW |
| (Empty) | |
| 1 <!-- |
| 2 Copyright 2017 The LUCI Authors. All rights reserved. |
| 3 Use of this source code is governed under the Apache License, Version 2.0 |
| 4 that can be found in the LICENSE file. |
| 5 --> |
| 6 |
| 7 <link rel="import" href="config-file-card.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"> |
| 10 <link rel="import" href="../../bower_components/polymer/polymer.html"> |
| 11 <link rel="import" href="../../bower_components/iron-icons/maps-icons.html"> |
| 12 |
| 13 <dom-module id="config-set"> |
| 14 <template> |
| 15 <style> |
| 16 .category { |
| 17 font-size: 100%; |
| 18 font-family: sans-serif; |
| 19 } |
| 20 |
| 21 .center { |
| 22 width: 27%; |
| 23 margin: auto; |
| 24 text-align: left; |
| 25 } |
| 26 |
| 27 .name { |
| 28 font-size: 200%; |
| 29 font-family: sans-serif; |
| 30 } |
| 31 |
| 32 .title { |
| 33 padding-bottom: 1%; |
| 34 padding-top: 5%; |
| 35 } |
| 36 </style> |
| 37 |
| 38 <iron-ajax |
| 39 auto |
| 40 id="requestConfigs" |
| 41 url="/_ah/api/config/v1/config-sets?config_set=[[category]]%2F[[name]][[
route.path]]&include_files=true&include_last_import_attempt=true" |
| 42 handle-as="json" |
| 43 on-response="_onGotConfigFiles"> |
| 44 </iron-ajax> |
| 45 |
| 46 <div class="center title"> |
| 47 <div class="name">[[name]][[route.path]] |
| 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> |
| 65 </div> |
| 66 |
| 67 <template is="dom-if" if="[[isLoading]]"> |
| 68 <div class="center">Fetching config files...</div> |
| 69 </template> |
| 70 <template is="dom-if" if="[[_not(isLoading)]]"> |
| 71 <template is="dom-if" if="[[_isEmpty(files)]]"> |
| 72 <div class="center" style="font-family: sans-serif;"> |
| 73 No config files found. |
| 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> |
| 82 </template> |
| 83 </template> |
| 84 </template> |
| 85 <script> |
| 86 Polymer({ |
| 87 is: "config-set", |
| 88 |
| 89 properties: { |
| 90 |
| 91 frontPageIsActive: { |
| 92 type: Boolean, |
| 93 observer: '_frontPageIsActive' |
| 94 }, |
| 95 |
| 96 category: { |
| 97 type: String |
| 98 }, |
| 99 |
| 100 files: { |
| 101 type: Array |
| 102 }, |
| 103 |
| 104 isLoading: { |
| 105 type: Boolean |
| 106 }, |
| 107 |
| 108 lastImportAttempt: { |
| 109 type: Object |
| 110 }, |
| 111 |
| 112 location: { |
| 113 type: String |
| 114 }, |
| 115 |
| 116 name: { |
| 117 type: String |
| 118 } |
| 119 }, |
| 120 |
| 121 _frontPageIsActive: function() { |
| 122 if (this.frontPageIsActive === false) { |
| 123 this.isLoading = true; |
| 124 this.$.requestConfigs.generateRequest(); |
| 125 } |
| 126 }, |
| 127 |
| 128 _isEmpty: function(list) { |
| 129 return list.length === 0; |
| 130 }, |
| 131 |
| 132 _formatCategory: function(category) { |
| 133 if (category === "projects") return "Project"; |
| 134 if (category === "services") return "Service"; |
| 135 }, |
| 136 |
| 137 _not: function(b) { |
| 138 return !b; |
| 139 }, |
| 140 |
| 141 _onGotConfigFiles: function(event) { |
| 142 this.files = event.detail.response.config_sets[0].files ? |
| 143 event.detail.response.config_sets[0].files : []; |
| 144 this.location = event.detail.response.config_sets[0].location; |
| 145 this.lastImportAttempt = |
| 146 event.detail.response.config_sets[0].last_import_attempt; |
| 147 this.isLoading = false; |
| 148 } |
| 149 }); |
| 150 </script> |
| 151 </dom-module> |
| OLD | NEW |