mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-16 22:50:10 +03:00
parent
3234ad9a93
commit
5c9f80cc23
@ -43,6 +43,11 @@ define(function(require) {
|
||||
DISABLED : 4
|
||||
};
|
||||
|
||||
var BUTTON_DEPENDENT_STATES = [
|
||||
STATES.INIT,
|
||||
STATES.READY,
|
||||
];
|
||||
|
||||
var TYPES = {
|
||||
UNKNOWN : 0,
|
||||
IMAGE : 1,
|
||||
@ -56,6 +61,7 @@ define(function(require) {
|
||||
return STATES_STR[stateId];
|
||||
},
|
||||
"STATES": STATES,
|
||||
"BUTTON_DEPENDENT_STATES": BUTTON_DEPENDENT_STATES,
|
||||
"typeStr": function(typeId) {
|
||||
return TYPES_STR[typeId];
|
||||
},
|
||||
|
@ -120,8 +120,33 @@ define(function(require) {
|
||||
},
|
||||
error: Notifier.onError
|
||||
},
|
||||
"MarketPlaceApp.list" : _commonActions.list(),
|
||||
"MarketPlaceApp.show" : _commonActions.show(),
|
||||
"MarketPlaceApp.list" : {
|
||||
type: "list",
|
||||
call: OpenNebulaResource.list,
|
||||
callback: function(request, response) {
|
||||
var datatable = Sunstone.getDataTable(TAB_ID);
|
||||
if (datatable){
|
||||
datatable.updateView(request, response);
|
||||
datatable.updateStateActions();
|
||||
}
|
||||
},
|
||||
error: Notifier.onError
|
||||
},
|
||||
"MarketPlaceApp.show" : {
|
||||
type: "single",
|
||||
call: OpenNebulaResource.show,
|
||||
callback: function(request, response) {
|
||||
var datatable = Sunstone.getDataTable(TAB_ID);
|
||||
if (datatable){
|
||||
datatable.updateElement(request, response);
|
||||
datatable.updateStateActions(response);
|
||||
if (Sunstone.rightInfoVisible($('#' + TAB_ID))) {
|
||||
Sunstone.insertPanels(TAB_ID, response);
|
||||
}
|
||||
}
|
||||
},
|
||||
error: Notifier.onError
|
||||
},
|
||||
"MarketPlaceApp.refresh" : _commonActions.refresh(),
|
||||
|
||||
"MarketPlaceApp.delete" : {
|
||||
|
@ -31,12 +31,14 @@ define(function(require) {
|
||||
"MarketPlaceApp.download_opennebula_dialog" : {
|
||||
type: "action",
|
||||
text: '<i class="fas fa-lg fa-cloud-download-alt"/>',
|
||||
tip: Locale.tr('Import into Datastore')
|
||||
tip: Locale.tr('Import into Datastore'),
|
||||
custom_classes : "state-dependent"
|
||||
},
|
||||
"MarketPlaceApp.download_local" : {
|
||||
type: "action",
|
||||
text: '<i class="fas fa-lg fa-download"/>',
|
||||
tip: Locale.tr('Download to your desktop')
|
||||
tip: Locale.tr('Download to your desktop'),
|
||||
custom_classes : "state-dependent"
|
||||
},
|
||||
"MarketPlaceApp.chown" : {
|
||||
type: "confirm_with_select",
|
||||
|
@ -20,11 +20,12 @@ define(function(require) {
|
||||
*/
|
||||
|
||||
var TabDataTable = require('utils/tab-datatable');
|
||||
var Sunstone = require('sunstone');
|
||||
var SunstoneConfig = require('sunstone-config');
|
||||
var Locale = require('utils/locale');
|
||||
var OpenNebulaMarketPlaceApp = require('opennebula/marketplaceapp');
|
||||
var OpenNebulaMarketPlace = require('opennebula/marketplace');
|
||||
var OpenNebulaZone = require('opennebula/zone');
|
||||
var StateActions = require('./utils/state-actions');
|
||||
var LabelsUtils = require('utils/labels/utils');
|
||||
var Humanize = require('utils/humanize');
|
||||
var SearchDropdown = require('hbs!./datatable/search');
|
||||
@ -118,9 +119,11 @@ define(function(require) {
|
||||
|
||||
Table.prototype = Object.create(TabDataTable.prototype);
|
||||
Table.prototype.constructor = Table;
|
||||
Table.prototype.initialize = _initialize;
|
||||
Table.prototype.elementArray = _elementArray;
|
||||
Table.prototype.preUpdateView = _preUpdateView;
|
||||
Table.prototype.postUpdateView = _postUpdateView;
|
||||
Table.prototype.updateStateActions = _updateStateActions;
|
||||
|
||||
return Table;
|
||||
|
||||
@ -128,6 +131,13 @@ define(function(require) {
|
||||
FUNCTION DEFINITIONS
|
||||
*/
|
||||
|
||||
function _initialize(opts) {
|
||||
var that = this;
|
||||
|
||||
TabDataTable.prototype.initialize.call(this, opts);
|
||||
_updateStateActions();
|
||||
}
|
||||
|
||||
function _elementArray(element_json) {
|
||||
var element = element_json[XML_ROOT];
|
||||
|
||||
@ -152,7 +162,12 @@ define(function(require) {
|
||||
var color_html = Status.state_lock_to_color("MARKETPLACEAPP",state, element_json[XML_ROOT]["LOCK"]);
|
||||
|
||||
return [
|
||||
'<input class="check_item" type="checkbox" style="vertical-align: inherit;" id="'+this.resource.toLowerCase()+'_' + element.ID + '" name="selected_items" value="' + element.ID + '"/>'+color_html,
|
||||
'<input class="check_item"' +
|
||||
'type="checkbox" style="vertical-align: inherit;"' +
|
||||
'id="'+this.resource.toLowerCase()+'_' + element.ID + '"' +
|
||||
'name="selected_items"' +
|
||||
'state="'+element.STATE+'"' +
|
||||
'value="' + element.ID + '"/>'+color_html,
|
||||
element.ID,
|
||||
element.NAME,
|
||||
element.UNAME,
|
||||
@ -169,16 +184,6 @@ define(function(require) {
|
||||
];
|
||||
}
|
||||
|
||||
function _lengthOf(ids){
|
||||
var l = 0;
|
||||
if ($.isArray(ids))
|
||||
l = ids.length;
|
||||
else if (!$.isEmptyObject(ids))
|
||||
l = 1;
|
||||
|
||||
return l;
|
||||
}
|
||||
|
||||
function _preUpdateView() {
|
||||
this.totalApps = 0;
|
||||
}
|
||||
@ -186,4 +191,27 @@ define(function(require) {
|
||||
function _postUpdateView() {
|
||||
$(".total_apps").text(this.totalApps);
|
||||
}
|
||||
|
||||
function _updateStateActions(response) {
|
||||
if (response) {
|
||||
var app = response.MARKETPLACEAPP;
|
||||
|
||||
app && app.STATE && OpenNebulaMarketPlaceApp.BUTTON_DEPENDENT_STATES[app.STATE]
|
||||
? StateActions.enableAllStateActions()
|
||||
: StateActions.disableAllStateActions();
|
||||
}
|
||||
else {
|
||||
$('#' + this.dataTableId).on("change", 'tbody input.check_item', function() {
|
||||
var dataTable = Sunstone.getDataTable(TAB_NAME);
|
||||
|
||||
// make sure if all checked inputs are available
|
||||
$(dataTable.elements()).filter(function() {
|
||||
var appState = $("input.check_item[value='"+this+"']", dataTable.dataTable).attr("state");
|
||||
return OpenNebulaMarketPlaceApp.BUTTON_DEPENDENT_STATES[appState];
|
||||
}).length === dataTable.elements().length && dataTable.elements().length > 0
|
||||
? StateActions.enableAllStateActions()
|
||||
: StateActions.disableAllStateActions();
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -82,16 +82,10 @@ define(function(require) {
|
||||
var valid = market.ZONE_ID == config.zone_id;
|
||||
|
||||
if (valid){
|
||||
var create_support = false;
|
||||
|
||||
$.each(config.oned_conf.MARKET_MAD_CONF, function(){
|
||||
if (this.NAME == market.MARKET_MAD){
|
||||
create_support = this.APP_ACTIONS.split(',').includes("create");
|
||||
return false; //break
|
||||
}
|
||||
});
|
||||
|
||||
valid = create_support;
|
||||
valid = $(config.oned_conf.MARKET_MAD_CONF)
|
||||
.filter(function(_, marketMad){
|
||||
return marketMad.NAME == market.MARKET_MAD && marketMad.APP_ACTIONS.indexOf('create') !== -1;
|
||||
}).length > 0;
|
||||
}
|
||||
|
||||
return valid;
|
||||
|
@ -0,0 +1,36 @@
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* Copyright 2002-2020, 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() {
|
||||
return {
|
||||
'disableAllStateActions': disableAllStateActions,
|
||||
'enableAllStateActions': enableAllStateActions
|
||||
};
|
||||
|
||||
function disableAllStateActions() {
|
||||
$(".state-dependent").prop("disabled", true)
|
||||
.removeClass("action-enabled")
|
||||
.addClass("action-disabled")
|
||||
.on("click.stateaction", function(e) { return false; });
|
||||
}
|
||||
|
||||
function enableAllStateActions() {
|
||||
$(".state-dependent").removeAttr("disabled")
|
||||
.addClass("action-enabled")
|
||||
.removeClass("action-disabled")
|
||||
.off("click.stateaction");
|
||||
}
|
||||
});
|
@ -134,22 +134,22 @@ define(function(require) {
|
||||
|
||||
function disableAllStateActions() {
|
||||
$(".state-dependent").prop("disabled", true).
|
||||
removeClass("vm-action-enabled").
|
||||
addClass("vm-action-disabled").
|
||||
removeClass("action-enabled").
|
||||
addClass("action-disabled").
|
||||
on("click.stateaction", function(e) { return false; });
|
||||
}
|
||||
|
||||
function resetStateButtons() {
|
||||
$(".state-dependent").
|
||||
addClass("vm-action-enabled").
|
||||
removeClass("vm-action-disabled").
|
||||
addClass("action-enabled").
|
||||
removeClass("action-disabled").
|
||||
off("click.stateaction");
|
||||
}
|
||||
|
||||
function enableStateButton(button_action) {
|
||||
$(".state-dependent[href='" + button_action + "']").removeAttr("disabled").
|
||||
addClass("vm-action-enabled").
|
||||
removeClass("vm-action-disabled").
|
||||
addClass("action-enabled").
|
||||
removeClass("action-disabled").
|
||||
off("click.stateaction");
|
||||
}
|
||||
|
||||
|
@ -109,7 +109,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
.vm-action-disabled {
|
||||
.action-disabled {
|
||||
//color: #cfcfcf !important;
|
||||
cursor: default !important;
|
||||
opacity: 0.25;
|
||||
|
Loading…
x
Reference in New Issue
Block a user