public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Stefan Reiter <s.reiter@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH manager 4/5] Utils: add is_windows and use in MachineEdit
Date: Mon,  8 Mar 2021 11:01:50 +0100	[thread overview]
Message-ID: <20210308100151.7886-4-s.reiter@proxmox.com> (raw)
In-Reply-To: <20210308100151.7886-1-s.reiter@proxmox.com>

A bit more future proof and reuseable than a regex match.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
---
 www/manager6/Utils.js            | 9 +++++++++
 www/manager6/qemu/MachineEdit.js | 4 +---
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/www/manager6/Utils.js b/www/manager6/Utils.js
index ab4988b0..f502950f 100644
--- a/www/manager6/Utils.js
+++ b/www/manager6/Utils.js
@@ -69,6 +69,15 @@ Ext.define('PVE.Utils', {
 	],
     },
 
+    is_windows: function(ostype) {
+	for (let entry of PVE.Utils.kvm_ostypes['Microsoft Windows']) {
+	    if (entry.val === ostype) {
+		return true;
+	    }
+	}
+	return false;
+    },
+
     get_health_icon: function(state, circle) {
 	if (circle === undefined) {
 	    circle = false;
diff --git a/www/manager6/qemu/MachineEdit.js b/www/manager6/qemu/MachineEdit.js
index 87b405f5..f928c80c 100644
--- a/www/manager6/qemu/MachineEdit.js
+++ b/www/manager6/qemu/MachineEdit.js
@@ -138,9 +138,7 @@ Ext.define('PVE.qemu.MachineEdit', {
 		let values = {
 		    machine: conf.machine || '__default__',
 		};
-		if (conf.ostype && conf.ostype.match(/^(win|wvista|wxp|w2k)/i)) {
-		    values.isWindows = true;
-		}
+		values.isWindows = PVE.Utils.is_windows(conf.ostype);
 		me.setValues(values);
 	    },
 	});
-- 
2.20.1





  parent reply	other threads:[~2021-03-08 10:02 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-08 10:01 [pve-devel] [PATCH manager 1/5] ui: add onlineHelp to rng Stefan Reiter
2021-03-08 10:01 ` [pve-devel] [PATCH manager 2/5] ui/machine: fix Windows pinning and detect "pc" as non-pinned Stefan Reiter
2021-03-08 10:01 ` [pve-devel] [PATCH manager 3/5] ui/machine: fix eslint warning (unnecessary parentheses) Stefan Reiter
2021-03-08 10:01 ` Stefan Reiter [this message]
2021-03-08 10:01 ` [pve-devel] [PATCH manager 5/5] ui/hardware: extend machine renderer to show pinned Windows versions Stefan Reiter
2021-03-08 10:15 ` [pve-devel] applied-series: [PATCH manager 1/5] ui: add onlineHelp to rng Thomas Lamprecht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210308100151.7886-4-s.reiter@proxmox.com \
    --to=s.reiter@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal