OLD | NEW |
1 <!-- The <failures-list-sk> custom element declaration. | 1 <!-- The <failures-list-sk> custom element declaration. |
2 | 2 |
3 The failures-list-sk custom element renders the list of digests that could | 3 The failures-list-sk custom element renders the list of digests that could |
4 not be downloaded or decoded. | 4 not be downloaded or decoded. |
5 | 5 |
6 Attributes: None | 6 Attributes: None |
7 | 7 |
8 Events: None | 8 Events: None |
9 | 9 |
10 Methods: None | 10 Methods: None |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 <td class="reasonHeader">Reason</td> | 47 <td class="reasonHeader">Reason</td> |
48 <td> </td> | 48 <td> </td> |
49 <td> </td> | 49 <td> </td> |
50 </tr> | 50 </tr> |
51 | 51 |
52 <template repeat="{{entry in failureEntries}}"> | 52 <template repeat="{{entry in failureEntries}}"> |
53 <tr> | 53 <tr> |
54 <td class="dateTimeValue">{{entry.ts | _toLocalDate}}</td> | 54 <td class="dateTimeValue">{{entry.ts | _toLocalDate}}</td> |
55 <td class="digestValue"><a href="/img/images/{{entry.digest}}.png" t
arget="_blank">{{entry.digest}}</a></td> | 55 <td class="digestValue"><a href="/img/images/{{entry.digest}}.png" t
arget="_blank">{{entry.digest}}</a></td> |
56 <td class="reasonValue">{{entry.reason}}</td> | 56 <td class="reasonValue">{{entry.reason}}</td> |
57 <td><paper-button on-click="{{clearHandler}}" data-entryid="{{entry.
id}}" title="Remove from server cache">Clear</paper-button></td> | 57 <td><paper-button on-click="{{clearHandler}}" data-digestid="{{entry
.digest}}" title="Remove from server cache">Clear</paper-button></td> |
58 <td><paper-button on-click="{{purgeHandler}}" data-entryid="{{entry.
id}}" title="Remove from cache and Google storage">Purge</paper-button></td> | 58 <td><paper-button on-click="{{purgeHandler}}" data-digestid="{{entry
.digest}}" title="Remove from cache and Google storage">Purge</paper-button></td
> |
59 </tr> | 59 </tr> |
60 </template> | 60 </template> |
61 </table> | 61 </table> |
62 <error-toast-sk></error-toast-sk> | 62 <error-toast-sk></error-toast-sk> |
63 <!-- TODO(stephana): Add paper-spinner element while content loads --> | 63 <!-- TODO(stephana): Add paper-spinner element while content loads --> |
64 | 64 |
65 </template> | 65 </template> |
66 <script> | 66 <script> |
67 Polymer({ | 67 Polymer({ |
68 ready: function() { | 68 ready: function() { |
69 this.page = {}; | 69 this.page = {}; |
70 | 70 |
71 // Set up the paging change handler and load the data. | 71 // Set up the paging change handler and load the data. |
72 this._reload(); | 72 this._reload(); |
73 }, | 73 }, |
74 | 74 |
75 // Load or reload the listing. | 75 // Load or reload the listing. |
76 // TODO(stephana): _reload will be called after a clear/purge to refresh | 76 // TODO(stephana): _reload will be called after a clear/purge to refresh |
77 // the list of failures. | 77 // the list of failures. |
78 _reload: function() { | 78 _reload: function() { |
79 var URL = '_/failure'; | 79 var URL = '_/failure'; |
80 this._handleServerResponse(sk.get(URL)); | 80 this._handleServerResponse(sk.get(URL)); |
81 }, | 81 }, |
82 | 82 |
| 83 _clear: function(event, gsPurge) { |
| 84 var URL = '_/failure/clear'; |
| 85 if (gsPurge) { |
| 86 URL += "?purge=true" |
| 87 } |
| 88 var digests = [ event.target.dataset.digestid ]; |
| 89 this._handleServerResponse(sk.post(URL, JSON.stringify(digests))); |
| 90 }, |
| 91 |
| 92 clearHandler: function(event) { this._clear(event, false); }, |
| 93 purgeHandler: function(event) { this._clear(event, true); }, |
| 94 |
83 _handleServerResponse: function(promise) { | 95 _handleServerResponse: function(promise) { |
84 promise.then(JSON.parse).then(function(json) { | 96 promise.then(JSON.parse).then(function(json) { |
85 this.failureEntries = json.failures; | 97 this.failureEntries = json.failures; |
86 }.bind(this)).catch(sk.errorMessage); | 98 }.bind(this)).catch(sk.errorMessage); |
87 }, | 99 }, |
88 | 100 |
89 _toLocalDate: function(timeStampSec) { | 101 _toLocalDate: function(timeStampSec) { |
90 return (new Date(timeStampSec * 1000)).toLocaleString(); | 102 return (new Date(timeStampSec * 1000)).toLocaleString(); |
91 } | 103 } |
92 }); | 104 }); |
93 | 105 |
94 </script> | 106 </script> |
95 </polymer-element> | 107 </polymer-element> |
OLD | NEW |