in source/idea/idea-cluster-manager/webapp/src/pages/virtual-desktops/virtual-desktop-settings.tsx [131:258]
buildUpdateDCVSessionSettingsForm() {
return (
<IdeaForm
ref={this.updateDCVSessionSettingsForm}
name="update-session-settings"
modal={true}
title="Update Session Settings"
onSubmit={() => {
if (!this.updateDCVSessionSettingsForm.current?.validate()) {
return;
}
const values = this.updateDCVSessionSettingsForm.current?.getValues();
const updateSettings: UpdateModuleSettingsRequestVDC = {
module_id: VDC_MODULE_ID,
settings: {
dcv_session: {},
},
};
const enforce_schedule = Utils.asBoolean(values.enforce_schedule, true);
if (values.idle_timeout !== String(dot.pick("dcv_session.idle_timeout", this.state.vdcSettings))) {
updateSettings.settings.dcv_session[UpdateModuleSettingsValuesDCVSession.IDLE_TIMEOUT] = values.idle_timeout;
}
if (values.cpu_utilization_threshold !== String(dot.pick("dcv_session.cpu_utilization_threshold", this.state.vdcSettings))) {
updateSettings.settings.dcv_session[UpdateModuleSettingsValuesDCVSession.CPU_UTILIZATION_THRESHOLD] = values.cpu_utilization_threshold;
}
if (enforce_schedule !== dot.pick("dcv_session.enforce_schedule", this.state.vdcSettings)) {
updateSettings.settings.dcv_session[UpdateModuleSettingsValuesDCVSession.ENFORCE_SCHEDULE] = values.enforce_schedule;
}
if(values.transition_state !== String(dot.pick("dcv_session.transition_state", this.state.vdcSettings))) {
updateSettings.settings.dcv_session[UpdateModuleSettingsValuesDCVSession.TRANSITION_STATE] = values.transition_state;
}
if(values.transition_state === 'Terminate') {
updateSettings.settings.dcv_session[UpdateModuleSettingsValuesDCVSession.ENFORCE_SCHEDULE] = false;
}
if (Object.keys(updateSettings.settings.dcv_session).length > 0) {
AppContext.get()
.client()
.clusterSettings()
.updateModuleSettings(updateSettings)
.then(() => {
this.props.onFlashbarChange({
items: [
{
type: "success",
content: "Session settings updated successfully.",
dismissible: true,
},
],
});
this.loadSettings();
this.updateDCVSessionSettingsForm.current?.hideModal();
})
.catch((error) => {
this.updateDCVSessionSettingsForm.current?.setError(error.errorCode, error.message);
});
} else {
this.updateDCVSessionSettingsForm.current?.setError("400", "No settings updated.");
}
}}
onCancel={() => {
this.updateDCVSessionSettingsForm.current?.hideModal();
}}
params={[
{
name: "idle_timeout",
title: "Idle Timeout (minutes)",
help_text: "Sessions idle for this time with CPU utilization below the threshold will time out. A 5 minute buffer is automatically added to the specific time to account for boot and startup differences amongst operating systems. For example, if the timeout value is entered as 10 minutes, the VDI sessions will auto-stop after 15 minutes of idle.",
data_type: "int",
validate: {
required: true,
min: 1,
max: 87600,
},
default: dot.pick("dcv_session.idle_timeout", this.state.vdcSettings),
},
{
name: "cpu_utilization_threshold",
title: "CPU Utilization Threshold (%)",
help_text: "Sessions under this threshold are considered idle. This threshold is used for both schedules and the configurable idle timeout.",
data_type: "int",
validate: {
required: true,
min: 0,
max: 100,
},
default: dot.pick("dcv_session.cpu_utilization_threshold", this.state.vdcSettings),
},
{
name: "transition_state",
title: "Transition State",
help_text: "Sessions will transition to this state after idle timeout",
data_type: "str",
param_type: "select",
multiple: false,
choices:[
{
title: "Stop",
value: "Stop"
},
{
title: "Terminate",
value: "Terminate",
}
],
default: dot.pick("dcv_session.transition_state", this.state.vdcSettings),
},
{
name: "enforce_schedule",
title: "Enforce Schedule",
help_text: "Enable to allow schedule to resume a session that has been stopped for being idle",
data_type: "bool",
param_type: "confirm",
default: Utils.asBoolean(dot.pick("dcv_session.enforce_schedule", this.state.vdcSettings)),
when: {
param: 'transition_state',
eq: 'Stop'
},
},
]}
/>
);
}