| OLD | NEW |
| 1 <!-- | 1 <!-- |
| 2 Copyright 2016 The LUCI Authors. All rights reserved. | 2 Copyright 2016 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 This in an HTML Import-able file that contains the definition | 6 This in an HTML Import-able file that contains the definition |
| 7 of the following elements: | 7 of the following elements: |
| 8 | 8 |
| 9 <task-page> | 9 <task-page> |
| 10 | 10 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 <link rel="import" href="/res/imp/bower_components/polymer/polymer.html"> | 34 <link rel="import" href="/res/imp/bower_components/polymer/polymer.html"> |
| 35 | 35 |
| 36 <link rel="import" href="/res/imp/common/common-behavior.html"> | 36 <link rel="import" href="/res/imp/common/common-behavior.html"> |
| 37 <link rel="import" href="/res/imp/common/interval-timer.html"> | 37 <link rel="import" href="/res/imp/common/interval-timer.html"> |
| 38 <link rel="import" href="/res/imp/common/single-page-style.html"> | 38 <link rel="import" href="/res/imp/common/single-page-style.html"> |
| 39 <link rel="import" href="/res/imp/common/swarming-app.html"> | 39 <link rel="import" href="/res/imp/common/swarming-app.html"> |
| 40 <link rel="import" href="/res/imp/common/task-behavior.html"> | 40 <link rel="import" href="/res/imp/common/task-behavior.html"> |
| 41 <link rel="import" href="/res/imp/common/url-param.html"> | 41 <link rel="import" href="/res/imp/common/url-param.html"> |
| 42 | 42 |
| 43 <link rel="import" href="task-page-data.html"> | 43 <link rel="import" href="task-page-data.html"> |
| 44 <link rel="import" href="task-retry-prompt.html"> |
| 44 <link rel="import" href="task-disambiguation.html"> | 45 <link rel="import" href="task-disambiguation.html"> |
| 45 | 46 |
| 46 <dom-module id="task-page"> | 47 <dom-module id="task-page"> |
| 47 <template> | 48 <template> |
| 48 <style include="iron-flex iron-flex-alignment swarming-app-style single-page
-style task-style"> | 49 <style include="iron-flex iron-flex-alignment swarming-app-style single-page
-style task-style"> |
| 49 .milo { | 50 .milo { |
| 50 width: calc(100% - 11px); | 51 width: calc(100% - 11px); |
| 51 /** We don't control the milo site and it's on a different domain than | 52 /** We don't control the milo site and it's on a different domain than |
| 52 us, so there's no good way to avoid scrolling other than tell the iframe | 53 us, so there's no good way to avoid scrolling other than tell the iframe |
| 53 it is really tall.*/ | 54 it is really tall.*/ |
| (...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 596 | 597 |
| 597 <paper-dialog id="prompt" modal on-iron-overlay-closed="_promptClosed"> | 598 <paper-dialog id="prompt" modal on-iron-overlay-closed="_promptClosed"> |
| 598 <h2>Are you sure?</h2> | 599 <h2>Are you sure?</h2> |
| 599 <div>Are you sure you want to [[_dialog_prompt]]?</div> | 600 <div>Are you sure you want to [[_dialog_prompt]]?</div> |
| 600 <div class="buttons"> | 601 <div class="buttons"> |
| 601 <paper-button dialog-dismiss autofocus>No</paper-button> | 602 <paper-button dialog-dismiss autofocus>No</paper-button> |
| 602 <paper-button dialog-confirm>Yes</paper-button> | 603 <paper-button dialog-confirm>Yes</paper-button> |
| 603 </div> | 604 </div> |
| 604 </paper-dialog> | 605 </paper-dialog> |
| 605 | 606 |
| 607 <paper-dialog id="retry_task" modal on-iron-overlay-closed="_retryClosed"> |
| 608 <task-retry-prompt id="retry_task_prompt" |
| 609 task_id="[[task_id]]" |
| 610 task_dimensions="{{_retry_dimensions}}"> |
| 611 </task-retry-prompt> |
| 612 <div class="buttons"> |
| 613 <paper-button dialog-dismiss>Cancel</paper-button> |
| 614 <paper-button dialog-confirm>OK</paper-button> |
| 615 </div> |
| 616 </paper-dialog> |
| 617 |
| 606 <interval-timer period="[[_refresh_interval]]" on-trigger="_softRefresh"> | 618 <interval-timer period="[[_refresh_interval]]" on-trigger="_softRefresh"> |
| 607 </interval-timer> | 619 </interval-timer> |
| 608 | 620 |
| 609 </template> | 621 </template> |
| 610 <script> | 622 <script> |
| 611 (function(){ | 623 (function(){ |
| 612 Polymer({ | 624 Polymer({ |
| 613 is: 'task-page', | 625 is: 'task-page', |
| 614 | 626 |
| 615 behaviors: [ | 627 behaviors: [ |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 686 _request: { | 698 _request: { |
| 687 type: Object, | 699 type: Object, |
| 688 observer: "_requestUpdated" | 700 observer: "_requestUpdated" |
| 689 }, | 701 }, |
| 690 _request_detail: { | 702 _request_detail: { |
| 691 type: Boolean, | 703 type: Boolean, |
| 692 }, | 704 }, |
| 693 _result: { | 705 _result: { |
| 694 type: Object, | 706 type: Object, |
| 695 }, | 707 }, |
| 708 _retry_dimensions: { |
| 709 type: Array, |
| 710 }, |
| 696 _server_details: { | 711 _server_details: { |
| 697 type: Object, | 712 type: Object, |
| 698 }, | 713 }, |
| 699 _stdout: { | 714 _stdout: { |
| 700 type: String, | 715 type: String, |
| 701 } | 716 } |
| 702 }, | 717 }, |
| 703 | 718 |
| 704 observers: [ | 719 observers: [ |
| 705 "_whyPending(_request,_result,_auth_headers)"], | 720 "_whyPending(_request,_result,_auth_headers)"], |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 882 var end = result.started_ts || result.abandoned_ts || new Date(); | 897 var end = result.started_ts || result.abandoned_ts || new Date(); |
| 883 // In the case of deduplicated tasks, started_ts comes before the task. | 898 // In the case of deduplicated tasks, started_ts comes before the task. |
| 884 if (end <= result.created_ts) { | 899 if (end <= result.created_ts) { |
| 885 return "0s"; | 900 return "0s"; |
| 886 } | 901 } |
| 887 return this._timeDiffExact(result.created_ts, end); | 902 return this._timeDiffExact(result.created_ts, end); |
| 888 }, | 903 }, |
| 889 | 904 |
| 890 _promptClosed: function(e) { | 905 _promptClosed: function(e) { |
| 891 if (e.detail.confirmed) { | 906 if (e.detail.confirmed) { |
| 892 if (this._dialog_prompt.startsWith("cancel")) { | 907 this._cancelTask(); |
| 893 this._cancelTask(); | |
| 894 } else { | |
| 895 this._retryTask(); | |
| 896 } | |
| 897 } | 908 } |
| 898 }, | 909 }, |
| 899 | 910 |
| 900 _promptCancel: function() { | 911 _promptCancel: function() { |
| 901 this.set("_dialog_prompt", "cancel task "+this.task_id); | 912 this.set("_dialog_prompt", "cancel task "+this.task_id); |
| 902 this.$.prompt.open(); | 913 this.$.prompt.open(); |
| 903 }, | 914 }, |
| 904 | 915 |
| 905 _promptRetry: function() { | 916 _promptRetry: function() { |
| 906 this.set("_dialog_prompt", "retry task "+this.task_id); | 917 this.$.retry_task_prompt.setDimensions(this._request.properties.dimensio
ns); |
| 907 this.$.prompt.open(); | 918 this.$.retry_task.open(); |
| 908 }, | 919 }, |
| 909 | 920 |
| 910 _rawOutput: function(stdout, result) { | 921 _retryClosed: function(e) { |
| 911 if (stdout) { | 922 if (!this._request) { |
| 912 return stdout; | 923 sk.errorMessage("Task not yet loaded", 3000); |
| 913 } | |
| 914 if (result.state === "PENDING" || result.state === "RUNNING") { | |
| 915 return "[No output yet]"; | |
| 916 } | |
| 917 return "[No output received]"; | |
| 918 }, | |
| 919 | |
| 920 _refresh: function() { | |
| 921 this.$.data.reload(); | |
| 922 }, | |
| 923 | |
| 924 _requestUpdated: function(request) { | |
| 925 if (this._noMilo(request)) { | |
| 926 this.set("_show_raw", 1); | |
| 927 } | |
| 928 }, | |
| 929 | |
| 930 _softRefresh: function() { | |
| 931 if (this._result && this._result.state !== "RUNNING" && | |
| 932 this._result.state !== "PENDING") { | |
| 933 return; | 924 return; |
| 934 } | 925 } |
| 935 this.$.data.reload(); | 926 if (!e.detail.confirmed) { |
| 936 var miloFrame = this.$$("iframe") | |
| 937 if (miloFrame) { | |
| 938 miloFrame.src = this._getDisplayServerLink(this._server_details.displa
y_server_url_template,this.task_id); | |
| 939 } | |
| 940 }, | |
| 941 | |
| 942 _retryTask: function() { | |
| 943 if (!this._request) { | |
| 944 sk.errorMessage("Task not yet loaded", 3000); | |
| 945 return; | 927 return; |
| 946 } | 928 } |
| 947 var newTask = { | 929 var newTask = { |
| 948 expiration_secs: this._request.expiration_secs, | 930 expiration_secs: this._request.expiration_secs, |
| 949 name: this._request.name +" (retry)", | 931 name: this._request.name +" (retry)", |
| 950 parent_task_id: this._request.parent_task_id, | 932 parent_task_id: this._request.parent_task_id, |
| 951 priority: this._request.priority, | 933 priority: this._request.priority, |
| 952 properties:this._request.properties, | 934 properties:this._request.properties, |
| 953 tags: this._request.tags, | 935 tags: this._request.tags, |
| 954 user: this._profile.email, | 936 user: this._profile.email, |
| 955 service_account: this._request.service_account, | 937 service_account: this._request.service_account, |
| 956 } | 938 } |
| 939 newTask.properties.dimensions = this._retry_dimensions.filter(function(d
){ |
| 940 return d && d.key && d.value; |
| 941 }); |
| 942 if (!newTask.properties.dimensions || !newTask.properties.dimensions.len
gth) { |
| 943 sk.errorMessage("Your retried task must specify dimensions", 5000); |
| 944 return; |
| 945 } |
| 946 console.log("Retrying with dimensions", newTask.properties.dimensions); |
| 957 newTask.properties.idempotent = false; | 947 newTask.properties.idempotent = false; |
| 958 swarming.postWithToast("/api/swarming/v1/tasks/new", "Retrying task " +
this.task_id, | 948 swarming.postWithToast("/api/swarming/v1/tasks/new", "Retrying task " +
this.task_id, |
| 959 this._auth_headers, newTask) | 949 this._auth_headers, newTask) |
| 960 .then(function(response) { | 950 .then(function(response) { |
| 961 response = JSON.parse(response); | 951 response = JSON.parse(response); |
| 962 if (response && response.task_id) { | 952 if (response && response.task_id) { |
| 963 var state = {id: this.task_id}; | 953 var state = {id: this.task_id}; |
| 964 history.pushState(state, "Task Page"); | 954 history.pushState(state, "Task Page"); |
| 965 this.set("task_id", response.task_id); | 955 this.set("task_id", response.task_id); |
| 966 } | 956 } |
| 967 }.bind(this), function(e) { | 957 }.bind(this), function(e) { |
| 968 console.log("Task could not be retried", e); | 958 console.log("Task could not be retried", e); |
| 969 } | 959 } |
| 970 ); | 960 ); |
| 971 }, | 961 }, |
| 972 | 962 |
| 963 _rawOutput: function(stdout, result) { |
| 964 if (stdout) { |
| 965 return stdout; |
| 966 } |
| 967 if (result.state === "PENDING" || result.state === "RUNNING") { |
| 968 return "[No output yet]"; |
| 969 } |
| 970 return "[No output received]"; |
| 971 }, |
| 972 |
| 973 _refresh: function() { |
| 974 this.$.data.reload(); |
| 975 }, |
| 976 |
| 977 _requestUpdated: function(request) { |
| 978 if (this._noMilo(request)) { |
| 979 this.set("_show_raw", 1); |
| 980 } |
| 981 }, |
| 982 |
| 983 _softRefresh: function() { |
| 984 if (this._result && this._result.state !== "RUNNING" && |
| 985 this._result.state !== "PENDING") { |
| 986 return; |
| 987 } |
| 988 this.$.data.reload(); |
| 989 var miloFrame = this.$$("iframe") |
| 990 if (miloFrame) { |
| 991 var templ = this._server_details.display_server_url_template; |
| 992 miloFrame.src = this._getDisplayServerLink(templ, this.task_id); |
| 993 } |
| 994 }, |
| 995 |
| 973 _rowspan: function(dims) { | 996 _rowspan: function(dims) { |
| 974 dims = dims || []; | 997 dims = dims || []; |
| 975 return dims.length + 1; | 998 return dims.length + 1; |
| 976 }, | 999 }, |
| 977 | 1000 |
| 978 _supportsMilo: function(request, showRaw) { | 1001 _supportsMilo: function(request, showRaw) { |
| 979 return !showRaw && request && this._tag(request, "allow_milo"); | 1002 return !showRaw && request && this._tag(request, "allow_milo"); |
| 980 }, | 1003 }, |
| 981 | 1004 |
| 982 _toggleDetails: function() { | 1005 _toggleDetails: function() { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1030 this._getJsonAsync("_other_running", "/api/swarming/v1/tasks/count", "
_busyRunningCount", this._auth_headers, taskCountParams); | 1053 this._getJsonAsync("_other_running", "/api/swarming/v1/tasks/count", "
_busyRunningCount", this._auth_headers, taskCountParams); |
| 1031 // change running to pending | 1054 // change running to pending |
| 1032 taskCountParams.state = ["PENDING"]; | 1055 taskCountParams.state = ["PENDING"]; |
| 1033 this._getJsonAsync("_other_pending", "/api/swarming/v1/tasks/count", "
_busyPendingCount", this._auth_headers, taskCountParams); | 1056 this._getJsonAsync("_other_pending", "/api/swarming/v1/tasks/count", "
_busyPendingCount", this._auth_headers, taskCountParams); |
| 1034 } | 1057 } |
| 1035 } | 1058 } |
| 1036 }); | 1059 }); |
| 1037 })(); | 1060 })(); |
| 1038 </script> | 1061 </script> |
| 1039 </dom-module> | 1062 </dom-module> |
| OLD | NEW |