[pve-devel] applied: [PATCH manager v2 1/2] ui/Parser: add generic functions property_strings
Thomas Lamprecht
t.lamprecht at proxmox.com
Thu Aug 2 16:21:32 CEST 2018
Am 08/01/2018 um 08:29 PM schrieb Stoiko Ivanov:
> Signed-off-by: Stoiko Ivanov <s.ivanov at proxmox.com>
> ---
> www/manager6/Parser.js | 43 +++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 43 insertions(+)
>
applied, with my suggested followups (the no-throw variant)
> diff --git a/www/manager6/Parser.js b/www/manager6/Parser.js
> index 13dce766..df2be5dc 100644
> --- a/www/manager6/Parser.js
> +++ b/www/manager6/Parser.js
> @@ -45,6 +45,49 @@ Ext.define('PVE.Parser', { statics: {
> value === 'true';
> },
>
> + parsePropertyString: function(value, defaultKey) {
> + var res = {},
> + errors = false;
> +
> + Ext.Array.each(value.split(','), function(p) {
> + var kv = p.split('=', 2);
> + if (Ext.isDefined(kv[1])) {
> + res[kv[0]] = kv[1];
> + } else if (Ext.isDefined(defaultKey)) {
> + if (Ext.isDefined(res[defaultKey])) {
> + errors = true;
> + return false; //break
> + }
> + res[defaultKey] = kv[0];
> + } else {
> + errors = true;
> + return false; // break
> + }
> + });
> +
> + if (errors) {
> + return;
> + }
> +
> + return res;
> + },
> +
> + printPropertyString: function(data, defaultKey) {
> + var stringparts = [];
> +
> + Ext.Object.each(data, function(key, value) {
> + var keystring = '' ;
> + if (key === defaultKey) {
> + keystring = '';
> + } else {
> + keystring = key + '=';
> + }
> + stringparts.push(keystring+value);
> + });
> +
> + return stringparts.join(',');
> + },
> +
> parseQemuNetwork: function(key, value) {
> if (!(key && value)) {
> return;
>
More information about the pve-devel
mailing list