Revision 6a3a5bf7 ui/static/snf/js/ui/web/ui_vms_base_view.js
b/ui/static/snf/js/ui/web/ui_vms_base_view.js | ||
---|---|---|
287 | 287 |
this.view_id = "vm_" + vm.id + "_actions"; |
288 | 288 |
views.VMActionsView.__super__.initialize.call(this); |
289 | 289 |
|
290 |
this.hovered = false; |
|
290 | 291 |
}, |
291 | 292 |
|
292 | 293 |
action: function(name) { |
... | ... | |
320 | 321 |
// some serious debugging is needed to |
321 | 322 |
// find out what is going on |
322 | 323 |
this.vm = storage.vms.get(this.vm.id); |
323 |
} catch (err) { return } |
|
324 |
this.init_vm_handlers(); |
|
325 |
} catch (err) { console.error(err); return } |
|
324 | 326 |
|
325 | 327 |
if (!this.vm) { return } |
326 |
|
|
328 |
|
|
327 | 329 |
// update selected action |
328 | 330 |
if (this.vm.pending_action) { |
329 | 331 |
this.selected_action = this.vm.pending_action; |
... | ... | |
340 | 342 |
this.reset(); |
341 | 343 |
} |
342 | 344 |
|
343 |
if (this.selected_action) { |
|
345 |
this.el.show(); |
|
346 |
|
|
347 |
if ((this.selected_action || this.hovered) && !this.vm.action_error) { |
|
344 | 348 |
// show selected action |
345 | 349 |
$(this.el).show(); |
346 | 350 |
$(this.el).find("a").css("visibility", "visible"); |
347 |
|
|
348 | 351 |
// show action icon |
349 | 352 |
this.view.show_indicator(this.vm); |
350 | 353 |
} else { |
351 |
if (this.hide) { |
|
354 |
if (this.hide || this.vm.action_error) {
|
|
352 | 355 |
// view shows actions on machine hover |
353 | 356 |
$(this.el).find("a").css("visibility", "hidden"); |
354 | 357 |
} else { |
355 |
// view shows actions always |
|
356 |
$(this.el).find("a").css("visibility", "visible"); |
|
357 |
$(this.el).show(); |
|
358 |
if (!this.vm.action_error) { |
|
359 |
// view shows actions always |
|
360 |
$(this.el).find("a").css("visibility", "visible"); |
|
361 |
$(this.el).show(); |
|
362 |
} |
|
358 | 363 |
} |
359 | 364 |
|
360 | 365 |
this.view.hide_indicator(this.vm); |
... | ... | |
383 | 388 |
}, this); |
384 | 389 |
}, |
385 | 390 |
|
391 |
init_vm_handlers: function() { |
|
392 |
try { |
|
393 |
this.vm.unbind("action:fail", this.update_layout) |
|
394 |
this.vm.unbind("action:fail:reset", this.update_layout) |
|
395 |
} catch (err) {}; |
|
396 |
|
|
397 |
this.vm.bind("action:fail", this.update_layout) |
|
398 |
this.vm.bind("action:fail:reset", this.update_layout) |
|
399 |
}, |
|
400 |
|
|
386 | 401 |
// bind event handlers |
387 | 402 |
set_handlers: function() { |
388 | 403 |
var self = this; |
... | ... | |
392 | 407 |
if (this.hide) { $(this.el).hide() }; |
393 | 408 |
|
394 | 409 |
// vm container hover (icon view) |
395 |
this.view.vm(this.vm).hover(function(){
|
|
396 |
$(self.el).show();
|
|
397 |
$(self.el).find("a").css("visibility", "visible");
|
|
410 |
this.view.vm(this.vm).hover(_.bind(function() {
|
|
411 |
this.hovered = true;
|
|
412 |
this.update_layout();
|
|
398 | 413 |
|
399 |
}, function() { |
|
414 |
}, this), _.bind(function() {
|
|
400 | 415 |
if (self.hide) { |
401 |
// icon view |
|
402 |
if (!self.selected_action) { |
|
403 |
$(self.el).find("a").css("visibility", "hidden"); |
|
404 |
} else { |
|
405 |
// single view (always visible) or icon view with |
|
406 |
// selected action |
|
407 |
$(self.el).show(); |
|
408 |
$(self.el).find("a").css("visibility", "visible"); |
|
409 |
} |
|
416 |
this.hovered = false; |
|
417 |
this.update_layout(); |
|
410 | 418 |
} |
411 |
}); |
|
419 |
}, this)); |
|
420 |
|
|
412 | 421 |
|
413 | 422 |
// action links events |
414 | 423 |
_.each(models.VM.ACTIONS, function(action) { |
Also available in: Unified diff