Skip to content
Snippets Groups Projects
Commit c743c277 authored by Muthu's avatar Muthu
Browse files

TMSS-347 - added scheduling list in project view

added scheduling list in project view page
parent 8c5de88b
No related branches found
No related tags found
1 merge request!214Resolve TMSS-348 - Merged other local branches
...@@ -12,7 +12,7 @@ import AppLoader from '../../layout/components/AppLoader'; ...@@ -12,7 +12,7 @@ import AppLoader from '../../layout/components/AppLoader';
import PageHeader from '../../layout/components/PageHeader'; import PageHeader from '../../layout/components/PageHeader';
import ProjectService from '../../services/project.service'; import ProjectService from '../../services/project.service';
import UnitConverter from '../../utils/unit.converter'; import UnitConverter from '../../utils/unit.converter';
import SchedulingUnitList from './../Scheduling/SchedulingUnitList';
/** /**
* Component to view the details of a project * Component to view the details of a project
*/ */
...@@ -54,9 +54,10 @@ export class ProjectView extends Component { ...@@ -54,9 +54,10 @@ export class ProjectView extends Component {
async getProjectDetails() { async getProjectDetails() {
let project = await ProjectService.getProjectDetails(this.state.projectId); let project = await ProjectService.getProjectDetails(this.state.projectId);
let projectQuota = []; let projectQuota = [];
let resources = []; let resources = [];
if (project) { if (project) {
// If resources are allocated for the project quota fetch the resources master from the API // If resources are allocated for the project quota fetch the resources master from the API
if (project.quota) { if (project.quota) {
resources = await ProjectService.getResources(); resources = await ProjectService.getResources();
...@@ -184,6 +185,13 @@ export class ProjectView extends Component { ...@@ -184,6 +185,13 @@ export class ProjectView extends Component {
<div className="p-field p-grid resource-input-grid"> <div className="p-field p-grid resource-input-grid">
<ResourceDisplayList projectQuota={this.state.projectQuota} unitMap={this.resourceUnitMap} /> <ResourceDisplayList projectQuota={this.state.projectQuota} unitMap={this.resourceUnitMap} />
</div> </div>
<div>
<div>
<h3>Scheduling Unit - List</h3>
</div>
<SchedulingUnitList projectname={this.state.project.name}/>
</div>
</div> </div>
</React.Fragment> </React.Fragment>
} }
......
...@@ -5,7 +5,6 @@ import AppLoader from "./../../layout/components/AppLoader"; ...@@ -5,7 +5,6 @@ import AppLoader from "./../../layout/components/AppLoader";
import ViewTable from './../../components/ViewTable'; import ViewTable from './../../components/ViewTable';
import ScheduleService from '../../services/schedule.service'; import ScheduleService from '../../services/schedule.service';
class SchedulingUnitList extends Component{ class SchedulingUnitList extends Component{
...@@ -39,32 +38,45 @@ class SchedulingUnitList extends Component{ ...@@ -39,32 +38,45 @@ class SchedulingUnitList extends Component{
defaultSortColumn: [{id: "Name", desc: false}], defaultSortColumn: [{id: "Name", desc: false}],
} }
} }
async getSchedulingUnitList () { async getSchedulingUnitList () {
const bluePrint = await ScheduleService.getSchedulingUnitBlueprint(); let projectname = this.props.projectname;
ScheduleService.getSchedulingUnitDraft().then(scheduleunit =>{ if(projectname){
const output = []; let scheduleunits = await ScheduleService.getSchedulingListByProject(projectname);
var scheduleunits = scheduleunit.data.results; if(scheduleunits){
for( const scheduleunit of scheduleunits){ for(const scheduleunit of scheduleunits){
const blueprintdata = bluePrint.data.results.filter(i => i.draft_id === scheduleunit.id); scheduleunit['actionpath']='/schedulingunit/view/draft/'+scheduleunit.id;
blueprintdata.map(blueP => { scheduleunit['type'] = 'Draft';
blueP.duration = moment.utc(blueP.duration*1000).format('HH:mm:ss'); scheduleunit['duration'] = moment.utc(scheduleunit.duration*1000).format('HH:mm:ss');
blueP.type="Blueprint"; }
blueP['actionpath'] = '/schedulingunit/view/blueprint/'+blueP.id; this.setState({
return blueP; 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({ }else{
scheduleunit: output, isLoading: false 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(){ componentDidMount(){
...@@ -88,6 +100,7 @@ class SchedulingUnitList extends Component{ ...@@ -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 paths - specify the path for navigation - Table will set "id" value for each row in action button
*/} */}
{this.state.scheduleunit && {this.state.scheduleunit &&
<ViewTable <ViewTable
data={this.state.scheduleunit} data={this.state.scheduleunit}
......
...@@ -227,7 +227,31 @@ const ScheduleService = { ...@@ -227,7 +227,31 @@ const ScheduleService = {
console.error(error); console.error(error);
return null; 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; export default ScheduleService;
\ 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