Revision 9ffd10ce ui/static/snf/js/ui/web/ui_error_view.js
b/ui/static/snf/js/ui/web/ui_error_view.js | ||
---|---|---|
52 | 52 |
|
53 | 53 |
this.$(".reload-app").click(function(){ |
54 | 54 |
window.location.reload(true); |
55 |
}) |
|
55 |
}); |
|
56 |
|
|
57 |
this.$(".show-next").click(_.bind(function(){ |
|
58 |
this.show_next_error(); |
|
59 |
}, this)); |
|
60 |
|
|
61 |
this.$(".show-prev").click(_.bind(function(){ |
|
62 |
this.show_prev_error(); |
|
63 |
}, this)); |
|
64 |
|
|
65 |
this.displaying_error = false; |
|
66 |
this.error_stack_index = []; |
|
67 |
this.error_stack = {}; |
|
56 | 68 |
}, |
57 | 69 |
|
58 | 70 |
error_object: function() { |
... | ... | |
62 | 74 |
report_error: function() { |
63 | 75 |
this.feedback_view = this.feedback_view || ui.main.feedback_view; |
64 | 76 |
this.hide(false); |
77 |
this.displaying_error = true; |
|
78 |
|
|
65 | 79 |
window.setTimeout(_.bind(function() { |
66 | 80 |
this.feedback_view.show(this.get_report_message(), true, {error: this.error_object()}); |
67 | 81 |
}, this), 400); |
... | ... | |
81 | 95 |
}, |
82 | 96 |
|
83 | 97 |
show_error: function(ns, code, message, type, details, error_options) { |
84 |
if (snf.api.error_state == snf.api.STATES.NORMAL) { this.error_stack = {} }; |
|
85 |
|
|
98 |
|
|
86 | 99 |
var error_entry = [ns, code, message, type, details, error_options]; |
87 |
this.error_stack[new Date()] = error_entry; |
|
88 |
this.display_error.apply(this, error_entry); |
|
89 |
this.show(); |
|
100 |
var last_error_key = this.update_errors_stack(error_entry); |
|
101 |
|
|
102 |
if (!this.is_visible && !this.displaying_error) { |
|
103 |
this.current_error = last_error_key; |
|
104 |
this.display_error.call(this, last_error_key); |
|
105 |
this.show(); |
|
106 |
} |
|
107 |
|
|
108 |
this.update_errors_stack(); |
|
109 |
}, |
|
110 |
|
|
111 |
update_errors_stack: function(entry) { |
|
112 |
if (snf.api.error_state != snf.api.STATES.ERROR) { |
|
113 |
this.error_stack = {}; |
|
114 |
this.error_stack_index = []; |
|
115 |
}; |
|
116 |
|
|
117 |
var stack_key = (new Date()).getTime(); |
|
118 |
this.error_stack[stack_key] = entry; |
|
119 |
this.error_stack_index.push(stack_key); |
|
120 |
this.errors_occured = this.error_stack_index.length; |
|
121 |
|
|
122 |
this.$(".error-nav").hide(); |
|
123 |
//this.update_errors_stack_layout(); |
|
124 |
return stack_key; |
|
90 | 125 |
}, |
91 | 126 |
|
92 |
display_error: function(ns, code, message, type, details, error_options) { |
|
127 |
is_last_error: function(stack_key) { |
|
128 |
return this.error_stack_index.indexOf(stack_key) == this.error_stack_index.length - 1; |
|
129 |
}, |
|
130 |
|
|
131 |
is_first_error: function(stack_key) { |
|
132 |
return this.error_stack_index.indexOf(stack_key) == 0; |
|
133 |
}, |
|
134 |
|
|
135 |
update_errors_stack_layout: function() { |
|
136 |
if (!this.current_error) { return }; |
|
137 |
|
|
138 |
if (this.errors_occured <= 1) { |
|
139 |
this.$(".error-nav").hide(); |
|
140 |
} else { |
|
141 |
this.$(".error-nav").show(); |
|
142 |
}; |
|
143 |
|
|
144 |
if (this.is_last_error(this.current_error)) { |
|
145 |
this.$(".show-next").hide(); |
|
146 |
} else { |
|
147 |
this.$(".show-next").show(); |
|
148 |
} |
|
149 |
|
|
150 |
if (this.is_first_error(this.current_error)) { |
|
151 |
this.$(".show-prev").hide(); |
|
152 |
} else { |
|
153 |
this.$(".show-prev").show(); |
|
154 |
} |
|
155 |
}, |
|
156 |
|
|
157 |
show_next_error: function() { |
|
158 |
}, |
|
159 |
|
|
160 |
show_prev_error: function() { |
|
161 |
}, |
|
162 |
|
|
163 |
display_error: function(stack_key) { |
|
164 |
var err = this.error_stack[stack_key]; |
|
165 |
var ns = err[0], code = err[1], message = err[2], type = err[3], details = err[4], error_options = err[5] |
|
166 |
|
|
93 | 167 |
this.error_options = {'allow_report': true, 'allow_reload': true, |
94 | 168 |
'extra_details': {}, 'non_critical': false, |
95 |
'allow_details': false }; |
|
169 |
'allow_details': false, |
|
170 |
'allow_close': true }; |
|
96 | 171 |
|
97 | 172 |
if (error_options) { |
98 | 173 |
this.error_options = _.extend(this.error_options, error_options); |
... | ... | |
120 | 195 |
} |
121 | 196 |
|
122 | 197 |
this.$(".actions .show-details").click(); |
198 |
this.$(".error-details").hide(); |
|
123 | 199 |
this.$(".key.details").click(); |
124 | 200 |
this.$(".error-more-details").hide(); |
125 | 201 |
}, |
... | ... | |
170 | 246 |
this.$(".reload-app").hide(); |
171 | 247 |
} |
172 | 248 |
|
249 |
if (this.error_options.allow_close) { |
|
250 |
this.$(".closeme").show(); |
|
251 |
} else { |
|
252 |
this.$(".closeme").hide(); |
|
253 |
} |
|
254 |
|
|
173 | 255 |
}, |
174 | 256 |
|
175 | 257 |
onOpen: function() { |
258 |
this.displaying_error = true; |
|
176 | 259 |
var self = this; |
177 | 260 |
|
178 | 261 |
this.$(".closeme").unbind("click"); |
179 | 262 |
this.$(".closeme").bind("click", function(){ |
180 |
self.hide("reset") |
|
263 |
self.hide("reset");
|
|
181 | 264 |
}) |
182 | 265 |
}, |
183 | 266 |
|
184 | 267 |
hide: function(reset_state) { |
185 |
if (reset_state === "reset") { snf.api.trigger("reset") }; |
|
268 |
if (reset_state === "reset") { |
|
269 |
// delay reset error state for fade out |
|
270 |
window.setTimeout(_.bind(function(){ |
|
271 |
this.displaying_error = false; |
|
272 |
this.error_stack = {}; |
|
273 |
snf.api.trigger("reset"); |
|
274 |
}, this), 500); |
|
275 |
} else { |
|
276 |
this.displaying_error = false; |
|
277 |
} |
|
186 | 278 |
views.ErrorView.__super__.hide.apply(this); |
187 | 279 |
}, |
188 | 280 |
|
Also available in: Unified diff