1
0
mirror of https://github.com/OpenNebula/one.git synced 2024-12-21 09:33:53 +03:00

B #2961 add timepicker in relative scheduled actions (#2984)

This commit is contained in:
jloboescalona2 2019-02-22 17:49:56 +01:00 committed by Tino Vázquez
parent f676656485
commit 483fccb08d
19 changed files with 991 additions and 960 deletions

3
package-lock.json generated Normal file
View File

@ -0,0 +1,3 @@
{
"lockfileVersion": 1
}

View File

@ -16,78 +16,78 @@
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
pkg: grunt.file.readJSON("package.json"),
sass: {
options: {
includePaths: ['bower_components/foundation-sites/scss']
includePaths: ["bower_components/foundation-sites/scss"]
},
dist: {
options: {
outputStyle: 'compressed'
outputStyle: "compressed"
},
files: {
'css/app.css': 'scss/app.scss'
"css/app.css": "scss/app.scss"
}
}
},
watch: {
grunt: {
files: ['Gruntfile.js']
files: ["Gruntfile.js"]
},
sass: {
files: 'scss/*.scss',
tasks: ['sass']
files: "scss/*.scss",
tasks: ["sass"]
},
requirejs: {
files: 'app/**/*.js',
tasks: ['requirejs']
files: "app/**/*.js",
tasks: ["requirejs"]
}
},
requirejs: {
compileCSS: {
options: {
out: './css/app.min.css',
cssIn: './css/app.css',
optimizeCss: 'default'
out: "./css/app.min.css",
cssIn: "./css/app.css",
optimizeCss: "default"
}
},
compileJS: {
options: {
appDir: './app',
baseUrl: './', // 1
dir: './dist', // 2
appDir: "./app",
baseUrl: "./", // 1
dir: "./dist", // 2
//name: 'vendor/almond', // 3
mainConfigFile: './app/main.js', // 5
mainConfigFile: "./app/main.js", // 5
preserveLicenseComments: false,
optimize: 'none',
optimize: "none",
generateSourceMaps: true,
removeCombined: true,
//skipDirOptimize: false,
//findNestedDependencies: true,
modules: [
{
name: 'main',
include: ['almond']
name: "main",
include: ["almond"]
},
{
name: 'login',
include: ['almond'],
insertRequire: ['login']
name: "login",
include: ["almond"],
insertRequire: ["login"]
},
{
name: 'console/vnc',
include: ['almond'],
insertRequire: ['console/vnc']
name: "console/vnc",
include: ["almond"],
insertRequire: ["console/vnc"]
},
{
name: 'console/spice',
include: ['almond'],
insertRequire: ['console/spice']
name: "console/spice",
include: ["almond"],
insertRequire: ["console/spice"]
}
/*{
name: 'main'
@ -232,10 +232,10 @@ module.exports = function(grunt) {
}
});
grunt.loadNpmTasks('grunt-sass');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-requirejs');
grunt.loadNpmTasks("grunt-sass");
grunt.loadNpmTasks("grunt-contrib-watch");
grunt.loadNpmTasks("grunt-contrib-requirejs");
grunt.registerTask('build', ['sass']);
grunt.registerTask('default', ['build','watch']);
}
grunt.registerTask("build", ["sass"]);
grunt.registerTask("default", ["build","watch"]);
};

View File

@ -17,7 +17,7 @@
define(function(require) {
require('jquery');
require('jquery-ui');
require('wickedpicker');
require('foundation');
Foundation.Dropdown.defaults.positionClass = 'left';

View File

@ -17,21 +17,24 @@
require.config({
paths: {
/* Almond */
'almond': '../bower_components/almond/almond',
"almond": "../bower_components/almond/almond",
/* jQuery */
'jquery': '../bower_components/jquery/dist/jquery',
'jquery-ui': '../bower_components/jquery-ui/jquery-ui',
"jquery": "../bower_components/jquery/dist/jquery",
"jquery-ui": "../bower_components/jquery-ui/jquery-ui",
/** Wickedpicker */
"wickedpicker": "../bower_components/wickedpicker/dist/wickedpicker.min",
/* DataTables */
'datatables.net': '../bower_components/datatables/media/js/jquery.dataTables',
'datatables.foundation': '../bower_components/datatables/media/js/dataTables.foundation',
"datatables.net": "../bower_components/datatables/media/js/jquery.dataTables",
"datatables.foundation": "../bower_components/datatables/media/js/dataTables.foundation",
/* DataTables */
'jgrowl': '../bower_components/jgrowl/jquery.jgrowl',
"jgrowl": "../bower_components/jgrowl/jquery.jgrowl",
/* Foundation */
'foundation': '../bower_components/foundation-sites/dist/foundation',
"foundation": "../bower_components/foundation-sites/dist/foundation",
//'foundation.core': '../bower_components/foundation/js/foundation/foundation',
//'foundation.abide': '../bower_components/foundation/js/foundation/foundation.abide',
//'foundation.accordion': '../bower_components/foundation/js/foundation/foundation.accordion',
@ -51,131 +54,131 @@ require.config({
//'foundation.topbar': '../bower_components/foundation/js/foundation/foundation.topbar',
/* Handlebars */
'hbs': '../bower_components/require-handlebars-plugin/hbs',
"hbs": "../bower_components/require-handlebars-plugin/hbs",
/* Resumable */
'resumable': '../bower_components/resumablejs/resumable',
"resumable": "../bower_components/resumablejs/resumable",
/* Flot Graphs */
'flot': '../bower_components/flot/jquery.flot',
'flot.stack': '../bower_components/flot/jquery.flot.stack',
'flot.navigate': '../bower_components/flot/jquery.flot.navigate',
'flot.canvas': '../bower_components/flot/jquery.flot.canvas',
'flot.resize': '../bower_components/flot/jquery.flot.resize',
'flot.time': '../bower_components/flot/jquery.flot.time',
'flot.tooltip': '../bower_components/flot.tooltip/js/jquery.flot.tooltip',
"flot": "../bower_components/flot/jquery.flot",
"flot.stack": "../bower_components/flot/jquery.flot.stack",
"flot.navigate": "../bower_components/flot/jquery.flot.navigate",
"flot.canvas": "../bower_components/flot/jquery.flot.canvas",
"flot.resize": "../bower_components/flot/jquery.flot.resize",
"flot.time": "../bower_components/flot/jquery.flot.time",
"flot.tooltip": "../bower_components/flot.tooltip/js/jquery.flot.tooltip",
/* VNC */
'vnc-util': '../bower_components/no-vnc/include/util',
'vnc-webutil': '../bower_components/no-vnc/include/webutil',
'vnc-base64': '../bower_components/no-vnc/include/base64',
'vnc-websock': '../bower_components/no-vnc/include/websock',
'vnc-des': '../bower_components/no-vnc/include/des',
'vnc-keysymdef': '../bower_components/no-vnc/include/keysymdef',
'vnc-keyboard': '../bower_components/no-vnc/include/keyboard',
'vnc-input': '../bower_components/no-vnc/include/input',
'vnc-display': '../bower_components/no-vnc/include/display',
'vnc-jsunzip': '../bower_components/no-vnc/include/jsunzip',
'vnc-rfb': '../bower_components/no-vnc/include/rfb',
'vnc-keysym': '../bower_components/no-vnc/include/keysym',
"vnc-util": "../bower_components/no-vnc/include/util",
"vnc-webutil": "../bower_components/no-vnc/include/webutil",
"vnc-base64": "../bower_components/no-vnc/include/base64",
"vnc-websock": "../bower_components/no-vnc/include/websock",
"vnc-des": "../bower_components/no-vnc/include/des",
"vnc-keysymdef": "../bower_components/no-vnc/include/keysymdef",
"vnc-keyboard": "../bower_components/no-vnc/include/keyboard",
"vnc-input": "../bower_components/no-vnc/include/input",
"vnc-display": "../bower_components/no-vnc/include/display",
"vnc-jsunzip": "../bower_components/no-vnc/include/jsunzip",
"vnc-rfb": "../bower_components/no-vnc/include/rfb",
"vnc-keysym": "../bower_components/no-vnc/include/keysym",
/* Spice */
'spice-main': '../bower_components/spice-html5/main',
'spice-spicearraybuffer': '../bower_components/spice-html5/spicearraybuffer',
'spice-enums': '../bower_components/spice-html5/enums',
'spice-atKeynames': '../bower_components/spice-html5/atKeynames',
'spice-utils': '../bower_components/spice-html5/utils',
'spice-png': '../bower_components/spice-html5/png',
'spice-lz': '../bower_components/spice-html5/lz',
'spice-quic': '../bower_components/spice-html5/quic',
'spice-bitmap': '../bower_components/spice-html5/bitmap',
'spice-spicedataview': '../bower_components/spice-html5/spicedataview',
'spice-spicetype': '../bower_components/spice-html5/spicetype',
'spice-spicemsg': '../bower_components/spice-html5/spicemsg',
'spice-wire': '../bower_components/spice-html5/wire',
'spice-spiceconn': '../bower_components/spice-html5/spiceconn',
'spice-display': '../bower_components/spice-html5/display',
'spice-inputs': '../bower_components/spice-html5/inputs',
'spice-webm': '../bower_components/spice-html5/webm',
'spice-playback': '../bower_components/spice-html5/playback',
'spice-simulatecursor': '../bower_components/spice-html5/simulatecursor',
'spice-cursor': '../bower_components/spice-html5/cursor',
'spice-jsbn': '../bower_components/spice-html5/thirdparty/jsbn',
'spice-rsa': '../bower_components/spice-html5/thirdparty/rsa',
'spice-prng4': '../bower_components/spice-html5/thirdparty/prng4',
'spice-rng': '../bower_components/spice-html5/thirdparty/rng',
'spice-sha1': '../bower_components/spice-html5/thirdparty/sha1',
'spice-ticket': '../bower_components/spice-html5/ticket',
'spice-resize': '../bower_components/spice-html5/resize',
'spice-filexfer': '../bower_components/spice-html5/filexfer',
"spice-main": "../bower_components/spice-html5/main",
"spice-spicearraybuffer": "../bower_components/spice-html5/spicearraybuffer",
"spice-enums": "../bower_components/spice-html5/enums",
"spice-atKeynames": "../bower_components/spice-html5/atKeynames",
"spice-utils": "../bower_components/spice-html5/utils",
"spice-png": "../bower_components/spice-html5/png",
"spice-lz": "../bower_components/spice-html5/lz",
"spice-quic": "../bower_components/spice-html5/quic",
"spice-bitmap": "../bower_components/spice-html5/bitmap",
"spice-spicedataview": "../bower_components/spice-html5/spicedataview",
"spice-spicetype": "../bower_components/spice-html5/spicetype",
"spice-spicemsg": "../bower_components/spice-html5/spicemsg",
"spice-wire": "../bower_components/spice-html5/wire",
"spice-spiceconn": "../bower_components/spice-html5/spiceconn",
"spice-display": "../bower_components/spice-html5/display",
"spice-inputs": "../bower_components/spice-html5/inputs",
"spice-webm": "../bower_components/spice-html5/webm",
"spice-playback": "../bower_components/spice-html5/playback",
"spice-simulatecursor": "../bower_components/spice-html5/simulatecursor",
"spice-cursor": "../bower_components/spice-html5/cursor",
"spice-jsbn": "../bower_components/spice-html5/thirdparty/jsbn",
"spice-rsa": "../bower_components/spice-html5/thirdparty/rsa",
"spice-prng4": "../bower_components/spice-html5/thirdparty/prng4",
"spice-rng": "../bower_components/spice-html5/thirdparty/rng",
"spice-sha1": "../bower_components/spice-html5/thirdparty/sha1",
"spice-ticket": "../bower_components/spice-html5/ticket",
"spice-resize": "../bower_components/spice-html5/resize",
"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',
"Navigo": "../bower_components/navigo/lib/navigo.min",
/* sprintf */
'sprintf': '../bower_components/sprintf/dist/sprintf.min'
"sprintf": "../bower_components/sprintf/dist/sprintf.min"
},
shim: {
/* Tabs */
'app': {
"app": {
deps: [
'foundation',
'jquery',
'tabs/provision-tab',
'tabs/dashboard-tab',
'tabs/system-top-tab',
'tabs/users-tab',
'tabs/groups-tab',
'tabs/vdcs-tab',
'tabs/acls-tab',
'tabs/templates-top-tab',
'tabs/templates-tab',
'tabs/oneflow-templates-tab',
'tabs/vrouter-templates-tab',
'tabs/instances-top-tab',
'tabs/vms-tab',
'tabs/oneflow-services-tab',
'tabs/vrouters-tab',
'tabs/infrastructure-top-tab',
'tabs/clusters-tab',
'tabs/hosts-tab',
'tabs/zones-tab',
'tabs/storage-top-tab',
'tabs/datastores-tab',
'tabs/images-tab',
'tabs/files-tab',
'tabs/marketplaces-tab',
'tabs/marketplaceapps-tab',
'tabs/network-top-tab',
'tabs/vnets-tab',
'tabs/vnets-templates-tab',
'tabs/vnets-topology-tab',
'tabs/secgroups-tab',
'tabs/settings-tab',
'tabs/support-tab',
'tabs/upgrade-top-tab',
'tabs/vmgroup-tab',
'addons/start',
'addons/end'
"foundation",
"jquery",
"tabs/provision-tab",
"tabs/dashboard-tab",
"tabs/system-top-tab",
"tabs/users-tab",
"tabs/groups-tab",
"tabs/vdcs-tab",
"tabs/acls-tab",
"tabs/templates-top-tab",
"tabs/templates-tab",
"tabs/oneflow-templates-tab",
"tabs/vrouter-templates-tab",
"tabs/instances-top-tab",
"tabs/vms-tab",
"tabs/oneflow-services-tab",
"tabs/vrouters-tab",
"tabs/infrastructure-top-tab",
"tabs/clusters-tab",
"tabs/hosts-tab",
"tabs/zones-tab",
"tabs/storage-top-tab",
"tabs/datastores-tab",
"tabs/images-tab",
"tabs/files-tab",
"tabs/marketplaces-tab",
"tabs/marketplaceapps-tab",
"tabs/network-top-tab",
"tabs/vnets-tab",
"tabs/vnets-templates-tab",
"tabs/vnets-topology-tab",
"tabs/secgroups-tab",
"tabs/settings-tab",
"tabs/support-tab",
"tabs/upgrade-top-tab",
"tabs/vmgroup-tab",
"addons/start",
"addons/end"
]
},
/* jQuery */
'jquery': {
exports: '$'
"jquery": {
exports: "$"
},
/* jGrowl */
'jgrowl': {
deps: ['jquery']
"jgrowl": {
deps: ["jquery"]
},
/* Foundation */
'foundation': {
deps: ['jquery']
"foundation": {
deps: ["jquery"]
},
//'foundation.core': {
// deps: ['jquery', 'modernizr'],
@ -245,123 +248,123 @@ require.config({
//},
/* Flot Graphs */
'flot': {
deps: ['jquery']
"flot": {
deps: ["jquery"]
},
'flot.stack': {
deps: ['flot']
"flot.stack": {
deps: ["flot"]
},
'flot.resize': {
deps: ['flot']
"flot.resize": {
deps: ["flot"]
},
'flot.time': {
deps: ['flot']
"flot.time": {
deps: ["flot"]
},
'flot.tooltip': {
deps: ['flot']
"flot.tooltip": {
deps: ["flot"]
},
/* VNC */
'vnc-util': {
exports: 'Util'
"vnc-util": {
exports: "Util"
},
'vnc-webutil': {
"vnc-webutil": {
deps: ["vnc-util"]
},
'vnc-base64': {
"vnc-base64": {
deps: ["vnc-util"]
},
'vnc-websock': {
"vnc-websock": {
deps: ["vnc-util"]
},
'vnc-des': {
"vnc-des": {
deps: ["vnc-util"]
},
'vnc-keysymdef': {
"vnc-keysymdef": {
deps: ["vnc-util"]
},
'vnc-keyboard': {
"vnc-keyboard": {
deps: ["vnc-util"]
},
'vnc-input': {
"vnc-input": {
deps: ["vnc-util"]
},
'vnc-display': {
"vnc-display": {
deps: ["vnc-util"]
},
'vnc-jsunzip': {
"vnc-jsunzip": {
deps: ["vnc-util"]
},
'vnc-rfb': {
"vnc-rfb": {
deps: ["vnc-util"]
},
'vnc-keysym': {
"vnc-keysym": {
deps: ["vnc-util"]
},
'spice-main': {
exports: 'SpiceMainConn',
"spice-main": {
exports: "SpiceMainConn",
deps: [
'spice-spiceconn',
'spice-spicearraybuffer',
'spice-enums',
'spice-atKeynames',
'spice-utils',
'spice-png',
'spice-lz',
'spice-quic',
'spice-bitmap',
'spice-spicedataview',
'spice-spicetype',
'spice-spicemsg',
'spice-wire',
'spice-display',
'spice-inputs',
'spice-webm',
'spice-playback',
'spice-simulatecursor',
'spice-cursor',
'spice-jsbn',
'spice-rsa',
'spice-prng4',
'spice-rng',
'spice-sha1',
'spice-ticket',
'spice-resize',
'spice-filexfer'
"spice-spiceconn",
"spice-spicearraybuffer",
"spice-enums",
"spice-atKeynames",
"spice-utils",
"spice-png",
"spice-lz",
"spice-quic",
"spice-bitmap",
"spice-spicedataview",
"spice-spicetype",
"spice-spicemsg",
"spice-wire",
"spice-display",
"spice-inputs",
"spice-webm",
"spice-playback",
"spice-simulatecursor",
"spice-cursor",
"spice-jsbn",
"spice-rsa",
"spice-prng4",
"spice-rng",
"spice-sha1",
"spice-ticket",
"spice-resize",
"spice-filexfer"
]
},
'spice-rng': {
"spice-rng": {
deps: [
'spice-prng4'
"spice-prng4"
]
},
'spice-display': {
"spice-display": {
deps: [
'spice-spiceconn'
"spice-spiceconn"
]
},
'spice-inputs': {
"spice-inputs": {
deps: [
'spice-spiceconn'
"spice-spiceconn"
]
},
'spice-playback': {
"spice-playback": {
deps: [
'spice-spiceconn'
"spice-spiceconn"
]
},
'spice-cursor': {
"spice-cursor": {
deps: [
'spice-spiceconn'
"spice-spiceconn"
]
}
}
});
require(['app'], function(App) {});
require(["app"], function(App) {});

View File

@ -85,7 +85,7 @@ define(function(require) {
$.each(Config.enabledTabs, function(i, tabName){
var name = "./tabs/" + tabName;
if (DefaultTabsArr.indexOf(tabName) == -1){
name = "./addons/tabs/" + tabName
name = "./addons/tabs/" + tabName;
}
var tabObj = require(name);
var _tabId = tabObj.tabId;
@ -122,7 +122,7 @@ define(function(require) {
$.each(Config.allTabs(), function(i, tabName){
var name = "./tabs/" + tabName;
if (DefaultTabsArr.indexOf(tabName) == -1){
name = "./addons/tabs/" + tabName
name = "./addons/tabs/" + tabName;
}
var tabObj = require(name);

View File

@ -19,20 +19,20 @@ define(function(require) {
DEPENDENCIES
*/
var BaseDialog = require('utils/dialogs/dialog');
var TemplateHTML = require('hbs!./clone/html');
var Sunstone = require('sunstone');
var DatastoreTable = require('tabs/datastores-tab/datatable')
var Notifier = require('utils/notifier');
var OpenNebulaImage = require('opennebula/image');
var OpenNebulaDatastore = require('opennebula/datastore');
var BaseDialog = require("utils/dialogs/dialog");
var TemplateHTML = require("hbs!./clone/html");
var Sunstone = require("sunstone");
var DatastoreTable = require("tabs/datastores-tab/datatable");
var Notifier = require("utils/notifier");
var OpenNebulaImage = require("opennebula/image");
var OpenNebulaDatastore = require("opennebula/datastore");
/*
CONSTANTS
*/
var DIALOG_ID = require('./clone/dialogId');
var IMAGES_TAB_ID = require('tabs/images-tab/tabId')
var DIALOG_ID = require("./clone/dialogId");
var IMAGES_TAB_ID = require("tabs/images-tab/tabId");
/*
CONSTRUCTOR
@ -41,10 +41,10 @@ define(function(require) {
function Dialog() {
this.dialogId = DIALOG_ID;
this.datastoreTable = new DatastoreTable('image_clone', {
'select': true,
'selectOptions': {
'filter_fn': function(ds) {
this.datastoreTable = new DatastoreTable("image_clone", {
"select": true,
"selectOptions": {
"filter_fn": function(ds) {
return ds.TYPE == OpenNebulaDatastore.TYPES.IMAGE_DS;
}
}
@ -68,8 +68,8 @@ define(function(require) {
function _html() {
return TemplateHTML({
'dialogId': this.dialogId,
'datastoreTableSelectHTML': this.datastoreTable.dataTableHTML
"dialogId": this.dialogId,
"datastoreTableSelectHTML": this.datastoreTable.dataTableHTML
});
}
@ -78,33 +78,34 @@ define(function(require) {
// TODO: Show DS with the same ds mad only
that.datastoreTable.initialize();
$('#' + DIALOG_ID + 'Form', dialog).submit(function() {
var name = $('input[name="image_clone_name"]', this).val();
$("#" + DIALOG_ID + "Form", dialog).submit(function() {
var name = $("input[name=\"image_clone_name\"]", this).val();
var sel_elems = Sunstone.getDataTable(IMAGES_TAB_ID).elements();
var extra_info = {};
var targeDS = that.datastoreTable.retrieveResourceTableSelect();
if (targeDS) {
extra_info['target_ds'] = targeDS;
extra_info["target_ds"] = targeDS;
}
if (sel_elems.length > 1) {
for (var i = 0; i < sel_elems.length; i++) {
//If we are cloning several images we
//use the name as prefix
extra_info['name'] = name + OpenNebulaImage.getName(sel_elems[i]);
Sunstone.runAction('Image.clone', sel_elems[i], extra_info);
extra_info["name"] = name + OpenNebulaImage.getName(sel_elems[i]);
Sunstone.runAction("Image.clone", sel_elems[i], extra_info);
}
} else {
extra_info['name'] = name;
Sunstone.runAction('Image.clone', sel_elems[0], extra_info)
extra_info["name"] = name;
Sunstone.runAction("Image.clone", sel_elems[0], extra_info);
}
Sunstone.getDialog(DIALOG_ID).hide();
Sunstone.getDialog(DIALOG_ID).reset();
setTimeout(function() {
Sunstone.runAction('Image.refresh');
console.log("d");
Sunstone.runAction("Image.refresh");
}, 1500);
return false;
});
@ -119,13 +120,13 @@ define(function(require) {
//show different text depending on how many elements are selected
if (sel_elems.length > 1) {
$('.clone_one', dialog).hide();
$('.clone_several', dialog).show();
$('input[name="image_clone_name"]', dialog).val('Copy of ');
$(".clone_one", dialog).hide();
$(".clone_several", dialog).show();
$("input[name=\"image_clone_name\"]", dialog).val("Copy of ");
} else {
$('.clone_one', dialog).show();
$('.clone_several', dialog).hide();
$('input[name="image_clone_name"]', dialog).val('Copy of ' + sel_elems[0].name);
$(".clone_one", dialog).show();
$(".clone_several", dialog).hide();
$("input[name=\"image_clone_name\"]", dialog).val("Copy of " + sel_elems[0].name);
};
this.datastoreTable.resetResourceTableSelect();

View File

@ -19,18 +19,18 @@ define(function(require) {
DEPENDENCIES
*/
var BaseDialog = require('utils/dialogs/dialog');
var TemplateHTML = require('hbs!./clone/html');
var Sunstone = require('sunstone');
var Notifier = require('utils/notifier');
var OpenNebulaServiceTemplate = require('opennebula/servicetemplate');
var BaseDialog = require("utils/dialogs/dialog");
var TemplateHTML = require("hbs!./clone/html");
var Sunstone = require("sunstone");
var Notifier = require("utils/notifier");
var OpenNebulaServiceTemplate = require("opennebula/servicetemplate");
/*
CONSTANTS
*/
var DIALOG_ID = require('./clone/dialogId');
var ONEFLOW_TEMPLATES_TAB_ID = require('tabs/oneflow-templates-tab/tabId')
var DIALOG_ID = require("./clone/dialogId");
var ONEFLOW_TEMPLATES_TAB_ID = require("tabs/oneflow-templates-tab/tabId");
/*
CONSTRUCTOR
@ -57,16 +57,16 @@ define(function(require) {
function _html() {
return TemplateHTML({
'dialogId': this.dialogId
"dialogId": this.dialogId
});
}
function _setup(context) {
var that = this;
$('#' + DIALOG_ID + 'Form', context).submit(function() {
$("#" + DIALOG_ID + "Form", context).submit(function() {
var extra_info;
var name = $('input[name="name"]', this).val();
var name = $("input[name=\"name\"]", this).val();
var sel_elems = Sunstone.getDataTable(ONEFLOW_TEMPLATES_TAB_ID).elements();
if (sel_elems.length > 1) {
@ -74,17 +74,18 @@ define(function(require) {
//If we are cloning several images we
//use the name as prefix
extra_info = name + OpenNebulaServiceTemplate.getName(sel_elems[i]);
Sunstone.runAction('ServiceTemplate.clone', sel_elems[i], extra_info);
Sunstone.runAction("ServiceTemplate.clone", sel_elems[i], extra_info);
}
} else {
extra_info = name;
Sunstone.runAction('ServiceTemplate.clone', sel_elems[0], extra_info)
Sunstone.runAction("ServiceTemplate.clone", sel_elems[0], extra_info);
}
Sunstone.getDialog(DIALOG_ID).hide();
Sunstone.getDialog(DIALOG_ID).reset();
setTimeout(function() {
Sunstone.runAction('ServiceTemplate.refresh');
console.log("e");
Sunstone.runAction("ServiceTemplate.refresh");
}, 1500);
return false;
});
@ -99,13 +100,13 @@ define(function(require) {
//show different text depending on how many elements are selected
if (sel_elems.length > 1) {
$('.clone_one', context).hide();
$('.clone_several', context).show();
$('input[name="name"]',context).val('Copy of ');
$(".clone_one", context).hide();
$(".clone_several", context).show();
$("input[name=\"name\"]",context).val("Copy of ");
} else {
$('.clone_one', context).show();
$('.clone_several', context).hide();
$('input[name="name"]', context).val('Copy of ' + sel_elems[0].name);
$(".clone_one", context).show();
$(".clone_several", context).hide();
$("input[name=\"name\"]", context).val("Copy of " + sel_elems[0].name);
};
$("input[name='name']", context).focus();

View File

@ -16,23 +16,23 @@
define(function(require) {
// require('foundation.alert');
var OpenNebula = require('opennebula');
var Locale = require('utils/locale');
var Notifier = require('utils/notifier');
var Humanize = require('utils/humanize');
var ResourceSelect = require('utils/resource-select');
var RangeSlider = require('utils/range-slider');
var TemplateUtils = require('utils/template-utils');
var OpenNebula = require("opennebula");
var Locale = require("utils/locale");
var Notifier = require("utils/notifier");
var Humanize = require("utils/humanize");
var ResourceSelect = require("utils/resource-select");
var RangeSlider = require("utils/range-slider");
var TemplateUtils = require("utils/template-utils");
var ProvisionVmsList = require('tabs/provision-tab/vms/list');
var ProvisionVmsList = require("tabs/provision-tab/vms/list");
var TemplateFlowsList = require('hbs!./list');
var TemplateFlowsList = require("hbs!./list");
var _accordionId = 0;
return {
'generate': generate_provision_flows_list,
'show': show_provision_flow_list
"generate": generate_provision_flows_list,
"show": show_provision_flow_list
};
@ -47,7 +47,7 @@ define(function(require) {
function generate_provision_flows_list(context, opts) {
context.off();
context.html(html(opts));
Foundation.reflow(context, 'accordion');
Foundation.reflow(context, "accordion");
setup_provision_flows_list(context, opts);
setup_info_flow(context);
}
@ -59,66 +59,67 @@ define(function(require) {
refresh: true,
create: true,
filter: true
},opts_arg)
},opts_arg);
_accordionId += 1;
return TemplateFlowsList({'accordionId': _accordionId, 'opts': opts});
return TemplateFlowsList({"accordionId": _accordionId, "opts": opts});
}
function update_provision_flows_datatable(datatable, timeout) {
datatable.html('<div class="text-center">'+
'<span class="fa-stack fa-5x">'+
'<i class="fas fa-cloud fa-stack-2x"></i>'+
'<i class="fa fa-spinner fa-spin fa-stack-1x fa-inverse"></i>'+
'</span>'+
'<br>'+
'<br>'+
'<span>'+
'</span>'+
'</div>');
datatable.html("<div class=\"text-center\">"+
"<span class=\"fa-stack fa-5x\">"+
"<i class=\"fas fa-cloud fa-stack-2x\"></i>"+
"<i class=\"fa fa-spinner fa-spin fa-stack-1x fa-inverse\"></i>"+
"</span>"+
"<br>"+
"<br>"+
"<span>"+
"</span>"+
"</div>");
setTimeout( function(){
console.log("g");
OpenNebula.Service.list({
timeout: true,
success: function (request, item_list){
$(".flow_error_message").hide();
datatable.fnClearTable(true);
if (item_list.length == 0) {
datatable.html('<div class="text-center">'+
'<span class="fa-stack fa-5x">'+
'<i class="fas fa-cloud fa-stack-2x"></i>'+
'<i class="fas fa-info-circle fa-stack-1x fa-inverse"></i>'+
'</span>'+
'<br>'+
'<br>'+
'<span>'+
datatable.html("<div class=\"text-center\">"+
"<span class=\"fa-stack fa-5x\">"+
"<i class=\"fas fa-cloud fa-stack-2x\"></i>"+
"<i class=\"fas fa-info-circle fa-stack-1x fa-inverse\"></i>"+
"</span>"+
"<br>"+
"<br>"+
"<span>"+
Locale.tr("There are no Services")+
'</span>'+
'<br>'+
'<br>'+
'</div>');
"</span>"+
"<br>"+
"<br>"+
"</div>");
} else {
datatable.fnAddData(item_list);
}
},
error: function(request, error_json) {
datatable.html('<div class="text-center">'+
'<br>'+
'<br>'+
'<div class="row flow_error_message" id="" hidden>'+
'<div class="small-6 columns small-centered text-center">'+
'<div class="label alert radius">'+Locale.tr("Cannot connect to OneFlow server")+'</div>'+
'</div>'+
'</div>'+
'<br>'+
'<br>'+
'<span>'+
'</span>'+
'</div>');
datatable.html("<div class=\"text-center\">"+
"<br>"+
"<br>"+
"<div class=\"row flow_error_message\" id=\"\" hidden>"+
"<div class=\"small-6 columns small-centered text-center\">"+
"<div class=\"label alert radius\">"+Locale.tr("Cannot connect to OneFlow server")+"</div>"+
"</div>"+
"</div>"+
"<br>"+
"<br>"+
"<span>"+
"</span>"+
"</div>");
Notifier.onError(request, error_json, $(".flow_error_message"));
}
})
});
}, timeout );
}
@ -127,9 +128,9 @@ define(function(require) {
// List Flows
//
provision_flows_datatable = $('.provision_flows_table', context).dataTable({
provision_flows_datatable = $(".provision_flows_table", context).dataTable({
"iDisplayLength": 6,
"sDom" : '<"H">t<"F"lp>',
"sDom" : "<\"H\">t<\"F\"lp>",
"aLengthMenu": [[6, 12, 36, 72], [6, 12, 36, 72]],
"aaSorting" : [[0, "desc"]],
"aoColumnDefs": [
@ -142,22 +143,22 @@ define(function(require) {
],
"fnPreDrawCallback": function (oSettings) {
// create a thumbs container if it doesn't exist. put it in the dataTables_scrollbody div
if (this.$('tr', {"filter": "applied"} ).length == 0) {
this.html('<div class="text-center">'+
'<span class="fa-stack fa-5x">'+
'<i class="fas fa-cloud fa-stack-2x"></i>'+
'<i class="fas fa-info-circle fa-stack-1x fa-inverse"></i>'+
'</span>'+
'<br>'+
'<br>'+
'<span>'+
if (this.$("tr", {"filter": "applied"} ).length == 0) {
this.html("<div class=\"text-center\">"+
"<span class=\"fa-stack fa-5x\">"+
"<i class=\"fas fa-cloud fa-stack-2x\"></i>"+
"<i class=\"fas fa-info-circle fa-stack-1x fa-inverse\"></i>"+
"</span>"+
"<br>"+
"<br>"+
"<span>"+
Locale.tr("There are no Services")+
'</span>'+
'<br>'+
'<br>'+
'</div>');
"</span>"+
"<br>"+
"<br>"+
"</div>");
} else {
$(".provision_flows_table", context).html('<div class="provision_flows_ul large-up-3 medium-up-3 small-up-1"></div>');
$(".provision_flows_table", context).html("<div class=\"provision_flows_ul large-up-3 medium-up-3 small-up-1\"></div>");
}
return true;
@ -175,47 +176,47 @@ define(function(require) {
var rvms = {
str : (role.nodes ? role.nodes.length : 0) + " / " + role.cardinality ,
percentage : Math.floor((role.nodes ? role.nodes.length : 0) / role.cardinality)*100
}
};
roles_li +=
'<li class="provision-bullet-item"">'+
'<i class="fas fa-fw fa-lg fa-cube"/> '+
"<li class=\"provision-bullet-item\"\">"+
"<i class=\"fas fa-fw fa-lg fa-cube\"/> "+
TemplateUtils.htmlEncode(role.name)+
'<span class="right">'+TemplateUtils.htmlEncode(rvms.str)+" VMs</span>"+
'</li>';
"<span class=\"right\">"+TemplateUtils.htmlEncode(rvms.str)+" VMs</span>"+
"</li>";
});
}
$(".provision_flows_ul", context).append('<div class="column">'+
'<ul class="provision-pricing-table menu vertical" opennebula_id="'+data.ID+'" datatable_index="'+iDisplayIndexFull+'">'+
'<li class="provision-title">'+
'<a class="provision_info_flow_button" href="#">'+
'<span class="'+ state.color +'-color right" title="'+ state.str +'">'+
'<i class="fas fa-square"/>'+
'</span>'+
$(".provision_flows_ul", context).append("<div class=\"column\">"+
"<ul class=\"provision-pricing-table menu vertical\" opennebula_id=\""+data.ID+"\" datatable_index=\""+iDisplayIndexFull+"\">"+
"<li class=\"provision-title\">"+
"<a class=\"provision_info_flow_button\" href=\"#\">"+
"<span class=\""+ state.color +"-color right\" title=\""+ state.str +"\">"+
"<i class=\"fas fa-square\"/>"+
"</span>"+
TemplateUtils.htmlEncode(data.NAME) +
'</a>'+
'</li>'+
"</a>"+
"</li>"+
roles_li +
'<li class="provision-bullet-item-last">'+
'<span>'+
'<i class="fas fa-fw fa-lg fa-user"/> '+
"<li class=\"provision-bullet-item-last\">"+
"<span>"+
"<i class=\"fas fa-fw fa-lg fa-user\"/> "+
TemplateUtils.htmlEncode(data.UNAME)+
'</span>'+
'<span class="right">'+
(start_time ? Humanize.prettyTimeAgo(start_time) : '-') +
'</span>'+
'</li>'+
'</ul>'+
'</div>');
"</span>"+
"<span class=\"right\">"+
(start_time ? Humanize.prettyTimeAgo(start_time) : "-") +
"</span>"+
"</li>"+
"</ul>"+
"</div>");
return nRow;
}
});
$('.provision_list_flows_search', context).on('input',function(){
$(".provision_list_flows_search", context).on("input",function(){
provision_flows_datatable.fnFilter( $(this).val() );
})
});
context.on("click", ".provision_flows_list_refresh_button", function(){
OpenNebula.Action.clear_cache("SERVICE");
@ -233,13 +234,13 @@ define(function(require) {
} else {
provision_flows_datatable.fnFilter("", 2);
}
})
});
ResourceSelect.insert({
context: $('.provision_list_flows_filter', context),
resourceName: 'User',
context: $(".provision_list_flows_filter", context),
resourceName: "User",
initValue: (opts.filter_expression ? opts.filter_expression : "-2"),
extraOptions: '<option value="-2">' + Locale.tr("ALL") + '</option>',
extraOptions: "<option value=\"-2\">" + Locale.tr("ALL") + "</option>",
triggerChange: true,
onlyName: true
});
@ -258,7 +259,7 @@ define(function(require) {
function setup_info_flow(context) {
function update_provision_flow_info(flow_id, context, role_id) {
$(".provision_info_flow_name", context).text("");
$(".provision_info_flow", context).css('visibility', 'hidden');
$(".provision_info_flow", context).css("visibility", "hidden");
$(".provision_info_flow_loading", context).fadeIn();
$(".provision_role_vms_container").html("");
@ -268,7 +269,7 @@ define(function(require) {
},
error: Notifier.onError,
success: function(request, response){
var data = response.DOCUMENT
var data = response.DOCUMENT;
var body = data.TEMPLATE.BODY;
var state = get_provision_flow_state(body);
var start_time = get_provision_flow_start_time(body);
@ -306,28 +307,28 @@ define(function(require) {
$(".provision_info_flow_name", context).text(data.NAME);
$(".provision-pricing-table_flow_info", context).html(
'<li class="provision-title">'+
'<span class="without-link '+ state.color +'-color">'+
'<span class="'+ state.color +'-color right">'+
'<i class="fas fa-square"/> '+
'</span>'+
"<li class=\"provision-title\">"+
"<span class=\"without-link "+ state.color +"-color\">"+
"<span class=\""+ state.color +"-color right\">"+
"<i class=\"fas fa-square\"/> "+
"</span>"+
state.str+
'</span>'+
'</li>'+
'<li class="provision-bullet-item-last text-right">'+
'<span class="left">'+
'<i class="fas fa-fw fa-lg fa-user"/> '+
"</span>"+
"</li>"+
"<li class=\"provision-bullet-item-last text-right\">"+
"<span class=\"left\">"+
"<i class=\"fas fa-fw fa-lg fa-user\"/> "+
TemplateUtils.htmlEncode(data.UNAME)+
'</span>'+
'<span>'+
'<i class="fas fa-fw fa-lg fa-clock-o"/> '+
"</span>"+
"<span>"+
"<i class=\"fas fa-fw fa-lg fa-clock-o\"/> "+
(start_time ? Humanize.prettyTimeAgo(start_time) : "...") +
' - '+
'ID: '+
" - "+
"ID: "+
data.ID+
'</span>'+
'</li>'+
'</ul>');
"</span>"+
"</li>"+
"</ul>");
$(".provision_roles_ul", context).html("");
if (body.roles) {
@ -336,39 +337,39 @@ define(function(require) {
var rvms = {
str : (role.nodes ? role.nodes.length : 0) + " / " + role.cardinality ,
percentage : Math.floor((role.nodes ? role.nodes.length : 0) / role.cardinality)*100
}
};
var li = $(
'<div class="column">'+
'<ul class="provision_role_ul provision-pricing-table menu vertical">'+
'<li class="provision-title">'+
'<span class="without-link">' +
'<i class="fas fa-fw fa-cube"/> '+
"<div class=\"column\">"+
"<ul class=\"provision_role_ul provision-pricing-table menu vertical\">"+
"<li class=\"provision-title\">"+
"<span class=\"without-link\">" +
"<i class=\"fas fa-fw fa-cube\"/> "+
TemplateUtils.htmlEncode(role.name)+
'</span>' +
'</li>'+
'<li class="provision-bullet-item">'+
'<meter id="' + TemplateUtils.htmlEncode(role.name) + '_meter" min="0" low="33" high="66" optimum="100" max="100" value="' + TemplateUtils.htmlEncode(rvms.percentage) + '"></meter>' +
'</li>'+
'<li class="provision-bullet-item text-right">'+
'<span class="'+ role_state.color +'-color left">'+
"</span>" +
"</li>"+
"<li class=\"provision-bullet-item\">"+
"<meter id=\"" + TemplateUtils.htmlEncode(role.name) + "_meter\" min=\"0\" low=\"33\" high=\"66\" optimum=\"100\" max=\"100\" value=\"" + TemplateUtils.htmlEncode(rvms.percentage) + "\"></meter>" +
"</li>"+
"<li class=\"provision-bullet-item text-right\">"+
"<span class=\""+ role_state.color +"-color left\">"+
role_state.str+
'</span>'+
'<span>'+TemplateUtils.htmlEncode(rvms.str)+" VMs</span>"+
'</li>'+
'<li class="provision-bullet-item">' +
'<hr>' +
'</li>' +
'<li class="provision-bullet-item-buttons">'+
'<button class="provision_role_vms_button button medium radius">'+
'<i class="fas fa-th fa-lg"></i>'+
'</button>'+
'<button class="provision_role_cardinality_button button medium success radius">'+
'<i class="fas fa-arrows-alt-h fa-lg"></i>'+
'</button>'+
'</li>'+
'</ul>'+
'</div>').appendTo($(".provision_roles_ul", context));
"</span>"+
"<span>"+TemplateUtils.htmlEncode(rvms.str)+" VMs</span>"+
"</li>"+
"<li class=\"provision-bullet-item\">" +
"<hr>" +
"</li>" +
"<li class=\"provision-bullet-item-buttons\">"+
"<button class=\"provision_role_vms_button button medium radius\">"+
"<i class=\"fas fa-th fa-lg\"></i>"+
"</button>"+
"<button class=\"provision_role_cardinality_button button medium success radius\">"+
"<i class=\"fas fa-arrows-alt-h fa-lg\"></i>"+
"</button>"+
"</li>"+
"</ul>"+
"</div>").appendTo($(".provision_roles_ul", context));
$(".provision_role_ul", li).data("role", role);
if (role_id && role_id == role.name) {
@ -380,72 +381,72 @@ define(function(require) {
$(".provision_confirm_action:first", context).html("");
$(".provision_info_flow_loading", context).hide();
$(".provision_info_flow", context).css('visibility', 'visible');
$(".provision_info_flow", context).css("visibility", "visible");
}
})
});
}
context.on("click", ".provision_role_vms_button", function(){
$(".provision_role_vms_container", context).html('<div class="text-center">'+
'<span class="fa-stack fa-5x">'+
'<i class="fas fa-cloud fa-stack-2x"></i>'+
'<i class="fa fa-spinner fa-spin fa-stack-1x fa-inverse"></i>'+
'</span>'+
'<br>'+
'<br>'+
'<span>'+
'</span>'+
'</div>');
$(".provision_role_vms_container", context).html("<div class=\"text-center\">"+
"<span class=\"fa-stack fa-5x\">"+
"<i class=\"fas fa-cloud fa-stack-2x\"></i>"+
"<i class=\"fa fa-spinner fa-spin fa-stack-1x fa-inverse\"></i>"+
"</span>"+
"<br>"+
"<br>"+
"<span>"+
"</span>"+
"</div>");
var role = $(this).closest(".provision_role_ul").data('role');
var role = $(this).closest(".provision_role_ul").data("role");
$(".provision_info_flow", context).data("role_id", role.name);
var vms = []
var vms = [];
if (role.nodes && role.nodes.length > 0) {
$.each(role.nodes, function(index, node){
if(node.vm_info != undefined){
vms.push(node.vm_info);
}
})
});
}
ProvisionVmsList.generate(
$(".provision_role_vms_container", context),
{
title: role.name + ' ' + Locale.tr("VMs"),
title: role.name + " " + Locale.tr("VMs"),
active: true,
refresh: false,
create: false,
filter: false,
data: vms
});
})
});
context.on("click", ".provision_role_cardinality_button", function(){
var role = $(this).closest(".provision_role_ul").data('role');
var role = $(this).closest(".provision_role_ul").data("role");
var min_vms = (role.min_vms||1);
var max_vms = (role.max_vms||100);
$(".provision_confirm_action:first", context).html(
'<div data-closable class="callout secondary large">'+
'<div class="row">'+
'<div class="large-12 large-centered columns">'+
'<div class="row">'+
'<div class="large-8 small-centered columns">'+
'<div class="cardinality_slider_div">'+
'</div>'+
'<br>'+
'<button href"#" class="provision_change_cardinality_button success button right" role_id="'+role.name+'">'+Locale.tr("Change Cardinality")+'</button>'+
'<div class="cardinality_no_slider_div">'+
'<span class="">'+Locale.tr("The cardinality for this role cannot be changed")+'</span>'+
'</div>'+
'</div>'+
'</div>'+
'</div>'+
'<button class="close-button" aria-label="' + Locale.tr("Dismiss Alert") + ' type="button" data-close>' +
'<span aria-hidden="true">&times;</span>' +
'</button>'+
'</div>');
"<div data-closable class=\"callout secondary large\">"+
"<div class=\"row\">"+
"<div class=\"large-12 large-centered columns\">"+
"<div class=\"row\">"+
"<div class=\"large-8 small-centered columns\">"+
"<div class=\"cardinality_slider_div\">"+
"</div>"+
"<br>"+
"<button href\"#\" class=\"provision_change_cardinality_button success button right\" role_id=\""+role.name+"\">"+Locale.tr("Change Cardinality")+"</button>"+
"<div class=\"cardinality_no_slider_div\">"+
"<span class=\"\">"+Locale.tr("The cardinality for this role cannot be changed")+"</span>"+
"</div>"+
"</div>"+
"</div>"+
"</div>"+
"<button class=\"close-button\" aria-label=\"" + Locale.tr("Dismiss Alert") + " type=\"button\" data-close>" +
"<span aria-hidden=\"true\">&times;</span>" +
"</button>"+
"</div>");
if (max_vms > min_vms) {
$( ".cardinality_slider_div", context).html(RangeSlider.html({
@ -469,11 +470,11 @@ define(function(require) {
context.on("click", ".provision_change_cardinality_button", function(){
var flow_id = $(".provision_info_flow", context).attr("flow_id");
var cardinality = $('.uinput-slider-val', context).val();
var cardinality = $(".uinput-slider-val", context).val();
OpenNebula.Role.update({
data : {
id: flow_id + '/role/' + $(this).attr("role_id"),
id: flow_id + "/role/" + $(this).attr("role_id"),
extra_param: {
cardinality: cardinality
}
@ -483,49 +484,49 @@ define(function(require) {
$(".provision_refresh_info", context).trigger("click");
},
error: Notifier.onError
})
});
});
context.on("click", ".provision_delete_confirm_button", function(){
$(".provision_confirm_action:first", context).html(
'<div data-closable class="callout secondary large">'+
'<div class="row">'+
'<div class="large-9 columns">'+
'<span>'+
"<div data-closable class=\"callout secondary large\">"+
"<div class=\"row\">"+
"<div class=\"large-9 columns\">"+
"<span>"+
Locale.tr("Be careful, this action will immediately destroy your Service")+
'<br>'+
"<br>"+
Locale.tr("All the information will be lost!")+
'</span>'+
'</div>'+
'<div class="large-3 columns">'+
'<button href"#" class="provision_delete_button alert button large-12 radius">'+Locale.tr("Delete")+'</button>'+
'</div>'+
'</div>'+
'<button class="close-button" aria-label="' + Locale.tr("Dismiss Alert") + ' type="button" data-close>' +
'<span aria-hidden="true">&times;</span>' +
'</button>'+
'</div>');
"</span>"+
"</div>"+
"<div class=\"large-3 columns\">"+
"<button href\"#\" class=\"provision_delete_button alert button large-12 radius\">"+Locale.tr("Delete")+"</button>"+
"</div>"+
"</div>"+
"<button class=\"close-button\" aria-label=\"" + Locale.tr("Dismiss Alert") + " type=\"button\" data-close>" +
"<span aria-hidden=\"true\">&times;</span>" +
"</button>"+
"</div>");
});
context.on("click", ".provision_shutdown_confirm_button", function(){
$(".provision_confirm_action:first", context).html(
'<div data-closable class="callout secondary large">'+
'<div class="row">'+
'<div class="large-9 columns">'+
'<span>'+
"<div data-closable class=\"callout secondary large\">"+
"<div class=\"row\">"+
"<div class=\"large-9 columns\">"+
"<span>"+
Locale.tr("Be careful, this action will immediately shutdown your Service")+
'<br>'+
"<br>"+
Locale.tr("All the information will be lost!")+
'</span>'+
'</div>'+
'<div class="large-3 columns">'+
'<button href"#" class="provision_shutdown_button alert button large-12 radius">'+Locale.tr("Shutdown")+'</button>'+
'</div>'+
'</div>'+
'<button class="close-button" aria-label="' + Locale.tr("Dismiss Alert") + ' type="button" data-close>' +
'<span aria-hidden="true">&times;</span>' +
'</button>'+
'</div>');
"</span>"+
"</div>"+
"<div class=\"large-3 columns\">"+
"<button href\"#\" class=\"provision_shutdown_button alert button large-12 radius\">"+Locale.tr("Shutdown")+"</button>"+
"</div>"+
"</div>"+
"<button class=\"close-button\" aria-label=\"" + Locale.tr("Dismiss Alert") + " type=\"button\" data-close>" +
"<span aria-hidden=\"true\">&times;</span>" +
"</button>"+
"</div>");
});
context.on("click", ".provision_recover_button", function(){
@ -539,7 +540,7 @@ define(function(require) {
update_provision_flow_info(flow_id, context);
},
error: Notifier.onError
})
});
});
context.on("click", ".provision_shutdown_button", function(){
@ -553,7 +554,7 @@ define(function(require) {
update_provision_flow_info(flow_id, context);
},
error: Notifier.onError
})
});
});
context.on("click", ".provision_delete_button", function(){
@ -574,7 +575,7 @@ define(function(require) {
Notifier.onError(request, response);
button.removeAttr("disabled");
}
})
});
});
context.on("click", ".provision_refresh_info", function(){
@ -592,15 +593,15 @@ define(function(require) {
$(".provision_list_flows", context).on("click", ".provision_info_flow_button", function(){
$("a.provision_show_flow_accordion", context).trigger("click");
var flow_id = $(this).parents(".provision-pricing-table").attr("opennebula_id")
var flow_id = $(this).parents(".provision-pricing-table").attr("opennebula_id");
update_provision_flow_info(flow_id, context);
return false;
})
});
}
function get_provision_flow_start_time(data) {
if (data.log) {
return data.log[0].timestamp
return data.log[0].timestamp;
} else {
return null;
}
@ -620,51 +621,51 @@ define(function(require) {
switch (parseInt(data.state)) {
case OpenNebula.Service.STATES.PENDING:
state_color = 'deploying';
state_color = "deploying";
state_str = Locale.tr("PENDING");
break;
case OpenNebula.Service.STATES.DEPLOYING:
state_color = 'deploying';
state_color = "deploying";
state_str = Locale.tr("DEPLOYING");
break;
case OpenNebula.Service.STATES.UNDEPLOYING:
state_color = 'powering_off';
state_color = "powering_off";
state_str = Locale.tr("UNDEPLOYING");
break;
case OpenNebula.Service.STATES.FAILED_UNDEPLOYING:
state_color = 'error';
state_color = "error";
state_str = Locale.tr("FAILED UNDEPLOYING");
break;
case OpenNebula.Service.STATES.FAILED_DEPLOYING:
state_color = 'error';
state_color = "error";
state_str = Locale.tr("FAILED DEPLOYING");
break;
case OpenNebula.Service.STATES.FAILED_SCALING:
state_color = 'error';
state_color = "error";
state_str = Locale.tr("FAILED SCALING");
break;
case OpenNebula.Service.STATES.WARNING:
state_color = 'error';
state_color = "error";
state_str = Locale.tr("WARNING");
break;
case OpenNebula.Service.STATES.RUNNING:
state_color = 'running';
state_color = "running";
state_str = Locale.tr("RUNNING");
break;
case OpenNebula.Service.STATES.SCALING:
state_color = 'deploying';
state_color = "deploying";
state_str = Locale.tr("SCALING");
break;
case OpenNebula.Service.STATES.COOLDOWN:
state_color = 'running';
state_color = "running";
state_str = Locale.tr("COOLDOWN");
break;
case OpenNebula.Service.STATES.DONE:
state_color = 'off';
state_color = "off";
state_str = Locale.tr("DONE");
break;
default:
state_color = 'powering_off';
state_color = "powering_off";
state_str = Locale.tr("UNKNOWN");
break;
}
@ -672,6 +673,6 @@ define(function(require) {
return {
color: state_color,
str: state_str
}
};
}
});

View File

@ -16,24 +16,24 @@
define(function(require) {
// require('foundation.alert');
var OpenNebula = require('opennebula');
var Locale = require('utils/locale');
var Config = require('sunstone-config');
var Notifier = require('utils/notifier');
var Humanize = require('utils/humanize');
var ResourceSelect = require('utils/resource-select');
var LabelsUtils = require('utils/labels/utils');
var TemplateUtils = require('utils/template-utils');
var OpenNebula = require("opennebula");
var Locale = require("utils/locale");
var Config = require("sunstone-config");
var Notifier = require("utils/notifier");
var Humanize = require("utils/humanize");
var ResourceSelect = require("utils/resource-select");
var LabelsUtils = require("utils/labels/utils");
var TemplateUtils = require("utils/template-utils");
var TemplateTemplatesList = require('hbs!./list');
var TemplateTemplatesList = require("hbs!./list");
var _accordionId = 0;
var TEMPLATE_LABELS_COLUMN = 3;
return {
'generate': generate_provision_templates_list,
'show': show_provision_template_list,
'updateDatatable': update_provision_templates_datatable,
"generate": generate_provision_templates_list,
"show": show_provision_template_list,
"updateDatatable": update_provision_templates_datatable,
};
function show_provision_template_list(timeout) {
@ -46,7 +46,7 @@ define(function(require) {
function generate_provision_templates_list(context, opts) {
context.off();
context.html(html(opts));
Foundation.reflow(context, 'accordion');
Foundation.reflow(context, "accordion");
setup_provision_templates_list(context, opts);
}
@ -57,23 +57,23 @@ define(function(require) {
create: true,
active: true,
filter: true
},opts_arg)
},opts_arg);
_accordionId += 1;
return TemplateTemplatesList({'accordionId': _accordionId, 'opts': opts});
return TemplateTemplatesList({"accordionId": _accordionId, "opts": opts});
}
function update_provision_templates_datatable(datatable, timeout) {
datatable.html('<div class="text-center">'+
'<span class="fa-stack fa-5x">'+
'<i class="fas fa-cloud fa-stack-2x"></i>'+
'<i class="fa fa-spinner fa-spin fa-stack-1x fa-inverse"></i>'+
'</span>'+
'<br>'+
'<br>'+
'<span>'+
'</span>'+
'</div>');
datatable.html("<div class=\"text-center\">"+
"<span class=\"fa-stack fa-5x\">"+
"<i class=\"fas fa-cloud fa-stack-2x\"></i>"+
"<i class=\"fa fa-spinner fa-spin fa-stack-1x fa-inverse\"></i>"+
"</span>"+
"<br>"+
"<br>"+
"<span>"+
"</span>"+
"</div>");
setTimeout( function(){
OpenNebula.Template.list({
@ -87,31 +87,31 @@ define(function(require) {
});
if (item_list.length == 0) {
datatable.html('<div class="text-center">'+
'<span class="fa-stack fa-5x">'+
'<i class="fas fa-cloud fa-stack-2x"></i>'+
'<i class="fas fa-info-circle fa-stack-1x fa-inverse"></i>'+
'</span>'+
'<br>'+
'<br>'+
'<span>'+
datatable.html("<div class=\"text-center\">"+
"<span class=\"fa-stack fa-5x\">"+
"<i class=\"fas fa-cloud fa-stack-2x\"></i>"+
"<i class=\"fas fa-info-circle fa-stack-1x fa-inverse\"></i>"+
"</span>"+
"<br>"+
"<br>"+
"<span>"+
Locale.tr("There are no templates available")+
'</span>'+
'</div>');
"</span>"+
"</div>");
} else {
datatable.fnAddData(item_list);
}
// Labels are inserted only in the new VM wizard
LabelsUtils.clearLabelsFilter(datatable, TEMPLATE_LABELS_COLUMN);
var context = $('.labels-dropdown', datatable.closest('#provisionVMInstantiateTemplatesRow'));
var context = $(".labels-dropdown", datatable.closest("#provisionVMInstantiateTemplatesRow"));
context.html("");
LabelsUtils.insertLabelsMenu({
'context': context,
'dataTable': datatable,
'labelsColumn': TEMPLATE_LABELS_COLUMN,
'labelsPath': 'VMTEMPLATE.TEMPLATE.LABELS',
'placeholder': Locale.tr("No labels defined")
"context": context,
"dataTable": datatable,
"labelsColumn": TEMPLATE_LABELS_COLUMN,
"labelsPath": "VMTEMPLATE.TEMPLATE.LABELS",
"placeholder": Locale.tr("No labels defined")
});
},
error: Notifier.onError
@ -120,9 +120,9 @@ define(function(require) {
}
function setup_provision_templates_list(context, opts) {
var provision_templates_datatable = $('.provision_templates_table', context).dataTable({
var provision_templates_datatable = $(".provision_templates_table", context).dataTable({
"iDisplayLength": 8,
"sDom" : '<"H">t<"F"lp>',
"sDom" : "<\"H\">t<\"F\"lp>",
"aLengthMenu": [[6, 12, 36, 72], [6, 12, 36, 72]],
"aaSorting" : [[0, "desc"]],
"aoColumnDefs": [
@ -135,22 +135,22 @@ define(function(require) {
],
"fnPreDrawCallback": function (oSettings) {
// create a thumbs container if it doesn't exist. put it in the dataTables_scrollbody div
if (this.$('tr', {"filter": "applied"} ).length == 0) {
this.html('<div class="text-center">'+
'<span class="fa-stack fa-5x">'+
'<i class="fas fa-cloud fa-stack-2x"></i>'+
'<i class="fas fa-info-circle fa-stack-1x fa-inverse"></i>'+
'</span>'+
'<br>'+
'<br>'+
'<span>'+
if (this.$("tr", {"filter": "applied"} ).length == 0) {
this.html("<div class=\"text-center\">"+
"<span class=\"fa-stack fa-5x\">"+
"<i class=\"fas fa-cloud fa-stack-2x\"></i>"+
"<i class=\"fas fa-info-circle fa-stack-1x fa-inverse\"></i>"+
"</span>"+
"<br>"+
"<br>"+
"<span>"+
Locale.tr("There are no templates available")+
'<br>'+
"<br>"+
Locale.tr("Create a template by saving a running Virtual Machine")+
'</span>'+
'</div>');
"</span>"+
"</div>");
} else {
$(".provision_templates_table", context).html('<div class="provision_templates_ul large-up-3 medium-up-3 small-up-1"></div>');
$(".provision_templates_table", context).html("<div class=\"provision_templates_ul large-up-3 medium-up-3 small-up-1\"></div>");
}
return true;
},
@ -158,74 +158,74 @@ define(function(require) {
var data = aData.VMTEMPLATE;
var actions_html = "";
if (Config.isTabActionEnabled("provision-tab", "Template.chmod")) {
if (data.UID == config['user_id']) {
if (data.UID == config["user_id"]) {
if (data.PERMISSIONS.GROUP_U == "1") {
actions_html += '<a class="provision_confirm_unshare_template_button left" title="'+ Locale.tr("Unshare")+'" href="#"><i class="fas fa-fw fa-lg fa-ban only-on-hover"/></a>';
actions_html += '<span>' + Locale.tr("SHARED") + '</span>';
actions_html += "<a class=\"provision_confirm_unshare_template_button left\" title=\""+ Locale.tr("Unshare")+"\" href=\"#\"><i class=\"fas fa-fw fa-lg fa-ban only-on-hover\"/></a>";
actions_html += "<span>" + Locale.tr("SHARED") + "</span>";
} else {
actions_html += '<a class="provision_confirm_chmod_template_button left" title="'+ Locale.tr("Share")+'" href="#"><i class="fas fa-fw fa-lg fa-share-alt only-on-hover"/></a>';
actions_html += "<a class=\"provision_confirm_chmod_template_button left\" title=\""+ Locale.tr("Share")+"\" href=\"#\"><i class=\"fas fa-fw fa-lg fa-share-alt only-on-hover\"/></a>";
}
}
}
if (Config.isTabActionEnabled("provision-tab", "Template.delete") && data["PERMISSIONS"]["OWNER_M"] === "1") {
actions_html += '<a class="provision_confirm_delete_template_button" title="'+ Locale.tr("Delete")+'" href="#"><i class="fas fa-fw fa-lg fa-trash-alt only-on-hover"/></a>';
actions_html += "<a class=\"provision_confirm_delete_template_button\" title=\""+ Locale.tr("Delete")+"\" href=\"#\"><i class=\"fas fa-fw fa-lg fa-trash-alt only-on-hover\"/></a>";
}
var cpu_txt = "";
var mem_txt = "";
if(data.TEMPLATE.CPU){
cpu_txt = 'x'+TemplateUtils.htmlEncode(data.TEMPLATE.CPU);
cpu_txt = "x"+TemplateUtils.htmlEncode(data.TEMPLATE.CPU);
}
if(data.TEMPLATE.MEMORY){
if (data.TEMPLATE.MEMORY > 1000){
mem_txt = Math.floor(data.TEMPLATE.MEMORY/1024)+'GB';
mem_txt = Math.floor(data.TEMPLATE.MEMORY/1024)+"GB";
} else {
mem_txt = TemplateUtils.htmlEncode(data.TEMPLATE.MEMORY)+'MB';
mem_txt = TemplateUtils.htmlEncode(data.TEMPLATE.MEMORY)+"MB";
}
}
$(".provision_templates_ul", context).append('<div class="column">'+
'<ul class="provision-pricing-table menu vertical" opennebula_id="'+data.ID+'" datatable_index="'+iDisplayIndexFull+'">'+
'<li class="provision-title" title="'+data.NAME+'">'+
'<span class="without-link">' +
$(".provision_templates_ul", context).append("<div class=\"column\">"+
"<ul class=\"provision-pricing-table menu vertical\" opennebula_id=\""+data.ID+"\" datatable_index=\""+iDisplayIndexFull+"\">"+
"<li class=\"provision-title\" title=\""+data.NAME+"\">"+
"<span class=\"without-link\">" +
TemplateUtils.htmlEncode(data.NAME) +
'</span>' +
'</li>'+
'<li class="provision-bullet-item">'+
(TemplateUtils.htmlEncode(data.TEMPLATE.DESCRIPTION) || '')+
'</li>'+
'<li class="provision-bullet-item" >'+
'<i class="fas fa-fw fa-lg fa-laptop"/> '+
cpu_txt+' - '+
mem_txt+' - '+
"</span>" +
"</li>"+
"<li class=\"provision-bullet-item\">"+
(TemplateUtils.htmlEncode(data.TEMPLATE.DESCRIPTION) || "")+
"</li>"+
"<li class=\"provision-bullet-item\" >"+
"<i class=\"fas fa-fw fa-lg fa-laptop\"/> "+
cpu_txt+" - "+
mem_txt+" - "+
get_provision_disk_image(data) +
'</li>'+
'<li class="provision-bullet-item text-right">'+
"</li>"+
"<li class=\"provision-bullet-item text-right\">"+
actions_html+
'</li>'+
'<li class="provision-bullet-item-last" >'+
'<span class="">'+
'<i class="fas fa-fw fa-lg fa-user"/> '+
"</li>"+
"<li class=\"provision-bullet-item-last\" >"+
"<span class=\"\">"+
"<i class=\"fas fa-fw fa-lg fa-user\"/> "+
TemplateUtils.htmlEncode(data.UNAME)+
'</span>'+
'<span class="right">'+
"</span>"+
"<span class=\"right\">"+
Humanize.prettyTimeAgo(data.REGTIME)+
'</span>'+
'</li>'+
'</ul>'+
'</div>');
"</span>"+
"</li>"+
"</ul>"+
"</div>");
return nRow;
}
});
$('.provision_list_templates_search', context).on('input',function(){
$(".provision_list_templates_search", context).on("input",function(){
provision_templates_datatable.fnFilter( $(this).val() );
})
});
context.on("click", ".provision_templates_list_refresh_button", function(){
OpenNebula.Action.clear_cache("VMTEMPLATE");
@ -244,13 +244,13 @@ define(function(require) {
} else {
provision_templates_datatable.fnFilter("", 2);
}
})
});
ResourceSelect.insert({
context: $('.provision_list_templates_filter', context),
resourceName: 'User',
context: $(".provision_list_templates_filter", context),
resourceName: "User",
initValue: (opts.filter_expression ? opts.filter_expression : "-2"),
extraOptions: '<option value="-2">' + Locale.tr("ALL") + '</option>',
extraOptions: "<option value=\"-2\">" + Locale.tr("ALL") + "</option>",
triggerChange: true,
onlyName: true
});
@ -267,23 +267,23 @@ define(function(require) {
var template_name = $(".provision-title", ul_context).text();
$(".provision_confirm_delete_template_div", context).html(
'<div data-closable class="callout large secondary">'+
'<div class="row">'+
'<div class="large-12 columns">'+
'<p>'+
"<div data-closable class=\"callout large secondary\">"+
"<div class=\"row\">"+
"<div class=\"large-12 columns\">"+
"<p>"+
Locale.tr("Handle with care! This action will immediately destroy the template")+
' "' + template_name + '" ' +
" \"" + template_name + "\" " +
Locale.tr("and the image associated.") +
'</p>'+
'</div>'+
'<div class="large-12 columns">'+
'<button href"#" class="provision_delete_template_button alert button right" template_id="'+template_id+'">'+Locale.tr("Delete")+'</button>'+
'</div>'+
'</div>'+
'<button class="close-button" aria-label="Dismiss alert" type="button" data-close>' +
'<span aria-hidden="true">&times;</span>' +
'</button>' +
'</div>');
"</p>"+
"</div>"+
"<div class=\"large-12 columns\">"+
"<button href\"#\" class=\"provision_delete_template_button alert button right\" template_id=\""+template_id+"\">"+Locale.tr("Delete")+"</button>"+
"</div>"+
"</div>"+
"<button class=\"close-button\" aria-label=\"Dismiss alert\" type=\"button\" data-close>" +
"<span aria-hidden=\"true\">&times;</span>" +
"</button>" +
"</div>");
});
context.on("click", ".provision_delete_template_button", function(){
@ -305,7 +305,7 @@ define(function(require) {
Notifier.onError(request, error_json, container);
$(".provision_templates_list_refresh_button", context).trigger("click");
}
})
});
});
}
@ -317,23 +317,23 @@ define(function(require) {
var template_name = $(".provision-title", ul_context).text();
$(".provision_confirm_delete_template_div", context).html(
'<div data-closable class="callout large secondary">'+
'<div class="row">'+
'<div class="large-12 columns">'+
'<p>'+
"<div data-closable class=\"callout large secondary\">"+
"<div class=\"row\">"+
"<div class=\"large-12 columns\">"+
"<p>"+
Locale.tr("The template")+
' "' + template_name + '" ' +
" \"" + template_name + "\" " +
Locale.tr("and the image associated will be shared and all the users will be able to instantiate new VMs using this template.") +
'</p>'+
'</div>'+
'<div class="large-12 columns">'+
'<button href"#" class="provision_chmod_template_button success button right" template_id="'+template_id+'">'+Locale.tr("Share template")+'</button>'+
'</div>'+
'</div>'+
'<button class="close-button" aria-label="Dismiss alert" type="button" data-close>' +
'<span aria-hidden="true">&times;</span>' +
'</button>' +
'</div>');
"</p>"+
"</div>"+
"<div class=\"large-12 columns\">"+
"<button href\"#\" class=\"provision_chmod_template_button success button right\" template_id=\""+template_id+"\">"+Locale.tr("Share template")+"</button>"+
"</div>"+
"</div>"+
"<button class=\"close-button\" aria-label=\"Dismiss alert\" type=\"button\" data-close>" +
"<span aria-hidden=\"true\">&times;</span>" +
"</button>" +
"</div>");
});
context.on("click", ".provision_chmod_template_button", function(){
@ -348,15 +348,15 @@ define(function(require) {
data : {
id : template_id,
extra_param: {
'group_u': 1,
'recursive' : true
"group_u": 1,
"recursive" : true
}
},
success: function (){
$(".provision_templates_list_refresh_button", context).trigger("click");
},
error: Notifier.onError
})
});
});
context.on("click", ".provision_confirm_unshare_template_button", function(){
@ -365,23 +365,23 @@ define(function(require) {
var template_name = $(".provision-title", ul_context).first().text();
$(".provision_confirm_delete_template_div", context).html(
'<div data-closable class="callout large secondary">'+
'<div class="row">'+
'<div class="large-12 columns">'+
'<p>'+
"<div data-closable class=\"callout large secondary\">"+
"<div class=\"row\">"+
"<div class=\"large-12 columns\">"+
"<p>"+
Locale.tr("The template")+
' "' + template_name + '" ' +
" \"" + template_name + "\" " +
Locale.tr("and the image associated will be unshared and the users will not be able to instantiate new VMs using this template.") +
'</p>'+
'</div>'+
'<div class="large-12 columns">'+
'<button href"#" class="provision_unshare_template_button success button right" template_id="'+template_id+'">'+Locale.tr("Unshare template")+'</button>'+
'</div>'+
'</div>'+
'<button class="close-button" aria-label="Dismiss alert" type="button" data-close>' +
'<span aria-hidden="true">&times;</span>' +
'</button>' +
'</div>');
"</p>"+
"</div>"+
"<div class=\"large-12 columns\">"+
"<button href\"#\" class=\"provision_unshare_template_button success button right\" template_id=\""+template_id+"\">"+Locale.tr("Unshare template")+"</button>"+
"</div>"+
"</div>"+
"<button class=\"close-button\" aria-label=\"Dismiss alert\" type=\"button\" data-close>" +
"<span aria-hidden=\"true\">&times;</span>" +
"</button>" +
"</div>");
});
context.on("click", ".provision_unshare_template_button", function(){
@ -395,15 +395,15 @@ define(function(require) {
data : {
id : template_id,
extra_param: {
'group_u': 0,
'recursive' : true
"group_u": 0,
"recursive" : true
}
},
success: function (){
$(".provision_templates_list_refresh_button", context).trigger("click");
},
error: Notifier.onError
})
});
});
}
@ -413,16 +413,16 @@ define(function(require) {
}
function get_provision_disk_image(data) {
var disks = []
var disks = [];
if ($.isArray(data.TEMPLATE.DISK))
disks = data.TEMPLATE.DISK
disks = data.TEMPLATE.DISK;
else if (!$.isEmptyObject(data.TEMPLATE.DISK))
disks = [data.TEMPLATE.DISK]
disks = [data.TEMPLATE.DISK];
if (disks.length > 0 && disks[0].IMAGE) {
return disks[0].IMAGE;
} else {
return '';
return "";
}
}
});

View File

@ -16,37 +16,37 @@
define(function(require) {
// require('foundation.alert');
var Sunstone = require('sunstone');
var OpenNebula = require('opennebula');
var OpenNebulaVM = require('opennebula/vm');
var Locale = require('utils/locale');
var Config = require('sunstone-config');
var Notifier = require('utils/notifier');
var Humanize = require('utils/humanize');
var ResourceSelect = require('utils/resource-select');
var Graphs = require('utils/graphs');
var TemplateUtils = require('utils/template-utils');
var StateActions = require('tabs/vms-tab/utils/state-actions');
var Vnc = require('utils/vnc');
var Spice = require('utils/spice');
var Sunstone = require("sunstone");
var OpenNebula = require("opennebula");
var OpenNebulaVM = require("opennebula/vm");
var Locale = require("utils/locale");
var Config = require("sunstone-config");
var Notifier = require("utils/notifier");
var Humanize = require("utils/humanize");
var ResourceSelect = require("utils/resource-select");
var Graphs = require("utils/graphs");
var TemplateUtils = require("utils/template-utils");
var StateActions = require("tabs/vms-tab/utils/state-actions");
var Vnc = require("utils/vnc");
var Spice = require("utils/spice");
var TemplateVmsList = require('hbs!./list');
var TemplateConfirmSaveAsTemplate = require('hbs!./confirm_save_as_template');
var TemplateConfirmTerminate = require('hbs!./confirm_terminate');
var TemplateConfirmPoweroff = require('hbs!./confirm_poweroff');
var TemplateConfirmUndeploy = require('hbs!./confirm_undeploy');
var TemplateConfirmReboot = require('hbs!./confirm_reboot');
var TemplateVmsList = require("hbs!./list");
var TemplateConfirmSaveAsTemplate = require("hbs!./confirm_save_as_template");
var TemplateConfirmTerminate = require("hbs!./confirm_terminate");
var TemplateConfirmPoweroff = require("hbs!./confirm_poweroff");
var TemplateConfirmUndeploy = require("hbs!./confirm_undeploy");
var TemplateConfirmReboot = require("hbs!./confirm_reboot");
var TAB_ID = require('../tabId');
var TAB_ID = require("../tabId");
var _accordionId = 0;
var VNC_DIALOG_ID = require('tabs/vms-tab/dialogs/vnc/dialogId');
var SPICE_DIALOG_ID = require('tabs/vms-tab/dialogs/spice/dialogId');
var VNC_DIALOG_ID = require("tabs/vms-tab/dialogs/vnc/dialogId");
var SPICE_DIALOG_ID = require("tabs/vms-tab/dialogs/spice/dialogId");
return {
'generate': generate_provision_vms_list,
'show': show_provision_vm_list,
'state': get_provision_vm_state
"generate": generate_provision_vms_list,
"show": show_provision_vm_list,
"state": get_provision_vm_state
};
function show_provision_vm_list(timeout, context) {
@ -61,10 +61,10 @@ define(function(require) {
context.off();
context.html(html(opts));
Foundation.reflow(context, 'accordion');
Foundation.reflow(context, "accordion");
if (opts.data) {
$(".provision_vms_table", context).data("opennebula", opts.data)
$(".provision_vms_table", context).data("opennebula", opts.data);
}
setup_provision_vms_list(context, opts);
@ -77,66 +77,67 @@ define(function(require) {
refresh: true,
create: true,
filter: true
}, opts_arg)
}, opts_arg);
_accordionId += 1;
return TemplateVmsList({'accordionId': _accordionId, 'opts': opts});
return TemplateVmsList({"accordionId": _accordionId, "opts": opts});
}
function fill_provision_vms_datatable(datatable, item_list) {
datatable.fnClearTable(true);
if (item_list.length == 0) {
datatable.html('<div class="text-center">' +
'<span class="fa-stack fa-5x">' +
'<i class="fas fa-cloud fa-stack-2x"></i>' +
'<i class="fas fa-info-circle fa-stack-1x fa-inverse"></i>' +
'</span>' +
'<br>' +
'<br>' +
'<span>' +
datatable.html("<div class=\"text-center\">" +
"<span class=\"fa-stack fa-5x\">" +
"<i class=\"fas fa-cloud fa-stack-2x\"></i>" +
"<i class=\"fas fa-info-circle fa-stack-1x fa-inverse\"></i>" +
"</span>" +
"<br>" +
"<br>" +
"<span>" +
Locale.tr("There are no Virtual Machines") +
'</span>' +
'<br>' +
'<br>' +
'</div>');
"</span>" +
"<br>" +
"<br>" +
"</div>");
} else {
datatable.fnAddData(item_list);
}
}
function update_provision_vms_datatable(datatable, timeout) {
datatable.html('<div class="text-center">' +
'<span class="fa-stack fa-5x">' +
'<i class="fas fa-cloud fa-stack-2x"></i>' +
'<i class="fa fa-spinner fa-spin fa-stack-1x fa-inverse"></i>' +
'</span>' +
'<br>' +
'<br>' +
'<span>' +
'</span>' +
'</div>');
datatable.html("<div class=\"text-center\">" +
"<span class=\"fa-stack fa-5x\">" +
"<i class=\"fas fa-cloud fa-stack-2x\"></i>" +
"<i class=\"fa fa-spinner fa-spin fa-stack-1x fa-inverse\"></i>" +
"</span>" +
"<br>" +
"<br>" +
"<span>" +
"</span>" +
"</div>");
var data = datatable.data('opennebula');
var data = datatable.data("opennebula");
if (data) {
fill_provision_vms_datatable(datatable, data)
fill_provision_vms_datatable(datatable, data);
} else {
setTimeout(function() {
console.log("i");
OpenNebula.VM.list({
timeout: true,
success: function (request, item_list) {
fill_provision_vms_datatable(datatable, item_list)
fill_provision_vms_datatable(datatable, item_list);
},
error: Notifier.onError
})
});
}, timeout);
}
}
function setup_provision_vms_list(context, opts) {
var provision_vms_datatable = $('.provision_vms_table', context).dataTable({
var provision_vms_datatable = $(".provision_vms_table", context).dataTable({
"iDisplayLength": 6,
"bAutoWidth": false,
"sDom" : '<"H">t<"F"lp>',
"sDom" : "<\"H\">t<\"F\"lp>",
"aLengthMenu": [[6, 12, 36, 72], [6, 12, 36, 72]],
"aaSorting" : [[0, "desc"]],
"aoColumnDefs": [
@ -150,20 +151,20 @@ define(function(require) {
],
"fnPreDrawCallback": function (oSettings) {
// create a thumbs container if it doesn't exist. put it in the dataTables_scrollbody div
if (this.$('tr', {"filter": "applied"} ).length == 0) {
this.html('<div class="text-center">'+
'<span class="fa-stack fa-5x">'+
'<i class="fas fa-cloud fa-stack-2x"></i>'+
'<i class="fas fa-info-circle fa-stack-1x fa-inverse"></i>'+
'</span>'+
'<br>'+
'<br>'+
'<span>'+
if (this.$("tr", {"filter": "applied"} ).length == 0) {
this.html("<div class=\"text-center\">"+
"<span class=\"fa-stack fa-5x\">"+
"<i class=\"fas fa-cloud fa-stack-2x\"></i>"+
"<i class=\"fas fa-info-circle fa-stack-1x fa-inverse\"></i>"+
"</span>"+
"<br>"+
"<br>"+
"<span>"+
Locale.tr("There are no Virtual Machines")+
'</span>'+
'</div>');
"</span>"+
"</div>");
} else {
$(".provision_vms_table", context).html('<div class="provision_vms_ul large-up-3 medium-up-3 small-up-1"></div>');
$(".provision_vms_table", context).html("<div class=\"provision_vms_ul large-up-3 medium-up-3 small-up-1\"></div>");
}
return true;
@ -179,51 +180,51 @@ define(function(require) {
var monitoring = "";
if(data.MONITORING.GUEST_IP){
monitoring = '<li class="provision-bullet-item"><span class=""><i class="fas fa-fw fa-lg fa-server"/>' + data.MONITORING.GUEST_IP + '</span></li>';
monitoring = "<li class=\"provision-bullet-item\"><span class=\"\"><i class=\"fas fa-fw fa-lg fa-server\"/>" + data.MONITORING.GUEST_IP + "</span></li>";
}
$(".provision_vms_ul", context).append('<div class="column">'+
'<ul class="provision-pricing-table menu vertical" opennebula_id="'+data.ID+'" datatable_index="'+iDisplayIndexFull+'">'+
'<li class="provision-title">'+
'<a class="provision_info_vm_button">'+
'<span class="'+ state.color +'-color right" title="'+state.str+'">'+
'<i class="fas fa-square"/>'+
'</span>'+
data.NAME + '</a>'+
'</li>'+
'<li class="provision-bullet-item" >'+
'<i class="fas fa-fw fa-lg fa-laptop"/> '+
'x'+data.TEMPLATE.CPU+' - '+
$(".provision_vms_ul", context).append("<div class=\"column\">"+
"<ul class=\"provision-pricing-table menu vertical\" opennebula_id=\""+data.ID+"\" datatable_index=\""+iDisplayIndexFull+"\">"+
"<li class=\"provision-title\">"+
"<a class=\"provision_info_vm_button\">"+
"<span class=\""+ state.color +"-color right\" title=\""+state.str+"\">"+
"<i class=\"fas fa-square\"/>"+
"</span>"+
data.NAME + "</a>"+
"</li>"+
"<li class=\"provision-bullet-item\" >"+
"<i class=\"fas fa-fw fa-lg fa-laptop\"/> "+
"x"+data.TEMPLATE.CPU+" - "+
((data.TEMPLATE.MEMORY > 1000) ?
(Math.floor(data.TEMPLATE.MEMORY/1024)+'GB') :
(TemplateUtils.htmlEncode(data.TEMPLATE.MEMORY)+'MB'))+
' - '+
(Math.floor(data.TEMPLATE.MEMORY/1024)+"GB") :
(TemplateUtils.htmlEncode(data.TEMPLATE.MEMORY)+"MB"))+
" - "+
get_provision_disk_image(data) +
'</li>'+
'<li class="provision-bullet-item" >'+
'<span class="">'+
"</li>"+
"<li class=\"provision-bullet-item\" >"+
"<span class=\"\">"+
get_provision_ips(data) +
'</span>'+
'</li>'+ monitoring +
'<li class="provision-bullet-item-last" >'+
'<span class="">'+
'<i class="fas fa-fw fa-lg fa-user"/> '+
"</span>"+
"</li>"+ monitoring +
"<li class=\"provision-bullet-item-last\" >"+
"<span class=\"\">"+
"<i class=\"fas fa-fw fa-lg fa-user\"/> "+
data.UNAME+
'</span>'+
'<span class="right">'+
"</span>"+
"<span class=\"right\">"+
Humanize.prettyTimeAgo(data.STIME)+
'</span>'+
'</li>'+
'</ul>'+
'</div>');
"</span>"+
"</li>"+
"</ul>"+
"</div>");
return nRow;
}
});
$('.provision_list_vms_search', context).on('input',function(){
$(".provision_list_vms_search", context).on("input",function(){
provision_vms_datatable.fnFilter( $(this).val() );
})
});
context.on("click", ".provision_vms_list_refresh_button", function(){
OpenNebula.Action.clear_cache("VM");
@ -237,13 +238,13 @@ define(function(require) {
} else {
provision_vms_datatable.fnFilter("", 2);
}
})
});
ResourceSelect.insert({
context: $('.provision_list_vms_filter', context),
resourceName: 'User',
context: $(".provision_list_vms_filter", context),
resourceName: "User",
initValue: (opts.filter_expression ? opts.filter_expression : "-2"),
extraOptions: '<option value="-2">' + Locale.tr("ALL") + '</option>',
extraOptions: "<option value=\"-2\">" + Locale.tr("ALL") + "</option>",
triggerChange: true,
onlyName: true
});
@ -264,7 +265,7 @@ define(function(require) {
//var tempScrollTop = $(window).scrollTop();
$(".provision_info_vm_name", context).text("");
$(".provision_info_vm_loading", context).show();
$(".provision_info_vm", context).css('visibility', 'hidden');
$(".provision_info_vm", context).css("visibility", "hidden");
OpenNebula.VM.show({
data : {
@ -274,7 +275,7 @@ define(function(require) {
success: function(request, response){
Sunstone.insertPanels(TAB_ID, response, TAB_ID, $(".provision-sunstone-info", context));
var data = response.VM
var data = response.VM;
var state = get_provision_vm_state(data);
// helper, cleaner code
@ -341,11 +342,11 @@ define(function(require) {
$(".provision_info_vm_name", context).text(data.NAME);
if (Config.isTabActionEnabled("provision-tab", 'VM.rename')) {
if (Config.isTabActionEnabled("provision-tab", "VM.rename")) {
context.off("click", ".provision_info_vm_rename a");
context.on("click", ".provision_info_vm_rename a", function() {
var valueStr = $(".provision_info_vm_name", context).text();
$(".provision_info_vm_name", context).html('<input class="input_edit_value_rename" type="text" value="' + valueStr + '"/>');
$(".provision_info_vm_name", context).html("<input class=\"input_edit_value_rename\" type=\"text\" value=\"" + valueStr + "\"/>");
});
context.off("change", ".input_edit_value_rename");
@ -371,45 +372,45 @@ define(function(require) {
}
$(".provision-pricing-table_vm_info", context).html(
'<li class="provision-title">'+
'<span class="without-link '+ state.color +'-color">'+
'<span class="'+ state.color +'-color right" title="'+state.str+'">'+
'<i class="fas fa-square"/>'+
'</span>'+
"<li class=\"provision-title\">"+
"<span class=\"without-link "+ state.color +"-color\">"+
"<span class=\""+ state.color +"-color right\" title=\""+state.str+"\">"+
"<i class=\"fas fa-square\"/>"+
"</span>"+
state.str+
'</span>'+
'</li>'+
'<li class="provision-bullet-item" >'+
'<span>'+
'<i class="fas fa-fw fa-lg fa-laptop"/> '+
'x'+TemplateUtils.htmlEncode(data.TEMPLATE.CPU)+' - '+
"</span>"+
"</li>"+
"<li class=\"provision-bullet-item\" >"+
"<span>"+
"<i class=\"fas fa-fw fa-lg fa-laptop\"/> "+
"x"+TemplateUtils.htmlEncode(data.TEMPLATE.CPU)+" - "+
((data.TEMPLATE.MEMORY > 1000) ?
(Math.floor(data.TEMPLATE.MEMORY/1024)+'GB') :
(TemplateUtils.htmlEncode(data.TEMPLATE.MEMORY)+'MB'))+
'</span>'+
' - '+
'<span>'+
(Math.floor(data.TEMPLATE.MEMORY/1024)+"GB") :
(TemplateUtils.htmlEncode(data.TEMPLATE.MEMORY)+"MB"))+
"</span>"+
" - "+
"<span>"+
get_provision_disk_image(data) +
'</span>'+
'</li>'+
'<li class="provision-bullet-item" >'+
'<span>'+
"</span>"+
"</li>"+
"<li class=\"provision-bullet-item\" >"+
"<span>"+
get_provision_ips(data) +
'</span>'+
'</li>'+
'<li class="provision-bullet-item-last text-right">'+
'<span class="left">'+
'<i class="fas fa-fw fa-lg fa-user"/> '+
"</span>"+
"</li>"+
"<li class=\"provision-bullet-item-last text-right\">"+
"<span class=\"left\">"+
"<i class=\"fas fa-fw fa-lg fa-user\"/> "+
data.UNAME+
'</span>'+
'<span>'+
'<i class="fas fa-fw fa-lg fa-clock-o"/> '+
"</span>"+
"<span>"+
"<i class=\"fas fa-fw fa-lg fa-clock-o\"/> "+
Humanize.prettyTimeAgo(data.STIME)+
' - '+
'ID: '+
" - "+
"ID: "+
data.ID+
'</span>'+
'</li>');
"</span>"+
"</li>");
if (Config.isFeatureEnabled("show_vcenter_info") && data.USER_TEMPLATE.HYPERVISOR === "vcenter"){
var vcenter_info = "";
@ -435,7 +436,7 @@ define(function(require) {
$(".provision_confirm_action:first", context).html("");
$(".provision_info_vm", context).css('visibility', 'visible');
$(".provision_info_vm", context).css("visibility", "visible");
$(".provision_info_vm_loading", context).hide();
//$(window).scrollTop(tempScrollTop);
@ -503,9 +504,9 @@ define(function(require) {
);
}
}
})
});
}
})
});
}
if (Config.isTabActionEnabled("provision-tab", "VM.save_as_template")) {
@ -520,10 +521,10 @@ define(function(require) {
var context = $(".provision_info_vm[vm_id]");
var vm_id = context.attr("vm_id");
var template_name = $('.provision_snapshot_name', context).val();
var template_description = $('.provision_snapshot_description', context).val();
var template_name = $(".provision_snapshot_name", context).val();
var template_description = $(".provision_snapshot_description", context).val();
var persistent =
($('input[name=provision_snapshot_radio]:checked').val() == "persistent");
($("input[name=provision_snapshot_radio]:checked").val() == "persistent");
OpenNebula.VM.save_as_template({
data : {
@ -537,7 +538,7 @@ define(function(require) {
timeout: false,
success: function(request, response){
OpenNebula.Action.clear_cache("VMTEMPLATE");
Notifier.notifyMessage(Locale.tr("VM Template") + ' ' + request.request.data[1].name + ' ' + Locale.tr("saved successfully"))
Notifier.notifyMessage(Locale.tr("VM Template") + " " + request.request.data[1].name + " " + Locale.tr("saved successfully"));
update_provision_vm_info(vm_id, context);
button.removeAttr("disabled");
},
@ -551,7 +552,7 @@ define(function(require) {
}
button.removeAttr("disabled");
}
})
});
return false;
});
@ -641,7 +642,7 @@ define(function(require) {
var button = $(this);
button.attr("disabled", "disabled");
var vm_id = $(".provision_info_vm", context).attr("vm_id");
var terminate_action = $('input[name=provision_terminate_radio]:checked').val()
var terminate_action = $("input[name=provision_terminate_radio]:checked").val();
OpenNebula.VM[terminate_action]({
data : {
@ -655,7 +656,7 @@ define(function(require) {
Notifier.onError(request, response);
button.removeAttr("disabled");
}
})
});
return false;
});
@ -664,7 +665,7 @@ define(function(require) {
var button = $(this);
button.attr("disabled", "disabled");
var vm_id = $(".provision_info_vm", context).attr("vm_id");
var poweroff_action = $('input[name=provision_poweroff_radio]:checked').val()
var poweroff_action = $("input[name=provision_poweroff_radio]:checked").val();
OpenNebula.VM[poweroff_action]({
data : {
@ -678,7 +679,7 @@ define(function(require) {
Notifier.onError(request, response);
button.removeAttr("disabled");
}
})
});
return false;
});
@ -687,7 +688,7 @@ define(function(require) {
var button = $(this);
button.attr("disabled", "disabled");
var vm_id = $(".provision_info_vm", context).attr("vm_id");
var undeploy_action = $('input[name=provision_undeploy_radio]:checked').val()
var undeploy_action = $("input[name=provision_undeploy_radio]:checked").val();
OpenNebula.VM[undeploy_action]({
data : {
@ -701,7 +702,7 @@ define(function(require) {
Notifier.onError(request, response);
button.removeAttr("disabled");
}
})
});
return false;
});
@ -711,7 +712,7 @@ define(function(require) {
button.attr("disabled", "disabled");
var vm_id = $(".provision_info_vm", context).attr("vm_id");
var reboot_action = $('input[name=provision_reboot_radio]:checked').val()
var reboot_action = $("input[name=provision_reboot_radio]:checked").val();
OpenNebula.VM[reboot_action]({
data : {
@ -725,7 +726,7 @@ define(function(require) {
Notifier.onError(request, response);
button.removeAttr("disabled");
}
})
});
return false;
});
@ -747,7 +748,7 @@ define(function(require) {
Notifier.onError(request, response);
button.removeAttr("disabled");
}
})
});
return false;
});
@ -777,14 +778,14 @@ define(function(require) {
button.removeAttr("disabled");
} else {
Notifier.notifyError("The remote console is not enabled for this VM")
Notifier.notifyError("The remote console is not enabled for this VM");
}
},
error: function(request, response){
Notifier.onError(request, response);
button.removeAttr("disabled");
}
})
});
return false;
});
@ -803,10 +804,10 @@ define(function(require) {
$("a.provision_show_vm_accordion", context).trigger("click");
// TODO loading
var vm_id = $(this).parents(".provision-pricing-table").attr("opennebula_id")
var vm_id = $(this).parents(".provision-pricing-table").attr("opennebula_id");
update_provision_vm_info(vm_id, context);
return false;
})
});
}
@ -827,7 +828,7 @@ define(function(require) {
case OpenNebulaVM.STATES.INIT:
case OpenNebulaVM.STATES.PENDING:
case OpenNebulaVM.STATES.HOLD:
state_color = 'deploying';
state_color = "deploying";
state_str = Locale.tr("DEPLOYING") + " (2/4)";
break;
case OpenNebulaVM.STATES.ACTIVE:
@ -835,13 +836,13 @@ define(function(require) {
switch (lcm_state) {
case OpenNebulaVM.LCM_STATES.LCM_INIT:
state_color = 'deploying';
state_color = "deploying";
state_str = Locale.tr("DEPLOYING") + " (2/4)";
break;
case OpenNebulaVM.LCM_STATES.PROLOG:
case OpenNebulaVM.LCM_STATES.PROLOG_RESUME:
case OpenNebulaVM.LCM_STATES.PROLOG_UNDEPLOY:
state_color = 'deploying';
state_color = "deploying";
state_str = Locale.tr("DEPLOYING") + " (3/4)";
break;
case OpenNebulaVM.LCM_STATES.BOOT:
@ -850,7 +851,7 @@ define(function(require) {
case OpenNebulaVM.LCM_STATES.BOOT_SUSPENDED:
case OpenNebulaVM.LCM_STATES.BOOT_STOPPED:
case OpenNebulaVM.LCM_STATES.BOOT_UNDEPLOY:
state_color = 'deploying';
state_color = "deploying";
state_str = Locale.tr("DEPLOYING") + " (4/4)";
break;
case OpenNebulaVM.LCM_STATES.RUNNING:
@ -872,7 +873,7 @@ define(function(require) {
case OpenNebulaVM.LCM_STATES.DISK_RESIZE:
case OpenNebulaVM.LCM_STATES.DISK_RESIZE_POWEROFF:
case OpenNebulaVM.LCM_STATES.DISK_RESIZE_UNDEPLOYED:
state_color = 'running';
state_color = "running";
state_str = Locale.tr("RUNNING");
break;
case OpenNebulaVM.LCM_STATES.HOTPLUG:
@ -882,7 +883,7 @@ define(function(require) {
case OpenNebulaVM.LCM_STATES.HOTPLUG_SAVEAS_SUSPENDED:
case OpenNebulaVM.LCM_STATES.HOTPLUG_PROLOG_POWEROFF:
case OpenNebulaVM.LCM_STATES.HOTPLUG_EPILOG_POWEROFF:
state_color = 'deploying';
state_color = "deploying";
state_str = Locale.tr("SAVING IMAGE");
break;
case OpenNebulaVM.LCM_STATES.FAILURE:
@ -900,7 +901,7 @@ define(function(require) {
case OpenNebulaVM.LCM_STATES.PROLOG_RESUME_FAILURE:
case OpenNebulaVM.LCM_STATES.PROLOG_UNDEPLOY_FAILURE:
case OpenNebulaVM.LCM_STATES.PROLOG_MIGRATE_UNKNOWN_FAILURE:
state_color = 'error';
state_color = "error";
state_str = Locale.tr("ERROR");
break;
case OpenNebulaVM.LCM_STATES.SAVE_STOP:
@ -915,15 +916,15 @@ define(function(require) {
case OpenNebulaVM.LCM_STATES.SHUTDOWN_UNDEPLOY:
case OpenNebulaVM.LCM_STATES.CLEANUP_RESUBMIT:
case OpenNebulaVM.LCM_STATES.CLEANUP_DELETE:
state_color = 'powering_off';
state_color = "powering_off";
state_str = Locale.tr("POWERING OFF");
break;
case OpenNebulaVM.LCM_STATES.UNKNOWN:
state_color = 'powering_off';
state_color = "powering_off";
state_str = Locale.tr("UNKNOWN");
break;
default:
state_color = 'powering_off';
state_color = "powering_off";
state_str = Locale.tr("UNKNOWN");
break;
}
@ -933,28 +934,28 @@ define(function(require) {
case OpenNebulaVM.STATES.SUSPENDED:
case OpenNebulaVM.STATES.POWEROFF:
case OpenNebulaVM.STATES.DONE:
state_color = 'off';
state_color = "off";
state_str = Locale.tr("OFF");
break;
case OpenNebulaVM.STATES.UNDEPLOYED:
state_color = 'undeployed';
state_color = "undeployed";
state_str = Locale.tr("UNDEPLOYED");
break;
case OpenNebulaVM.STATES.CLONING:
state_color = 'deploying';
state_color = "deploying";
state_str = Locale.tr("DEPLOYING") + " (1/4)";
break;
case OpenNebulaVM.STATES.CLONING_FAILURE:
state_color = 'error';
state_color = "error";
state_str = Locale.tr("ERROR");
break;
default:
state_color = 'powering_off';
state_color = "powering_off";
state_str = Locale.tr("UNKNOWN");
break;
}
@ -962,25 +963,25 @@ define(function(require) {
return {
color: state_color,
str: state_str
}
};
}
function get_provision_disk_image(data) {
var disks = []
var disks = [];
if ($.isArray(data.TEMPLATE.DISK))
disks = data.TEMPLATE.DISK
disks = data.TEMPLATE.DISK;
else if (!$.isEmptyObject(data.TEMPLATE.DISK))
disks = [data.TEMPLATE.DISK]
disks = [data.TEMPLATE.DISK];
if (disks.length > 0) {
return disks[0].IMAGE != undefined ? disks[0].IMAGE : '';
return disks[0].IMAGE != undefined ? disks[0].IMAGE : "";
} else {
return '';
return "";
}
}
function get_provision_ips(data) {
return '<i class="fas fa-fw fa-lg fa-globe"></i> ' + OpenNebula.VM.ipsStr(data, ', ');
return "<i class=\"fas fa-fw fa-lg fa-globe\"></i> " + OpenNebula.VM.ipsStr(data, ", ");
}
// @params
@ -999,30 +1000,30 @@ define(function(require) {
switch (state) {
case "READY":
case "USED":
state_color = 'running';
state_color = "running";
state_str = Locale.tr("READY");
break;
case "DISABLED":
case "USED_PERS":
state_color = 'off';
state_color = "off";
state_str = Locale.tr("OFF");
break;
case "LOCKED":
case "CLONE":
case "INIT":
state_color = 'deploying';
state_color = "deploying";
state_str = Locale.tr("DEPLOYING") + " (1/3)";
break;
case "ERROR":
state_color = 'error';
state_color = "error";
state_str = Locale.tr("ERROR");
break;
case "DELETE":
state_color = 'error';
state_color = "error";
state_str = Locale.tr("DELETING");
break;
default:
state_color = 'powering_off';
state_color = "powering_off";
state_str = Locale.tr("UNKNOWN");
break;
}
@ -1030,6 +1031,6 @@ define(function(require) {
return {
color: state_color,
str: state_str
}
};
}
});

View File

@ -19,17 +19,17 @@ define(function(require) {
DEPENDENCIES
*/
var BaseDialog = require('utils/dialogs/dialog');
var TemplateHTML = require('hbs!./clone/html');
var Sunstone = require('sunstone');
var Notifier = require('utils/notifier');
var OpenNebulaTemplate = require('opennebula/template');
var BaseDialog = require("utils/dialogs/dialog");
var TemplateHTML = require("hbs!./clone/html");
var Sunstone = require("sunstone");
var Notifier = require("utils/notifier");
var OpenNebulaTemplate = require("opennebula/template");
/*
CONSTANTS
*/
var DIALOG_ID = require('./clone/dialogId');
var DIALOG_ID = require("./clone/dialogId");
/*
CONSTRUCTOR
@ -57,7 +57,7 @@ define(function(require) {
function _html() {
return TemplateHTML({
'dialogId': this.dialogId
"dialogId": this.dialogId
});
}
@ -70,15 +70,15 @@ define(function(require) {
function _setup(context) {
var that = this;
$('#' + DIALOG_ID + 'Form', context).submit(function(e) {
$("#" + DIALOG_ID + "Form", context).submit(function(e) {
e.preventDefault();
return false;
});
$('#' + DIALOG_ID + 'Form', context).on("click", "button.custom_submit", function() {
if(!$('#' + DIALOG_ID + 'Form', context)[0].checkValidity()){
$("#" + DIALOG_ID + "Form", context).on("click", "button.custom_submit", function() {
if(!$("#" + DIALOG_ID + "Form", context)[0].checkValidity()){
if ($(this).val() == that.resource+".clone_recursive"){
$('#' + DIALOG_ID + 'Form button[type="submit"]', context).click();
$("#" + DIALOG_ID + "Form button[type=\"submit\"]", context).click();
return true;
} else {
return true;
@ -86,7 +86,7 @@ define(function(require) {
}
var extra_info;
var name = $('#' + DIALOG_ID + 'Form input[name="name"]').val();
var name = $("#" + DIALOG_ID + "Form input[name=\"name\"]").val();
var sel_elems = Sunstone.getDataTable(that.tabId).elements();
if (sel_elems.length > 1) {
@ -98,13 +98,14 @@ define(function(require) {
}
} else {
extra_info = name;
Sunstone.runAction($(this).val(), sel_elems[0], extra_info)
Sunstone.runAction($(this).val(), sel_elems[0], extra_info);
}
Sunstone.getDialog(DIALOG_ID).hide();
Sunstone.getDialog(DIALOG_ID).reset();
setTimeout(function() {
Sunstone.runAction(that.resource+'.refresh');
Sunstone.runAction(that.resource+".refresh");
}, 1500);
return false;
@ -120,13 +121,13 @@ define(function(require) {
//show different text depending on how many elements are selected
if (sel_elems.length > 1) {
$('.clone_one', context).hide();
$('.clone_several', context).show();
$('input[name="name"]',context).val('Copy of ');
$(".clone_one", context).hide();
$(".clone_several", context).show();
$("input[name=\"name\"]",context).val("Copy of ");
} else {
$('.clone_one', context).show();
$('.clone_several', context).hide();
$('input[name="name"]', context).val('Copy of ' + sel_elems[0].name);
$(".clone_one", context).show();
$(".clone_several", context).hide();
$("input[name=\"name\"]", context).val("Copy of " + sel_elems[0].name);
};
$("input[name='name']", context).focus();

View File

@ -18,41 +18,41 @@ define(function(require) {
/*
DEPENDENCIES
*/
var Notifier = require('utils/notifier');
var BaseFormPanel = require('utils/form-panels/form-panel');
var Sunstone = require('sunstone');
var Locale = require('utils/locale');
var Tips = require('utils/tips');
var TemplateUtils = require('utils/template-utils');
var WizardFields = require('utils/wizard-fields');
var Notifier = require("utils/notifier");
var BaseFormPanel = require("utils/form-panels/form-panel");
var Sunstone = require("sunstone");
var Locale = require("utils/locale");
var Tips = require("utils/tips");
var TemplateUtils = require("utils/template-utils");
var WizardFields = require("utils/wizard-fields");
/*
TEMPLATES
*/
var TemplateWizardHTML = require('hbs!./create/wizard');
var TemplateAdvancedHTML = require('hbs!./create/advanced');
var TemplateWizardHTML = require("hbs!./create/wizard");
var TemplateAdvancedHTML = require("hbs!./create/advanced");
/*
CONSTANTS
*/
var WIZARD_TABS = [
require('./create/wizard-tabs/general'),
require('./create/wizard-tabs/storage'),
require('./create/wizard-tabs/network'),
require('./create/wizard-tabs/os'),
require('./create/wizard-tabs/io'),
require('./create/wizard-tabs/actions'),
require('./create/wizard-tabs/context'),
require('./create/wizard-tabs/scheduling'),
require('./create/wizard-tabs/hybrid'),
require('./create/wizard-tabs/vmgroup'),
require('./create/wizard-tabs/other')
]
require("./create/wizard-tabs/general"),
require("./create/wizard-tabs/storage"),
require("./create/wizard-tabs/network"),
require("./create/wizard-tabs/os"),
require("./create/wizard-tabs/io"),
require("./create/wizard-tabs/actions"),
require("./create/wizard-tabs/context"),
require("./create/wizard-tabs/scheduling"),
require("./create/wizard-tabs/hybrid"),
require("./create/wizard-tabs/vmgroup"),
require("./create/wizard-tabs/other")
];
var TEMPLATES_TAB_ID = require('tabs/templates-tab/tabId');
var VROUTER_TEMPLATES_TAB_ID = require('tabs/vrouter-templates-tab/tabId');
var TEMPLATES_TAB_ID = require("tabs/templates-tab/tabId");
var VROUTER_TEMPLATES_TAB_ID = require("tabs/vrouter-templates-tab/tabId");
/*
CONSTRUCTOR
@ -71,15 +71,15 @@ define(function(require) {
}
this.actions = {
'create': {
'title': create_title,
'buttonText': Locale.tr("Create"),
'resetButton': true
"create": {
"title": create_title,
"buttonText": Locale.tr("Create"),
"resetButton": true
},
'update': {
'title': update_title,
'buttonText': Locale.tr("Update"),
'resetButton': false
"update": {
"title": update_title,
"buttonText": Locale.tr("Update"),
"resetButton": false
}
};
@ -103,7 +103,7 @@ define(function(require) {
} catch (err) {
console.log(err);
}
})
});
BaseFormPanel.call(this);
}
@ -129,8 +129,8 @@ define(function(require) {
function _htmlWizard() {
return TemplateWizardHTML({
'formPanelId': this.formPanelId,
'wizardTabs': this.wizardTabs
"formPanelId": this.formPanelId,
"wizardTabs": this.wizardTabs
});
}
@ -140,26 +140,26 @@ define(function(require) {
function _setup(context) {
$.each(this.wizardTabs, function(index, wizardTab) {
wizardTab.setup($('#' + wizardTab.wizardTabId, context));
wizardTab.setup($("#" + wizardTab.wizardTabId, context));
});
Foundation.reflow(context, 'tabs');
Foundation.reflow(context, 'tooltip');
Foundation.reflow(context, "tabs");
Foundation.reflow(context, "tooltip");
}
function _onShow(context) {
var that = this;
$('a[href="#'+ that.wizardTabs[0].wizardTabId +'"]', context).trigger("click");
$("a[href=\"#"+ that.wizardTabs[0].wizardTabId +"\"]", context).trigger("click");
$.each(that.wizardTabs, function(index, wizardTab) {
wizardTab.onShow($('#' + wizardTab.wizardTabId, context), that);
wizardTab.onShow($("#" + wizardTab.wizardTabId, context), that);
});
}
function _retrieve(context) {
var templateJSON = {}
var templateJSON = {};
$.each(this.wizardTabs, function(index, wizardTab) {
$.extend(true, templateJSON, wizardTab.retrieve($('#' + wizardTab.wizardTabId, context)));
$.extend(true, templateJSON, wizardTab.retrieve($("#" + wizardTab.wizardTabId, context)));
var a = templateJSON;
});
@ -168,8 +168,8 @@ define(function(require) {
// part of an array, and it is filled in different tabs, the $.extend deep
// merge can't work. We define an auxiliary attribute for it.
if (templateJSON['PUBLIC_CLOUD'] == undefined) {
templateJSON['PUBLIC_CLOUD'] = [];
if (templateJSON["PUBLIC_CLOUD"] == undefined) {
templateJSON["PUBLIC_CLOUD"] = [];
}
// PCI with TYPE=NIC is not defined in the 'other' tab. Because it is
@ -187,11 +187,11 @@ define(function(require) {
}
if (templateJSON["NIC_PCI"] != undefined) {
if (templateJSON['PCI'] == undefined) {
templateJSON['PCI'] = [];
if (templateJSON["PCI"] == undefined) {
templateJSON["PCI"] = [];
}
templateJSON['PCI'] = templateJSON['PCI'].concat(templateJSON["NIC_PCI"]);
templateJSON["PCI"] = templateJSON["PCI"].concat(templateJSON["NIC_PCI"]);
delete templateJSON["NIC_PCI"];
}
@ -203,7 +203,7 @@ define(function(require) {
var templateJSON = this.retrieve(context);
if (this.action == "create") {
Sunstone.runAction(this.resource+".create", {'vmtemplate': templateJSON});
Sunstone.runAction(this.resource+".create", {"vmtemplate": templateJSON});
return false;
} else if (this.action == "update") {
Sunstone.runAction(this.resource+".update", this.resourceId, TemplateUtils.templateToString(templateJSON));
@ -212,7 +212,7 @@ define(function(require) {
}
function _submitAdvanced(context) {
var templateStr = $('textarea#template', context).val();
var templateStr = $("textarea#template", context).val();
if (this.action == "create") {
Sunstone.runAction(this.resource+".create", {"vmtemplate": {"template_raw": templateStr}});
@ -237,10 +237,10 @@ define(function(require) {
WizardFields.fillInput($("#NAME", context), element.NAME);
// Populates the Avanced mode Tab
$('#template', context).val(TemplateUtils.templateToString(templateJSON));
$("#template", context).val(TemplateUtils.templateToString(templateJSON));
$.each(this.wizardTabs, function(index, wizardTab) {
wizardTab.fill($('#' + wizardTab.wizardTabId, context), templateJSON);
wizardTab.fill($("#" + wizardTab.wizardTabId, context), templateJSON);
});
// After all tabs have been filled, perform a notify
@ -265,7 +265,7 @@ define(function(require) {
$.each(that.wizardTabs, function(index, wizardTab) {
if (wizardTab.notify != undefined){
wizardTab.notify($('#' + wizardTab.wizardTabId, context), templateJSON);
wizardTab.notify($("#" + wizardTab.wizardTabId, context), templateJSON);
}
});

View File

@ -19,29 +19,29 @@ define(function(require) {
DEPENDENCIES
*/
var Config = require('sunstone-config');
var ScheduleActions = require('utils/schedule_action');
var Locale = require('utils/locale');
var Tips = require('utils/tips');
var WizardFields = require('utils/wizard-fields');
var UniqueId = require('utils/unique-id');
var Humanize = require('utils/humanize');
var TemplateUtils = require('utils/template-utils');
var Actions = require('utils/actions');
var Config = require("sunstone-config");
var ScheduleActions = require("utils/schedule_action");
var Locale = require("utils/locale");
var Tips = require("utils/tips");
var WizardFields = require("utils/wizard-fields");
var UniqueId = require("utils/unique-id");
var Humanize = require("utils/humanize");
var TemplateUtils = require("utils/template-utils");
var Actions = require("utils/actions");
var TemplateHTML = require('hbs!./actions/html');
var TemplateHTML = require("hbs!./actions/html");
/*
CONSTANTS
*/
var WIZARD_TAB_ID = require('./actions/wizardTabId');
var WIZARD_TAB_ID = require("./actions/wizardTabId");
/*
CONSTRUCTOR
*/
function WizardTab(opts) {
if (!Config.isTemplateCreationTabEnabled(opts.tabId, 'actions')) {
if (!Config.isTemplateCreationTabEnabled(opts.tabId, "actions")) {
throw "Wizard Tab not enabled";
}
@ -61,7 +61,7 @@ define(function(require) {
function _html() {
return TemplateHTML({
'table_sched_actions': ScheduleActions.htmlTable("temp")
"table_sched_actions": ScheduleActions.htmlTable("temp")
});
}
@ -72,16 +72,17 @@ define(function(require) {
var that = this;
var actions = ["terminate", "terminate-hard", "hold", "release", "stop", "suspend", "resume", "reboot", "reboot-hard", "poweroff", "poweroff-hard", "undeploy", "undeploy-hard", "snapshot-create"];
context.off('click', '#add_scheduling_temp_action');
context.on('click', '#add_scheduling_temp_action', function() {
context.off("click", "#add_scheduling_temp_action");
context.on("click", "#add_scheduling_temp_action", function() {
$("#add_scheduling_temp_action", context).attr("disabled", "disabled");
ScheduleActions.htmlNewAction(actions, context, "temp");
ScheduleActions.setup(context)
ScheduleActions.setup(context);
return false;
});
context.off("click", "#add_temp_action_json");
context.on("click" , "#add_temp_action_json", function(){
$(".wickedpicker").hide();
var sched_action = ScheduleActions.retrieveNewAction(context);
if (sched_action != false) {
$("#sched_temp_actions_body").append(ScheduleActions.fromJSONtoActionsTable(sched_action));
@ -91,20 +92,20 @@ define(function(require) {
context.off("click", ".remove_action_x");
context.on("click", ".remove_action_x", function () {
$(this).parents('tr').remove();
$(this).parents("tr").remove();
});
}
function _retrieve(context) {
var templateJSON = {};
templateJSON['SCHED_ACTION'] = ScheduleActions.retrieve(context);
templateJSON["SCHED_ACTION"] = ScheduleActions.retrieve(context);
return templateJSON;
}
function _fill(context, templateJSON) {
var actions = ScheduleActions.fromJSONtoActionsTable(templateJSON.SCHED_ACTION);
$("#sched_temp_actions_body").append(actions);
delete templateJSON['SCHED_ACTION'];
delete templateJSON["SCHED_ACTION"];
}
});

View File

@ -19,23 +19,23 @@ define(function(require) {
DEPENDENCIES
*/
var Locale = require('utils/locale');
var GroupsTable = require('tabs/groups-tab/datatable');
var TemplateChgrpTr = require('hbs!./info/chgrp-tr');
var ResourceSelect = require('utils/resource-select');
var Sunstone = require('sunstone');
var Locale = require("utils/locale");
var GroupsTable = require("tabs/groups-tab/datatable");
var TemplateChgrpTr = require("hbs!./info/chgrp-tr");
var ResourceSelect = require("utils/resource-select");
var Sunstone = require("sunstone");
/*
TEMPLATES
*/
var TemplateHTML = require('hbs!./groups/html');
var TemplateHTML = require("hbs!./groups/html");
/*
CONSTANTS
*/
var PANEL_ID = require('./groups/panelId');
var PANEL_ID = require("./groups/panelId");
var GROUPS_TABLE_ID = PANEL_ID + "GroupsTable";
var RESOURCE = "User";
var XML_ROOT = "USER";
@ -65,7 +65,7 @@ define(function(require) {
function _html() {
var groups;
var groupTrHTML = TemplateChgrpTr({'element': this.element});
var groupTrHTML = TemplateChgrpTr({"element": this.element});
if (this.element.GROUPS !== undefined && this.element.GROUPS.ID !== undefined) {
if ($.isArray(this.element.GROUPS.ID)) {
groups = this.element.GROUPS.ID;
@ -82,21 +82,21 @@ define(function(require) {
selectOptions: {
read_only: true,
fixed_ids: this.groups
}
}
};
this.groupsTable = new GroupsTable(GROUPS_TABLE_ID, opts);
this.groupsTableEdit = new GroupsTable('user_groups_edit', {
this.groupsTableEdit = new GroupsTable("user_groups_edit", {
info: false,
select: true,
selectOptions: {
'multiple_choice': true
"multiple_choice": true
}
});
return TemplateHTML({
'groupsTableHTML': this.groupsTable.dataTableHTML,
'groupsTableEditHTML': this.groupsTableEdit.dataTableHTML,
'element': this.element
"groupsTableHTML": this.groupsTable.dataTableHTML,
"groupsTableEditHTML": this.groupsTableEdit.dataTableHTML,
"element": this.element
});
}
@ -113,8 +113,8 @@ define(function(require) {
context.off("click", "#update_group");
context.on("click", "#update_group", function() {
ResourceSelect.insert({
context: $('#choose_primary_grp', context),
resourceName: 'Group',
context: $("#choose_primary_grp", context),
resourceName: "Group",
callback : function(response){
$("#choose_primary_grp").html(response[0].outerHTML);
$(".resource_list_select option[elem_id=" + that.element.GID + "]").prop("selected", true);
@ -132,7 +132,7 @@ define(function(require) {
$("#submit-group").hide();
});
$('#Form_change_second_grp').submit(function() {
$("#Form_change_second_grp").submit(function() {
var selectPrimaryGrp = $("#choose_primary_grp .resource_list_select").val();
var selectedGroupsList = that.groupsTableEdit.retrieveResourceTableSelect();
@ -142,13 +142,13 @@ define(function(require) {
$.each(selectedGroupsList, function(index, groupId) {
if ($.inArray(groupId, that.groups) === -1) {
Sunstone.runAction('User.addgroup', [that.element.ID], groupId);
Sunstone.runAction("User.addgroup", [that.element.ID], groupId);
}
});
$.each(that.groups, function(index, groupId) {
if ($.inArray(groupId, selectedGroupsList) === -1) {
Sunstone.runAction('User.delgroup', [that.element.ID], groupId);
Sunstone.runAction("User.delgroup", [that.element.ID], groupId);
}
});
@ -156,6 +156,7 @@ define(function(require) {
$(".show_labels").show();
setTimeout(function() {
Sunstone.runAction('User.refresh');
Sunstone.runAction("User.refresh");
}, 1500);
return false;

View File

@ -19,25 +19,25 @@ define(function(require) {
DEPENDENCIES
*/
var BaseDialog = require('utils/dialogs/dialog');
var ClustersTable = require('tabs/clusters-tab/datatable');
var Sunstone = require('sunstone');
var BaseDialog = require("utils/dialogs/dialog");
var ClustersTable = require("tabs/clusters-tab/datatable");
var Sunstone = require("sunstone");
var TemplateUtils = require("utils/template-utils");
/*
TEMPLATES
*/
var TemplateHTML = require('hbs!./clusters/html');
var TemplateHTML = require("hbs!./clusters/html");
/*
CONSTANTS
*/
var DIALOG_ID = require('./clusters/dialogId');
var DATASTORES_TAB_ID = require('tabs/datastores-tab/tabId');
var VNETS_TAB_ID = require('tabs/vnets-tab/tabId');
var VNTEMPLATE_TAB_ID = require('tabs/vnets-templates-tab/tabId');
var DIALOG_ID = require("./clusters/dialogId");
var DATASTORES_TAB_ID = require("tabs/datastores-tab/tabId");
var VNETS_TAB_ID = require("tabs/vnets-tab/tabId");
var VNTEMPLATE_TAB_ID = require("tabs/vnets-templates-tab/tabId");
/*
CONSTRUCTOR
@ -64,15 +64,15 @@ define(function(require) {
*/
function _html() {
this.clustersTable = new ClustersTable('clusters-'+this.dialogId, {
this.clustersTable = new ClustersTable("clusters-"+this.dialogId, {
info: false,
select: true,
selectOptions: {'multiple_choice': true}
selectOptions: {"multiple_choice": true}
});
return TemplateHTML({
'dialogId': this.dialogId,
'clustersTableHTML': this.clustersTable.dataTableHTML
"dialogId": this.dialogId,
"clustersTableHTML": this.clustersTable.dataTableHTML
});
}
@ -80,7 +80,7 @@ define(function(require) {
var that = this;
that.clustersTable.initialize();
$('#' + DIALOG_ID + 'Form', dialog).submit(function() {
$("#" + DIALOG_ID + "Form", dialog).submit(function() {
var selectedClustersList = that.clustersTable.retrieveResourceTableSelect();
if ( that.only_update_template != undefined && that.only_update_template != true) {
@ -88,9 +88,9 @@ define(function(require) {
$.each(selectedClustersList, function(index, clusterId) {
if ($.inArray(clusterId, that.originalClusterIds) === -1) {
if(that.resource == "datastore"){
Sunstone.runAction('Cluster.adddatastore', clusterId, that.element.ID);
Sunstone.runAction("Cluster.adddatastore", clusterId, that.element.ID);
} else {
Sunstone.runAction('Cluster.addvnet', clusterId, that.element.ID);
Sunstone.runAction("Cluster.addvnet", clusterId, that.element.ID);
}
}
});
@ -98,21 +98,22 @@ define(function(require) {
$.each(that.originalClusterIds, function(index, clusterId) {
if ($.inArray(clusterId, selectedClustersList) === -1) {
if(that.resource == "datastore"){
Sunstone.runAction('Cluster.deldatastore', clusterId, that.element.ID);
Sunstone.runAction("Cluster.deldatastore", clusterId, that.element.ID);
} else {
Sunstone.runAction('Cluster.delvnet', clusterId, that.element.ID);
Sunstone.runAction("Cluster.delvnet", clusterId, that.element.ID);
}
}
});
} else {
that.element.TEMPLATE.CLUSTER = selectedClustersList.join(",");
Sunstone.runAction(that.resource_name+".update", that.element.ID, TemplateUtils.templateToString(that.element.TEMPLATE))
Sunstone.runAction(that.resource_name+".update", that.element.ID, TemplateUtils.templateToString(that.element.TEMPLATE));
}
Sunstone.getDialog(DIALOG_ID).hide();
Sunstone.getDialog(DIALOG_ID).reset();
setTimeout(function() {
console.log("n");
Sunstone.runAction(that.resource_name+".refresh");
}, 1500);

View File

@ -34,6 +34,17 @@ define(function (require) {
function _htmlNewAction(actions, context, res) {
var options = "";
var clearEmpySpaces = function(e){
var value = e.val().replace(/\s/g, "");
e.val(value);
};
var options_date_picker = {
title: Locale.tr("Hour"),
twentyFour: "true",
timeSeparator: ":",
beforeShow: clearEmpySpaces,
now: "12:30"
};
var that = this;
$.each(actions, function (key, action) {
var actionAux = action.replace("-", "_");
@ -41,10 +52,12 @@ define(function (require) {
options += "<option value=\"" + action + "\">" + Locale.tr(action) + "</option>";
}
});
$("#scheduling_" + res + "_actions_table tbody", context).append(TemplateHTML({
var schedule = $("#scheduling_" + res + "_actions_table tbody", context).append(TemplateHTML({
"actions": options,
"res": that.res
})).find("#relative_time", context).on("click", function (e) {
}));
schedule.find("#time_input",context).on("click",function(e){e.stopPropagation();}).wickedpicker(options_date_picker);
schedule.find("#relative_time", context).on("click", function (e) {
$("#schedule_type", context).prop("checked", false);
if ($(this).is(":checked")) {
$("#no_relative_time_form, .periodic", context).addClass("hide");

View File

@ -44,7 +44,7 @@ the License for the specific language governing permissions and }} {{! limitatio
<input style="width: 80%" id="date_input" type="date" />
</td>
<td>
<input style="width: 80%" id="time_input" type="time" placeholder="12:30" />
<input style="width: 80%" class="timepicker" id="time_input" type="text" />
</td>
<td>
<input id="schedule_type" type="checkbox">

View File

@ -17,7 +17,8 @@
"datatables": "1.10.12",
"navigo": "2.1.1",
"sprintf": "1.0.3",
"jquery-ui": "^1.12.1"
"jquery-ui": "^1.12.1",
"wickedpicker": "git://github.com/ericjgagnon/wickedpicker#dd2cce3"
},
"authors": [
"Daniel Molina <dmolina@opennebula.org>",
@ -35,5 +36,6 @@
"bower_components",
"test",
"tests"
]
],
"main": ""
}

View File

@ -67,9 +67,11 @@
<% if $conf[:env] == 'dev' %>
<link href="bower_components/wickedpicker/dist/wickedpicker.min.css" media="screen, projector, print" rel="stylesheet" type="text/css"></link>
<link href="css/app.css?v=<%= OpenNebula::VERSION %>" media="screen, projector, print" rel="stylesheet" type="text/css"></link>
<link href="css/custom.css?v=<%= OpenNebula::VERSION %>" media="screen, projector, print" rel="stylesheet" type="text/css"></link>
<% else %>
<link href="bower_components/wickedpicker/dist/wickedpicker.min.css" media="screen, projector, print" rel="stylesheet" type="text/css"></link>
<link href="css/app.min.css?v=<%= OpenNebula::VERSION %>" media="screen, projector, print" rel="stylesheet" type="text/css"></link>
<link href="css/custom.css?v=<%= OpenNebula::VERSION %>" media="screen, projector, print" rel="stylesheet" type="text/css"></link>
<% end %>