mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-21 14:50:08 +03:00
parent
e6b26c3c52
commit
228d0df5be
@ -27,7 +27,6 @@ define(function(require) {
|
||||
|
||||
_setupDataTableSearch();
|
||||
|
||||
var DASHBOARD_TAB_ID = require('tabs/dashboard-tab/tabId');
|
||||
var SETTINGS_TAB_ID = require('tabs/settings-tab/tabId');
|
||||
var PROVISION_TAB_ID = require('tabs/provision-tab/tabId');
|
||||
var Sunstone = require('sunstone');
|
||||
@ -61,6 +60,7 @@ define(function(require) {
|
||||
Menu.insertProvision();
|
||||
}else{
|
||||
Menu.insert();
|
||||
Sunstone.setupNavigoRoutes();
|
||||
}
|
||||
|
||||
_setupAccordion();
|
||||
@ -69,11 +69,9 @@ define(function(require) {
|
||||
|
||||
if (Config.isTabEnabled(PROVISION_TAB_ID)) {
|
||||
Sunstone.showTab(PROVISION_TAB_ID);
|
||||
$('#loading').hide();
|
||||
} else if (Config.isTabEnabled(DASHBOARD_TAB_ID)) {
|
||||
Sunstone.showTab(DASHBOARD_TAB_ID);
|
||||
$('#loading').hide();
|
||||
}
|
||||
|
||||
$('#loading').hide();
|
||||
});
|
||||
|
||||
function _setupCloseDropdownsOnClick() {
|
||||
|
@ -107,7 +107,10 @@ require.config({
|
||||
'spice-filexfer': '../bower_components/spice-html5/filexfer',
|
||||
|
||||
/* vis.js */
|
||||
'vis': '../bower_components/vis/dist/vis.min'
|
||||
'vis': '../bower_components/vis/dist/vis.min',
|
||||
|
||||
/* navigo */
|
||||
'Navigo': '../bower_components/navigo/lib/navigo.min'
|
||||
},
|
||||
shim: {
|
||||
/* Tabs */
|
||||
|
@ -25,10 +25,14 @@ define(function(require) {
|
||||
var Notifier = require('utils/notifier');
|
||||
var Menu = require('utils/menu');
|
||||
var Tips = require('utils/tips');
|
||||
var Navigo = require('Navigo');
|
||||
|
||||
var router;
|
||||
|
||||
var TOP_INTERVAL = 10000; //ms
|
||||
var CONFIRM_DIALOG_ID = require('utils/dialogs/confirm/dialogId');
|
||||
var CONFIRM_WITH_SELECT_DIALOG_ID = require('utils/dialogs/confirm-with-select/dialogId');
|
||||
var DASHBOARD_TAB_ID = require('tabs/dashboard-tab/tabId');
|
||||
|
||||
var SunstoneCfg = {
|
||||
"actions" : {},
|
||||
@ -121,7 +125,7 @@ define(function(require) {
|
||||
|
||||
//Inserts all main tabs in the DOM
|
||||
var _insertTabs = function() {
|
||||
for (tabName in SunstoneCfg["tabs"]) {
|
||||
for (var tabName in SunstoneCfg["tabs"]) {
|
||||
_insertTab(tabName);
|
||||
_insertButtonsInTab(tabName);
|
||||
_setupDataTable(tabName);
|
||||
@ -505,7 +509,7 @@ define(function(require) {
|
||||
|
||||
// Button to return to the list view from the detailed view
|
||||
$(document).on("click", "button[href='back']", function(e) {
|
||||
$(".navigation-active-li a", $("#navigation")).click();
|
||||
window.history.back();
|
||||
e.preventDefault();
|
||||
});
|
||||
}
|
||||
@ -572,6 +576,18 @@ define(function(require) {
|
||||
}
|
||||
|
||||
var _showTab = function(tabName) {
|
||||
if (_getTab() == tabName && _rightListVisible()){
|
||||
_routerShowTab(tabName);
|
||||
} else {
|
||||
if (router != undefined){
|
||||
router.navigate(tabName);
|
||||
}else{
|
||||
_routerShowTab(tabName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var _routerShowTab = function(tabName) {
|
||||
$('.labels-tree', '#navigation').remove();
|
||||
|
||||
if (!SunstoneCfg['tabs'][tabName]) {
|
||||
@ -614,8 +630,28 @@ define(function(require) {
|
||||
return $(".tab:visible").attr("id");
|
||||
}
|
||||
|
||||
var _showElement = function(tabName, infoAction, elementId) {
|
||||
_showTab(tabName);
|
||||
var _showElement = function(tabName, elementId) {
|
||||
if(!Config.isTabEnabled(tabName)){
|
||||
return;
|
||||
}
|
||||
|
||||
if (router != undefined){
|
||||
router.navigate(tabName + "/" + elementId);
|
||||
}else{
|
||||
_routerShowElement(tabName, elementId);
|
||||
}
|
||||
}
|
||||
|
||||
var _routerShowElement = function(tabName, elementId) {
|
||||
var resource = SunstoneCfg["tabs"][tabName].resource;
|
||||
|
||||
if (resource == undefined){
|
||||
return;
|
||||
}
|
||||
|
||||
var infoAction = resource + ".show";
|
||||
|
||||
_routerShowTab(tabName);
|
||||
|
||||
var context = $('#' + tabName);
|
||||
|
||||
@ -993,6 +1029,10 @@ define(function(require) {
|
||||
}
|
||||
|
||||
function _popFormPanelLoading(tabId) {
|
||||
if (!_formPanelVisible($("#"+tabId)) && router != undefined){
|
||||
router.navigate(tabId+"/form");
|
||||
}
|
||||
|
||||
var context = $("#" + tabId);
|
||||
$(".sunstone-list", context).hide();
|
||||
$(".sunstone-info", context).hide();
|
||||
@ -1093,6 +1133,36 @@ define(function(require) {
|
||||
return dialogInstance;
|
||||
}
|
||||
|
||||
var _setupNavigoRoutes = function() {
|
||||
router = new Navigo(null, true);
|
||||
|
||||
for (var tabName in SunstoneCfg["tabs"]) {
|
||||
router.on(new RegExp("(?:#|/)"+tabName+"/form"), function(){
|
||||
}.bind(tabName));
|
||||
|
||||
router.on(new RegExp("(?:#|/)"+tabName+"/(\\d+)"), function(id){
|
||||
_routerShowElement(this, id)
|
||||
}.bind(tabName));
|
||||
|
||||
router.on(new RegExp("(?:#|/)"+tabName), function(){
|
||||
_routerShowTab(this);
|
||||
}.bind(tabName));
|
||||
}
|
||||
|
||||
router.on(function(){
|
||||
_routerShowTab(DASHBOARD_TAB_ID);
|
||||
});
|
||||
|
||||
$(document).on("click", "a", function(e){
|
||||
if ($(this).attr("href") != undefined &&
|
||||
$(this).attr("href").startsWith("#")){
|
||||
e.preventDefault();
|
||||
}
|
||||
});
|
||||
|
||||
router.resolve();
|
||||
}
|
||||
|
||||
var Sunstone = {
|
||||
"addMainTabs": _addMainTabs,
|
||||
"addDialogs": _addDialogs,
|
||||
@ -1128,7 +1198,9 @@ define(function(require) {
|
||||
|
||||
"insertButtonsInTab": _insertButtonsInTab,
|
||||
|
||||
"TOP_INTERVAL": TOP_INTERVAL
|
||||
"TOP_INTERVAL": TOP_INTERVAL,
|
||||
|
||||
"setupNavigoRoutes": _setupNavigoRoutes
|
||||
}
|
||||
|
||||
return Sunstone;
|
||||
|
@ -127,12 +127,7 @@ define(function(require) {
|
||||
PermissionsTable.setup(TAB_ID, RESOURCE, this.element, context);
|
||||
|
||||
$("a.vrid", context).on("click", function(){
|
||||
// TODO: this should be checked internally in showElement,
|
||||
// but it won't work because of bug #4198
|
||||
|
||||
if (Config.isTabEnabled("vrouters-tab")){
|
||||
Sunstone.showElement("vrouters-tab", "VirtualRouter.show", $(this).text());
|
||||
}
|
||||
Sunstone.showElement("vrouters-tab", $(this).text());
|
||||
});
|
||||
|
||||
// Get rid of the unwanted (for show) SCHED_* keys
|
||||
|
@ -485,26 +485,11 @@ define(function(require) {
|
||||
_network.on("doubleClick", function(params) {
|
||||
if (params.nodes.length == 1 && _network.isCluster(params.nodes[0]) == false) {
|
||||
if ( params.nodes[0].match(/vm\d+/) ){
|
||||
// TODO: this should be checked internally in showElement,
|
||||
// but it won't work because of bug #4198
|
||||
|
||||
if (Config.isTabEnabled("vms-tab")){
|
||||
Sunstone.showElement("vms-tab", "VM.show", params.nodes[0].split("vm")[1]);
|
||||
}
|
||||
Sunstone.showElement("vms-tab", params.nodes[0].split("vm")[1]);
|
||||
} else if ( params.nodes[0].match(/vnet\d+/) ){
|
||||
// TODO: this should be checked internally in showElement,
|
||||
// but it won't work because of bug #4198
|
||||
|
||||
if (Config.isTabEnabled("vnets-tab")){
|
||||
Sunstone.showElement("vnets-tab", "Network.show", params.nodes[0].split("vnet")[1]);
|
||||
}
|
||||
Sunstone.showElement("vnets-tab", params.nodes[0].split("vnet")[1]);
|
||||
} else if ( params.nodes[0].match(/vr\d+/) ){
|
||||
// TODO: this should be checked internally in showElement,
|
||||
// but it won't work because of bug #4198
|
||||
|
||||
if (Config.isTabEnabled("vrouters-tab")){
|
||||
Sunstone.showElement("vrouters-tab", "VirtualRouter.show", params.nodes[0].split("vr")[1]);
|
||||
}
|
||||
Sunstone.showElement("vrouters-tab", params.nodes[0].split("vr")[1]);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -402,7 +402,7 @@ define(function(require) {
|
||||
var id = $(aData[0]).val();
|
||||
if (!id) return true;
|
||||
|
||||
Sunstone.showElement(tableObj.tabId, tableObj.resource + ".show", id);
|
||||
Sunstone.showElement(tableObj.tabId, id);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -22,10 +22,12 @@
|
||||
"requirejs": "2.1.22",
|
||||
"foundation-sites": "6.2.1",
|
||||
"jquery": "2.2.3",
|
||||
"datatables": "1.10.12"
|
||||
"datatables": "1.10.12",
|
||||
"navigo": "2.1.1"
|
||||
},
|
||||
"authors": [
|
||||
"Daniel Molina <dmolina@opennebula.org>"
|
||||
"Daniel Molina <dmolina@opennebula.org>",
|
||||
"Carlos Martin <cmartin@opennebula.org>"
|
||||
],
|
||||
"description": "OpenNebula Sunstone",
|
||||
"moduleType": [
|
||||
|
@ -479,6 +479,8 @@ get '/login' do
|
||||
content_type 'text/html', :charset => 'utf-8'
|
||||
if !authorized?
|
||||
erb :login
|
||||
else
|
||||
redirect to('/')
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user