| <!-- |
| The <chromium-build-runs-sk> custom element declaration. Displays a table with details about each |
| completed and pending Chromium build task. |
| |
| Attributes: |
| defaultSize: The number of Chromium build runs to show per page, default 10. |
| |
| Events: |
| None. |
| |
| Methods: |
| reload: queries for updated information on Chromium build runs. |
| --> |
| |
| <dom-module id="chromium-build-runs-sk"> |
| <style> |
| table.runshistory { |
| border-spacing: 0px; |
| } |
| tr.headers { |
| background-color: #CCCCFF; |
| text-align: center; |
| } |
| td.nowrap { |
| white-space: nowrap; |
| } |
| table.runshistory > tbody > tr > td { |
| padding: 10px; |
| border: solid black 1px; |
| } |
| .delete-button, .redo-button { |
| --paper-icon-button-disabled: { |
| display: none; |
| } |
| } |
| .oldruns { |
| margin-left: 20px; |
| } |
| </style> |
| <template> |
| |
| <confirm-dialog-sk id="confirm_dialog"></confirm-dialog-sk> |
| |
| <h2>Chromium Builds</h2> |
| <paging-sk pagination="{{pagination}}" on-pagechange="pageChangedHandler"></paging-sk> |
| <br/> |
| |
| <table class="runshistory" id="runshistory" cellpadding="5" border="1"> |
| <tr class="headers"> |
| <td>Id</td> |
| <td>Chromium Commit Hash</td> |
| <td>Submitted On</td> |
| <td>Skia Commit Hash</td> |
| <td>User</td> |
| <td>Timestamps</td> |
| <td>Results</td> |
| <td>Task Repeats</td> |
| </tr> |
| |
| <template is="dom-repeat" items="{{chromiumBuilds}}" as="chromiumBuild" index-as="index"> |
| <tr style="border: 1px solid black;"> |
| <!-- Id col --> |
| <td class="nowrap"> |
| <span>{{chromiumBuild.Id}}</span> |
| <paper-icon-button icon="delete" mini |
| class="delete-button" |
| disabled="{{!chromiumBuild.canDelete}}" |
| alt="Delete" |
| data-index$="{{index}}" |
| data-type="delete"> |
| </paper-icon-button> |
| <paper-icon-button icon="redo" mini |
| class="redo-button" |
| disabled="{{!chromiumBuild.canRedo}}" |
| alt="Redo" |
| data-index$="{{index}}" |
| data-type="redo"> |
| </paper-icon-button> |
| </td> |
| |
| <!-- Chromium Commit Hash col --> |
| <td><a href="{{chromiumCommitUrl(chromiumBuild.ChromiumRev)}}">{{shortHash(chromiumBuild.ChromiumRev)}}</a></td> |
| |
| <!-- Submitted On col --> |
| <td class="nowrap">{{ formatTimestamp(chromiumBuild.ChromiumRevTs) }}</td> |
| |
| <!-- Skia Commit Hash col --> |
| <td><a href="{{skiaCommitUrl(chromiumBuild.SkiaRev)}}">{{shortHash(chromiumBuild.SkiaRev)}}</a></td> |
| |
| <!-- User col --> |
| <td>{{chromiumBuild.Username}}</td> |
| |
| <!-- Timestamps col --> |
| <td> |
| <table> |
| <tr> |
| <td>Requested:</td> |
| <td class="nowrap">{{ formatTimestamp(chromiumBuild.TsAdded) }}</td> |
| </tr> |
| <tr> |
| <td>Started:</td> |
| <td class="nowrap">{{ formatTimestamp(chromiumBuild.TsStarted) }}</td> |
| </tr> |
| <tr> |
| <td>Completed:</td> |
| <td class="nowrap">{{ formatTimestamp(chromiumBuild.TsCompleted) }}</td> |
| </tr> |
| </table> |
| </td> |
| |
| <!-- Results col --> |
| <td class="nowrap"> |
| <template is="dom-if" if="{{chromiumBuild.Failure}}"> |
| <div style="color:red;">Failed</div> |
| </template> |
| <template is="dom-if" if="{{!chromiumBuild.TaskDone}}"> |
| <div style="color:green;">Waiting</div> |
| </template> |
| <template is="dom-if" |
| if="{{isDone(chromiumBuild.Failure, chromiumBuild.TaskDone)}}"> |
| Done |
| </template> |
| <template is="dom-if" if="{{chromiumBuild.Log}}"> |
| <a href="{{chromiumBuild.Log}}" target="_blank">log</a> |
| </template> |
| <template is="dom-if" if="{{chromiumBuild.SwarmingLogs}}"> |
| <br/> |
| <a href="{{chromiumBuild.SwarmingLogs}}" target="_blank">Swarming Logs</a> |
| </template> |
| </td> |
| |
| <!-- Task Repeats --> |
| <td>{{ formatRepeatAfterDays(chromiumBuild.RepeatAfterDays) }}</td> |
| |
| </tr> |
| </template> |
| </table> |
| |
| </template> |
| </dom-module> |
| |
| <script> |
| Polymer({ |
| is: "chromium-build-runs-sk", |
| properties: { |
| chromiumBuilds: { |
| type: Array, |
| value: function() { return []; }, |
| }, |
| defaultSize: { |
| type: Number, |
| value: 10, |
| }, |
| pagination: { |
| type: Object, |
| value: function() { return {}; }, |
| }, |
| pageChangedHandler: { |
| type: Object, |
| value: function() { return null; }, |
| }, |
| }, |
| |
| ready: function() { |
| this.pagination = {"offset": 0, "size": this.defaultSize}; |
| this.pageChangedHandler = this.reload.bind(this); |
| var that = this; |
| this.$.runshistory.addEventListener('click', function(e) { |
| var button = sk.findParent(e.target, "PAPER-ICON-BUTTON"); |
| if (button != null) { |
| if (button.dataset.type == "delete") { |
| var index = button.dataset.index; |
| var note = that.deleteNote(that.chromiumBuilds, index); |
| that.$.confirm_dialog.open("Proceed with deleting task?" + note) |
| .then(that.deleteTask.bind(that, index)); |
| } else if (button.dataset.type == "redo") { |
| var index = button.dataset.index; |
| that.$.confirm_dialog.open("Reschedule this task?") |
| .then(that.redoTask.bind(that, index)); |
| } |
| } |
| }); |
| this.reload(); |
| }, |
| |
| reload: function() { |
| var queryParams = { |
| "offset": this.pagination.offset, |
| "size": this.pagination.size, |
| } |
| var queryStr = "?" + sk.query.fromObject(queryParams); |
| sk.post("/_/get_chromium_build_tasks" + queryStr).then(JSON.parse).then(function(json) { |
| this.pagination = json.pagination; |
| this.chromiumBuilds = json.data; |
| for (var i = 0; i < this.chromiumBuilds.length; i++) { |
| this.chromiumBuilds[i].canDelete = json.permissions[i].DeleteAllowed; |
| this.chromiumBuilds[i].canRedo = json.permissions[i].RedoAllowed; |
| this.chromiumBuilds[i].Id = json.ids[i]; |
| } |
| }.bind(this)).catch(sk.errorMessage); |
| }, |
| |
| deleteNote: function(chromiumBuilds, deleteIndex) { |
| if (deleteIndex >= 0 && |
| chromiumBuilds[deleteIndex].TaskDone && |
| !chromiumBuilds[deleteIndex].Failure) { |
| return " Note: This build will no longer be available for running other tasks."; |
| } else { |
| return ""; |
| } |
| }, |
| |
| deleteTask: function(deleteIndex) { |
| var params = {}; |
| params["id"] = this.chromiumBuilds[deleteIndex].Id; |
| sk.post("/_/delete_chromium_build_task", JSON.stringify(params)).then(function() { |
| $$$("#confirm_toast").text = "Deleted task " + params["id"]; |
| $$$("#confirm_toast").show(); |
| }.bind(this)).catch(sk.errorMessage).then(function() { |
| this.reload(); |
| }.bind(this)); |
| }, |
| |
| redoTask: function(redoIndex) { |
| var params = {}; |
| params["id"] = this.chromiumBuilds[redoIndex].Id; |
| sk.post("/_/redo_chromium_build_task", JSON.stringify(params)).then(function() { |
| $$$("#confirm_toast").text = "Resubmitted task " + params["id"]; |
| $$$("#confirm_toast").show(); |
| }.bind(this)).catch(sk.errorMessage).then(function() { |
| this.reload(); |
| }.bind(this)); |
| }, |
| |
| chromiumCommitUrl: ctfe.chromiumBuild.chromiumCommitUrl, |
| skiaCommitUrl: ctfe.chromiumBuild.skiaCommitUrl, |
| shortHash: ctfe.chromiumBuild.shortHash, |
| formatTimestamp: ctfe.getFormattedTimestamp, |
| formatRepeatAfterDays: ctfe.formatRepeatAfterDays, |
| |
| isDone: function(failure, taskDone) { |
| return !failure && taskDone; |
| }, |
| }); |
| </script> |