mirror of
https://github.com/xcp-ng/xenadmin.git
synced 2024-12-04 17:11:06 +01:00
CP-21658: Expose UI of feature REQ-378 to user when the XenServer support the feature
Signed-off-by: Kun Ma <kun.ma@citrix.com>
This commit is contained in:
parent
8c837bb2c2
commit
c007194e06
@ -60,6 +60,7 @@ namespace XenAdmin.SettingsPanels
|
|||||||
private string _OrigSmtpServerAddrTextBox;
|
private string _OrigSmtpServerAddrTextBox;
|
||||||
private string _OrigSmtpServerPortTextBox;
|
private string _OrigSmtpServerPortTextBox;
|
||||||
private string _OrigMailLanguageCodeComboBox;
|
private string _OrigMailLanguageCodeComboBox;
|
||||||
|
private bool _bSupportMailLanguage;
|
||||||
|
|
||||||
private readonly ToolTip InvalidParamToolTip;
|
private readonly ToolTip InvalidParamToolTip;
|
||||||
|
|
||||||
@ -112,10 +113,35 @@ namespace XenAdmin.SettingsPanels
|
|||||||
return !SmtpServerAddrTextBox.Text.ToCharArray().Any((c) => c >= 128) && SmtpServerAddrTextBox.Text.Trim().Length > 0;
|
return !SmtpServerAddrTextBox.Text.ToCharArray().Any((c) => c >= 128) && SmtpServerAddrTextBox.Text.Trim().Length > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetMailLanguageComboBoxValue(String code)
|
||||||
|
{
|
||||||
|
if (_bSupportMailLanguage)
|
||||||
|
{ // Feature supported
|
||||||
|
if (null == code)
|
||||||
|
{ // Set default value
|
||||||
|
if (PerfmonOptionsDefinition.MailLanguageHasCode(Branding.BRANDING_PERF_ALERT_MAIL_LANGUAGE_DEFAULT))
|
||||||
|
MailLanguageComboBox.SelectedValue = Branding.BRANDING_PERF_ALERT_MAIL_LANGUAGE_DEFAULT;
|
||||||
|
else
|
||||||
|
MailLanguageComboBox.SelectedIndex = 0;
|
||||||
|
}
|
||||||
|
else if (PerfmonOptionsDefinition.MailLanguageHasCode(code))
|
||||||
|
MailLanguageComboBox.SelectedValue = code; // Valid language code, set it to MailLanguageComboBox
|
||||||
|
else
|
||||||
|
MailLanguageComboBox.SelectedValue = null; // Invalid language code, set null to MailLanguageComboBox
|
||||||
|
}
|
||||||
|
else
|
||||||
|
MailLanguageComboBox.SelectedValue = null; // Feature not supported
|
||||||
|
}
|
||||||
|
|
||||||
public void SetXenObjects(IXenObject orig, IXenObject clone)
|
public void SetXenObjects(IXenObject orig, IXenObject clone)
|
||||||
{
|
{
|
||||||
_XenModelObject = clone;
|
_XenModelObject = clone;
|
||||||
|
|
||||||
|
if (Helpers.FalconOrGreater(_XenModelObject.Connection))
|
||||||
|
_bSupportMailLanguage = true;
|
||||||
|
else
|
||||||
|
_bSupportMailLanguage = false;
|
||||||
|
|
||||||
Repopulate();
|
Repopulate();
|
||||||
|
|
||||||
// Save original settings for change detection
|
// Save original settings for change detection
|
||||||
@ -123,7 +149,11 @@ namespace XenAdmin.SettingsPanels
|
|||||||
_OrigEmailAddressTextBox = EmailAddressTextBox.Text;
|
_OrigEmailAddressTextBox = EmailAddressTextBox.Text;
|
||||||
_OrigSmtpServerAddrTextBox = SmtpServerAddrTextBox.Text;
|
_OrigSmtpServerAddrTextBox = SmtpServerAddrTextBox.Text;
|
||||||
_OrigSmtpServerPortTextBox = SmtpServerPortTextBox.Text;
|
_OrigSmtpServerPortTextBox = SmtpServerPortTextBox.Text;
|
||||||
_OrigMailLanguageCodeComboBox = null == MailLanguageComboBox.SelectedValue ? "" : MailLanguageComboBox.SelectedValue.ToString();
|
|
||||||
|
if (_bSupportMailLanguage)
|
||||||
|
_OrigMailLanguageCodeComboBox = null == MailLanguageComboBox.SelectedValue ? null : MailLanguageComboBox.SelectedValue.ToString();
|
||||||
|
else
|
||||||
|
_OrigMailLanguageCodeComboBox = null;
|
||||||
}
|
}
|
||||||
public void Repopulate()
|
public void Repopulate()
|
||||||
{
|
{
|
||||||
@ -131,6 +161,12 @@ namespace XenAdmin.SettingsPanels
|
|||||||
return;
|
return;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
if (_bSupportMailLanguage)
|
||||||
|
{
|
||||||
|
MailLanguageComboBox.Visible = true;
|
||||||
|
MailLanguageLabel.Visible = true;
|
||||||
|
}
|
||||||
|
|
||||||
_PerfmonOptions = PerfmonOptionsDefinition.GetPerfmonOptionsDefinitions(_XenModelObject);
|
_PerfmonOptions = PerfmonOptionsDefinition.GetPerfmonOptionsDefinitions(_XenModelObject);
|
||||||
if (_PerfmonOptions != null)
|
if (_PerfmonOptions != null)
|
||||||
{
|
{
|
||||||
@ -138,16 +174,12 @@ namespace XenAdmin.SettingsPanels
|
|||||||
EmailAddressTextBox.Text = _PerfmonOptions.MailDestination;
|
EmailAddressTextBox.Text = _PerfmonOptions.MailDestination;
|
||||||
SmtpServerAddrTextBox.Text = PerfmonOptionsDefinition.GetSmtpServerAddress(_PerfmonOptions.MailHub);
|
SmtpServerAddrTextBox.Text = PerfmonOptionsDefinition.GetSmtpServerAddress(_PerfmonOptions.MailHub);
|
||||||
SmtpServerPortTextBox.Text = PerfmonOptionsDefinition.GetSmtpPort(_PerfmonOptions.MailHub);
|
SmtpServerPortTextBox.Text = PerfmonOptionsDefinition.GetSmtpPort(_PerfmonOptions.MailHub);
|
||||||
if (null != _PerfmonOptions.MailLanguageCode)
|
|
||||||
MailLanguageComboBox.SelectedValue = _PerfmonOptions.MailLanguageCode;
|
SetMailLanguageComboBoxValue(_PerfmonOptions.MailLanguageCode);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Set default language value
|
SetMailLanguageComboBoxValue(null);
|
||||||
if (PerfmonOptionsDefinition.MailLanguageHasCode(Branding.BRANDING_PERF_ALERT_MAIL_LANGUAGE_DEFAULT))
|
|
||||||
MailLanguageComboBox.SelectedValue = Branding.BRANDING_PERF_ALERT_MAIL_LANGUAGE_DEFAULT;
|
|
||||||
else
|
|
||||||
MailLanguageComboBox.SelectedIndex = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
@ -161,7 +193,7 @@ namespace XenAdmin.SettingsPanels
|
|||||||
(_OrigEmailAddressTextBox != EmailAddressTextBox.Text) ||
|
(_OrigEmailAddressTextBox != EmailAddressTextBox.Text) ||
|
||||||
(_OrigSmtpServerAddrTextBox != SmtpServerAddrTextBox.Text) ||
|
(_OrigSmtpServerAddrTextBox != SmtpServerAddrTextBox.Text) ||
|
||||||
(_OrigSmtpServerPortTextBox != SmtpServerPortTextBox.Text) ||
|
(_OrigSmtpServerPortTextBox != SmtpServerPortTextBox.Text) ||
|
||||||
(_OrigMailLanguageCodeComboBox != MailLanguageComboBox.SelectedValue.ToString()));
|
(_bSupportMailLanguage && null != MailLanguageComboBox.SelectedValue && (_OrigMailLanguageCodeComboBox != MailLanguageComboBox.SelectedValue.ToString())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -207,7 +239,10 @@ namespace XenAdmin.SettingsPanels
|
|||||||
if (EmailNotificationCheckBox.Checked)
|
if (EmailNotificationCheckBox.Checked)
|
||||||
{
|
{
|
||||||
string smtpMailHub = SmtpServerAddrTextBox.Text + ":" + SmtpServerPortTextBox.Text;
|
string smtpMailHub = SmtpServerAddrTextBox.Text + ":" + SmtpServerPortTextBox.Text;
|
||||||
perfmonOptions = new PerfmonOptionsDefinition(smtpMailHub, EmailAddressTextBox.Text, MailLanguageComboBox.SelectedValue.ToString());
|
string mailLanguageCode = null;
|
||||||
|
if (_bSupportMailLanguage && null != MailLanguageComboBox.SelectedValue)
|
||||||
|
mailLanguageCode = MailLanguageComboBox.SelectedValue.ToString();
|
||||||
|
perfmonOptions = new PerfmonOptionsDefinition(smtpMailHub, EmailAddressTextBox.Text, mailLanguageCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new PerfmonOptionsDefinitionAction(_XenModelObject.Connection, perfmonOptions, true);
|
return new PerfmonOptionsDefinitionAction(_XenModelObject.Connection, perfmonOptions, true);
|
||||||
|
@ -210,6 +210,9 @@
|
|||||||
<data name="MailLanguageComboBox.TabIndex" type="System.Int32, mscorlib">
|
<data name="MailLanguageComboBox.TabIndex" type="System.Int32, mscorlib">
|
||||||
<value>9</value>
|
<value>9</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="MailLanguageComboBox.Visible" type="System.Boolean, mscorlib">
|
||||||
|
<value>False</value>
|
||||||
|
</data>
|
||||||
<data name=">>MailLanguageComboBox.Name" xml:space="preserve">
|
<data name=">>MailLanguageComboBox.Name" xml:space="preserve">
|
||||||
<value>MailLanguageComboBox</value>
|
<value>MailLanguageComboBox</value>
|
||||||
</data>
|
</data>
|
||||||
@ -243,6 +246,9 @@
|
|||||||
<data name="MailLanguageLabel.TextAlign" type="System.Drawing.ContentAlignment, System.Drawing">
|
<data name="MailLanguageLabel.TextAlign" type="System.Drawing.ContentAlignment, System.Drawing">
|
||||||
<value>MiddleLeft</value>
|
<value>MiddleLeft</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="MailLanguageLabel.Visible" type="System.Boolean, mscorlib">
|
||||||
|
<value>False</value>
|
||||||
|
</data>
|
||||||
<data name=">>MailLanguageLabel.Name" xml:space="preserve">
|
<data name=">>MailLanguageLabel.Name" xml:space="preserve">
|
||||||
<value>MailLanguageLabel</value>
|
<value>MailLanguageLabel</value>
|
||||||
</data>
|
</data>
|
||||||
|
@ -68,7 +68,8 @@ namespace XenAdmin.Actions
|
|||||||
{
|
{
|
||||||
Helpers.SetOtherConfig(Session, pool, PerfmonOptionsDefinition.MAIL_DESTINATION_KEY_NAME, perfmonOptions.MailDestination);
|
Helpers.SetOtherConfig(Session, pool, PerfmonOptionsDefinition.MAIL_DESTINATION_KEY_NAME, perfmonOptions.MailDestination);
|
||||||
Helpers.SetOtherConfig(Session, pool, PerfmonOptionsDefinition.SMTP_MAILHUB_KEY_NAME, perfmonOptions.MailHub);
|
Helpers.SetOtherConfig(Session, pool, PerfmonOptionsDefinition.SMTP_MAILHUB_KEY_NAME, perfmonOptions.MailHub);
|
||||||
Helpers.SetOtherConfig(Session, pool, PerfmonOptionsDefinition.MAIL_LANGUAGE_KEY_NAME, perfmonOptions.MailLanguageCode);
|
if(null != perfmonOptions.MailLanguageCode)
|
||||||
|
Helpers.SetOtherConfig(Session, pool, PerfmonOptionsDefinition.MAIL_LANGUAGE_KEY_NAME, perfmonOptions.MailLanguageCode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -61,6 +61,9 @@ namespace XenAdmin.Alerts
|
|||||||
{
|
{
|
||||||
String ret = null;
|
String ret = null;
|
||||||
|
|
||||||
|
if (null == name)
|
||||||
|
return ret;
|
||||||
|
|
||||||
foreach(KeyValuePair<String, String> pair in _list)
|
foreach(KeyValuePair<String, String> pair in _list)
|
||||||
{
|
{
|
||||||
if(pair.Value == name)
|
if(pair.Value == name)
|
||||||
@ -77,6 +80,9 @@ namespace XenAdmin.Alerts
|
|||||||
{
|
{
|
||||||
String ret = null;
|
String ret = null;
|
||||||
|
|
||||||
|
if (null == code)
|
||||||
|
return ret;
|
||||||
|
|
||||||
foreach (KeyValuePair<String, String> pair in _list)
|
foreach (KeyValuePair<String, String> pair in _list)
|
||||||
{
|
{
|
||||||
if (pair.Key == code)
|
if (pair.Key == code)
|
||||||
|
Loading…
Reference in New Issue
Block a user