Skip to content
Snippets Groups Projects
Commit bab738b1 authored by Ramesh Kumar's avatar Ramesh Kumar
Browse files

Merge branch 'TMSS-347' into TMSS-348

parents 4a14aaf9 5c72a218
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';
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,17 @@ export class ProjectView extends Component {
<div className="p-field p-grid resource-input-grid">
<ResourceDisplayList projectQuota={this.state.projectQuota} unitMap={this.resourceUnitMap} />
</div>
{/* Show Schedule Unit blongest to Project */}
<div className="p-fluid">
<div className="p-field p-grid">
<div className="col-lg-3 col-md-3 col-sm-12">
<h5 data-testid="resource_alloc">Scheduling Unit - List</h5>
</div>
<div className="col-lg-12 col-md-12 ">
<SchedulingUnitList project={this.state.project.name}/>
</div>
</div>
</div>
</div>
</React.Fragment>
}
......
......@@ -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,41 @@ 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;
//Get SU Draft/Blueprints for the Project ID. This request is coming from view Project page. Otherwise it will show all SU
let project = this.props.project;
if(project){
let scheduleunits = await ScheduleService.getSchedulingListByProject(project);
if(scheduleunits){
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,7 +96,8 @@ class SchedulingUnitList extends Component{
paths - specify the path for navigation - Table will set "id" value for each row in action button
*/}
{this.state.scheduleunit &&
{ (this.state.scheduleunit && this.state.scheduleunit.length>0)?
<ViewTable
data={this.state.scheduleunit}
defaultcolumns={this.state.defaultcolumns}
......@@ -100,6 +109,7 @@ class SchedulingUnitList extends Component{
paths={this.state.paths}
unittest={this.state.unittest}
/>
:<div>No scheduling unit found </div>
}
</>
)
......
......@@ -227,7 +227,52 @@ const ScheduleService = {
console.error(error);
return null;
}
}
},
getSchedulingListByProject: async function(project){
/*
SU - Schedulign Unit
Get Scheduling Unit Draft and It's Blueprints using Project ID. there is no direct API to get SU form project (API request -TMSS-349)
Use Fetch all Scheduling Set and filter Scheduling Set with Project ID => Get SU Draft list and SU Blueprints
*/
try {
let schedulingunitlist = [];
//Fetch all Scheduling Set as there is no API to fetch Scheduling Set for a Project
await this.getSchedulingSets().then(async schedulingsetlist =>{
let schedulingsets = schedulingsetlist.filter(scheduingset => scheduingset.project_id === project)
for(const scheduleset of schedulingsets){
//Fecth SU Drafts for the Scheduling Set
await this.getSchedulingBySet(scheduleset.id).then(async suDraftList =>{
for(const suDraft of suDraftList){
suDraft['actionpath']='/schedulingunit/view/draft/'+suDraft.id;
suDraft['type'] = 'Draft';
suDraft['duration'] = moment.utc(suDraft.duration*1000).format('HH:mm:ss');
schedulingunitlist = schedulingunitlist.concat(suDraft);
//Fetch SU Blue prints for the SU Draft
await this.getBlueprintsByschedulingUnitId(suDraft.id).then(suBlueprintList =>{
for(const suBlueprint of suBlueprintList.data.results){
suBlueprint.duration = moment.utc(suBlueprint.duration*1000).format('HH:mm:ss');
suBlueprint.type="Blueprint";
suBlueprint['actionpath'] = '/schedulingunit/view/blueprint/'+suBlueprint.id;
schedulingunitlist = schedulingunitlist.concat(suBlueprint);
}
})
}
})
}
})
return schedulingunitlist;
} catch (error) {
console.error('[project.services.getSchedulingListByProject]',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
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