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

Feature #4348: Service create action

This commit is contained in:
Carlos Martín 2016-07-11 15:58:19 +02:00
parent 8be474c8e5
commit fcf5b771c7
12 changed files with 154 additions and 29 deletions

View File

@ -394,6 +394,7 @@ tabs:
#- 7 # Search data
actions:
Service.refresh: true
Service.create_dialog: true
Service.chown: true
Service.chgrp: true
Service.chmod: true

View File

@ -394,6 +394,7 @@ tabs:
#- 7 # Search data
actions:
Service.refresh: true
Service.create_dialog: true
Service.chown: true
Service.chgrp: true
Service.chmod: true

View File

@ -394,6 +394,7 @@ tabs:
#- 7 # Search data
actions:
Service.refresh: true
Service.create_dialog: true
Service.chown: true
Service.chgrp: false
Service.chmod: false

View File

@ -396,6 +396,7 @@ tabs:
#- 7 # Search data
actions:
Service.refresh: true
Service.create_dialog: true
Service.chown: true
Service.chgrp: false
Service.chmod: false

View File

@ -395,6 +395,7 @@ tabs:
#- 7 # Search data
actions:
Service.refresh: true
Service.create_dialog: true
Service.chown: false
Service.chgrp: false
Service.chmod: true

View File

@ -39,6 +39,7 @@ define(function(require) {
];
var _formPanels = [
require('./oneflow-services-tab/form-panels/create')
];
var Tab = {

View File

@ -29,6 +29,7 @@ define(function(require) {
var ROLES_PANEL_ID = require('./panels/roles/panelId');
var SCALE_DIALOG_ID = require('./dialogs/scale/dialogId');
var CREATE_DIALOG_ID = require('./form-panels/create/formPanelId');
var _commonActions = new CommonActions(OpenNebulaResource, RESOURCE, TAB_ID,
XML_ROOT, Locale.tr("Service created"));
@ -81,7 +82,12 @@ define(function(require) {
"Service.rename": _commonActions.singleAction('rename'),
"Service.shutdown": _commonActions.multipleAction('shutdown'),
"Service.recover": _commonActions.multipleAction('recover'),
"Service.create_dialog" : {
type: "custom",
call: function() {
Sunstone.showFormPanel(TAB_ID, CREATE_DIALOG_ID, "create");
}
},
"Service.list" : {
type: "list",
call: OpenNebulaResource.list,

View File

@ -23,6 +23,11 @@ define(function(require) {
layout: "refresh",
alwaysActive: true
},
"Service.create_dialog" : {
type: "action",
layout: "create",
alwaysActive: true
},
"Service.chown" : {
type: "confirm_with_select",
text: Locale.tr("Change owner"),

View File

@ -0,0 +1,89 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2016, OpenNebula Project, OpenNebula Systems */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
/* a copy of the License at */
/* */
/* http://www.apache.org/licenses/LICENSE-2.0 */
/* */
/* Unless required by applicable law or agreed to in writing, software */
/* distributed under the License is distributed on an "AS IS" BASIS, */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
/* See the License for the specific language governing permissions and */
/* limitations under the License. */
/* -------------------------------------------------------------------------- */
define(function(require) {
/*
DEPENDENCIES
*/
var InstantiateTemplateFormPanel = require('tabs/oneflow-templates-tab/form-panels/instantiate');
var Locale = require('utils/locale');
var Tips = require('utils/tips');
var TemplatesTable = require('tabs/oneflow-templates-tab/datatable');
/*
CONSTANTS
*/
var FORM_PANEL_ID = require('./create/formPanelId');
var TAB_ID = require('../tabId');
/*
CONSTRUCTOR
*/
function FormPanel() {
InstantiateTemplateFormPanel.call(this);
this.formPanelId = FORM_PANEL_ID;
this.tabId = TAB_ID;
this.actions = {
'create': {
'title': Locale.tr("Create Service"),
'buttonText': Locale.tr("Create"),
'resetButton': true
}
};
this.templatesTable = new TemplatesTable('service_create', {'select': true});
}
FormPanel.FORM_PANEL_ID = FORM_PANEL_ID;
FormPanel.prototype = Object.create(InstantiateTemplateFormPanel.prototype);
FormPanel.prototype.constructor = FormPanel;
FormPanel.prototype.onShow = _onShow;
FormPanel.prototype.setup = _setup;
return FormPanel;
/*
FUNCTION DEFINITIONS
*/
function _setup(context) {
var that = this;
InstantiateTemplateFormPanel.prototype.setup.call(this, context);
$(".selectTemplateTable", context).html(
'<br/>' + this.templatesTable.dataTableHTML + '<br/>');
this.templatesTable.initialize();
$(".instantiate_wrapper", context).hide();
this.templatesTable.idInput().on("change", function(){
$(".instantiate_wrapper", context).show();
var template_id = $(this).val();
that.setTemplateId(context, template_id);
});
Tips.setup(context);
}
function _onShow(context) {
this.templatesTable.refreshResourceTableSelect();
InstantiateTemplateFormPanel.prototype.onShow.call(this, context);
}
});

View File

@ -0,0 +1,19 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2016, OpenNebula Project, OpenNebula Systems */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
/* a copy of the License at */
/* */
/* http://www.apache.org/licenses/LICENSE-2.0 */
/* */
/* Unless required by applicable law or agreed to in writing, software */
/* distributed under the License is distributed on an "AS IS" BASIS, */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
/* See the License for the specific language governing permissions and */
/* limitations under the License. */
/* -------------------------------------------------------------------------- */
define(function(require){
return 'createServiceForm';
})

View File

@ -16,28 +16,34 @@
<form data-abide novalidate id="{{formPanelId}}Wizard" class="custom creation">
<div class="row">
<div class="medium-6 columns">
<label for="service_name">{{tr "Service name"}}
<span class="tip">{{tr "When creating several Services, the wildcard %i will be replaced with a number starting from 0"}}.</span>
</label>
<input type="text" name="service_name" id="service_name" />
</div>
<div class="medium-6 columns">
<label for="service_n_times">{{tr "Number of instances"}}
</label>
<input type="number" min="1" name="service_n_times" id="service_n_times" value="1">
<div class="large-12 large-centered columns selectTemplateTable">
</div>
</div>
<h5>
<span class="name"></span>
<span class="total_cost_div" hidden>
<small class="cost_value">0.00</small>
<small>{{tr "COST"}} / {{tr "HOUR"}}</small>
</span>
</h5>
<div id="instantiate_service_user_inputs">
<i class="fa fa-spinner fa-spin"></i>
</div>
<div class="row" id="instantiate_service_role_user_inputs">
<div class="instantiate_wrapper">
<div class="row">
<div class="medium-6 columns">
<label for="service_name">{{tr "Service name"}}
<span class="tip">{{tr "When creating several Services, the wildcard %i will be replaced with a number starting from 0"}}.</span>
</label>
<input type="text" name="service_name" id="service_name" />
</div>
<div class="medium-6 columns">
<label for="service_n_times">{{tr "Number of instances"}}
</label>
<input type="number" min="1" name="service_n_times" id="service_n_times" value="1">
</div>
</div>
<h5>
<span class="name"></span>
<span class="total_cost_div" hidden>
<small class="cost_value">0.00</small>
<small>{{tr "COST"}} / {{tr "HOUR"}}</small>
</span>
</h5>
<div id="instantiate_service_user_inputs">
<i class="fa fa-spinner fa-spin"></i>
</div>
<div class="row" id="instantiate_service_role_user_inputs">
</div>
</div>
</form>

View File

@ -19,15 +19,9 @@ define(function(require) {
DEPENDENCIES
*/
// require('foundation.tab');
var InstantiateTemplateFormPanel = require('tabs/templates-tab/form-panels/instantiate');
var Sunstone = require('sunstone');
var Locale = require('utils/locale');
var Tips = require('utils/tips');
var Notifier = require('utils/notifier');
var WizardFields = require('utils/wizard-fields');
var UserInputs = require('utils/user-inputs');
var OpenNebulaTemplate = require('opennebula/template');
var TemplatesTable = require('tabs/templates-tab/datatable');
/*
CONSTANTS
@ -76,7 +70,7 @@ define(function(require) {
this.templatesTable.initialize();
$("#selected_resource_id_vm_create", context).on("change", function(){
this.templatesTable.idInput().on("change", function(){
$(".nameContainer", context).show();
$(".persistentContainer", context).show();