Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(151)

Side by Side Diff: appengine/swarming/ui/res/imp/common/common-behavior.html

Issue 2470973003: give user notification if bot or task not found (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 It contains the definition of the following Behaviors: 6 It contains the definition of the following Behaviors:
7 7
8 SwarmingBehaviors.CommonBehavior 8 SwarmingBehaviors.CommonBehavior
9 9
10 To use it, include 10 To use it, include
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 console.log("Need at least a polymer element to bind to, a busy elemen t, and a url"); 70 console.log("Need at least a polymer element to bind to, a busy elemen t, and a url");
71 return; 71 return;
72 } 72 }
73 this.set(busy, true); 73 this.set(busy, true);
74 var now = new Date(); 74 var now = new Date();
75 this._jsonAsync = this._jsonAsync || {}; 75 this._jsonAsync = this._jsonAsync || {};
76 this._jsonAsync[bindTo] = now; 76 this._jsonAsync[bindTo] = now;
77 if (params) { 77 if (params) {
78 url = url + "?" + sk.query.fromParamSet(params); 78 url = url + "?" + sk.query.fromParamSet(params);
79 } 79 }
80 sk.request("GET", url, "", headers).then(JSON.parse).then(function(json) { 80 return sk.request("GET", url, "", headers).then(JSON.parse).then(functio n(json){
81 if (this._jsonAsync[bindTo] !== now) { 81 if (this._jsonAsync[bindTo] !== now) {
82 console.log("ignoring result because a second request happened."); 82 console.log("ignoring result because a second request happened.");
83 this.set(busy, false); 83 this.set(busy, false);
84 return; 84 return;
85 } 85 }
86 this.set(bindTo, json); 86 this.set(bindTo, json);
87 this.set(busy, false); 87 this.set(busy, false);
88 }.bind(this)).catch(function(reason){ 88 }.bind(this)).catch(function(reason){
89 console.log("Reason for failure of request to " + url, reason); 89 console.log("Reason for failure of request to " + url, reason);
90 90
91 if (this._jsonAsync[bindTo] !== now) { 91 if (this._jsonAsync[bindTo] !== now) {
92 console.log("ignoring failure because a second request happened."); 92 console.log("ignoring failure because a second request happened.");
93 this.set(busy, false); 93 this.set(busy, false);
94 return; 94 return;
95 } 95 }
96 this.set(bindTo, false); 96 this.set(bindTo, false);
97 this.set(busy, false); 97 this.set(busy, false);
98 return Promise.reject(reason);
nodir 2016/11/02 18:46:29 What is reason? Can a caller check HTTP status cod
kjlubick 2016/11/03 15:48:35 reason is (after https://skia-review.googlesource.
nodir 2016/11/03 18:34:16 i think it should a part of the comment. The fact
kjlubick 2016/11/03 19:23:54 Done.
98 }.bind(this)); 99 }.bind(this));
99 }, 100 },
100 101
101 _humanDuration: function(timeInSecs) { 102 _humanDuration: function(timeInSecs) {
102 return sk.human.strDuration(timeInSecs) || "0s"; 103 return sk.human.strDuration(timeInSecs) || "0s";
103 }, 104 },
104 105
105 _not: function(a) { 106 _not: function(a) {
106 return !a; 107 return !a;
107 }, 108 },
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 } 152 }
152 return this._humanDuration((second.getTime() - first.getTime())/1000); 153 return this._humanDuration((second.getTime() - first.getTime())/1000);
153 }, 154 },
154 155
155 _truthy: function(a){ 156 _truthy: function(a){
156 return !!a; 157 return !!a;
157 } 158 }
158 }; 159 };
159 })(); 160 })();
160 </script> 161 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698