Revision 6000acf9

View differences:

src/sunstone/public/app/tabs/files-tab/actions.js
3 3
  var Notifier = require('utils/notifier');
4 4
  var Locale = require('utils/locale');
5 5
  var OpenNebulaResource = require('opennebula/image');
6
  var CommonActions = require('utils/common-actions');
6 7

  
7 8
  var RESOURCE = "File";
8 9
  var XML_ROOT = "IMAGE";
9 10
  var TAB_ID = require('./tabId');
10 11
  var CREATE_DIALOG_ID = require('./form-panels/create/formPanelId');
11 12

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

  
28
    "File.create_dialog" : {
29
      type: "custom",
30
      call: function() {
31
        Sunstone.showFormPanel(TAB_ID, CREATE_DIALOG_ID, "create");
32
      }
33
    },
34

  
35
    "File.list" : {
36
      type: "list",
37
      call: OpenNebulaResource.list,
38
      callback: function(request, response) {
39
        Sunstone.getDataTable(TAB_ID).updateView(request, response);
40
      },
41
      error: Notifier.onError
42
    },
43

  
44
    "File.show" : {
45
      type : "single",
46
      call: OpenNebulaResource.show,
47
      callback: function(request, response) {
48
        Sunstone.getDataTable(TAB_ID).updateElement(request, response);
49
        if (Sunstone.rightInfoVisible($('#'+TAB_ID))) {
50
          Sunstone.insertPanels(TAB_ID, response);
51
        }
52
      },
53
      error: Notifier.onError
54
    },
55

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

  
69
    "File.update_template" : {
70
      type: "single",
71
      call: OpenNebulaResource.update,
72
      callback: function(request) {
73
        Sunstone.runAction(RESOURCE+".show", request.request.data[0][0]);
74
      },
75
      error: Notifier.onError
76
    },
77

  
78
    "File.enable" : {
79
      type: "multiple",
80
      call: OpenNebulaResource.enable,
81
      callback: function (req) {
82
        Sunstone.runAction(RESOURCE+".show", req.request.data[0]);
83
      },
84
      elements: function() {
85
        return Sunstone.getDataTable(TAB_ID).elements();
86
      },
87
      error: Notifier.onError,
88
      notify: true
89
    },
13
  var _commonActions = new CommonActions(OpenNebulaResource, RESOURCE, TAB_ID, XML_ROOT);
90 14

  
91
    "File.disable" : {
92
      type: "multiple",
93
      call: OpenNebulaResource.disable,
94
      callback: function (req) {
95
        Sunstone.runAction(RESOURCE+".show", req.request.data[0]);
96
      },
97
      elements: function() {
98
        return Sunstone.getDataTable(TAB_ID).elements();
99
      },
100
      error: Notifier.onError,
101
      notify: true
102
    },
103

  
104
    "File.delete" : {
105
      type: "multiple",
106
      call: OpenNebulaResource.del,
107
      callback : function(request, response) {
108
        Sunstone.getDataTable(TAB_ID).deleteElement(request, response);
109
      },
110
      elements: function() {
111
        return Sunstone.getDataTable(TAB_ID).elements();
112
      },
113
      error: Notifier.onError,
114
      notify: true
115
    },
116

  
117
    "File.chown" : {
118
      type: "multiple",
119
      call: OpenNebulaResource.chown,
120
      callback:  function (req) {
121
        Sunstone.runAction(RESOURCE+".show", req.request.data[0]);
122
      },
123
      elements: function() {
124
        return Sunstone.getDataTable(TAB_ID).elements();
125
      },
126
      error: Notifier.onError,
127
      notify: true
128
    },
129

  
130
    "File.chgrp" : {
131
      type: "multiple",
132
      call: OpenNebulaResource.chgrp,
133
      callback: function (req) {
134
        Sunstone.runAction(RESOURCE+".show", req.request.data[0]);
135
      },
136
      elements: function() {
137
        return Sunstone.getDataTable(TAB_ID).elements();
138
      },
139
      error: Notifier.onError,
140
      notify: true
141
    },
142

  
143
    "File.chmod" : {
144
      type: "single",
145
      call: OpenNebulaResource.chmod,
146
      callback: function (req) {
147
        Sunstone.runAction(RESOURCE+".show", req.request.data[0]);
148
      },
149
      error: Notifier.onError,
150
      notify: true
151
    },
152

  
153
    "File.chtype" : {
154
      type: "single",
155
      call: OpenNebulaResource.chtype,
156
      callback: function (req) {
157
        Sunstone.runAction(RESOURCE+".show", req.request.data[0][0]);
158
      },
159
      elements: function() {
160
        return Sunstone.getDataTable(TAB_ID).elements();
161
      },
162
      error: Notifier.onError,
163
      notify: true
164
    },
165

  
166
    "File.rename" : {
167
      type: "single",
168
      call: OpenNebulaResource.rename,
169
      callback: function(request) {
170
        Sunstone.runAction(RESOURCE+".show", request.request.data[0][0]);
171
      },
172
      error: Notifier.onError,
173
      notify: true
174
    }
15
  var _actions = {
16
    "File.create" : _commonActions.create(CREATE_DIALOG_ID),
17
    "File.create_dialog" : _commonActions.showCreate(CREATE_DIALOG_ID),
18
    "File.list" : _commonActions.list(),
19
    "File.show" : _commonActions.show(),
20
    "File.refresh" : _commonActions.refresh(),
21
    "File.delete" : _commonActions.del(),
22
    "File.update_template" : _commonActions.updateTemplate(),
23
    "File.chown": _commonActions.multipleAction('chown'),
24
    "File.chgrp": _commonActions.multipleAction('chgrp'),
25
    "File.chmod": _commonActions.singleAction('chmod'),
26
    "File.rename": _commonActions.singleAction('rename'),
27
    "File.enable": _commonActions.multipleAction('enable'),
28
    "File.disable": _commonActions.multipleAction('disable'),
29
    "File.chtype": _commonActions.singleAction('chtype')
175 30
  };
176 31

  
177 32
  return _actions;

Also available in: Unified diff