Skip to content
Snippets Groups Projects
Commit 2ad73573 authored by Muthukrishnanmatriot's avatar Muthukrishnanmatriot
Browse files

TMSS-936 & TMSS-941 - added On/Off switch and filter update

parent 4e47e418
No related branches found
No related tags found
2 merge requests!634WIP: COBALT commissioning delta,!545Resolve TMSS-936
......@@ -44,7 +44,8 @@ const PermissionStackUtil = {
task_blueprint: 'task_blueprint',
reservation: 'reservation',
task_relation_draft: 'task_relation_draft',
task_relation_blueprint: 'task_relation_blueprint'
task_relation_blueprint: 'task_relation_blueprint',
dynamicScheduler: 'setting/dynamic_scheduling_enabled'
}
const modules = Object.keys(module_url);
for(const module of modules) {
......@@ -115,7 +116,12 @@ const PermissionStackUtil = {
edit: allowedPermission?(_.includes(allowedPermission, 'PATCH')):false,
delete: allowedPermission?(_.includes(allowedPermission, 'DELETE')):false
};
}
}
else if (module === 'dynamicScheduler') {
permissionStack[module] = {
setting: allowedPermission?(_.includes(allowedPermission, 'PATCH')):false,
};
}
}
}
permissionStack['workflow'] = {
......
import React, { Component } from 'react';
import UtilService from '../services/util.service';
import { CustomDialog } from '../layout/components/CustomDialog';
import { Growl } from 'primereact/components/growl/Growl';
import { ToggleButton } from 'primereact/togglebutton';
export default class DynamicScheduler extends Component {
constructor(props) {
super(props);
this.dailyOptions= [];
this.state= {
dsStatus: false, // Dynamic Scheduler Status
showDialog: false,
}
this.currentStatus = null;
this.updateDSStatus = this.updateDSStatus.bind(this);
this.closeDialog = this.closeDialog.bind(this);
this.showConfirmDialog = this.showConfirmDialog.bind(this);
}
async componentDidMount(){
let response = await UtilService.getDynamicSchedulerStatus();
var status = false;
if(response) {
status = response.value;
}
this.setState({dynamicScheduler: response, dsStatus: status});
}
/**
* Update Dynamic Scheduling
*/
async updateDSStatus() {
let dynamicScheduler = this.state.dynamicScheduler;
dynamicScheduler.value = this.currentStatus;
let response = await UtilService.updateDynamicSchedulerStatus(dynamicScheduler);
if(response) {
this.growl.show({severity: 'success', summary: 'Success', detail: 'Dynamic Scheduling Switched '+((this.currentStatus === true)?'On' : 'Off')+' successfully!'});
} else {
this.growl.show({severity: 'error', summary: 'Error', detail: 'Dynamic Scheduling is not updated successfully.'});
}
this.setState({dsStatus: this.currentStatus, showDialog: false});
}
/**
* Show confirmation dialog to enable/disable Dynamic Scheduling
* @param {*} e
*/
async showConfirmDialog(e) {
this.currentStatus = e.value;
await this.setState({showDialog: true})
}
/**
* Close the Confirmation dialog
*/
closeDialog() {
this.setState({showDialog: false});
}
render() {
return (
<>
<Growl ref={(el) => this.growl = el} />
<div className="p-field p-grid">
<label htmlFor="autodeletion" style={{marginRight: '10px', marginLeft: '50px'}}>Dynamic Scheduling : </label>
<div data-testid="autodeletion" >
<ToggleButton onLabel="On" offLabel="Off" onIcon="pi pi-check" offIcon="pi pi-times"
checked={this.state.dsStatus} onChange={(e) => this.showConfirmDialog(e)}
tooltip={`Click to ${this.state.dsStatus? "'Switch Off'" : "'Switch On'"} the Dynamic Scheduling`}
tooltipOptions={this.tooltipOptions}/>
</div>
</div>
<CustomDialog type="confirmation" visible={this.state.showDialog} width={'35vw'}
header={'Confirmation'} message={`Are you sure want to switch ${this.currentStatus === true ? 'On' : 'Off'} the Dynamic Scheduling?` }
content={''} showIcon={true}
onClose={this.closeDialog} onCancel={this.closeDialog} onSubmit={this.updateDSStatus}
/>
</>
);
}
}
\ No newline at end of file
This diff is collapsed.
......@@ -36,7 +36,6 @@ class WorkflowList extends Component{
suName:"Scheduling Unit Name",
su: {
name: "Scheduling Unit ID",
filter: "range",
format: UIConstants.CALENDAR_TIME_FORMAT
},
status: {
......
......@@ -229,7 +229,36 @@ const UtilService = {
console.error('[UtilService.getProjectRoles]', error);
return [];
}
}
},
/**
* Get Dynamic Schediling On/Off Status
* @returns JSON object
*/
getDynamicSchedulerStatus: async function() {
try {
const url = `/api/setting/dynamic_scheduling_enabled`;
const response = await axios.get(url);
return response.data;
} catch (error) {
console.error('[getDynamicSchedulerStatus]',"Mistake", error);
return null;
}
},
/**
* Update Switch On/Off status of Dynamic Scheduling
* @param {Object} JSON object
* @returns
*/
updateDynamicSchedulerStatus: async function (response) {
try {
const url = `/api/setting/dynamic_scheduling_enabled`;
response = await axios.patch(url, response);
return response.data;
} catch (error) {
console.error('[updateDynamicSchedulerStatus]',"Mistake", error);
return null
}
},
}
export default UtilService;
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment