From a9b34fac12ca1e825d4b3f81a01a071f593b19ad Mon Sep 17 00:00:00 2001 From: unknown <n.santhanam@redkarma.eu> Date: Fri, 11 Sep 2020 09:51:06 +0530 Subject: [PATCH] TMSS-319 Changes updated. --- .../tmss_webapp/src/routes/Project/create.js | 50 ++++++++----------- .../tmss_webapp/src/routes/Project/edit.js | 41 +++++---------- .../tmss_webapp/src/routes/Project/list.js | 18 +++---- .../tmss_webapp/src/routes/Project/view.js | 34 ++----------- 4 files changed, 46 insertions(+), 97 deletions(-) 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 6e7e5a74313..68259927abb 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/routes/Project/create.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/routes/Project/create.js @@ -17,10 +17,9 @@ import AppLoader from '../../layout/components/AppLoader'; import PageHeader from '../../layout/components/PageHeader'; import CycleService from '../../services/cycle.service'; import ProjectService from '../../services/project.service'; -//import ProjectServices from '../../services/project.services'; import UnitConverter from '../../utils/unit.converter'; import UIConstants from '../../utils/ui.constants'; -import { string } from 'prop-types'; + /** * Component to create a new Project @@ -98,11 +97,11 @@ export class ProjectCreate extends Component { }); Promise.all([ProjectService.getFileSystem(), ProjectService.getCluster()]).then(response => { const options = []; - response[0].map(i => { - const cluster = response[1].filter(j => j.id === i.cluster_id && j.archive_site); - if (cluster.length) { - i.label =`${cluster[0].name} - ${i.name}` - options.push(i); + 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); } }); this.setState({archive_location: response[0], ltaStorage: options, cluster: response[1] }); @@ -186,10 +185,17 @@ export class ProjectCreate extends Component { break; } case 'SUB-DIRECTORY': { - const directory = value.split(' ').join('_') ; + const directory = value.replaceAll(' ', '_'); project[key] = (directory.substr(-1) === '/' ? directory : `${directory}/`).toLowerCase(); break; } + case 'PROJECT_NAME': { + project[key] = value; + const directory = value.split(' ').join('_'); + project['archive_subdirectory'] = (directory.substr(-1) === '/' ? directory : `${directory}/`).toLowerCase(); + // this.setState({ ltaStorageEnable: true }); + break; + } default: { project[key] = value; break; @@ -356,17 +362,6 @@ export class ProjectCreate extends Component { 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 /> : <> @@ -384,8 +379,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> @@ -475,7 +470,7 @@ export class ProjectCreate extends Component { <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" // Need to pass key name from object whatever we need to pass to api + optionValue="url" tooltip="LTA Storage" tooltipOptions={this.tooltipOptions} value={this.state.project.archive_location} options={this.state.ltaStorage} @@ -486,15 +481,12 @@ export class ProjectCreate extends Component { <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 </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 project name as storage relative path" tooltipOptions={this.tooltipOptions} maxLength="128" - value={this.state.project.archieve_subdirectory} + <InputText disabled className={this.state.errors.archive_subdirectory ?'input-error':''} id="StoragePath" data-testid="name" + tooltip="Enter storage relative path" tooltipOptions={this.tooltipOptions} maxLength="128" + value={this.state.project.archive_subdirectory} onChange={(e) => this.setProjectParams('archive_subdirectory', e.target.value, 'SUB-DIRECTORY')} onBlur={(e) => this.setProjectParams('archive_subdirectory', e.target.value,'SUB-DIRECTORY')}/> - <label className={this.state.errors.archieve_subdirectory?"error":"info"}> - {this.state.errors.archieve_subdirectory? this.state.archieve_subdirectory : "Max 128 characters"} - </label> - </div> + </div> </div> {this.defaultResourcesEnabled && this.state.resourceList && <div className="p-fluid"> 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 39b660274b1..380f13379f8 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'; @@ -18,7 +18,6 @@ import AppLoader from '../../layout/components/AppLoader'; import PageHeader from '../../layout/components/PageHeader'; import CycleService from '../../services/cycle.service'; import ProjectService from '../../services/project.service'; -//import ProjectServices from '../../services/project.services'; import UnitConverter from '../../utils/unit.converter'; import UIConstants from '../../utils/ui.constants'; @@ -94,11 +93,11 @@ export class ProjectEdit extends Component { }); Promise.all([ProjectService.getFileSystem(), ProjectService.getCluster()]).then(response => { const options = []; - response[0].map(i => { - const cluster = response[1].filter(j => j.id === i.cluster_id && j.archive_site); + response[0].map(fileSystem => { + const cluster = response[1].filter(clusterObj => clusterObj.id === fileSystem.cluster_id && clusterObj.archive_site); if (cluster.length) { - i.label =`${cluster[0].name} - ${i.name}` - options.push(i); + fileSystem.label =`${cluster[0].name} - ${fileSystem.name}` + options.push(fileSystem); } }); this.setState({archive_location: response[0], ltaStorage: options, cluster: response[1] }); @@ -206,16 +205,9 @@ export class ProjectEdit extends Component { project[key] = value?parseInt(value):0; break; } - case 'SUB-DIRECTORY': { - const directory = value.split(' ').join('_'); - project[key] = directory.substr(-1) === '/' ? directory : `${directory}/`; - break; - } case 'PROJECT_NAME': { project[key] = value; - const directory = value.split(' ').join('_'); - project['archive_subdirectory'] = (directory.substr(-1) === '/' ? directory : `${directory}/`).toLowerCase(); - this.setState({ ltaStorageEnable: true }); + project['archive_subdirectory'] = (value.substr(-1) === '/' ? value.slice(0, -1) : value).toLowerCase(); break; } default: { @@ -302,7 +294,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); @@ -382,18 +376,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/> : @@ -496,7 +479,7 @@ export class ProjectEdit extends Component { <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" disabled + <Dropdown inputId="ltaStore" optionValue="url" tooltip="LTA Storage" tooltipOptions={this.tooltipOptions} value={this.state.project.archive_location} options={this.state.ltaStorage} @@ -507,7 +490,7 @@ export class ProjectEdit extends Component { <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 </label> <div className="col-lg-3 col-md-3 col-sm-12"> - <InputText disabled={!this.state.ltaStorageEnable} className={this.state.errors.archive_subdirectory ?'input-error':''} id="StoragePath" data-testid="name" + <InputText className={this.state.errors.archive_subdirectory ?'input-error':''} id="StoragePath" data-testid="name" tooltip="Enter storage relative path" tooltipOptions={this.tooltipOptions} maxLength="128" value={this.state.project.archive_subdirectory} onChange={(e) => this.setProjectParams('archive_subdirectory', e.target.value, 'SUB-DIRECTORY')} 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 e63d55106b0..722885fdae7 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/routes/Project/list.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/routes/Project/list.js @@ -1,8 +1,6 @@ import React, {Component} from 'react'; import ProjectService from '../../services/project.service'; -//import ProjectServices from '../../services/project.services'; import ViewTable from '../../components/ViewTable'; -// import { Link } from 'react-router-dom/cjs/react-router-dom.min'; import AppLoader from '../../layout/components/AppLoader'; import PageHeader from '../../layout/components/PageHeader'; @@ -19,8 +17,8 @@ export class ProjectList extends Component{ "status":"Status" , "project_category_value":"Category of Project", "description":"Description", - "archive_location_label":"Archieve Location", - "archive_subdirectory":"Archieve Subdirectory" + "archive_location_label":"LTA Storage Location", + "archive_subdirectory":"LTA Storage Path" }], optionalcolumns: [{ "priority_rank":"Project Priority", @@ -50,8 +48,8 @@ export class ProjectList extends Component{ "Trigger Priority":"filter-input-50", "Category of Period":"filter-input-50", "Cycles":"filter-input-100", - " Archieve Location":"filter-input-100", - "Archieve Subdirectory":"filter-input-100" + "LTA Storage Location":"filter-input-100", + "LTA Storage Path":"filter-input-100" }], defaultSortColumn: [{id: "Name / Project Code", desc: false}], isprocessed: false, @@ -64,11 +62,11 @@ export class ProjectList extends Component{ this.unittestDataProvider(); Promise.all([ProjectService.getFileSystem(), ProjectService.getCluster()]).then(response => { const options = {}; - response[0].map(i => { - const cluster = response[1].filter(j => j.id === i.cluster_id && j.archive_site); + response[0].map(fileSystem => { + const cluster = response[1].filter(clusterObj => clusterObj.id === fileSystem.cluster_id && clusterObj.archive_site); if (cluster.length) { - i.label =`${cluster[0].name} - ${i.name}` - options[i.url] = i; + fileSystem.label =`${cluster[0].name} - ${fileSystem.name}` + options[fileSystem.url] = fileSystem; } }); ProjectService.getProjectList() 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 076f478c19b..ae68d518969 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/routes/Project/view.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/routes/Project/view.js @@ -7,11 +7,9 @@ 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'; -//import ProjectServices from '../../services/project.services'; import UnitConverter from '../../utils/unit.converter'; /** @@ -49,10 +47,10 @@ export class ProjectView extends Component { } Promise.all([ProjectService.getFileSystem(), ProjectService.getCluster()]).then(response => { const options = {}; - response[0].map(i => { - const cluster = response[1].filter(j => j.id === i.cluster_id && j.archive_site); + response[0].map(fileSystem => { + const cluster = response[1].filter(clusterObj => clusterObj.id === fileSystem.cluster_id && clusterObj.archive_site); if (cluster.length) { - options[i.url] = `${cluster[0].name} - ${i.name}` + options[fileSystem.url] = `${cluster[0].name} - ${fileSystem.name}` } }); this.setState({archive_location: response[0], ltaStorage: options, cluster: response[1] }); @@ -111,28 +109,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', @@ -178,9 +154,9 @@ export class ProjectView extends Component { <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">Archieve Location</label> + <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">Archieve SubDirectory</label> + <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"> -- GitLab