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

B #6333: INCREMENT_MODE input in backups (Rsunstone/FireEdge) (#2834)

This commit is contained in:
Jorge Miguel Lobo Escalona 2023-11-23 17:20:07 +01:00 committed by GitHub
parent 89045b3bcf
commit f72d2437ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 74 additions and 12 deletions

View File

@ -13,21 +13,22 @@
* See the License for the specific language governing permissions and *
* limitations under the License. *
* ------------------------------------------------------------------------- */
import { string, boolean, number, ObjectSchema } from 'yup'
import { ObjectSchema, boolean, number, string } from 'yup'
import {
BACKUP_INCREMENT_MODE_OPTIONS,
BACKUP_MODE_OPTIONS,
FS_FREEZE_OPTIONS,
INPUT_TYPES,
T,
} from 'client/constants'
import {
Field,
Section,
arrayToOptions,
getObjectSchemaFromFields,
disableFields,
getObjectSchemaFromFields,
} from 'client/utils'
import {
T,
INPUT_TYPES,
FS_FREEZE_OPTIONS,
BACKUP_MODE_OPTIONS,
} from 'client/constants'
const BACKUP_VOLATILE_FIELD = {
name: 'BACKUP_CONFIG.BACKUP_VOLATILE',
@ -80,12 +81,36 @@ const MODE_FIELD = {
grid: { xs: 12, md: 6 },
}
const INCREMENT_MODE = {
name: 'BACKUP_CONFIG.INCREMENT_MODE',
label: T.IncrementMode,
type: INPUT_TYPES.SELECT,
dependOf: MODE_FIELD.name,
htmlType: (mode) =>
mode !== BACKUP_MODE_OPTIONS[T.Increment] && INPUT_TYPES.HIDDEN,
values: arrayToOptions(Object.keys(BACKUP_INCREMENT_MODE_OPTIONS), {
addEmpty: true,
getText: (type) => type,
getValue: (type) => BACKUP_INCREMENT_MODE_OPTIONS[type],
}),
validation: string()
.trim()
.default(() => undefined),
grid: { xs: 12, md: 6 },
}
/** @type {Section[]} Sections */
export const SECTIONS = (oneConfig, adminGroup) => [
{
id: 'backup-configuration',
fields: disableFields(
[BACKUP_VOLATILE_FIELD, FS_FREEZE_FIELD, KEEP_LAST_FIELD, MODE_FIELD],
[
BACKUP_VOLATILE_FIELD,
FS_FREEZE_FIELD,
KEEP_LAST_FIELD,
MODE_FIELD,
INCREMENT_MODE,
],
'BACKUP_CONFIG',
oneConfig,
adminGroup
@ -99,7 +124,10 @@ export const FIELDS = [
FS_FREEZE_FIELD,
KEEP_LAST_FIELD,
MODE_FIELD,
INCREMENT_MODE,
]
console.log({ FIELDS })
/** @type {ObjectSchema} Graphics schema */
export const BACKUP_SCHEMA = getObjectSchemaFromFields(FIELDS)

View File

@ -39,7 +39,8 @@ define(function(require) {
backup_volatile: "#backup-volatile",
fs_freeze: "#fs-freeze",
keep_last: "#keep-last",
mode: "#mode"
mode: "#mode",
increment_mode: "#increment-mode"
}
/*
@ -72,7 +73,17 @@ define(function(require) {
return TemplateHTML();
}
function _onShow(context) {
function _onShow(dialog) {
dialog.off("change", idsElements.mode)
dialog.on('change', idsElements.mode, function() {
var value = $(this).val()
var parent = $(idsElements.increment_mode, dialog).parent().closest('div')
if(value === "INCREMENT" && parent.hasClass("hide")){
parent.removeClass("hide")
}else{
parent.addClass("hide")
}
});
}
function _setup(context) {
@ -86,6 +97,7 @@ define(function(require) {
var fsFreeze = _getValue(idsElements.fs_freeze, context);
var keepLast = _getValue(idsElements.keep_last, context);
var mode = _getValue(idsElements.mode, context);
var increment_mode = _getValue(idsElements.increment_mode, context);
if (backupVolatile){
backupConfigJSON['BACKUP_VOLATILE'] = 'YES'
@ -103,6 +115,10 @@ define(function(require) {
backupConfigJSON['MODE'] = mode
}
if (increment_mode !== ''){
backupConfigJSON['INCREMENT_MODE'] = increment_mode
}
return { 'BACKUP_CONFIG' : backupConfigJSON}
}
@ -119,6 +135,7 @@ define(function(require) {
function _fill(context, templateJSON) {
if(templateJSON && templateJSON.BACKUP_CONFIG){
var configs = templateJSON.BACKUP_CONFIG
console.log("dsadas", configs)
if(configs && configs.BACKUP_VOLATILE && configs.BACKUP_VOLATILE === 'YES'){
$(idsElements.backup_volatile, context).click();
}
@ -130,6 +147,13 @@ define(function(require) {
}
if(configs && configs.MODE){
_fillBootValue(idsElements.mode, context, configs.MODE);
if(configs.MODE==="INCREMENT"){
var parent = $(idsElements.increment_mode, context).parent().closest('div')
parent.hasClass("hide") && parent.removeClass("hide")
if(configs && configs.INCREMENT_MODE){
_fillBootValue(idsElements.increment_mode, context, configs.INCREMENT_MODE);
}
}
}
}
}

View File

@ -44,7 +44,7 @@
<label for="keep-last">
{{tr "How many backups do you want to keep?"}}
</label>
<input type="number" id="keep-last" class="disabled_firecracker">
<input type="number" id="keep-last" min="0" class="disabled_firecracker">
</div>
<div class="small-12 columns">
<label for="mode">
@ -56,6 +56,16 @@
<option value="INCREMENT">{{tr "Increment"}}</option>
</select>
</div>
<div class="small-12 columns hide">
<label for="increment-mode" >
{{tr "Increment Mode"}}
</label>
<select id="increment-mode">
<option value="">{{tr "-"}}</option>
<option value="CBT">{{tr "CBT"}}</option>
<option value="SNAPSHOT">{{tr "Snapshot"}}</option>
</select>
</div>
</div>
</div>
</div>