Revision ae0a8b37

View differences:

src/sunstone/public/app/tabs/images-tab/actions.js
11 11
  var CREATE_DIALOG_ID = require('./form-panels/create/formPanelId');
12 12
  var CLONE_DIALOG_ID = require('./dialogs/clone/dialogId');
13 13

  
14
  var _commonActions = new CommonActions(OpenNebulaImage, RESOURCE, TAB_ID);
14
  var _commonActions = new CommonActions(OpenNebulaImage, RESOURCE, TAB_ID, XML_ROOT);
15 15

  
16 16
  var _actions = {
17
    "Image.create" : {
18
      type: "create",
19
      call: OpenNebulaImage.create,
20
      callback: function(request, response) {
21
        Sunstone.resetFormPanel(TAB_ID, CREATE_DIALOG_ID);
22
        Sunstone.hideFormPanel(TAB_ID);
23
        Sunstone.getDataTable(TAB_ID).addElement(request, response);
24
        Notifier.notifyCustom(Locale.tr("Image created"), " ID: " + response[XML_ROOT].ID, false);
25
      },
26
      error: function(request, response) {
27
        Sunstone.hideFormPanelLoading(TAB_ID);
28
        Notifier.onError(request, response);
29
      },
30
    },
31

  
32
    "Image.create_dialog" : {
33
      type: "custom",
34
      call: function() {
35
        Sunstone.showFormPanel(TAB_ID, CREATE_DIALOG_ID, "create");
36
      }
37
    },
38

  
39
    "Image.list" : {
40
      type: "list",
41
      call: OpenNebulaImage.list,
42
      callback: function(request, response) {
43
        Sunstone.getDataTable(TAB_ID).updateView(request, response);
44
      },
45
      error: Notifier.onError
46
    },
47

  
48
    "Image.show" : {
49
      type : "single",
50
      call: OpenNebulaImage.show,
51
      callback: function(request, response) {
52
        Sunstone.getDataTable(TAB_ID).updateElement(request, response);
53
        if (Sunstone.rightInfoVisible($('#'+TAB_ID))) {
54
          Sunstone.insertPanels(TAB_ID, response);
55
        }
56
      },
57
      error: Notifier.onError
58
    },
59

  
60
    "Image.refresh" : {
61
      type: "custom",
62
      call: function () {
63
        var tab = $('#' + TAB_ID);
64
        if (Sunstone.rightInfoVisible(tab)) {
65
          Sunstone.runAction(RESOURCE+".show", Sunstone.rightInfoResourceId(tab));
66
        } else {
67
          Sunstone.getDataTable(TAB_ID).waitingNodes();
68
          Sunstone.runAction(RESOURCE+".list", {force: true});
69
        }
70
      }
71
    },
72

  
73
    "Image.update_template" : {
74
      type: "single",
75
      call: OpenNebulaImage.update,
76
      callback: function(request) {
77
        Sunstone.runAction(RESOURCE+".show", request.request.data[0][0]);
78
      },
79
      error: Notifier.onError
80
    },
81

  
82
    "Image.enable" : {
83
      type: "multiple",
84
      call: OpenNebulaImage.enable,
85
      callback: function (req) {
86
        Sunstone.runAction(RESOURCE+".show", req.request.data[0]);
87
      },
88
      elements: function() {
89
        return Sunstone.getDataTable(TAB_ID).elements();
90
      },
91
      error: Notifier.onError,
92
      notify: true
93
    },
94

  
95
    "Image.disable" : {
96
      type: "multiple",
97
      call: OpenNebulaImage.disable,
98
      callback: function (req) {
99
        Sunstone.runAction(RESOURCE+".show", req.request.data[0]);
100
      },
101
      elements: function() {
102
        return Sunstone.getDataTable(TAB_ID).elements();
103
      },
104
      error: Notifier.onError,
105
      notify: true
106
    },
107

  
108
    "Image.persistent" : {
109
      type: "multiple",
110
      call: OpenNebulaImage.persistent,
111
      callback: function (req) {
112
        Sunstone.runAction(RESOURCE+".show", req.request.data[0]);
113
      },
114
      elements: function() {
115
        return Sunstone.getDataTable(TAB_ID).elements();
116
      },
117
      error: Notifier.onError,
118
      notify: true
119
    },
120

  
121
    "Image.nonpersistent" : {
122
      type: "multiple",
123
      call: OpenNebulaImage.nonpersistent,
124
      callback: function (req) {
125
        Sunstone.runAction(RESOURCE+".show", req.request.data[0]);
126
      },
127
      elements: function() {
128
        return Sunstone.getDataTable(TAB_ID).elements();
129
      },
130
      error: Notifier.onError,
131
      notify: true
132
    },
133

  
134
    "Image.delete" : {
135
      type: "multiple",
136
      call: OpenNebulaImage.del,
137
      callback : function(request, response) {
138
        Sunstone.getDataTable(TAB_ID).deleteElement(request, response);
139
      },
140
      elements: function() {
141
        return Sunstone.getDataTable(TAB_ID).elements();
142
      },
143
      error: Notifier.onError,
144
      notify: true
145
    },
146

  
147
    "Image.chown" : {
148
      type: "multiple",
149
      call: OpenNebulaImage.chown,
150
      callback:  function (req) {
151
        Sunstone.runAction(RESOURCE+".show", req.request.data[0]);
152
      },
153
      elements: function() {
154
        return Sunstone.getDataTable(TAB_ID).elements();
155
      },
156
      error: Notifier.onError,
157
      notify: true
158
    },
159

  
160
    "Image.chgrp" : {
161
      type: "multiple",
162
      call: OpenNebulaImage.chgrp,
163
      callback: function (req) {
164
        Sunstone.runAction(RESOURCE+".show", req.request.data[0]);
165
      },
166
      elements: function() {
167
        return Sunstone.getDataTable(TAB_ID).elements();
168
      },
169
      error: Notifier.onError,
170
      notify: true
171
    },
172

  
173
    "Image.chmod" : {
174
      type: "single",
175
      call: OpenNebulaImage.chmod,
176
      callback: function (req) {
177
        Sunstone.runAction(RESOURCE+".show", req.request.data[0]);
178
      },
179
      error: Notifier.onError,
180
      notify: true
181
    },
182

  
183
    "Image.chtype" : {
184
      type: "single",
185
      call: OpenNebulaImage.chtype,
186
      callback: function (req) {
187
        Sunstone.runAction(RESOURCE+".show", req.request.data[0][0]);
188
      },
189
      elements: function() {
190
        return Sunstone.getDataTable(TAB_ID).elements();
191
      },
192
      error: Notifier.onError,
193
      notify: true
194
    },
17
    "Image.create" : _commonActions.create(CREATE_DIALOG_ID),
18
    "Image.create_dialog" : _commonActions.showCreate(CREATE_DIALOG_ID),
19
    "Image.list" : _commonActions.list(),
20
    "Image.show" : _commonActions.show(),
21
    "Image.refresh" : _commonActions.refresh(),
22
    "Image.delete" : _commonActions.del(),
23
    "Image.update_template" : _commonActions.updateTemplate(),
24
    "Image.chown": _commonActions.multipleAction('chown'),
25
    "Image.chgrp": _commonActions.multipleAction('chgrp'),
26
    "Image.chmod": _commonActions.singleAction('chmod'),
27
    "Image.rename": _commonActions.singleAction('rename'),
28
    "Image.enable": _commonActions.multipleAction('enable'),
29
    "Image.disable": _commonActions.multipleAction('disable'),
30
    "Image.persistent": _commonActions.multipleAction('persistent'),
31
    "Image.nonpersistent": _commonActions.multipleAction('nonpersistent'),
32
    "Image.chtype": _commonActions.singleAction('chtype'),
33
    "Image.snapshot_flatten": _commonActions.singleAction("snapshot_flatten"),
34
    "Image.snapshot_revert": _commonActions.singleAction("snapshot_revert"),
35
    "Image.snapshot_delete": _commonActions.singleAction("snapshot_delete"),
36
    
195 37
    "Image.clone_dialog" : {
196 38
      type: "custom",
197 39
      call: function(){
......
203 45
      call: OpenNebulaImage.clone,
204 46
      error: Notifier.onError,
205 47
      notify: true
206
    },
207
    "Image.rename" : {
208
      type: "single",
209
      call: OpenNebulaImage.rename,
210
      callback: function(request) {
211
        Sunstone.runAction(RESOURCE+".show", request.request.data[0][0]);
212
      },
213
      error: Notifier.onError,
214
      notify: true
215
    },
216
    "Image.snapshot_flatten": _commonActions.singleAction("snapshot_flatten"),
217
    "Image.snapshot_revert": _commonActions.singleAction("snapshot_revert"),
218
    "Image.snapshot_delete": _commonActions.singleAction("snapshot_delete"),
48
    }
219 49
  };
220 50

  
221 51
  return _actions;

Also available in: Unified diff