Skip to content
Snippets Groups Projects
Commit a25fc71a authored by Nithya's avatar Nithya
Browse files
Changes updated
parent c9ac6aed
No related branches found
No related tags found
1 merge request!196Resolve TMSS-239
...@@ -12,7 +12,7 @@ class CycleList extends Component{ ...@@ -12,7 +12,7 @@ class CycleList extends Component{
this.state = { this.state = {
cyclelist: [], cyclelist: [],
paths: [{ paths: [{
"View": "/cycle", "View": "/cycle/view",
}], }],
projectCategory: ['regular', 'user_shared_support'], projectCategory: ['regular', 'user_shared_support'],
periodCategory: ['long_term'], periodCategory: ['long_term'],
...@@ -21,36 +21,37 @@ class CycleList extends Component{ ...@@ -21,36 +21,37 @@ class CycleList extends Component{
id:"Cycle Code", id:"Cycle Code",
start:"Start Date", start:"Start Date",
stop: "End Date", stop: "End Date",
duration: "Duration", duration: "Duration (Days)",
totalProjects: 'No.of Projects', totalProjects: 'No.of Projects',
longterm : 'LongTerm Projects',
observingTime: 'Lofar Observing Time (Hrs)', observingTime: 'Lofar Observing Time (Hrs)',
processingTime: 'Lofar Processing Time (Hrs)', processingTime: 'Lofar Processing Time (Hrs)',
ltaResources: 'Lofar LTA Resources(TB)', ltaResources: 'Lofar LTA Resources(TB)',
support: 'Lofar Support (Hrs)', support: 'Lofar Support (Hrs)',
longterm : 'Long Term Projects'
} }
], ],
optionalcolumns : [{ optionalcolumns : [{
regularProjects: 'No.of Regular', regularProjects: 'No.of Regular/Project',
observingTimeDDT: 'Lofar Observing Time Commissioning (Hrs)', observingTimeDDT: 'Lofar Observing Time Commissioning (Hrs)',
observingTimePrioA: 'Lofar Observing Time Prio A (Hrs)', observingTimePrioA: 'Lofar Observing Time Prio A (Hrs)',
observingTimePrioB: 'Lofar Observing Time Prio B (Hrs)' observingTimePrioB: 'Lofar Observing Time Prio B (Hrs)'
}], }],
columnclassname: [{ columnclassname: [{
"Cycle Code":"filter-input-50", "Cycle Code":"filter-input-75",
"Duration" : "filter-input-75", "Duration (Days)" : "filter-input-50",
"No.of Projects" : "filter-input-75", "No.of Projects" : "filter-input-50",
"LongTerm Projects" : "filter-input-75", "Lofar Observing Time (Hrs)" : "filter-input-50",
"Lofar Observing Time (hr)" : "filter-input-75", "Lofar Processing Time (Hrs)" : "filter-input-50",
"Lofar Processing Time (hr)" : "filter-input-75", "Lofar LTA Resources(TB)" : "filter-input-50",
"Lofar LTA Resources(TB)" : "filter-input-100", "Lofar Support (Hrs)" : "filter-input-50",
"Lofar Support (hr)" : "filter-input-50", "Long Term Projects" : "filter-input-50",
"No.of Regular" : "filter-input-50", "No.of Regular/Project" : "filter-input-50",
"Lofar Observing Time Commissioning (hr)" : "filter-input-50", "Lofar Observing Time Commissioning (Hrs)" : "filter-input-50",
"Lofar Observing Time Prio A (hr)" : "filter-input-50", "Lofar Observing Time Prio A (Hrs)" : "filter-input-50",
"Lofar Observing Time Prio B (hr)" : "filter-input-50" "Lofar Observing Time Prio B (Hrs)" : "filter-input-50"
}], }],
isprocessed: false, isprocessed: false,
isLoading: true isLoading: true
...@@ -62,24 +63,20 @@ class CycleList extends Component{ ...@@ -62,24 +63,20 @@ class CycleList extends Component{
return UnitConversion.getUIResourceUnit(coversionType,d) return UnitConversion.getUIResourceUnit(coversionType,d)
} }
componentDidMount(){ getCycles(cycles = [], cycleQuota) {
const { projectCategory} = this.state; const { projectCategory} = this.state;
const { periodCategory} = this.state; const { periodCategory} = this.state;
const promises = [];
const promises = [CycleService.getProjects(), CycleService.getCycleQuota(),CycleService.getResources()] cycles.map(cycle => promises.push(CycleService.getCycleById(cycle.name)));
Promise.all(promises).then(responses => { Promise.all(promises).then(responses => {
const projects = responses[0]; const results = cycles;
const cycleQuota = responses[1]; results.map(async (cycle, index) => {
this.setState({ resources: responses[2].data.results }); const projects = responses[index];
CycleService.getAllCycles().then(cyclelist =>{ const regularProjects = projects.filter(project => projectCategory.includes(project.project_category_value));
const results = cyclelist || []; const longterm = projects.filter(project => periodCategory.includes(project.period_category_value));
results.map(cycle => { cycle.duration = UnitConversion.getUIResourceUnit('days', cycle.duration);
const regularProjects = projects.data.results.filter(project => project.cycles_ids.includes(cycle.name) && projectCategory.includes(project.project_category_value));
const longterm = projects.data.results.filter(project => project.cycles_ids.includes(cycle.name) && periodCategory.includes(project.period_category_value));
const timediff = new Date(cycle.stop).getTime() - new Date(cycle.start).getTime();
cycle.duration = timediff / (1000 * 3600 * 24);
cycle.totalProjects = cycle.projects ? cycle.projects.length : 0; cycle.totalProjects = cycle.projects ? cycle.projects.length : 0;
cycle.id = cycle.name ? cycle.name.split(' ').join('') : cycle.name; cycle.id = cycle.name ;
cycle.regularProjects = regularProjects.length; cycle.regularProjects = regularProjects.length;
cycle.longterm = longterm.length; cycle.longterm = longterm.length;
cycle.observingTime = this.conversion((cycleQuota.data.results.find(quota => quota.cycle_id === cycle.name && quota.resource_type_id === 'observing_time') || {value: 0}).value, 'observing_time') cycle.observingTime = this.conversion((cycleQuota.data.results.find(quota => quota.cycle_id === cycle.name && quota.resource_type_id === 'observing_time') || {value: 0}).value, 'observing_time')
...@@ -89,7 +86,7 @@ class CycleList extends Component{ ...@@ -89,7 +86,7 @@ class CycleList extends Component{
cycle.observingTimeDDT = this.conversion((cycleQuota.data.results.find(quota => quota.cycle_id === cycle.name && quota.resource_type_id === 'observing_time_commissioning') || {value: 0}).value, 'observing_time_commissioning') cycle.observingTimeDDT = this.conversion((cycleQuota.data.results.find(quota => quota.cycle_id === cycle.name && quota.resource_type_id === 'observing_time_commissioning') || {value: 0}).value, 'observing_time_commissioning')
cycle.observingTimePrioA = this.conversion((cycleQuota.data.results.find(quota => quota.cycle_id === cycle.name && quota.resource_type_id === 'observing_time_prio_a') || {value: 0}).value, 'observing_time_prio_a') cycle.observingTimePrioA = this.conversion((cycleQuota.data.results.find(quota => quota.cycle_id === cycle.name && quota.resource_type_id === 'observing_time_prio_a') || {value: 0}).value, 'observing_time_prio_a')
cycle.observingTimePrioB = this.conversion((cycleQuota.data.results.find(quota => quota.cycle_id === cycle.name && quota.resource_type_id === 'observing_time_prio_b') || {value: 0}).value, 'observing_time_prio_b') cycle.observingTimePrioB = this.conversion((cycleQuota.data.results.find(quota => quota.cycle_id === cycle.name && quota.resource_type_id === 'observing_time_prio_b') || {value: 0}).value, 'observing_time_prio_b')
cycle.actionpath = "/cycle/view/{cycle_name}"; cycle['actionpath'] = '/cycle/view';
return cycle; return cycle;
}); });
this.setState({ this.setState({
...@@ -97,8 +94,18 @@ class CycleList extends Component{ ...@@ -97,8 +94,18 @@ class CycleList extends Component{
isprocessed: true, isprocessed: true,
isLoading: false isLoading: false
}); });
}) });
}) }
componentDidMount(){
const promises = [CycleService.getCycleQuota(), CycleService.getResources()]
Promise.all(promises).then(responses => {
const cycleQuota = responses[0];
this.setState({ resources: responses[1].data.results });
CycleService.getAllCycles().then(cyclelist => {
this.getCycles(cyclelist, cycleQuota)
});
});
} }
render(){ render(){
...@@ -133,9 +140,13 @@ class CycleList extends Component{ ...@@ -133,9 +140,13 @@ class CycleList extends Component{
paths={this.state.paths} paths={this.state.paths}
/> : <></> /> : <></>
} }
</> </>
) )
} }
} }
export default CycleList export default CycleList
import React, {Component} from 'react';
export class CycleView extends Component {
constructor(props){
super(props)
console.log(this.props)
}
render() {
return (
<h1>CycleView</h1>
);
}
}
export default CycleView;
\ No newline at end of file
...@@ -12,6 +12,7 @@ import {Scheduling} from './Scheduling'; ...@@ -12,6 +12,7 @@ import {Scheduling} from './Scheduling';
import {TaskEdit, TaskView} from './Task'; import {TaskEdit, TaskView} from './Task';
import ViewSchedulingUnit from './Scheduling/ViewSchedulingUnit' import ViewSchedulingUnit from './Scheduling/ViewSchedulingUnit'
import CycleList from './Cycle/list'; import CycleList from './Cycle/list';
import CycleView from './Cycle/view';
export const routes = [ export const routes = [
{ {
...@@ -71,6 +72,11 @@ export const routes = [ ...@@ -71,6 +72,11 @@ export const routes = [
component: CycleList, component: CycleList,
name: 'Cycle List' name: 'Cycle List'
}, },
{
path: "/cycle/view",
component: CycleView,
name: 'Cycle View'
},
]; ];
export const RoutedContent = () => { export const RoutedContent = () => {
......
...@@ -13,9 +13,9 @@ const CycleService = { ...@@ -13,9 +13,9 @@ const CycleService = {
console.error(error); console.error(error);
} }
}, },
getCycle: async function(id) { getCycleById: async function (id) {
try { try {
const url = `/api/cycle/${id}`; const url = `/api/cycle/${id}/project`;
const response = await axios.get(url); const response = await axios.get(url);
return response.data.results; return response.data.results;
} catch (error) { } catch (error) {
...@@ -23,16 +23,6 @@ const CycleService = { ...@@ -23,16 +23,6 @@ const CycleService = {
} }
}, },
getProjects: async function() {
let res = [];
await axios.get('/api/project/')
.then(response => {
res= response;
}).catch(function(error) {
console.error('[cycle.services.project]',error);
});
return res;
},
getCycleQuota: async function () { getCycleQuota: async function () {
let res = []; let res = [];
await axios.get('/api/cycle_quota/') await axios.get('/api/cycle_quota/')
......
const UnitConverter = { const UnitConverter = {
resourceUnitMap: {'time':{display: 'Hours', conversionFactor: 3600, mode:'decimal', minFractionDigits:0, maxFractionDigits: 2 }, resourceUnitMap: {'time':{display: 'Hours', conversionFactor: 3600, mode:'decimal', minFractionDigits:0, maxFractionDigits: 2 },
'bytes': {display: 'TB', conversionFactor: (1024*1024*1024*1024), mode:'decimal', minFractionDigits:0, maxFractionDigits: 3}, 'bytes': {display: 'TB', conversionFactor: (1024*1024*1024*1024), mode:'decimal', minFractionDigits:0, maxFractionDigits: 3},
'number': {display: 'Numbers', conversionFactor: 1, mode:'decimal', minFractionDigits:0, maxFractionDigits: 0}}, 'number': {display: 'Numbers', conversionFactor: 1, mode:'decimal', minFractionDigits:0, maxFractionDigits: 0},
'days': {display: 'Days', conversionFactor: (3600*24), mode:'decimal', minFractionDigits:0, maxFractionDigits: 0}},
getDBResourceUnit: function() { getDBResourceUnit: function() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment