| <!-- |
| The <capture-skp-runs-sk> custom element declaration. Displays a table with details about each |
| completed and pending capture SKPs task. |
| |
| Attributes: |
| defaultSize: The number of tasks to show per page, default 10. |
| constrainByUser: Whether to show only tasks created by the logged-in user initially, default |
| false. |
| myRunsConstrainText: Button text to constrain by user, default "View only my runs". |
| everyonesRunsConstrainText: Button text to disable constraining by user, default "View |
| everyone's runs". |
| constrainByTestRun: Whether to show only non-test tasks, default true. Test tasks are those that |
| use the "Dummy1k" page sets. |
| nonTestRunsConstrainText: Button text to constrain to non-test tasks, default "Exclude test |
| runs". |
| testRunsConstrainText: Button text to disable constraining by test tasks, default "Include test |
| runs". |
| |
| Events: |
| None. |
| |
| Methods: |
| reload: queries for updated information on tasks. |
| resetPagination: Moves to the first page of tasks. |
| constrainRunsByUser: Toggles constrainByUser and reloads the appropriate data. |
| constrainTestRuns: Toggles constrainByTestRun and reloads the appropriate data. |
| --> |
| |
| <dom-module id="capture-skp-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><template is="dom-if" if="{{constrainByUser}}">My </template>Capture SkPicture Runs</h2> |
| <paging-sk pagination="{{pagination}}" on-pagechange="pageChangedHandler"></paging-sk> |
| <br/> |
| <paper-button raised on-click="constrainRunsByUser">{{ |
| constrainButtonText(constrainByUser, myRunsConstrainText, everyonesRunsConstrainText) |
| }}</paper-button> |
| <paper-button raised on-click="constrainTestRuns">{{ |
| constrainButtonText(constrainByTestRun, nonTestRunsConstrainText, testRunsConstrainText) |
| }}</paper-button> |
| |
| <br/> |
| <br/> |
| |
| <table class="runshistory" id="runshistory" cellpadding="5" border="1"> |
| <tr class="headers"> |
| <td>Id</td> |
| <td>User</td> |
| <td>Timestamps</td> |
| <td>Task Config</td> |
| <td>Description</td> |
| <td>Results</td> |
| <td>Task Repeats</td> |
| </tr> |
| |
| <template is="dom-repeat" items="{{captureSkpsTasks}}" as="captureSkpsTask" index-as="index"> |
| <tr style="border: 1px solid black;"> |
| <!-- Id col --> |
| <td class="nowrap"> |
| <span>{{captureSkpsTask.Id}}</span> |
| <paper-icon-button icon="delete" mini |
| class="delete-button" |
| disabled="{{!captureSkpsTask.canDelete}}" |
| alt="Delete" |
| data-index$="{{index}}" |
| data-type="delete"> |
| </paper-icon-button> |
| <paper-icon-button icon="redo" mini |
| class="redo-button" |
| disabled="{{!captureSkpsTask.canRedo}}" |
| alt="Redo" |
| data-index$="{{index}}" |
| data-type="redo"> |
| </paper-icon-button> |
| </td> |
| |
| <!-- User col --> |
| <td>{{captureSkpsTask.Username}}</td> |
| |
| <!-- Timestamps col --> |
| <td> |
| <table> |
| <tr> |
| <td>Added:</td> |
| <td class="nowrap">{{ formatTimestamp(captureSkpsTask.TsAdded) }}</td> |
| </tr> |
| <tr> |
| <td>Started:</td> |
| <td class="nowrap">{{ formatTimestamp(captureSkpsTask.TsStarted) }}</td> |
| </tr> |
| <tr> |
| <td>Completed:</td> |
| <td class="nowrap">{{ formatTimestamp(captureSkpsTask.TsCompleted) }}</td> |
| </tr> |
| </table> |
| </td> |
| |
| <!-- Task Config col --> |
| <td> |
| <table> |
| <tr> |
| <td>PageSet:</td> |
| <td>{{captureSkpsTask.PageSets}}</td> |
| </tr> |
| <tr> |
| <td>ChromiumBuild:</td> |
| <td class="nowrap"> |
| <a href="{{chromiumCommitUrl(captureSkpsTask.ChromiumRev)}}">{{shortHash(captureSkpsTask.ChromiumRev)}}</a>-<a href="{{skiaCommitUrl(captureSkpsTask.SkiaRev)}}">{{shortHash(captureSkpsTask.SkiaRev)}}</a> |
| </td> |
| </tr> |
| </table> |
| </td> |
| |
| <!-- Description col --> |
| <td>{{captureSkpsTask.Description}}</td> |
| |
| <!-- Results col --> |
| <td class="nowrap"> |
| <template is="dom-if" if="{{captureSkpsTask.Failure}}"> |
| <div style="color:red;">Failed</div> |
| </template> |
| <template is="dom-if" if="{{!captureSkpsTask.TaskDone}}"> |
| <div style="color:green;">Waiting</div> |
| </template> |
| <template is="dom-if" if="{{isDone(captureSkpsTask.Failure, captureSkpsTask.TaskDone)}}"> |
| Done |
| </template> |
| <template is="dom-if" if="{{captureSkpsTask.SwarmingLogs}}"> |
| <br/> |
| <a href="{{captureSkpsTask.SwarmingLogs}}" target="_blank">Swarming Logs</a> |
| </template> |
| </td> |
| |
| <!-- Task Repeats --> |
| <td>{{ formatRepeatAfterDays(captureSkpsTask.RepeatAfterDays) }}</td> |
| |
| </tr> |
| </template> |
| </table> |
| |
| </template> |
| </dom-module> |
| |
| <script> |
| Polymer({ |
| is: "capture-skp-runs-sk", |
| properties: { |
| captureSkpsTasks: { |
| type: Array, |
| value: function() { return []; }, |
| }, |
| defaultSize: { |
| type: Number, |
| value: 10, |
| }, |
| constrainByUser: { |
| type: Boolean, |
| value: false, |
| }, |
| myRunsConstrainText: { |
| type: String, |
| value: "View only my runs", |
| }, |
| everyonesRunsConstrainText: { |
| type: String, |
| value: "View everyone's runs", |
| }, |
| constrainByTestRun: { |
| type: Boolean, |
| value: true, |
| }, |
| nonTestRunsConstrainText: { |
| type: String, |
| value: "Exclude test runs", |
| }, |
| testRunsConstrainText: { |
| type: String, |
| value: "Include test runs", |
| }, |
| 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.captureSkpsTasks, 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, |
| } |
| if (this.constrainByUser) { |
| queryParams["filter_by_logged_in_user"] = true; |
| } |
| if (this.constrainByTestRun) { |
| queryParams["exclude_dummy_page_sets"] = true; |
| } |
| var queryStr = "?" + sk.query.fromObject(queryParams); |
| var that = this; |
| sk.post('/_/get_capture_skp_tasks' + queryStr).then(JSON.parse).then(function(json) { |
| that.captureSkpsTasks = json.data; |
| that.pagination = json.pagination; |
| for (var i = 0; i < that.captureSkpsTasks.length; i++) { |
| that.captureSkpsTasks[i].canDelete = json.permissions[i].DeleteAllowed; |
| that.captureSkpsTasks[i].canRedo = json.permissions[i].RedoAllowed; |
| that.captureSkpsTasks[i].Id = json.ids[i]; |
| } |
| }).catch(sk.errorMessage); |
| }, |
| |
| resetPagination: function() { |
| this.pagination.offset = 0; |
| this.pagination.size = this.defaultSize; |
| }, |
| |
| constrainRunsByUser: function() { |
| this.constrainByUser = !this.constrainByUser; |
| this.resetPagination(); |
| this.reload(); |
| }, |
| |
| constrainTestRuns: function() { |
| this.constrainByTestRun = !this.constrainByTestRun; |
| this.resetPagination(); |
| this.reload(); |
| }, |
| |
| constrainButtonText: function(constrained, constrainText, unconstrainText) { |
| if (constrained) { |
| return unconstrainText; |
| } else { |
| return constrainText; |
| } |
| }, |
| |
| deleteNote: function(captureSkpsTasks, deleteIndex) { |
| if (deleteIndex >= 0 && |
| captureSkpsTasks[deleteIndex].TaskDone && |
| !captureSkpsTasks[deleteIndex].Failure) { |
| return " Note: This SKP repository will no longer be available."; |
| } else { |
| return ""; |
| } |
| }, |
| |
| deleteTask: function(deleteIndex) { |
| var params = {}; |
| params["id"] = this.captureSkpsTasks[deleteIndex].Id; |
| sk.post("/_/delete_capture_skps_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(); |
| this.$.delete_dialog.close(); |
| }.bind(this)); |
| }, |
| |
| redoTask: function(redoIndex) { |
| var params = {}; |
| params["id"] = this.captureSkpsTasks[redoIndex].Id; |
| sk.post("/_/redo_capture_skps_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(); |
| this.$.redo_dialog.close(); |
| }.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> |