diff --git a/SAS/TMSS/frontend/tmss_webapp/src/__mocks__/project.service.data.js b/SAS/TMSS/frontend/tmss_webapp/src/__mocks__/project.service.data.js index ab49f92eec7585581a21305ed884ead2f8c929a9..114b35b7085b8cb2a3ab809696635554697f319d 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/__mocks__/project.service.data.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/__mocks__/project.service.data.js @@ -1,4 +1,5 @@ + const ProjectServiceMock= { project_categories: [{url: "Regular", value: 'Regular'}, {url: "User Shared Support", value: 'User Shared Support'}], period_categories: [{url: "Single Cycle", value: 'Single Cycle'}, {url: "Long Term", value: 'Long Term'}], @@ -330,4 +331,7 @@ const ProjectServiceMock= { ] } + + + export default ProjectServiceMock; \ No newline at end of file diff --git a/SAS/TMSS/frontend/tmss_webapp/src/routes/Project/create.js b/SAS/TMSS/frontend/tmss_webapp/src/routes/Project/create.js index bc55f4dd20415f977128ce93c86597967b440a99..38fb8b0813bd8adf07687769ea221ec3d1514914 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/routes/Project/create.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/routes/Project/create.js @@ -1,7 +1,6 @@ import React, {Component} from 'react'; import { Redirect } from 'react-router-dom'; import _ from 'lodash'; - import {InputText} from 'primereact/inputtext'; import {InputNumber} from 'primereact/inputnumber'; import {InputTextarea} from 'primereact/inputtextarea'; @@ -21,6 +20,7 @@ import ProjectService from '../../services/project.service'; import UnitConverter from '../../utils/unit.converter'; import UIConstants from '../../utils/ui.constants'; + /** * Component to create a new Project */ @@ -28,6 +28,7 @@ export class ProjectCreate extends Component { constructor(props) { super(props); this.state = { + ltaStorage: [], isLoading: true, dialog: { header: '', detail: ''}, project: { @@ -44,13 +45,16 @@ export class ProjectCreate extends Component { projectCategories: [], resources: [], // Selected Resources for Allocation resourceList: [], // Available Resources for Allocation - cycles: [] + cycles: [], + archive_location:[], + cluster:[] } // Validateion Rules this.formRules = { name: {required: true, message: "Name can not be empty"}, description: {required: true, message: "Description can not be empty"}, - priority_rank: {required: true, message: "Enter Project Rank"} + priority_rank: {required: true, message: "Enter Project Rank"}, + archive_subdirectory: {required:true, message:"Enter Storage Path"} }; this.defaultResourcesEnabled = true; // This property and functionality to be concluded based on PO input this.defaultResources = [{name:'LOFAR Observing Time'}, @@ -92,6 +96,18 @@ export class ProjectCreate extends Component { .then(categories => { this.setState({periodCategories: categories}); }); + Promise.all([ProjectService.getFileSystem(), ProjectService.getCluster()]).then(response => { + const options = []; + response[0].map(fileSystem => { + const cluster = response[1].find(clusterObj => clusterObj.id === fileSystem.cluster_id && clusterObj.archive_site); + if (cluster) { + fileSystem.label =`${cluster.name} - ${fileSystem.name}` + options.push(fileSystem); + } + return fileSystem; + }); + this.setState({archive_location: response[0], ltaStorage: options, cluster: response[1] }); + }); ProjectService.getResources() .then(resourceList => { const defaultResources = this.defaultResources; @@ -170,12 +186,31 @@ export class ProjectCreate extends Component { project[key] = value?parseInt(value):0; break; } + case 'SUB-DIRECTORY': { + const directory = value.split(' ').join('_').toLowerCase(); + project[key] = (directory!=="" && !directory.endsWith('/'))? `${directory}/`: `${directory}`; + break; + } + case 'PROJECT_NAME': { + let directory = project[key]?project[key].split(' ').join('_').toLowerCase():""; + if (!project['archive_subdirectory'] || project['archive_subdirectory'] === "" || + project['archive_subdirectory'] === `${directory}/`) { + directory = value.split(' ').join('_').toLowerCase(); + project['archive_subdirectory'] = `${directory}/`; + } + project[key] = value; + break; + } default: { project[key] = value; break; } } - this.setState({project: project, validForm: this.validateForm(key)}); + let validForm = this.validateForm(key); + if (type==='PROJECT_NAME' & value!=="") { + validForm = this.validateForm('archive_subdirectory'); + } + this.setState({project: project, validForm: validForm}); } /** @@ -314,7 +349,9 @@ export class ProjectCreate extends Component { description: '', trigger_priority: 1000, priority_rank: null, - quota: [] + quota: [], + archive_location: null, + archive_subdirectory:"" }, projectQuota: projectQuota, validFields: {}, @@ -333,21 +370,9 @@ export class ProjectCreate extends Component { if (this.state.redirect) { return <Redirect to={ {pathname: this.state.redirect} }></Redirect> } - return ( <React.Fragment> <Growl ref={(el) => this.growl = el} /> - { /* <div className="p-grid"> - - <div className="p-col-10 p-lg-10 p-md-10"> - <h2>Project - Add</h2> - </div> - <div className="p-col-2 p-lg-2 p-md-2"> - <Link to={{ pathname: '/project'}} tite="Close Edit" style={{float: "right"}}> - <i className="fa fa-window-close" style={{marginTop: "10px"}}></i> - </Link> - </div> - </div> */ } <PageHeader location={this.props.location} title={'Project - Add'} actions={[{icon:'fa-window-close',title:'Click to Close Project', props:{ pathname: '/project'}}]}/> { this.state.isLoading ? <AppLoader /> : <> @@ -365,8 +390,8 @@ export class ProjectCreate extends Component { <InputText className={this.state.errors.name ?'input-error':''} id="projectName" data-testid="name" tooltip="Enter name of the project" tooltipOptions={this.tooltipOptions} maxLength="128" value={this.state.project.name} - onChange={(e) => this.setProjectParams('name', e.target.value)} - onBlur={(e) => this.setProjectParams('name', e.target.value)}/> + onChange={(e) => this.setProjectParams('name', e.target.value,'PROJECT_NAME')} + onBlur={(e) => this.setProjectParams('name', e.target.value,'PROJECT_NAME')}/> <label className={this.state.errors.name?"error":"info"}> {this.state.errors.name ? this.state.errors.name : "Max 128 characters"} </label> @@ -451,9 +476,34 @@ export class ProjectCreate extends Component { {this.state.errors.priority_rank ? this.state.errors.priority_rank : ""} </label> </div> - </div> - - {this.defaultResourcesEnabled && this.state.resourceList && + </div> + <div className="p-field p-grid"> + <label htmlFor="ltaStorage" className="col-lg-2 col-md-2 col-sm-12">LTA Storage Location</label> + <div className="col-lg-3 col-md-3 col-sm-12" > + <Dropdown inputId="ltaStore" + optionValue="url" + tooltip="LTA Storage" tooltipOptions={this.tooltipOptions} + value={this.state.project.archive_location} + options={this.state.ltaStorage} + onChange={(e) => this.setProjectParams('archive_location', e.target.value)} + placeholder="Select LTA Storage" /> + </div> + + <div className="col-lg-1 col-md-1 col-sm-12"></div> + <label htmlFor="ltastoragepath" className="col-lg-2 col-md-2 col-sm-12">LTA Storage Path <span style={{color:'red'}}>*</span> </label> + <div className="col-lg-3 col-md-3 col-sm-12"> + <InputText className={this.state.errors.archive_subdirectory ?'input-error':''} id="StoragePath" data-testid="name" + tooltip="Enter storage relative path" tooltipOptions={this.tooltipOptions} maxLength="1024" + value={this.state.project.archive_subdirectory} + onChange={(e) => this.setProjectParams('archive_subdirectory', e.target.value)} + onBlur={(e) => this.setProjectParams('archive_subdirectory', e.target.value,'SUB-DIRECTORY')}/> + <label className={this.state.errors.archive_subdirectory ?"error":"info"}> + {this.state.errors.archive_subdirectory ? this.state.errors.archive_subdirectory : "Max 1024 characters"} + </label> + </div> + + </div> + {this.defaultResourcesEnabled && this.state.resourceList && <div className="p-fluid"> <div className="p-field p-grid"> <div className="col-lg-2 col-md-2 col-sm-112"> @@ -511,8 +561,7 @@ export class ProjectCreate extends Component { </div> </Dialog> </div> - </React.Fragment> ); } -} \ No newline at end of file +} diff --git a/SAS/TMSS/frontend/tmss_webapp/src/routes/Project/edit.js b/SAS/TMSS/frontend/tmss_webapp/src/routes/Project/edit.js index a1f48c927de8d73a0acbd2090c0892ad09ed6896..bf0a21d382e7be73d805b87a545f74b008007e77 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/routes/Project/edit.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/routes/Project/edit.js @@ -10,7 +10,7 @@ import {Dropdown} from 'primereact/dropdown'; import {MultiSelect} from 'primereact/multiselect'; import { Button } from 'primereact/button'; import {Dialog} from 'primereact/components/dialog/Dialog'; -//import {Growl} from 'primereact/components/growl/Growl'; +import {Growl} from 'primereact/components/growl/Growl'; import {ResourceInputList} from './ResourceInputList'; @@ -26,6 +26,7 @@ export class ProjectEdit extends Component { super(props); this.state = { isLoading: true, + ltaStorage: [], dialog: { header: '', detail: ''}, project: { trigger_priority: 1000, @@ -48,7 +49,8 @@ export class ProjectEdit extends Component { this.formRules = { name: {required: true, message: "Name can not be empty"}, description: {required: true, message: "Description can not be empty"}, - priority_rank: {required: true, message: "Enter Project Rank"} + priority_rank: {required: true, message: "Enter Project Rank"}, + archive_subdirectory: {required:true, message: "Enter Storage Path"} }; this.defaultResources = [{name:'LOFAR Observing Time'}, {name:'LOFAR Observing Time prio A'}, @@ -90,6 +92,18 @@ export class ProjectEdit extends Component { .then(categories => { this.setState({periodCategories: categories}); }); + Promise.all([ProjectService.getFileSystem(), ProjectService.getCluster()]).then(response => { + const options = []; + response[0].map(fileSystem => { + const cluster = response[1].filter(clusterObj => clusterObj.id === fileSystem.cluster_id && clusterObj.archive_site); + if (cluster.length) { + fileSystem.label =`${cluster[0].name} - ${fileSystem.name}` + options.push(fileSystem); + } + return fileSystem; + }); + this.setState({archive_location: response[0], ltaStorage: options, cluster: response[1] }); + }); ProjectService.getResources() .then(resourceList => { this.setState({resourceList: resourceList}); @@ -193,12 +207,31 @@ export class ProjectEdit extends Component { project[key] = value?parseInt(value):0; break; } + case 'SUB-DIRECTORY': { + const directory = value.split(' ').join('_').toLowerCase(); + project[key] = (directory!=="" && !directory.endsWith('/'))? `${directory}/`: `${directory}`; + break; + } + case 'PROJECT_NAME': { + let directory = project[key]?project[key].split(' ').join('_').toLowerCase():""; + if (!project['archive_subdirectory'] || project['archive_subdirectory'] === "" || + project['archive_subdirectory'] === `${directory}/`) { + directory = value.split(' ').join('_').toLowerCase(); + project['archive_subdirectory'] = `${directory}/`; + } + project[key] = value; + break; + } default: { project[key] = value; break; } } - this.setState({project: project, validForm: this.validateForm(key)}); + let validForm = this.validateForm(key); + if (type==='PROJECT_NAME' & value!=="") { + validForm = this.validateForm('archive_subdirectory'); + } + this.setState({project: project, validForm: validForm}); } /** @@ -277,7 +310,9 @@ export class ProjectEdit extends Component { */ saveProject() { if (this.validateForm) { - ProjectService.updateProject(this.props.match.params.id, this.state.project) + const project = { ...this.state.project }; + // project['archive_subdirectory'] = (project['archive_subdirectory'].substr(-1) === '/' ? project['archive_subdirectory'] : `${project['archive_subdirectory']}/`).toLowerCase(); + ProjectService.updateProject(this.props.match.params.id, project) .then(async (project) => { if (project && this.state.project.updated_at !== project.updated_at) { this.saveProjectQuota(project); @@ -357,18 +392,7 @@ export class ProjectEdit extends Component { return ( <React.Fragment> - {/*} <div className="p-grid"> - <Growl ref={(el) => this.growl = el} /> - - <div className="p-col-10 p-lg-10 p-md-10"> - <h2>Project - Edit</h2> - </div> - <div className="p-col-2 p-lg-2 p-md-2"> - <Link to={{ pathname: `/project/view/${this.state.project.name}`}} title="Close Edit" style={{float: "right"}}> - <i className="fa fa-window-close" style={{marginTop: "10px"}}></i> - </Link> - </div> - </div> */} + <Growl ref={(el) => this.growl = el} /> <PageHeader location={this.props.location} title={'Project - Edit'} actions={[{icon:'fa-window-close',title:'Click to Close Project Edit Page', props : { pathname: `/project/view/${this.state.project.name}`}}]}/> { this.state.isLoading ? <AppLoader/> : @@ -381,8 +405,8 @@ export class ProjectEdit extends Component { <InputText className={this.state.errors.name ?'input-error':''} id="projectName" data-testid="name" tooltip="Enter name of the project" tooltipOptions={this.tooltipOptions} maxLength="128" value={this.state.project.name} - onChange={(e) => this.setProjectParams('name', e.target.value)} - onBlur={(e) => this.setProjectParams('name', e.target.value)}/> + onChange={(e) => this.setProjectParams('name', e.target.value, 'PROJECT_NAME')} + onBlur={(e) => this.setProjectParams('name', e.target.value, 'PROJECT_NAME')}/> <label className={this.state.errors.name?"error":"info"}> {this.state.errors.name ? this.state.errors.name : "Max 128 characters"} </label> @@ -468,6 +492,30 @@ export class ProjectEdit extends Component { </label> </div> </div> + <div className="p-field p-grid"> + <label htmlFor="ltaStorage" className="col-lg-2 col-md-2 col-sm-12">LTA Storage Location</label> + <div className="col-lg-3 col-md-3 col-sm-12" > + <Dropdown inputId="ltaStore" optionValue="url" + tooltip="LTA Storage" tooltipOptions={this.tooltipOptions} + value={this.state.project.archive_location} + options={this.state.ltaStorage} + onChange={(e) => {this.setProjectParams('archive_location', e.value)}} + placeholder="Select LTA Storage" /> + </div> + + <div className="col-lg-1 col-md-1 col-sm-12"></div> + <label htmlFor="ltastoragepath" className="col-lg-2 col-md-2 col-sm-12">LTA Storage Path <span style={{color:'red'}}>*</span> </label> + <div className="col-lg-3 col-md-3 col-sm-12"> + <InputText className={this.state.errors.archive_subdirectory ?'input-error':''} id="StoragePath" data-testid="name" + tooltip="Enter storage relative path" tooltipOptions={this.tooltipOptions} maxLength="1024" + value={this.state.project.archive_subdirectory} + onChange={(e) => this.setProjectParams('archive_subdirectory', e.target.value)} + onBlur={(e) => this.setProjectParams('archive_subdirectory', e.target.value,'SUB-DIRECTORY')}/> + <label className={this.state.errors.archive_subdirectory?"error":"info"}> + {this.state.errors.archive_subdirectory? this.state.errors.archive_subdirectory : "Max 1024 characters"} + </label> + </div> + </div> {this.state.resourceList && <div className="p-fluid"> <div className="p-field p-grid"> @@ -531,4 +579,4 @@ export class ProjectEdit extends Component { </React.Fragment> ); } -} \ No newline at end of file +} diff --git a/SAS/TMSS/frontend/tmss_webapp/src/routes/Project/list.js b/SAS/TMSS/frontend/tmss_webapp/src/routes/Project/list.js index 2d64cfce1891e9da59223f0c45832cd087ca5b49..2072bf74706c387a9b84682cd48ed59cb53850a8 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/routes/Project/list.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/routes/Project/list.js @@ -14,7 +14,9 @@ export class ProjectList extends Component{ "name":"Name / Project Code", "status":"Status" , "project_category_value":"Category of Project", - "description":"Description" + "description":"Description", + "archive_location_label":"LTA Storage Location", + "archive_subdirectory":"LTA Storage Path" }], optionalcolumns: [{ "priority_rank":"Project Priority", @@ -29,6 +31,7 @@ export class ProjectList extends Component{ "LTA Storage":"LTA storage (TB)", "Number of triggers":"Number of Triggers", "actionpath":"actionpath", + }], columnclassname: [{ "Observing time (Hrs)":"filter-input-50", @@ -43,22 +46,43 @@ export class ProjectList extends Component{ "Trigger Priority":"filter-input-50", "Category of Period":"filter-input-50", "Cycles":"filter-input-100", + "LTA Storage Location":"filter-input-100", + "LTA Storage Path":"filter-input-100" }], defaultSortColumn: [{id: "Name / Project Code", desc: false}], isprocessed: false, isLoading: true } + this.getPopulatedProjectList = this.getPopulatedProjectList.bind(this); } - getProjectList(cycleid){ - CycleService.getProjectsByCycle(cycleid) - .then(async (projects) => { - await ProjectService.getUpdatedProjectQuota(projects) - .then( async projectlist => { - this.setState({ - projectlist: projectlist, - isprocessed: true, - isLoading: false - }) + + getPopulatedProjectList(cycleId) { + Promise.all([ProjectService.getFileSystem(), ProjectService.getCluster()]).then(async(response) => { + const options = {}; + response[0].map(fileSystem => { + const cluster = response[1].filter(clusterObj => { return (clusterObj.id === fileSystem.cluster_id && clusterObj.archive_site);}); + if (cluster.length) { + fileSystem.label =`${cluster[0].name} - ${fileSystem.name}` + options[fileSystem.url] = fileSystem; + } + return fileSystem; + }); + let projects = []; + if (cycleId) { + projects = await CycleService.getProjectsByCycle(cycleId); + } else { + projects = await ProjectService.getProjectList(); + } + projects = await ProjectService.getUpdatedProjectQuota(projects); + let list = projects.map(project => { + project.archive_location_label = (options[project.archive_location] || {}).label; + return project; + }); + this.setState({ + projectlist: list, + isprocessed: true, + isLoading: false, + ltaStorage: options }) }); } @@ -66,23 +90,7 @@ export class ProjectList extends Component{ componentDidMount(){ // Show Project for the Cycle, This request will be coming from Cycle View. Otherwise it is consider as normal Project List. let cycle = this.props.cycle; - if(cycle){ - this.getProjectList(cycle); - }else{ - // for Unit test, Table data - this.unittestDataProvider(); - ProjectService.getProjectList() - .then(async (projects) => { - await ProjectService.getUpdatedProjectQuota(projects) - .then( async projlist => { - this.setState({ - projectlist: projlist, - isprocessed: true, - isLoading: false - }) - }) - }); - } + this.getPopulatedProjectList(cycle); } render(){ @@ -155,4 +163,3 @@ export class ProjectList extends Component{ } } } - 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 dbea143e575af3d136dfed6a2e2146741e628bd4..9498a81b929948705bc5c2eb31ae36d6750916b9 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/routes/Project/view.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/routes/Project/view.js @@ -7,7 +7,6 @@ import { Chips } from 'primereact/chips'; import { TieredMenu } from 'primereact/tieredmenu'; import ResourceDisplayList from './ResourceDisplayList'; - import AppLoader from '../../layout/components/AppLoader'; import PageHeader from '../../layout/components/PageHeader'; import ProjectService from '../../services/project.service'; @@ -21,6 +20,7 @@ export class ProjectView extends Component { constructor(props) { super(props); this.state = { + ltaStorage: [], isLoading: true, project:'', }; @@ -45,6 +45,17 @@ export class ProjectView extends Component { } else { this.setState({redirect: "/not-found"}); } + Promise.all([ProjectService.getFileSystem(), ProjectService.getCluster()]).then(response => { + const options = {}; + response[0].map(fileSystem => { + const cluster = response[1].filter(clusterObj => clusterObj.id === fileSystem.cluster_id && clusterObj.archive_site); + if (cluster.length) { + options[fileSystem.url] = `${cluster[0].name} - ${fileSystem.name}` + } + return fileSystem; + }); + this.setState({archive_location: response[0], ltaStorage: options, cluster: response[1] }); + }); } /** @@ -100,28 +111,6 @@ export class ProjectView extends Component { return ( <React.Fragment> - { /*} <div className="p-grid"> - <div className="p-col-10 p-lg-10 p-md-10"> - <h2>Project - Details </h2> - </div> - { this.state.project && - <div className="p-col-2 p-lg-2 p-md-2"> - <Link to={{ pathname: `/project`}} title="Close View" style={{float: "right"}}> - <i className="fa fa-times" style={{marginTop: "10px", marginLeft: "5px"}}></i> - </Link> - <Link to={{ pathname: `/project/edit/${this.state.project.name}`, state: {id: this.state.project?this.state.project.name:''}}} title="Edit Project" - style={{float: "right"}}> - <i className="fa fa-edit" style={{marginTop: "10px", marginLeft: "5px"}}></i> - </Link> - <TieredMenu model={this.menuOptions} popup ref={el => this.optionsMenu = el} /> - <button className="p-link" style={{float: "right"}}> - <i className="fa fa-bars" label="Toggle Columns" style={{marginTop: "10px", marginLeft: "5px"}} - onMouseOver={(e) => this.optionsMenu.toggle(e)} /> - </button> - - </div> - } - </div> */} <TieredMenu model={this.menuOptions} popup ref={el => this.optionsMenu = el} /> <PageHeader location={this.props.location} title={'Project - View'} actions={[ {icon:'fa-bars',title: '', type:'button', @@ -166,6 +155,12 @@ export class ProjectView extends Component { <label className="col-lg-2 col-md-2 col-sm-12">Project Rank</label> <span className="col-lg-4 col-md-4 col-sm-12">{this.state.project.priority_rank}</span> </div> + <div className="p-grid"> + <label className="col-lg-2 col-md-2 col-sm-12">LTA Storage Location</label> + <span className="col-lg-4 col-md-4 col-sm-12">{this.state.ltaStorage[this.state.project.archive_location]}</span> + <label className="col-lg-2 col-md-2 col-sm-12">LTA Storage Path</label> + <span className="col-lg-4 col-md-4 col-sm-12">{this.state.project.archive_subdirectory }</span> + </div> <div className="p-fluid"> <div className="p-field p-grid"> <div className="col-lg-3 col-md-3 col-sm-12"> diff --git a/SAS/TMSS/frontend/tmss_webapp/src/services/project.service.js b/SAS/TMSS/frontend/tmss_webapp/src/services/project.service.js index 18598cc1c90e304931d4f4e55c1a4c39a4d6c69e..76ccb93de8442f9ea043f0d41f142f3a95b7e3c2 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/services/project.service.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/services/project.service.js @@ -25,6 +25,24 @@ const ProjectService = { console.error(error); } }, + getFileSystem: async function(){ + try { + const url = `/api/filesystem/`; + const response = await axios.get(url); + return response.data.results; + } catch (error) { + console.error(error); + } + }, + getCluster:async function(){ + try { + const url = `/api/cluster/`; + const response = await axios.get(url); + return response.data.results; + } catch (error) { + console.error(error); + } + }, getResources: async function() { try { // const url = `/api/resource_type/?ordering=name`; diff --git a/SAS/TMSS/frontend/tmss_webapp/src/services/project.services.js b/SAS/TMSS/frontend/tmss_webapp/src/services/project.services.js new file mode 100644 index 0000000000000000000000000000000000000000..77483cb57de2f45e0c8c304c69c03a3146da534c --- /dev/null +++ b/SAS/TMSS/frontend/tmss_webapp/src/services/project.services.js @@ -0,0 +1,162 @@ +import _ from 'lodash'; + + +const axios = require('axios'); + + +// axios.defaults.baseURL = 'http://localhost:3000/api'; + +const ProjectServices = { + + getFileSystem: async function(){ + try { + const url = `/filesystem/`; + const response = await axios.get(url); + return [ + { + "id": 1, + "url": "http://localhost:3000/api/filesystem/1", + "capacity": 3600000000000000, + "cluster": "http://localhost:3000/api/cluster/1", + "cluster_id": 1, + "created_at": "2020-08-26T08:40:24.880194", + "description": "", + "name": "LustreFS", + "tags": [], + "updated_at": "2020-08-26T08:40:24.880239" + }, + { + "id": 2, + "url": "http://localhost:3000/api/filesystem/2", + "capacity": 360000000000000, + "cluster": "http://localhost:3000/api/cluster/1", + "cluster_id": 1, + "created_at": "2020-08-26T13:06:20.442543", + "description": "new storage", + "name": "Lofar Storage (SARA)", + "tags": [], + "updated_at": "2020-08-26T13:06:20.442591" + }, + { + "id": 3, + "url": "http://localhost:3000/api/filesystem/3", + "capacity": 360000000000000, + "cluster": "http://localhost:3000/api/cluster/1", + "cluster_id": 1, + "created_at": "2020-08-26T13:06:21.060517", + "description": "new storage", + "name": "Lofar Test Storage (SARA)", + "tags": [], + "updated_at": "2020-08-26T13:06:21.060545" + }, + { + "id": 4, + "url": "http://localhost:3000/api/filesystem/4", + "capacity": 360000000000000, + "cluster": "http://localhost:3000/api/cluster/1", + "cluster_id": 1, + "created_at": "2020-08-26T13:06:22.776714", + "description": "new storage", + "name": "Sara", + "tags": [], + "updated_at": "2020-08-26T13:06:22.776760" + }, + { + "id": 5, + "url": "http://localhost:3000/api/filesystem/5", + "capacity": 360000000000000, + "cluster": "http://localhost:3000/api/cluster/1", + "cluster_id": 1, + "created_at": "2020-08-26T13:12:22.651907", + "description": "new storage", + "name": "Lofar Storage (Jülich)", + "tags": [], + "updated_at": "2020-08-26T13:12:22.651953" + }, + { + "id": 6, + "url": "http://localhost:3000/api/filesystem/6", + "capacity": 360000000000000, + "cluster": "http://localhost:3000/api/cluster/1", + "cluster_id": 1, + "created_at": "2020-08-26T13:12:24.505652", + "description": "new storage", + "name": "Lofar User Disk Storage (SARA)", + "tags": [], + "updated_at": "2020-08-26T13:12:24.505701" + }, + { + "id": 7, + "url": "http://localhost:3000/api/filesystem/1", + "capacity": 360000000000000, + "cluster": "http://localhost:3000/api/cluster/3", + "cluster_id": 3, + "created_at": "2020-08-26T13:12:24.505652", + "description": "new storage", + "name": "Lofar Storage (Poznan)", + "tags": [], + "updated_at": "2020-08-26T13:12:24.505701" + }, + { + "id": 8, + "url": "http://localhost:3000/api/filesystem/1", + "capacity": 360000000000000, + "cluster": "http://localhost:3000/api/cluster/3", + "cluster_id": 3, + "created_at": "2020-08-26T13:12:24.505652", + "description": "new storage", + "name": "Lofar (Poznan)", + "tags": [], + "updated_at": "2020-08-26T13:12:24.505701" + } + ]; + } catch (error) { + console.error(error); + } + }, + getCluster:async function(){ + try { + const url = `/cluster/`; + const response = await axios.get(url); + // return response.data.results; + return [{ + "id": 1, + "url": "http://localhost:3000/api/cluster/1", + "created_at": "2020-08-26T08:40:24.876529", + "description": "", + "location": "CIT", + "name": "CEP4", + "tags": [], + "archieve_site":false, + "updated_at": "2020-08-26T08:40:24.876560" + }, + { + "id": 2, + "url": "http://localhost:3000/api/cluster/2", + "created_at": "2020-08-26T08:40:24.876529", + "description": "", + "location": "CSK", + "name": "CEP4", + "tags": [], + "archieve_site":false, + "updated_at": "2020-08-26T08:40:24.876560" + }, + { + "id": 3, + "url": "http://localhost:3000/api/cluster/3", + "created_at": "2020-08-26T08:40:24.876529", + "description": "", + "location": "CSK", + "name": "ABC", + "tags": [], + "archive_site":true, + "updated_at": "2020-08-26T08:40:24.876560" + } + + ] + } catch (error) { + console.error(error); + } + }, +} +export default ProjectServices; \ No newline at end of file