]> git.proxmox.com Git - pve-manager.git/blobdiff - www/manager6/Parser.js
ui: eslint: fix various spacing related issues
[pve-manager.git] / www / manager6 / Parser.js
index 43cc4f5f9c77cffd09e86ad09dc2a977c500e3d2..4a2eac2caf68aba52b9c81b5396c67ea63832c19 100644 (file)
@@ -1,13 +1,21 @@
 // Some configuration values are complex strings -
 // so we need parsers/generators for them.
 
-Ext.define('PVE.Parser', { statics: {
+Ext.define('PVE.Parser', {
+ statics: {
 
     // this class only contains static functions
 
+    printACME: function(value) {
+       if (Ext.isArray(value.domains)) {
+           value.domains = value.domains.join(';');
+       }
+       return PVE.Parser.printPropertyString(value);
+    },
+
     parseACME: function(value) {
        if (!value) {
-           return;
+           return {};
        }
 
        var res = {};
@@ -148,7 +156,6 @@ Ext.define('PVE.Parser', { statics: {
     },
 
     printQemuNetwork: function(net) {
-
        var netstr = net.model;
        if (net.macaddr) {
            netstr += "=" + net.macaddr;
@@ -232,7 +239,6 @@ Ext.define('PVE.Parser', { statics: {
     },
 
     printQemuDrive: function(drive) {
-
        var drivestr = drive.file;
 
        Ext.Object.each(drive, function(key, value) {
@@ -326,7 +332,7 @@ Ext.define('PVE.Parser', { statics: {
                    errors = true;
                    return false; // break
                }
-               if (match_res[1] === 'bridge'){
+               if (match_res[1] === 'bridge') {
                    var bridgevlanf = match_res[2];
                    var bridge_res = bridgevlanf.match(/^(vmbr(\d+))(v(\d+))?(f)?$/);
                    if (!bridge_res) {
@@ -335,9 +341,7 @@ Ext.define('PVE.Parser', { statics: {
                    }
                    data.bridge = bridge_res[1];
                    data.tag = bridge_res[4];
-                   /*jslint confusion: true*/
                    data.firewall = bridge_res[5] ? 1 : 0;
-                   /*jslint confusion: false*/
                } else {
                    data[match_res[1]] = match_res[2];
                }
@@ -361,20 +365,19 @@ Ext.define('PVE.Parser', { statics: {
 
        Ext.Object.each(netif, function(iface, data) {
            var tmparray = [];
-           Ext.Array.each(['ifname', 'mac', 'bridge', 'host_ifname' , 'host_mac', 'mac_filter', 'tag', 'firewall'], function(key) {
+           Ext.Array.each(['ifname', 'mac', 'bridge', 'host_ifname', 'host_mac', 'mac_filter', 'tag', 'firewall'], function(key) {
                var value = data[key];
-               if (key === 'bridge'){
-                   if(data.tag){
+               if (key === 'bridge') {
+                   if (data.tag) {
                        value = value + 'v' + data.tag;
                    }
-                   if (data.firewall){
+                   if (data.firewall) {
                        value = value + 'f';
                    }
                }
                if (value) {
                    tmparray.push(key + '=' + value);
                }
-
            });
            netarray.push(tmparray.join(','));
        });
@@ -416,11 +419,9 @@ Ext.define('PVE.Parser', { statics: {
                }
        });
 
-       /*jslint confusion: true*/
        if (data.rate > 0) {
            tmparray.push('rate=' + data.rate);
        }
-       /*jslint confusion: false*/
        return tmparray.join(',');
     },
 
@@ -541,7 +542,7 @@ Ext.define('PVE.Parser', { statics: {
     },
 
     parseQemuSmbios1: function(value) {
-       var res = value.split(',').reduce(function (accumulator, currentValue) {
+       var res = value.split(',').reduce(function(accumulator, currentValue) {
            var splitted = currentValue.split(new RegExp("=(.+)"));
            accumulator[splitted[0]] = splitted[1];
            return accumulator;
@@ -558,7 +559,6 @@ Ext.define('PVE.Parser', { statics: {
     },
 
     printQemuSmbios1: function(data) {
-
        var datastr = '';
        var base64 = false;
        Ext.Object.each(data, function(key, value) {
@@ -590,7 +590,6 @@ Ext.define('PVE.Parser', { statics: {
     },
 
     parseTfaType: function(value) {
-       /*jslint confusion: true*/
        var match;
        if (!value || !value.length) {
            return undefined;
@@ -684,7 +683,7 @@ Ext.define('PVE.Parser', { statics: {
            return {
                type: m[1],
                key: m[2],
-               comment: m[3]
+               comment: m[3],
            };
        }
        if (m[2].match(typere)) {
@@ -692,9 +691,25 @@ Ext.define('PVE.Parser', { statics: {
                options: m[1],
                type: m[2],
                key: m[3],
-               comment: m[4]
+               comment: m[4],
            };
        }
        return null;
-    }
-}});
+    },
+
+    parseACMEPluginData: function(data) {
+       let res = {};
+       let extradata = [];
+       data.split('\n').forEach((line) => {
+           // capture everything after the first = as value
+           let [key, value] = line.split(/=(.+)/);
+           if (value !== undefined) {
+               res[key] = value;
+           } else {
+               extradata.push(line);
+           }
+       });
+       return [res, extradata];
+    },
+}
+});