Revision 6a3a5bf7 ui/static/snf/js/ui/web/ui_icon_view.js
b/ui/static/snf/js/ui/web/ui_icon_view.js | ||
---|---|---|
16 | 16 |
var bb = root.Backbone; |
17 | 17 |
|
18 | 18 |
// handle extended info toggler |
19 |
views.VMActionErrorView = views.View.extend({ |
|
20 |
|
|
21 |
initialize: function (vm, view) { |
|
22 |
this.vm = vm; |
|
23 |
this.view = view; |
|
24 |
this.vm_view = this.view.vm(vm); |
|
25 |
|
|
26 |
this.has_error = false; |
|
27 |
|
|
28 |
this.error = this.vm_view.find(".action-error"); |
|
29 |
this.close = this.vm_view.find(".close-action-error"); |
|
30 |
this.show_btn = this.vm_view.find(".show-action-error"); |
|
31 |
|
|
32 |
this.init_handlers(); |
|
33 |
this.update_layout(); |
|
34 |
}, |
|
35 |
|
|
36 |
init_handlers: function() { |
|
37 |
// action call failed notify the user |
|
38 |
this.vm.bind("action:fail", _.bind(function(args){ |
|
39 |
if (this.vm.action_error) { |
|
40 |
this.has_error = true; |
|
41 |
action = args[0].ajax.error_params.extra_details['Action']; |
|
42 |
this.error.find(".action").text(action); |
|
43 |
this.error.show(); |
|
44 |
} |
|
45 |
}, this)); |
|
46 |
|
|
47 |
// show error overlay |
|
48 |
this.show_btn.click(_.bind(function() { |
|
49 |
this.show_error_overlay(this.vm.action_error); |
|
50 |
this.vm.reset_action_error(); |
|
51 |
}, this)); |
|
52 |
|
|
53 |
// user requests to forget about the error |
|
54 |
this.close.click(_.bind(_.bind(function() { |
|
55 |
this.error.hide(); |
|
56 |
this.vm.reset_action_error(); |
|
57 |
}, this))); |
|
58 |
|
|
59 |
// hide error message if action fail get reset |
|
60 |
this.vm.bind("action:fail:reset", _.bind(function(){ |
|
61 |
this.error.hide(); |
|
62 |
}, this)); |
|
63 |
}, |
|
64 |
|
|
65 |
show_error_overlay: function(arguments) { |
|
66 |
var xhr = arguments[0]; |
|
67 |
var args = util.parse_api_error(arguments); |
|
68 |
|
|
69 |
// force logout if UNAUTHORIZED request arrives |
|
70 |
if (args.code == 401) { snf.ui.logout(); return }; |
|
71 |
|
|
72 |
var error_entry = [args.ns, args.code, args.message, args.type, args.details, args]; |
|
73 |
ui.main.error_view.show_error.apply(ui.main.error_view, error_entry); |
|
74 |
}, |
|
75 |
|
|
76 |
update_layout: function() { |
|
77 |
if (this.vm.action_error) { |
|
78 |
this.error.show(); |
|
79 |
} |
|
80 |
} |
|
81 |
}); |
|
82 |
|
|
83 |
// handle extended info toggler |
|
19 | 84 |
views.IconInfoView = views.View.extend({ |
20 | 85 |
|
21 | 86 |
initialize: function (vm, view) { |
... | ... | |
565 | 630 |
this.tags_views = this.tags_views || {}; |
566 | 631 |
this.details_views = this.details_views || {}; |
567 | 632 |
this.info_views = this.info_views || {}; |
633 |
this.action_error_views = this.action_error_views || {}; |
|
568 | 634 |
this.action_views = this.action_views || {}; |
569 | 635 |
|
570 | 636 |
this.action_views[vm.id] = new views.VMActionsView(vm, this, this.vm(vm), this.hide_actions); |
... | ... | |
574 | 640 |
this.tags_views[vm.id] = new views.VMTagsView(vm, this); |
575 | 641 |
this.details_views[vm.id] = new views.VMDetailsView(vm, this); |
576 | 642 |
this.info_views[vm.id] = new views.IconInfoView(vm, this); |
643 |
this.action_error_views[vm.id] = new views.VMActionErrorView(vm, this); |
|
577 | 644 |
}, |
578 | 645 |
|
579 | 646 |
// vm specific event handlers |
Also available in: Unified diff