in source/web-ui/src/views/machines/MachineStatusCard.tsx [226:278]
async onClickConfigModalSaveBtn(event: React.FormEvent<HTMLFormElement>) {
event.preventDefault();
event.stopPropagation();
if (!this._isMounted) { return; }
if (this.state.isMutating) { return; }
try {
this.setState({
isMutating: true,
machineStatusDownValue: this.state.machineStatusDownValue.split(',').map(val => val.trim()).join(','),
machineStatusIdleValue: this.state.machineStatusIdleValue.split(',').map(val => val.trim()).join(','),
machineStatusUpValue: this.state.machineStatusUpValue.split(',').map(val => val.trim()).join(',')
});
// Update the machine's display name
const updateMachineNameResponse = (await API.graphql({
query: updateMachineName, variables: {
input: {
id: this.state.id,
name: this.state.newMachineName
}
}
}) as IUpdateMachineNameResponse);
if (!updateMachineNameResponse || !updateMachineNameResponse.data || !updateMachineNameResponse.data.updateMachineName) {
throw new Error('Updating the UI Reference Data was not successful');
}
// Update the machine configuration
const updateMachineConfigResponse = (await API.graphql({
query: updateMachineConfig, variables: {
input: {
id: this.state.id,
machineProductionCountTagName: this.state.machineProductionCountTagName,
machineStatusTagName: this.state.machineStatusTagName,
machineStatusUpValue: this.state.machineStatusUpValue,
machineStatusDownValue: this.state.machineStatusDownValue,
machineStatusIdleValue: this.state.machineStatusIdleValue
}
}
}) as IUpdateMachineConfigResponse);
if (!updateMachineConfigResponse || !updateMachineConfigResponse.data || !updateMachineConfigResponse.data.updateMachineConfig) {
throw new Error('Updating the machine config was not successful');
}
this.setState({ isMutating: false });
this.onCloseConfigModal();
} catch (err) {
console.error(err);
this.setState({ isMutating: false });
}
}