[pve-devel] [PATCH manager 1/2] ui: Parser: add BWLimit and general FormatString parser

Thomas Lamprecht t.lamprecht at proxmox.com
Wed Mar 28 17:40:06 CEST 2018


Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---
 www/manager6/Parser.js | 43 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)

diff --git a/www/manager6/Parser.js b/www/manager6/Parser.js
index 8253bd80..5616d5b0 100644
--- a/www/manager6/Parser.js
+++ b/www/manager6/Parser.js
@@ -580,5 +580,48 @@ Ext.define('PVE.Parser', { statics: {
 	    };
 	}
 	return null;
+    },
+
+    parseBWLimits: function(value) {
+	if (!value) {
+	    return;
+	}
+
+	var res = {};
+
+	var errors = false;
+	Ext.Array.each(value.split(','), function(p) {
+	    if (!p || p.match(/^\s*$/)) {
+		return; // continue
+	    }
+
+	    var m;
+	    if ((m = p.match(/^(restore|clone|default|migration|move)=(\d+)$/)) !== null) {
+		res[m[1]] = m[2] / 1024;
+	    } else {
+		errors = true;
+		return false; // break
+	    }
+	});
+
+	if (errors) {
+	    return;
+	}
+
+	return res;
+    },
+
+    printFormatString: function(data) {
+	var datastr;
+	Ext.Object.each(data, function(key, value) {
+	    if (value === '') { return; }
+	    if (!datastr) {
+		datastr = key + '=' + value;
+	    } else {
+		datastr += ',' + key + '=' + value;
+	    }
+	});
+
+	return datastr;
     }
 }});
-- 
2.14.2





More information about the pve-devel mailing list