Revision 0f62bf63

View differences:

src/sunstone/public/app/tabs/datastores-tab/actions.js
2 2
  var Sunstone = require('sunstone');
3 3
  var Notifier = require('utils/notifier');
4 4
  var Locale = require('utils/locale');
5
  var OpenNebulaDatastore = require('opennebula/datastore');
5
  var OpenNebulaResource = require('opennebula/datastore');
6 6
  var OpenNebulaCluster = require('opennebula/cluster');
7 7
  var OpenNebulaAction = require('opennebula/action');
8
  var CommonActions = require('utils/common-actions');
8 9

  
10
  var RESOURCE = "Datastore";
11
  var XML_ROOT = "DATASTORE";
9 12
  var TAB_ID = require('./tabId');
10 13
  var CREATE_DIALOG_ID = require('./form-panels/create/formPanelId');
11 14

  
12
  var _actions = {
13
    "Datastore.create" : {
14
      type: "create",
15
      call : OpenNebulaDatastore.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("Datastore created"), " ID: " + response.DATASTORE.ID, false);
21
      },
22
      error: function(request, response) {
23
        Sunstone.hideFormPanelLoading(TAB_ID);
24
        Notifier.onError(request, response);
25
      },
26
    },
27

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

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

  
44
    "Datastore.show" : {
45
      type: "single",
46
      call: OpenNebulaDatastore.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
    "Datastore.refresh" : {
57
      type: "custom",
58
      call: function() {
59
          var tab = $('#' + TAB_ID);
60
          if (Sunstone.rightInfoVisible(tab)) {
61
            Sunstone.runAction("Datastore.show", Sunstone.rightInfoResourceId(tab))
62
          } else {
63
            Sunstone.getDataTable(TAB_ID).waitingNodes();
64
            Sunstone.runAction("Datastore.list", {force: true});
65
          }
66
        },
67
      error: Notifier.onError
68
    },
69

  
70
    "Datastore.fetch_permissions" : {
71
      type: "single",
72
      call: OpenNebulaDatastore.show,
73
      callback: function(request, element_json) {
74
        //var ds = element_json.DATASTORE;
75
        //setPermissionsTable(ds, $(".datastore_permissions_table"));
76
      },
77
      error: Notifier.onError
78
    },
15
  var _commonActions = new CommonActions(OpenNebulaResource, RESOURCE, TAB_ID, XML_ROOT);
79 16

  
80
    "Datastore.update_template" : {
81
      type: "single",
82
      call: OpenNebulaDatastore.update,
83
      callback: function(request) {
84
        Sunstone.runAction('Datastore.show', request.request.data[0][0]);
85
      },
86
      error: Notifier.onError
87
    },
88

  
89
    "Datastore.update" : {
90
      type: "single",
91
      call: OpenNebulaDatastore.update,
92
      callback: function() {
93
        Sunstone.runAction('Datastore.show', request.request.data[0][0]);
94
      },
95
      error: Notifier.onError
96
    },
97

  
98
    "Datastore.delete" : {
99
      type: "multiple",
100
      call : OpenNebulaDatastore.del,
101
      callback: function(request, response) {
102
        Sunstone.getDataTable(TAB_ID).deleteElement(request, response);
103
      },
104
      elements: function() {
105
        return Sunstone.getDataTable(TAB_ID).elements();
106
      },
107
      error : Notifier.onError,
108
      notify: true
109
    },
110

  
111
    "Datastore.chown" : {
112
      type: "multiple",
113
      call: OpenNebulaDatastore.chown,
114
      callback:  function (req) {
115
        Sunstone.runAction("Datastore.show", req.request.data[0][0]);
116
      },
117
      elements: function() {
118
        return Sunstone.getDataTable(TAB_ID).elements();
119
      },
120
      error: Notifier.onError
121
    },
122

  
123
    "Datastore.chgrp" : {
124
      type: "multiple",
125
      call: OpenNebulaDatastore.chgrp,
126
      callback: function (req) {
127
        Sunstone.runAction("Datastore.show", req.request.data[0][0]);
128
      },
129
      elements: function() {
130
        return Sunstone.getDataTable(TAB_ID).elements();
131
      },
132
      error: Notifier.onError
133
    },
134

  
135
    "Datastore.chmod" : {
136
      type: "single",
137
      call: OpenNebulaDatastore.chmod,
138
      callback: function (req) {
139
        Sunstone.runAction("Datastore.show", req.request.data[0]);
140
      },
141
      error: Notifier.onError
142
    },
17
  var _actions = {
18
    "Datastore.create" : _commonActions.create(CREATE_DIALOG_ID),
19
    "Datastore.create_dialog" : _commonActions.showCreate(CREATE_DIALOG_ID),
20
    "Datastore.list" : _commonActions.list(),
21
    "Datastore.show" : _commonActions.show(),
22
    "Datastore.refresh" : _commonActions.refresh(),
23
    "Datastore.delete" : _commonActions.del(),
24
    "Datastore.chown": _commonActions.multipleAction('chown'),
25
    "Datastore.chgrp": _commonActions.multipleAction('chgrp'),
26
    "Datastore.chmod": _commonActions.singleAction('chmod'),
27
    "Datastore.update" : _commonActions.updateTemplate(),
28
    "Datastore.update_template" : _commonActions.updateTemplate(),
29
    "Datastore.rename": _commonActions.singleAction('rename'),
30
    "Datastore.enable": _commonActions.multipleAction('enable'),
31
    "Datastore.disable": _commonActions.multipleAction('disable'),
143 32

  
144 33
    "Datastore.addtocluster" : {
145 34
      type: "multiple",
......
148 37
        var ds = params.data.id;
149 38

  
150 39
        if (cluster == -1) {
151
          OpenNebulaDatastore.show({
40
          OpenNebulaResource.show({
152 41
            data : {
153 42
              id: ds
154 43
            },
......
191 80
      elements: function() {
192 81
        return Sunstone.getDataTable(TAB_ID).elements();
193 82
      }
194
    },
195

  
196
    "Datastore.rename" : {
197
      type: "single",
198
      call: OpenNebulaDatastore.rename,
199
      callback: function(request) {
200
        Sunstone.runAction('Datastore.show', request.request.data[0][0]);
201
      },
202
      error: Notifier.onError,
203
      notify: true
204
    },
205

  
206
    "Datastore.enable" : {
207
      type: "multiple",
208
      call: OpenNebulaDatastore.enable,
209
      callback: function (req) {
210
        Sunstone.runAction("Datastore.show", req.request.data[0]);
211
      },
212
      elements: function() {
213
        return Sunstone.getDataTable(TAB_ID).elements();
214
      },
215
      error: Notifier.onError,
216
      notify: true
217
    },
218

  
219
    "Datastore.disable" : {
220
      type: "multiple",
221
      call: OpenNebulaDatastore.disable,
222
      callback: function (req) {
223
        Sunstone.runAction("Datastore.show", req.request.data[0]);
224
      },
225
      elements: function() {
226
        return Sunstone.getDataTable(TAB_ID).elements();
227
      },
228
      error: Notifier.onError,
229
      notify: true
230 83
    }
231 84
  };
232 85

  

Also available in: Unified diff