diff --git a/SAS/TMSS/frontend/tmss_webapp/src/routes/Project/view.js b/SAS/TMSS/frontend/tmss_webapp/src/routes/Project/view.js index 799d8cef35b4b39270d1d6cce36c79fe0f50606a..d8edfebf7b7183bb45a7ae4aab1df57d9cecfcb6 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/routes/Project/view.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/routes/Project/view.js @@ -12,7 +12,7 @@ import AppLoader from '../../layout/components/AppLoader'; import PageHeader from '../../layout/components/PageHeader'; import ProjectService from '../../services/project.service'; import UnitConverter from '../../utils/unit.converter'; - +import SchedulingUnitList from './../Scheduling/SchedulingUnitList'; /** * Component to view the details of a project */ @@ -54,9 +54,10 @@ export class ProjectView extends Component { async getProjectDetails() { let project = await ProjectService.getProjectDetails(this.state.projectId); let projectQuota = []; - let resources = []; + let resources = []; if (project) { + // If resources are allocated for the project quota fetch the resources master from the API if (project.quota) { resources = await ProjectService.getResources(); @@ -184,6 +185,13 @@ export class ProjectView extends Component { <div className="p-field p-grid resource-input-grid"> <ResourceDisplayList projectQuota={this.state.projectQuota} unitMap={this.resourceUnitMap} /> </div> + <div> + <div> + <h3>Scheduling Unit - List</h3> + </div> + <SchedulingUnitList projectname={this.state.project.name}/> + </div> + </div> </React.Fragment> } diff --git a/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/SchedulingUnitList.js b/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/SchedulingUnitList.js index 0a6258a315d9c1b44aeed07cf9dbefdcd497b5fc..3787de63cf108b0b92efe0621344a0d717f2feda 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/SchedulingUnitList.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/SchedulingUnitList.js @@ -5,7 +5,6 @@ import AppLoader from "./../../layout/components/AppLoader"; import ViewTable from './../../components/ViewTable'; import ScheduleService from '../../services/schedule.service'; - class SchedulingUnitList extends Component{ @@ -39,32 +38,45 @@ class SchedulingUnitList extends Component{ defaultSortColumn: [{id: "Name", desc: false}], } } - - async getSchedulingUnitList () { - const bluePrint = await ScheduleService.getSchedulingUnitBlueprint(); - ScheduleService.getSchedulingUnitDraft().then(scheduleunit =>{ - const output = []; - var scheduleunits = scheduleunit.data.results; - for( const scheduleunit of scheduleunits){ - const blueprintdata = bluePrint.data.results.filter(i => i.draft_id === scheduleunit.id); - blueprintdata.map(blueP => { - blueP.duration = moment.utc(blueP.duration*1000).format('HH:mm:ss'); - blueP.type="Blueprint"; - blueP['actionpath'] = '/schedulingunit/view/blueprint/'+blueP.id; - return blueP; + let projectname = this.props.projectname; + if(projectname){ + let scheduleunits = await ScheduleService.getSchedulingListByProject(projectname); + if(scheduleunits){ + for(const scheduleunit of scheduleunits){ + scheduleunit['actionpath']='/schedulingunit/view/draft/'+scheduleunit.id; + scheduleunit['type'] = 'Draft'; + scheduleunit['duration'] = moment.utc(scheduleunit.duration*1000).format('HH:mm:ss'); + } + this.setState({ + scheduleunit: scheduleunits, isLoading: false }); - output.push(...blueprintdata); - scheduleunit['actionpath']='/schedulingunit/view/draft/'+scheduleunit.id; - scheduleunit['type'] = 'Draft'; - scheduleunit['duration'] = moment.utc(scheduleunit.duration*1000).format('HH:mm:ss'); - output.push(scheduleunit); } - this.setState({ - scheduleunit: output, isLoading: false - }); - }) + }else{ + const bluePrint = await ScheduleService.getSchedulingUnitBlueprint(); + ScheduleService.getSchedulingUnitDraft().then(scheduleunit =>{ + const output = []; + var scheduleunits = scheduleunit.data.results; + for( const scheduleunit of scheduleunits){ + const blueprintdata = bluePrint.data.results.filter(i => i.draft_id === scheduleunit.id); + blueprintdata.map(blueP => { + blueP.duration = moment.utc(blueP.duration*1000).format('HH:mm:ss'); + blueP.type="Blueprint"; + blueP['actionpath'] = '/schedulingunit/view/blueprint/'+blueP.id; + return blueP; + }); + output.push(...blueprintdata); + scheduleunit['actionpath']='/schedulingunit/view/draft/'+scheduleunit.id; + scheduleunit['type'] = 'Draft'; + scheduleunit['duration'] = moment.utc(scheduleunit.duration*1000).format('HH:mm:ss'); + output.push(scheduleunit); + } + this.setState({ + scheduleunit: output, isLoading: false + }); + }) + } } componentDidMount(){ @@ -88,6 +100,7 @@ class SchedulingUnitList extends Component{ paths - specify the path for navigation - Table will set "id" value for each row in action button */} + {this.state.scheduleunit && <ViewTable data={this.state.scheduleunit} diff --git a/SAS/TMSS/frontend/tmss_webapp/src/services/schedule.service.js b/SAS/TMSS/frontend/tmss_webapp/src/services/schedule.service.js index a7e65ace0ccd24316cb5902bf1741a14cc94fddb..9b3a944f52ecdb4ef8f5b48b94245a63c04d2baa 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/services/schedule.service.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/services/schedule.service.js @@ -227,7 +227,31 @@ const ScheduleService = { console.error(error); return null; } - } + }, + getSchedulingListByProject: async function(projectname){ + try { + let schedulingunitlist = []; + await this.getSchedulingSets().then(async schedulingsetlist =>{ + let schedulingsets = schedulingsetlist.filter(scheduingset => scheduingset.project_id === projectname) + for(const scheduleset of schedulingsets){ + await this.getSchedulingBySet(scheduleset.id).then(suList =>{ + schedulingunitlist = schedulingunitlist.concat(suList); + }) + } + }) + return schedulingunitlist; + } catch (error) { + console.error('[project.services.getSchedulingUnitListByProject]',error); + } + }, + getSchedulingBySet: async function(id){ + try{ + const response = await axios.get(`/api/scheduling_set/${id}/scheduling_unit_draft/?ordering=id`); + return response.data.results; + } catch (error) { + console.error('[project.services.getSchedulingUnitBySet]',error); + } + } } export default ScheduleService; \ No newline at end of file