From 8aebff91f528bf9afbbe85bbe594545a86e5229e Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Fri, 29 Jan 2016 10:26:23 +0100 Subject: [PATCH] extjs: add parseBoolean for drive backup and iothreads The backup and iothread options are now boolean types internally instead of strings and need to be treated as such. Added a parseBoolean() function to deal with this with an optional default value to use for undefined values. The default for an undefined backup value is true. --- www/manager/Parser.js | 10 ++++++++++ www/manager/qemu/HDEdit.js | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/www/manager/Parser.js b/www/manager/Parser.js index 90c98c79..5a5e47f9 100644 --- a/www/manager/Parser.js +++ b/www/manager/Parser.js @@ -5,6 +5,16 @@ Ext.define('PVE.Parser', { statics: { // this class only contains static functions + parseBoolean: function(value, default_value) { + if (!Ext.isDefined(value)) + return default_value; + value = value.toLowerCase(); + return value === 1 || value === '1' || + value === 'on' || + value === 'yes' || + value === 'true'; + }, + parseQemuNetwork: function(key, value) { if (!(key && value)) { return; diff --git a/www/manager/qemu/HDEdit.js b/www/manager/qemu/HDEdit.js index ffca0b05..a9858764 100644 --- a/www/manager/qemu/HDEdit.js +++ b/www/manager/qemu/HDEdit.js @@ -90,11 +90,11 @@ Ext.define('PVE.qemu.HDInputPanel', { } values.hdimage = drive.file; - values.nobackup = (drive.backup === 'no'); + values.nobackup = !PVE.Parser.parseBoolean(drive.backup, 1); values.diskformat = drive.format || 'raw'; values.cache = drive.cache || ''; values.discard = (drive.discard === 'on'); - values.iothread = (drive.iothread === 'on'); + values.iothread = PVE.Parser.parseBoolean(drive.iothread); me.setValues(values); },