1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-23 22:50:09 +03:00

Bug #4134: Create a hook to fill tabs headers

(cherry picked from commit 9ac387cc7d67b8441beddb060c956c58ad13d11e)
This commit is contained in:
Carlos Martín 2015-11-05 15:44:02 +01:00
parent 759f7aae30
commit 4e51084c19
37 changed files with 265 additions and 31 deletions

View File

@ -582,7 +582,7 @@ define(function(require) {
if (hooks) {
$.each(hooks, function(i, hook){
hook.pre(info, contextTabId);
hook.pre(info, (contextTabId||tabName));
});
}
@ -648,7 +648,7 @@ define(function(require) {
if (hooks) {
$.each(hooks, function(i, hook){
hook.post(info, contextTabId);
hook.post(info, (contextTabId||tabName));
});
}
}

View File

@ -33,6 +33,10 @@ define(function(require) {
require('./clusters-tab/panels/datastores')
];
var _panelsHooks = [
require('../utils/hooks/header')
];
var _formPanels = [
require('./clusters-tab/form-panels/create')
];
@ -50,6 +54,7 @@ define(function(require) {
actions: Actions,
dataTable: new Table(DATATABLE_ID, {actions: true, info: true}),
panels: _panels,
panelsHooks: _panelsHooks,
formPanels: _formPanels,
dialogs: _dialogs
};

View File

@ -69,7 +69,6 @@ define(function(require) {
}
function _setup(context) {
$('.resource-info-header', '#' + TAB_ID).text(this.element.NAME);
RenameTr.setup(RESOURCE, this.element.ID, context);
TemplateTable.setup(this.element.TEMPLATE, RESOURCE, this.element.ID, context);

View File

@ -35,6 +35,10 @@ define(function(require) {
require('./datastores-tab/panels/images')
];
var _panelsHooks = [
require('../utils/hooks/header')
];
var DatastoresTab = {
tabId: TAB_ID,
title: Locale.tr("Datastores"),
@ -48,6 +52,7 @@ define(function(require) {
actions: Actions,
dataTable: new Table(DATATABLE_ID, {actions: true, info: true}),
panels: _panels,
panelsHooks: _panelsHooks,
formPanels: _formPanels,
dialogs: _dialogs
};

View File

@ -96,7 +96,6 @@ define(function(require) {
}
function _setup(context) {
$('.resource-info-header', '#' + TAB_ID).text(this.element.NAME);
RenameTr.setup(RESOURCE, this.element.ID, context);
ClusterTr.setup(RESOURCE, this.element.ID, this.element.CLUSTER_ID, context);
TemplateTable.setup(this.element.TEMPLATE, RESOURCE, this.element.ID, context);

View File

@ -29,6 +29,10 @@ define(function(require) {
require('./files-tab/panels/info')
];
var _panelsHooks = [
require('../utils/hooks/header')
];
var _formPanels = [
require('./files-tab/form-panels/create')
];
@ -49,6 +53,7 @@ define(function(require) {
actions: Actions,
dataTable: new Table(DATATABLE_ID, {actions: true, info: true}),
panels: _panels,
panelsHooks: _panelsHooks,
formPanels: _formPanels,
dialogs: _dialogs
};

View File

@ -89,7 +89,6 @@ define(function(require) {
}
function _setup(context) {
$('.resource-info-header', '#' + TAB_ID).text(this.element.NAME);
RenameTr.setup(RESOURCE, this.element.ID, context);
TemplateTable.setup(this.element.TEMPLATE, RESOURCE, this.element.ID, context);
PermissionsTable.setup(TAB_ID, RESOURCE, this.element, context);

View File

@ -35,6 +35,10 @@ define(function(require) {
require('./groups-tab/panels/showback')
];
var _panelsHooks = [
require('../utils/hooks/header')
];
var _formPanels = [
require('./groups-tab/form-panels/create')
];
@ -54,6 +58,7 @@ define(function(require) {
actions: Actions,
dataTable: new Table(DATATABLE_ID, {actions: true, info: true}),
panels: _panels,
panelsHooks: _panelsHooks,
formPanels: _formPanels,
dialogs: _dialogs
};

View File

@ -94,8 +94,6 @@ define(function(require) {
function _setup(context) {
var that = this;
$('.resource-info-header', '#' + TAB_ID).text(that.element.NAME);
Tips.setup(context);
// Template update

View File

@ -37,6 +37,10 @@ define(function(require) {
require('./hosts-tab/panels/pci')
];
var _panelsHooks = [
require('../utils/hooks/header')
];
var _formPanels = [
require('./hosts-tab/form-panels/create')
]
@ -58,6 +62,7 @@ define(function(require) {
actions: Actions,
dataTable: new Table(DATATABLE_ID, {actions: true, info: true}),
panels: _panels,
panelsHooks: _panelsHooks,
formPanels: _formPanels,
//dialogs: _dialogs
};

View File

@ -113,7 +113,6 @@ define(function(require) {
}
function _setup(context) {
$('.resource-info-header', '#' + TAB_ID).text(this.element.NAME);
RenameTr.setup(RESOURCE, this.element.ID, context);
ClusterTr.setup(RESOURCE, this.element.ID, this.element.CLUSTER_ID, context);
TemplateTable.setup(this.strippedTemplate, RESOURCE, this.element.ID, context, this.unshownTemplate);

View File

@ -33,6 +33,10 @@ define(function(require) {
require('./images-tab/panels/snapshots')
];
var _panelsHooks = [
require('../utils/hooks/header')
];
var _formPanels = [
require('./images-tab/form-panels/create')
];
@ -51,6 +55,7 @@ define(function(require) {
actions: Actions,
dataTable: new Table(DATATABLE_ID, {actions: true, info: true}),
panels: _panels,
panelsHooks: _panelsHooks,
formPanels: _formPanels,
dialogs: _dialogs
};

View File

@ -90,7 +90,6 @@ define(function(require) {
}
function _setup(context) {
$('.resource-info-header', '#' + TAB_ID).text(this.element.NAME);
RenameTr.setup(RESOURCE, this.element.ID, context);
TemplateTable.setup(this.element.TEMPLATE, RESOURCE, this.element.ID, context);
PermissionsTable.setup(TAB_ID, RESOURCE, this.element, context);

View File

@ -31,6 +31,10 @@ define(function(require) {
require('./marketplace-tab/panels/info')
];
var _panelsHooks = [
require('./marketplace-tab/hooks/header')
];
var _formPanels = [
];
@ -50,6 +54,7 @@ define(function(require) {
actions: Actions,
dataTable: new Table(DATATABLE_ID, {actions: true, info: true, oneSelection: true}),
panels: _panels,
panelsHooks: _panelsHooks,
formPanels: _formPanels,
dialogs: _dialogs
};

View File

@ -0,0 +1,43 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2015, OpenNebula Project, OpenNebula Systems */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
/* a copy of the License at */
/* */
/* http://www.apache.org/licenses/LICENSE-2.0 */
/* */
/* Unless required by applicable law or agreed to in writing, software */
/* distributed under the License is distributed on an "AS IS" BASIS, */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
/* See the License for the specific language governing permissions and */
/* limitations under the License. */
/* -------------------------------------------------------------------------- */
define(function(require) {
/*
CONSTANTS
*/
var TAB_ID = require('../tabId');
/*
FUNCTION DEFINITIONS
*/
function _pre(info, contextTabId) {
var element = info;
$('.resource-id', '#' + TAB_ID).hide();
$('.resource-info-header', '#' + TAB_ID).text(element.name);
}
function _post(info, contextTabId) {
}
return {
'pre': _pre,
'post': _post
};
});

View File

@ -82,8 +82,6 @@ define(function(require) {
}
function _setup(context) {
$('.resource-id', '#' + TAB_ID).hide();
$('.resource-info-header', '#' + TAB_ID).text(this.element.name);
return false;
}
});

View File

@ -34,6 +34,10 @@ define(function(require) {
require('./oneflow-services-tab/panels/log')
];
var _panelsHooks = [
require('./oneflow-services-tab/hooks/header')
];
var _formPanels = [
];
@ -55,6 +59,7 @@ define(function(require) {
actions: Actions,
dataTable: new Table(DATATABLE_ID, {actions: true, info: true}),
panels: _panels,
panelsHooks: _panelsHooks,
formPanels: _formPanels,
dialogs: _dialogs
};

View File

@ -0,0 +1,51 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2015, OpenNebula Project, OpenNebula Systems */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
/* a copy of the License at */
/* */
/* http://www.apache.org/licenses/LICENSE-2.0 */
/* */
/* Unless required by applicable law or agreed to in writing, software */
/* distributed under the License is distributed on an "AS IS" BASIS, */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
/* See the License for the specific language governing permissions and */
/* limitations under the License. */
/* -------------------------------------------------------------------------- */
define(function(require) {
/*
DEPENDENCIES
*/
var OpenNebulaService = require('opennebula/service');
/*
CONSTANTS
*/
var TAB_ID = require('../tabId');
var XML_ROOT = "DOCUMENT";
var RESOURCE = "Service";
/*
FUNCTION DEFINITIONS
*/
function _pre(info, contextTabId) {
var element = info[XML_ROOT];
var state = OpenNebulaService.stateStr(element.TEMPLATE.BODY.state);
$('.resource-info-header', '#' + TAB_ID).text(element.NAME);
$('.resource-info-header-small', '#' + TAB_ID).text(state);
}
function _post(info, contextTabId) {
}
return {
'pre': _pre,
'post': _post
};
});

View File

@ -72,7 +72,6 @@ define(function(require) {
}
function _setup(context) {
$('.resource-info-header', '#' + TAB_ID).text(this.element.NAME);
PermissionsTable.setup(TAB_ID, RESOURCE, this.element, context);
}
});

View File

@ -32,6 +32,10 @@ define(function(require) {
require('./oneflow-templates-tab/panels/roles')
];
var _panelsHooks = [
require('../utils/hooks/header')
];
var _formPanels = [
require('./oneflow-templates-tab/form-panels/create'),
require('./oneflow-templates-tab/form-panels/instantiate')
@ -55,6 +59,7 @@ define(function(require) {
actions: Actions,
dataTable: new Table(DATATABLE_ID, {actions: true, info: true}),
panels: _panels,
panelsHooks: _panelsHooks,
formPanels: _formPanels,
dialogs: _dialogs
};

View File

@ -108,7 +108,6 @@ define(function(require) {
}
function _setup(context) {
$('.resource-info-header', '#' + TAB_ID).text(this.element.NAME);
PermissionsTable.setup(TAB_ID, RESOURCE, this.element, context);
}
});

View File

@ -31,6 +31,10 @@ define(function(require) {
require('./secgroups-tab/panels/info')
];
var _panelsHooks = [
require('../utils/hooks/header')
];
var _formPanels = [
require('./secgroups-tab/form-panels/create')
];
@ -48,6 +52,7 @@ define(function(require) {
actions: Actions,
dataTable: new Table(DATATABLE_ID, {actions: true, info: true}),
panels: _panels,
panelsHooks: _panelsHooks,
formPanels: _formPanels,
dialogs: _dialogs
};

View File

@ -97,7 +97,6 @@ define(function(require) {
}
function _setup(context) {
$('.resource-info-header', '#' + TAB_ID).text(this.element.NAME);
RenameTr.setup(RESOURCE, this.element.ID, context);
PermissionsTable.setup(TAB_ID, RESOURCE, this.element, context);

View File

@ -32,6 +32,10 @@ define(function(require) {
require('./templates-tab/panels/template')
];
var _panelsHooks = [
require('../utils/hooks/header')
];
var _formPanels = [
require('./templates-tab/form-panels/create'),
require('./templates-tab/form-panels/import'),
@ -51,6 +55,7 @@ define(function(require) {
actions: Actions,
dataTable: new Table(DATATABLE_ID, {actions: true, info: true}),
panels: _panels,
panelsHooks: _panelsHooks,
formPanels: _formPanels,
dialogs: _dialogs
};

View File

@ -76,7 +76,6 @@ define(function(require) {
}
function _setup(context) {
$('.resource-info-header', '#' + TAB_ID).text(this.element.NAME);
RenameTr.setup(RESOURCE, this.element.ID, context);
PermissionsTable.setup(TAB_ID, RESOURCE, this.element, context);
}

View File

@ -36,6 +36,10 @@ define(function(require) {
require('./users-tab/panels/showback')
];
var _panelsHooks = [
require('../utils/hooks/header')
];
var _formPanels = [
require('./users-tab/form-panels/create')
];
@ -55,6 +59,7 @@ define(function(require) {
actions: Actions,
dataTable: new Table(DATATABLE_ID, {actions: true, info: true}),
panels: _panels,
panelsHooks: _panelsHooks,
formPanels: _formPanels,
dialogs: _dialogs
};

View File

@ -103,8 +103,6 @@ define(function(require) {
function _setup(context) {
var that = this;
$('.resource-info-header', '#' + TAB_ID).text(that.element.NAME);
// Template update
// TODO: simplify interface?
var strippedTemplate = $.extend({}, this.element.TEMPLATE);

View File

@ -32,6 +32,10 @@ define(function(require) {
require('./vdcs-tab/panels/resources')
];
var _panelsHooks = [
require('../utils/hooks/header')
];
var _formPanels = [
require('./vdcs-tab/form-panels/create')
];
@ -51,6 +55,7 @@ define(function(require) {
actions: Actions,
dataTable: new Table(DATATABLE_ID, {actions: true, info: true}),
panels: _panels,
panelsHooks: _panelsHooks,
formPanels: _formPanels,
dialogs: _dialogs
};

View File

@ -69,8 +69,6 @@ define(function(require) {
}
function _setup(context) {
$('.resource-info-header', '#' + TAB_ID).text(this.element.NAME);
RenameTr.setup(RESOURCE, this.element.ID, context);
TemplateTable.setup(this.element.TEMPLATE, RESOURCE, this.element.ID, context);

View File

@ -38,6 +38,7 @@ define(function(require) {
];
var _panelsHooks = [
require('./vms-tab/hooks/header'),
require('./vms-tab/hooks/state')
];

View File

@ -0,0 +1,57 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2015, OpenNebula Project, OpenNebula Systems */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
/* a copy of the License at */
/* */
/* http://www.apache.org/licenses/LICENSE-2.0 */
/* */
/* Unless required by applicable law or agreed to in writing, software */
/* distributed under the License is distributed on an "AS IS" BASIS, */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
/* See the License for the specific language governing permissions and */
/* limitations under the License. */
/* -------------------------------------------------------------------------- */
define(function(require) {
/*
DEPENDENCIES
*/
var OpenNebulaVM = require('opennebula/vm');
/*
CONSTANTS
*/
var TAB_ID = require('../tabId');
var RESOURCE = "VM";
var XML_ROOT = "VM";
/*
FUNCTION DEFINITIONS
*/
function _pre(info, contextTabId) {
var element = info[XML_ROOT];
var state;
if (element.STATE == OpenNebulaVM.STATES.ACTIVE) {
state = OpenNebulaVM.shortLcmStateStr(element.LCM_STATE);
} else {
state = OpenNebulaVM.stateStr(element.STATE);
}
$('.resource-info-header', '#' + TAB_ID).text(element.NAME);
$('.resource-info-header-small', '#' + TAB_ID).text(state);
}
function _post(info, contextTabId) {
}
return {
'pre': _pre,
'post': _post
};
});

View File

@ -37,16 +37,6 @@ define(function(require) {
function _pre(info, contextTabId) {
var element = info[XML_ROOT];
var state;
if (element.STATE == OpenNebulaVM.STATES.ACTIVE) {
state = OpenNebulaVM.shortLcmStateStr(element.LCM_STATE);
} else {
state = OpenNebulaVM.stateStr(element.STATE);
}
$('.resource-info-header', '#' + TAB_ID).text(element.NAME);
$('.resource-info-header-small', '#' + TAB_ID).text(state);
// Enable only action buttons for the current state
StateActions.disableAllStateActions();
StateActions.enableStateActions(element.STATE, element.LCM_STATE);

View File

@ -36,6 +36,10 @@ define(function(require) {
require('./vnets-tab/panels/secgroups')
];
var _panelsHooks = [
require('../utils/hooks/header')
];
var _formPanels = [
require('./vnets-tab/form-panels/create'),
require('./vnets-tab/form-panels/import')
@ -55,6 +59,7 @@ define(function(require) {
actions: Actions,
dataTable: new Table(DATATABLE_ID, {actions: true, info: true}),
panels: _panels,
panelsHooks: _panelsHooks,
formPanels: _formPanels,
dialogs: _dialogs
};

View File

@ -109,7 +109,6 @@ define(function(require) {
}
function _setup(context) {
$('.resource-info-header', '#' + TAB_ID).text(this.element.NAME);
RenameTr.setup(RESOURCE, this.element.ID, context);
ClusterTr.setup(RESOURCE, this.element.ID, this.element.CLUSTER_ID, context);
PermissionsTable.setup(TAB_ID, RESOURCE, this.element, context);

View File

@ -31,6 +31,10 @@ define(function(require) {
require('./zones-tab/panels/info')
];
var _panelsHooks = [
require('../utils/hooks/header')
];
var ZonesTab = {
tabId: TAB_ID,
title: Locale.tr("Zones"),
@ -44,6 +48,7 @@ define(function(require) {
actions: Actions,
dataTable: new Table(DATATABLE_ID, {actions: true, info: true}),
panels: _panels,
panelsHooks: _panelsHooks,
dialogs: _dialogs
};

View File

@ -73,7 +73,6 @@ define(function(require) {
}
function _setup(context) {
$('.resource-info-header', '#' + TAB_ID).text(this.element.NAME);
RenameTr.setup(RESOURCE, this.element.ID, context);
TemplateTable.setup(this.element.TEMPLATE, RESOURCE, this.element.ID, context);
return false;

View File

@ -0,0 +1,36 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2015, OpenNebula Project, OpenNebula Systems */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
/* a copy of the License at */
/* */
/* http://www.apache.org/licenses/LICENSE-2.0 */
/* */
/* Unless required by applicable law or agreed to in writing, software */
/* distributed under the License is distributed on an "AS IS" BASIS, */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
/* See the License for the specific language governing permissions and */
/* limitations under the License. */
/* -------------------------------------------------------------------------- */
define(function(require) {
/*
FUNCTION DEFINITIONS
*/
function _pre(info, contextTabId) {
var element = info[Object.keys(info)[0]];
$('.resource-info-header', '#' + contextTabId).text(element.NAME);
}
function _post(info, contextTabId) {
}
return {
'pre': _pre,
'post': _post
};
});