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
*/ */
...@@ -57,6 +57,7 @@ export class ProjectView extends Component { ...@@ -57,6 +57,7 @@ export class ProjectView extends Component {
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>
} }
......
...@@ -6,7 +6,6 @@ import ViewTable from './../../components/ViewTable'; ...@@ -6,7 +6,6 @@ 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{
constructor(props){ constructor(props){
...@@ -40,9 +39,21 @@ class SchedulingUnitList extends Component{ ...@@ -40,9 +39,21 @@ class SchedulingUnitList extends Component{
} }
} }
async getSchedulingUnitList () { async getSchedulingUnitList () {
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
});
}
}else{
const bluePrint = await ScheduleService.getSchedulingUnitBlueprint(); const bluePrint = await ScheduleService.getSchedulingUnitBlueprint();
ScheduleService.getSchedulingUnitDraft().then(scheduleunit =>{ ScheduleService.getSchedulingUnitDraft().then(scheduleunit =>{
const output = []; const output = [];
...@@ -66,6 +77,7 @@ class SchedulingUnitList extends Component{ ...@@ -66,6 +77,7 @@ class SchedulingUnitList extends Component{
}); });
}) })
} }
}
componentDidMount(){ componentDidMount(){
this.getSchedulingUnitList(); this.getSchedulingUnitList();
...@@ -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,6 +227,30 @@ const ScheduleService = { ...@@ -227,6 +227,30 @@ 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);
}
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment