Reordered templates on the NewVM wizard:

- Moved Windows Server templates to a different category.
- Show templates in reverse alphabetical (typically release) order.

Signed-off-by: Konstantina Chremmou <Konstantina.Chremmou@cloud.com>
This commit is contained in:
Konstantina Chremmou 2023-03-01 13:10:30 +00:00
parent e5664bab7e
commit 4034a48ee3
2 changed files with 35 additions and 26 deletions

View File

@ -161,7 +161,7 @@ namespace XenAdmin.Wizards.NewVMWizard
TemplatesGridView.ResumeLayout(); TemplatesGridView.ResumeLayout();
RowsChanged(); RowsChanged();
TemplatesGridView.Sort(new Sorter()); TemplatesGridView.Sort(new TemplateSorter());
} }
private void RefreshRows() private void RefreshRows()
@ -232,7 +232,7 @@ namespace XenAdmin.Wizards.NewVMWizard
} }
} }
private class Sorter : IComparer private class TemplateSorter : IComparer
{ {
public int Compare(object x, object y) public int Compare(object x, object y)
{ {
@ -250,7 +250,8 @@ namespace XenAdmin.Wizards.NewVMWizard
if (result != 0) if (result != 0)
return result; return result;
result = StringUtility.NaturalCompare(xItem.Template.Name(), yItem.Template.Name()); //reverse alphabetical order so most recent version appears first
result = -StringUtility.NaturalCompare(xItem.Template.Name(), yItem.Template.Name());
if (result != 0) if (result != 0)
return result; return result;
@ -291,7 +292,10 @@ namespace XenAdmin.Wizards.NewVMWizard
{ {
switch (templateType) switch (templateType)
{ {
case VM.VmTemplateType.Custom:
return Messages.NEWVMWIZARD_TEMPLATEPAGE_CUSTOM;
case VM.VmTemplateType.Windows: case VM.VmTemplateType.Windows:
case VM.VmTemplateType.WindowsServer:
case VM.VmTemplateType.LegacyWindows: case VM.VmTemplateType.LegacyWindows:
return Messages.NEWVMWIZARD_TEMPLATEPAGE_WINDOWS; return Messages.NEWVMWIZARD_TEMPLATEPAGE_WINDOWS;
case VM.VmTemplateType.Centos: case VM.VmTemplateType.Centos:
@ -344,6 +348,7 @@ namespace XenAdmin.Wizards.NewVMWizard
return Images.StaticImages._000_UserTemplate_h32bit_16; return Images.StaticImages._000_UserTemplate_h32bit_16;
case VM.VmTemplateType.Windows: case VM.VmTemplateType.Windows:
case VM.VmTemplateType.LegacyWindows: case VM.VmTemplateType.LegacyWindows:
case VM.VmTemplateType.WindowsServer:
return Images.StaticImages.windows_h32bit_16; return Images.StaticImages.windows_h32bit_16;
case VM.VmTemplateType.Centos: case VM.VmTemplateType.Centos:
return Images.StaticImages.centos_16x; return Images.StaticImages.centos_16x;

View File

@ -842,28 +842,29 @@ namespace XenAPI
NoTemplate = 0,//it's not a template NoTemplate = 0,//it's not a template
Custom = 1, Custom = 1,
Windows = 2, Windows = 2,
LegacyWindows = 3, WindowsServer = 3,
Asianux = 4, LegacyWindows = 4,
Centos = 5, Asianux = 5,
CoreOS = 6, Centos = 6,
Debian = 7, CoreOS = 7,
Gooroom = 8, Debian = 8,
Linx = 9, Gooroom = 9,
NeoKylin = 10, Linx = 10,
Oracle = 11, NeoKylin = 11,
RedHat = 12, Oracle = 12,
Rocky = 13, RedHat = 13,
SciLinux = 14, Rocky = 14,
Suse = 15, SciLinux = 15,
Turbo = 16, Suse = 16,
Ubuntu = 17, Turbo = 17,
YinheKylin = 18, Ubuntu = 18,
Citrix = 19, YinheKylin = 19,
Solaris = 20, Citrix = 20,
Misc = 21, Solaris = 21,
Snapshot = 22, Misc = 22,
SnapshotFromVmpp = 23, Snapshot = 23,
Count = 24 //bump this if values are added SnapshotFromVmpp = 24,
Count = 25 //bump this if values are added
} }
public VmTemplateType TemplateType() public VmTemplateType TemplateType()
@ -915,6 +916,9 @@ namespace XenAPI
if (os.Contains("legacy windows")) if (os.Contains("legacy windows"))
return VmTemplateType.LegacyWindows; return VmTemplateType.LegacyWindows;
if (os.Contains("windows") && os.Contains("server"))
return VmTemplateType.WindowsServer;
if (os.Contains("windows")) if (os.Contains("windows"))
return VmTemplateType.Windows; return VmTemplateType.Windows;