mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-21 14:50:08 +03:00
feature #3912: Use commonAction in hosts tab
This commit is contained in:
parent
0f62bf63d5
commit
bcafe19375
@ -3,118 +3,29 @@ define(function(require) {
|
||||
var Notifier = require('utils/notifier');
|
||||
var Locale = require('utils/locale');
|
||||
var DataTable = require('./datatable');
|
||||
var OpenNebulaHost = require('opennebula/host');
|
||||
var OpenNebulaResource = require('opennebula/host');
|
||||
var OpenNebulaCluster = require('opennebula/cluster');
|
||||
var OpenNebulaAction = require('opennebula/action');
|
||||
var CommonActions = require('utils/common-actions');
|
||||
|
||||
var TAB_ID = require('./tabId');
|
||||
var XML_ROOT = "HOST"
|
||||
var RESOURCE = "Host"
|
||||
var CREATE_DIALOG_ID = require('./form-panels/create/formPanelId');
|
||||
|
||||
var _commonActions = new CommonActions(OpenNebulaResource, RESOURCE, TAB_ID, XML_ROOT);
|
||||
|
||||
var _actions = {
|
||||
"Host.create" : {
|
||||
type: "create",
|
||||
call : OpenNebulaHost.create,
|
||||
callback : function(request, response) {
|
||||
Sunstone.resetFormPanel(TAB_ID, CREATE_DIALOG_ID);
|
||||
Sunstone.hideFormPanel(TAB_ID);
|
||||
Sunstone.getDataTable(TAB_ID).addElement(request, response);
|
||||
},
|
||||
error: function(request, response) {
|
||||
Sunstone.hideFormPanelLoading(TAB_ID);
|
||||
Notifier.onError(request, response);
|
||||
},
|
||||
notify: true
|
||||
},
|
||||
|
||||
"Host.create_dialog" : {
|
||||
type: "custom",
|
||||
call: function() {
|
||||
Sunstone.showFormPanel(TAB_ID, CREATE_DIALOG_ID, "create");
|
||||
}
|
||||
},
|
||||
|
||||
"Host.list" : {
|
||||
type: "list",
|
||||
call: OpenNebulaHost.list,
|
||||
callback: function(request, response) {
|
||||
Sunstone.getDataTable(TAB_ID).updateView(request, response);
|
||||
},
|
||||
error: Notifier.onError
|
||||
},
|
||||
|
||||
"Host.show" : {
|
||||
type: "single",
|
||||
call: OpenNebulaHost.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
|
||||
},
|
||||
|
||||
"Host.refresh" : {
|
||||
type: "custom",
|
||||
call: function() {
|
||||
var tab = $('#' + TAB_ID);
|
||||
if (Sunstone.rightInfoVisible(tab)) {
|
||||
Sunstone.runAction("Host.show", Sunstone.rightInfoResourceId(tab))
|
||||
} else {
|
||||
Sunstone.getDataTable(TAB_ID).waitingNodes();
|
||||
Sunstone.runAction("Host.list", {force: true});
|
||||
}
|
||||
},
|
||||
error: Notifier.onError
|
||||
},
|
||||
|
||||
"Host.enable" : {
|
||||
type: "multiple",
|
||||
call: OpenNebulaHost.enable,
|
||||
callback: function (req) {
|
||||
Sunstone.runAction("Host.show", req.request.data[0]);
|
||||
},
|
||||
elements: function() {
|
||||
return Sunstone.getDataTable(TAB_ID).elements();
|
||||
},
|
||||
error: Notifier.onError,
|
||||
notify: true
|
||||
},
|
||||
|
||||
"Host.disable" : {
|
||||
type: "multiple",
|
||||
call: OpenNebulaHost.disable,
|
||||
callback: function (req) {
|
||||
Sunstone.runAction("Host.show", req.request.data[0]);
|
||||
},
|
||||
elements: function() {
|
||||
return Sunstone.getDataTable(TAB_ID).elements();
|
||||
},
|
||||
error: Notifier.onError,
|
||||
notify: true
|
||||
},
|
||||
|
||||
"Host.delete" : {
|
||||
type: "multiple",
|
||||
call: OpenNebulaHost.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
|
||||
},
|
||||
|
||||
"Host.update_template" : {
|
||||
type: "single",
|
||||
call: OpenNebulaHost.update,
|
||||
callback: function(request) {
|
||||
Sunstone.runAction('Host.show', request.request.data[0][0]);
|
||||
},
|
||||
error: Notifier.onError
|
||||
},
|
||||
"Host.create" : _commonActions.create(CREATE_DIALOG_ID),
|
||||
"Host.create_dialog" : _commonActions.showCreate(CREATE_DIALOG_ID),
|
||||
"Host.list" : _commonActions.list(),
|
||||
"Host.show" : _commonActions.show(),
|
||||
"Host.refresh" : _commonActions.refresh(),
|
||||
"Host.delete" : _commonActions.del(),
|
||||
"Host.update_template" : _commonActions.updateTemplate(),
|
||||
"Host.enable": _commonActions.multipleAction('enable'),
|
||||
"Host.disable": _commonActions.multipleAction('disable'),
|
||||
"Host.rename": _commonActions.singleAction('rename'),
|
||||
|
||||
"Host.addtocluster" : {
|
||||
type: "multiple",
|
||||
@ -123,7 +34,7 @@ define(function(require) {
|
||||
var host = params.data.id;
|
||||
|
||||
if (cluster == -1){
|
||||
OpenNebulaHost.show({
|
||||
OpenNebulaResource.show({
|
||||
data : {
|
||||
id: host
|
||||
},
|
||||
@ -168,16 +79,6 @@ define(function(require) {
|
||||
elements: function() {
|
||||
return Sunstone.getDataTable(TAB_ID).elements();
|
||||
}
|
||||
},
|
||||
|
||||
"Host.rename" : {
|
||||
type: "single",
|
||||
call: OpenNebulaHost.rename,
|
||||
callback: function(request) {
|
||||
Sunstone.runAction('Host.show', request.request.data[0][0]);
|
||||
},
|
||||
error: Notifier.onError,
|
||||
notify: true
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user