From ae0a8b37c1764269a23aaaf7076d856c458c23c2 Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Mon, 24 Aug 2015 13:05:39 +0200 Subject: [PATCH] feature #3912: Use commonActions in images tab --- .../public/app/tabs/images-tab/actions.js | 214 ++---------------- 1 file changed, 22 insertions(+), 192 deletions(-) diff --git a/src/sunstone/public/app/tabs/images-tab/actions.js b/src/sunstone/public/app/tabs/images-tab/actions.js index 4435ce9e90..91abfb60e2 100644 --- a/src/sunstone/public/app/tabs/images-tab/actions.js +++ b/src/sunstone/public/app/tabs/images-tab/actions.js @@ -11,187 +11,29 @@ define(function(require) { var CREATE_DIALOG_ID = require('./form-panels/create/formPanelId'); var CLONE_DIALOG_ID = require('./dialogs/clone/dialogId'); - var _commonActions = new CommonActions(OpenNebulaImage, RESOURCE, TAB_ID); + var _commonActions = new CommonActions(OpenNebulaImage, RESOURCE, TAB_ID, XML_ROOT); var _actions = { - "Image.create" : { - type: "create", - call: OpenNebulaImage.create, - callback: function(request, response) { - Sunstone.resetFormPanel(TAB_ID, CREATE_DIALOG_ID); - Sunstone.hideFormPanel(TAB_ID); - Sunstone.getDataTable(TAB_ID).addElement(request, response); - Notifier.notifyCustom(Locale.tr("Image created"), " ID: " + response[XML_ROOT].ID, false); - }, - error: function(request, response) { - Sunstone.hideFormPanelLoading(TAB_ID); - Notifier.onError(request, response); - }, - }, - - "Image.create_dialog" : { - type: "custom", - call: function() { - Sunstone.showFormPanel(TAB_ID, CREATE_DIALOG_ID, "create"); - } - }, - - "Image.list" : { - type: "list", - call: OpenNebulaImage.list, - callback: function(request, response) { - Sunstone.getDataTable(TAB_ID).updateView(request, response); - }, - error: Notifier.onError - }, - - "Image.show" : { - type : "single", - call: OpenNebulaImage.show, - callback: function(request, response) { - Sunstone.getDataTable(TAB_ID).updateElement(request, response); - if (Sunstone.rightInfoVisible($('#'+TAB_ID))) { - Sunstone.insertPanels(TAB_ID, response); - } - }, - error: Notifier.onError - }, - - "Image.refresh" : { - type: "custom", - call: function () { - var tab = $('#' + TAB_ID); - if (Sunstone.rightInfoVisible(tab)) { - Sunstone.runAction(RESOURCE+".show", Sunstone.rightInfoResourceId(tab)); - } else { - Sunstone.getDataTable(TAB_ID).waitingNodes(); - Sunstone.runAction(RESOURCE+".list", {force: true}); - } - } - }, - - "Image.update_template" : { - type: "single", - call: OpenNebulaImage.update, - callback: function(request) { - Sunstone.runAction(RESOURCE+".show", request.request.data[0][0]); - }, - error: Notifier.onError - }, - - "Image.enable" : { - type: "multiple", - call: OpenNebulaImage.enable, - callback: function (req) { - Sunstone.runAction(RESOURCE+".show", req.request.data[0]); - }, - elements: function() { - return Sunstone.getDataTable(TAB_ID).elements(); - }, - error: Notifier.onError, - notify: true - }, - - "Image.disable" : { - type: "multiple", - call: OpenNebulaImage.disable, - callback: function (req) { - Sunstone.runAction(RESOURCE+".show", req.request.data[0]); - }, - elements: function() { - return Sunstone.getDataTable(TAB_ID).elements(); - }, - error: Notifier.onError, - notify: true - }, - - "Image.persistent" : { - type: "multiple", - call: OpenNebulaImage.persistent, - callback: function (req) { - Sunstone.runAction(RESOURCE+".show", req.request.data[0]); - }, - elements: function() { - return Sunstone.getDataTable(TAB_ID).elements(); - }, - error: Notifier.onError, - notify: true - }, - - "Image.nonpersistent" : { - type: "multiple", - call: OpenNebulaImage.nonpersistent, - callback: function (req) { - Sunstone.runAction(RESOURCE+".show", req.request.data[0]); - }, - elements: function() { - return Sunstone.getDataTable(TAB_ID).elements(); - }, - error: Notifier.onError, - notify: true - }, - - "Image.delete" : { - type: "multiple", - call: OpenNebulaImage.del, - callback : function(request, response) { - Sunstone.getDataTable(TAB_ID).deleteElement(request, response); - }, - elements: function() { - return Sunstone.getDataTable(TAB_ID).elements(); - }, - error: Notifier.onError, - notify: true - }, - - "Image.chown" : { - type: "multiple", - call: OpenNebulaImage.chown, - callback: function (req) { - Sunstone.runAction(RESOURCE+".show", req.request.data[0]); - }, - elements: function() { - return Sunstone.getDataTable(TAB_ID).elements(); - }, - error: Notifier.onError, - notify: true - }, - - "Image.chgrp" : { - type: "multiple", - call: OpenNebulaImage.chgrp, - callback: function (req) { - Sunstone.runAction(RESOURCE+".show", req.request.data[0]); - }, - elements: function() { - return Sunstone.getDataTable(TAB_ID).elements(); - }, - error: Notifier.onError, - notify: true - }, - - "Image.chmod" : { - type: "single", - call: OpenNebulaImage.chmod, - callback: function (req) { - Sunstone.runAction(RESOURCE+".show", req.request.data[0]); - }, - error: Notifier.onError, - notify: true - }, - - "Image.chtype" : { - type: "single", - call: OpenNebulaImage.chtype, - callback: function (req) { - Sunstone.runAction(RESOURCE+".show", req.request.data[0][0]); - }, - elements: function() { - return Sunstone.getDataTable(TAB_ID).elements(); - }, - error: Notifier.onError, - notify: true - }, + "Image.create" : _commonActions.create(CREATE_DIALOG_ID), + "Image.create_dialog" : _commonActions.showCreate(CREATE_DIALOG_ID), + "Image.list" : _commonActions.list(), + "Image.show" : _commonActions.show(), + "Image.refresh" : _commonActions.refresh(), + "Image.delete" : _commonActions.del(), + "Image.update_template" : _commonActions.updateTemplate(), + "Image.chown": _commonActions.multipleAction('chown'), + "Image.chgrp": _commonActions.multipleAction('chgrp'), + "Image.chmod": _commonActions.singleAction('chmod'), + "Image.rename": _commonActions.singleAction('rename'), + "Image.enable": _commonActions.multipleAction('enable'), + "Image.disable": _commonActions.multipleAction('disable'), + "Image.persistent": _commonActions.multipleAction('persistent'), + "Image.nonpersistent": _commonActions.multipleAction('nonpersistent'), + "Image.chtype": _commonActions.singleAction('chtype'), + "Image.snapshot_flatten": _commonActions.singleAction("snapshot_flatten"), + "Image.snapshot_revert": _commonActions.singleAction("snapshot_revert"), + "Image.snapshot_delete": _commonActions.singleAction("snapshot_delete"), + "Image.clone_dialog" : { type: "custom", call: function(){ @@ -203,19 +45,7 @@ define(function(require) { call: OpenNebulaImage.clone, error: Notifier.onError, notify: true - }, - "Image.rename" : { - type: "single", - call: OpenNebulaImage.rename, - callback: function(request) { - Sunstone.runAction(RESOURCE+".show", request.request.data[0][0]); - }, - error: Notifier.onError, - notify: true - }, - "Image.snapshot_flatten": _commonActions.singleAction("snapshot_flatten"), - "Image.snapshot_revert": _commonActions.singleAction("snapshot_revert"), - "Image.snapshot_delete": _commonActions.singleAction("snapshot_delete"), + } }; return _actions;