diff --git a/SAS/TMSS/frontend/tmss_webapp/src/authenticate/permission.stack.handler.js b/SAS/TMSS/frontend/tmss_webapp/src/authenticate/permission.stack.handler.js index a99a197a0e50b9e777c233a0e398319cb662c73d..3035ca5352ebf159800930b6b2a897e3059eb37d 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/authenticate/permission.stack.handler.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/authenticate/permission.stack.handler.js @@ -3,34 +3,37 @@ import AuthService from '../services/auth.service'; import _ from 'lodash'; import axios from 'axios'; +let isPermissionValidated = false const PermissionStackUtil = { + + /** * Get current user permission from API * @param {*} loadPermission * @returns */ getPermissions: async(loadPermission) => { - let permissionStack = {}; + console.log("getPermissions", isPermissionValidated) + let permissionStack = {} + permissionStack = localStorage.getItem("permissionStack"); + if (permissionStack) { + permissionStack = JSON.parse(permissionStack); + if (permissionStack?.token === axios.defaults.headers.common['Authorization']) + { + if(permissionStack?.token!==undefined) { + console.log("Returning with permissionstack",permissionStack) + loadPermission=false + } + } + } + if (loadPermission) { permissionStack = await PermissionStackUtil.getAPIBasedPermission(); - //Use this code if API role permission is not ready for demo - /* let user = Auth.getUser(); - user = user?user.name:""; - if (user === 'scientist' ) { - permissionStack['project'] = {create: true, edit: false, delete: true}; - permissionStack['scheduleunit'] = {create: true, edit: false, delete: true, createsub: false, autodeletion:false, - copysu:false, excelview:true, cleanuptask:false, cancelsu:false, viewworkflow:true,dataproduct: true,}; - } else if (user === 'operator' ) { - permissionStack['project'] = {create: true, edit: false, delete: false}; - permissionStack['scheduleunit'] = {create: true, edit: false, delete: false, createsub: false, autodeletion:true, - copysu:true, excelview:false, cleanuptask:true, cancelsu:false, viewworkflow:true,dataproduct: false,}; - } else { - permissionStack['project'] = {create: true, edit: false, delete: true}; - permissionStack['scheduleunit'] = {create: true, edit: false, delete: true, createsub: false, autodeletion:false, - copysu:false, excelview:true, cleanuptask:false, cancelsu:false, viewworkflow:true,dataproduct: true,}; - } */ - } - AuthStore.dispatch({ type: 'loadpermission', payload: permissionStack}); + console.log("permissionStack after retrieval",isPermissionValidated,permissionStack) + permissionStack.token = axios.defaults.headers.common['Authorization']; + localStorage.setItem("permissionStack", JSON.stringify(permissionStack)); + } + AuthStore.dispatch({ type: 'loadpermission', payload: permissionStack}); return permissionStack; }, async getAPIBasedPermission() { diff --git a/SAS/TMSS/frontend/tmss_webapp/src/components/FormActionbar.js b/SAS/TMSS/frontend/tmss_webapp/src/components/FormActionbar.js index 51da6a4d5482f039ad8448e5ce4b04a887516167..d8ab08210f9e3899e6bcac36a37f06a98cd9dfc8 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/components/FormActionbar.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/components/FormActionbar.js @@ -2,7 +2,7 @@ import { Component } from 'react'; import { Button } from 'primereact/button'; import { Checkbox } from 'primereact/checkbox'; import UIConstants from '../utils/ui.constants'; - +import PropTypes from 'prop-types'; export default class FormActionbar extends Component { constructor(props) { super(props); @@ -13,6 +13,18 @@ export default class FormActionbar extends Component { this.tooltipOptions = UIConstants.tooltipOptions; } + + + static propTypes = { + createAnother: PropTypes.bool, + submitTitle:PropTypes.string, + onSubmit:PropTypes.func, + disableSaveBtn:PropTypes.bool, // the enableSaveBtn was badly named, it was actually is written in the code as means disable save button hence a rename. + onCancel:PropTypes.func, + createAnotherCallBack:PropTypes.func, + tooltip:PropTypes.string, + } + /** * * @param {*} e @@ -23,7 +35,6 @@ export default class FormActionbar extends Component { render() { return ( - <> <div className='footer-short-div' > {this.props.createAnother !== undefined && <> @@ -35,10 +46,10 @@ export default class FormActionbar extends Component { <Button label="Save" className="p-button-primary p-button--small act-btn-save" id="save-btn" data-testid="save-btn" title={this.props.submitTitle} icon="pi pi-check" style={{marginRight: "1em", color: "white", marginTop: "5px", paddingBottom: "5px"}} - onClick={this.props.onSubmit} disabled={this.props.enableSaveBtn}/> + onClick={this.props.onSubmit} disabled={this.props.disableSaveBtn}/> <Button label="Cancel" className="p-button--small act-btn-cancel" icon="pi pi-times" onClick={this.props.onCancel}/> </div> - </> ); } -} \ No newline at end of file +} + diff --git a/SAS/TMSS/frontend/tmss_webapp/src/components/JSONEditor/JEditor.js b/SAS/TMSS/frontend/tmss_webapp/src/components/JSONEditor/JEditor.js index 1565cce1d0d563868a1be233a7d07f23e8ff961e..96f6f98a20ce230bbe882195b1f7b04c85c83cbe 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/components/JSONEditor/JEditor.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/components/JSONEditor/JEditor.js @@ -400,7 +400,14 @@ function Jeditor(props) { singlePulseSearch = (startVal['single_pulse_search'])?true:false; editorOptions.startval = updateInput(startVal); } - editor = new JSONEditor(element, editorOptions); + let editor + try { + editor = new JSONEditor(element, editorOptions); + } + catch (ex) { + console.info("Failure in Creating editor",ex); + } + // Remove loader div after editor intialization const loadingElement = document.getElementById(props.id?`${props.id}_loader`:'editor_holder_loader'); diff --git a/SAS/TMSS/frontend/tmss_webapp/src/layout/components/PageActionMenu.js b/SAS/TMSS/frontend/tmss_webapp/src/layout/components/PageActionMenu.js index 1f4b3c4c03a3418dabbf580fc3af9bdb7201a132..3fa56ea0f3edbfbe7e3b90d510c5bba78621a9f9 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/layout/components/PageActionMenu.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/layout/components/PageActionMenu.js @@ -2,6 +2,7 @@ import { Link } from "react-router-dom"; import { Button } from 'primereact/button'; import { Dropdown } from 'primereact/dropdown'; +import { Calendar } from 'primereact/calendar'; const PageActionMenu = ({ actions, className }) => { const onClickLink = (action) => { if (action.link) { @@ -39,7 +40,7 @@ const PageActionMenu = ({ actions, className }) => { return <div className={"page-action-menu " + className}> - {(actions || []).map((action) => { + {(actions || []).map((action,index) => { if (action.type === 'buttonv2') { return ( <Button key={action.title + '_page_header'} title={action.title || ''} @@ -66,14 +67,26 @@ const PageActionMenu = ({ actions, className }) => { </button> ); case 'divider': - return (<span className="action-divider" key={action.title}></span>); + return (<span className="action-divider" key={index}></span>); case 'element': return ( - <div key={`index`} className={action.classes} dangerouslySetInnerHTML={{ __html: action.element }} /> + <div key={index} className={action.classes} dangerouslySetInnerHTML={{ __html: action.element }} /> ) case 'dropdown': - return (<div className={action.classes} key={action.title}> <span className="dropdown-title">{action.title} </span><Dropdown value={action.selected} onChange={(e) => setSelected(e, action)} options={action.options} optionValue="value" optionLabel="label" className="w-full md:w-14rem" /></div>) + if (!action.options) { + return <div className={action.classes} key={action.title}> <span className="dropdown-title">{action.title} </span> <i className="pi pi-spin pi-hourglass"></i> </div> + } + + if (action.optionsvalue) { + return (<div className={action.classes} key={action.title}> <span className="dropdown-title">{action.title} </span><Dropdown value={action.selected} onChange={(e) => setSelected(e, action)} options={action.options} optionValue={action.optionvalue} optionLabel={action.optionlabel} className="w-full md:w-14rem" /></div>) + } + else { + return (<div className={action.classes} key={action.title}> <span className="dropdown-title">{action.title} </span><Dropdown value={action.selected} onChange={(e) => setSelected(e, action)} options={action.options} optionLabel={action.optionlabel} className="w-full md:w-14rem" placeholder={action.optionSelectionLabel}/></div>) + } + + case 'dropdownb': + case 'ext_link': return ( <a href={action.props.pathname} title={action.title || ''} key={action.title} @@ -89,7 +102,10 @@ const PageActionMenu = ({ actions, className }) => { <span key={action.title + '_page_header'} className={action.className} title={action.title || ''}>{action.content}</span> ); - + case 'calendar': + return ( + <div key={`index`}><span>{action.title}</span> <Calendar value={action.selected} onChange={(e) => setSelected(e, action)} dateFormat="yy-mm-dd" showIcon className={action.className} /> </div> + ) default: return ( diff --git a/SAS/TMSS/frontend/tmss_webapp/src/layout/components/PageHeader.js b/SAS/TMSS/frontend/tmss_webapp/src/layout/components/PageHeader.js index 3e6f9209caf8163aae1a9ca12a20ef28f7d72c11..46f217f1ca14774346f3816ab6573b3f83e70b06 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/layout/components/PageHeader.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/layout/components/PageHeader.js @@ -30,7 +30,7 @@ const PageHeader = ({title, subTitle, actions, className, ...props}) => { <h2 className="page-title">{title || page.title}</h2> {(page.subTitle || subTitle) && <h6 className="page-subtitle">{subTitle || page.subTitle}</h6>} </div> - <PageActionMenu actions={actions}/> + <PageActionMenu actions={actions} className={"page-actions" + className || ""} /> </div> ); } diff --git a/SAS/TMSS/frontend/tmss_webapp/src/layout/sass/_pageheader.scss b/SAS/TMSS/frontend/tmss_webapp/src/layout/sass/_pageheader.scss index 1fae2ac8ff9025e5d0e94e175413ea58eeb44ee8..8a43ae5b1578fdf2b941cb83000a40e559150a2d 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/layout/sass/_pageheader.scss +++ b/SAS/TMSS/frontend/tmss_webapp/src/layout/sass/_pageheader.scss @@ -27,6 +27,14 @@ margin-top: 5px; } +.page-actionsdefaultpageHeader{ + display: flex; + + button { + height: 30px; + } +} + .subsystem { font-size: 12px !important; padding: 0.3rem 0.5rem; diff --git a/SAS/TMSS/frontend/tmss_webapp/src/layout/sass/station.scss b/SAS/TMSS/frontend/tmss_webapp/src/layout/sass/station.scss index 9d328042a9d92866a38c6b6b37ab2a70436fefec..d577a3dd70e7127ad3fe6ffde6834d272bb55793 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/layout/sass/station.scss +++ b/SAS/TMSS/frontend/tmss_webapp/src/layout/sass/station.scss @@ -4,9 +4,37 @@ .StationTable { } + + + .StationListWrap{ display: flex; } +.ConstraintsStart{ + width: 100%; + + justify-content: center; +} + +.Progress{ + margin-left: 10px; +} +.ConstraintsHeader { + display: flex; + flex-direction: row; + padding-bottom: 5px; + padding-left:25px; + border-bottom: 1px solid grey; + .p-calendar{ + + button { + margin-left: 0px; + } + } + +} + + .GeoMap { height:calc(#{$vh * 100} - 11.5em); @@ -53,6 +81,16 @@ } +.BluePrintLoading { + margin-left:25px; +} +.BoxLabel +{ + margin-left:25px; + margin-right: 5px; + line-height: 29px; +} + .custom-marker-icon { display: flex; flex-direction: column; @@ -74,3 +112,33 @@ background-color:rgba(255, 255, 255, 0.5); } + .station-blueprint-dropdown{ + display: flex; + float:left; + margin-right: 10px; + padding-right:5px; + height: 30px; + width:400px; + border-right: 1px solid var(--gray-200); + border-left : 1px solid var(--gray-200); + color:black; + .dropdown-title { + + padding-right: 5px; + padding-left: 5px; + font-size: 14px; + line-height: 28px; + min-width: 70px; + } + } + + .NoOverride + { + padding-left:5px !important; + button { + margin-left: 0px !important; + + } + } + + \ No newline at end of file diff --git a/SAS/TMSS/frontend/tmss_webapp/src/routes/Cycle/create.js b/SAS/TMSS/frontend/tmss_webapp/src/routes/Cycle/create.js index c67c1baa33364aa6d6e563b1c43b00e0f864ef0e..0d6e2ef64e7ee69b0e08816280b71d6f179896b7 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/routes/Cycle/create.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/routes/Cycle/create.js @@ -543,7 +543,7 @@ export class CycleCreate extends Component { <div className="p-breadcrumb footer-long-div actions" > <FormActionbar createAnotherCallBack={this.setCreateAnother} createAnother={this.state.createAnother} tooltip="Select checkbox to create another Cycle after saving this cycle" - onSubmit={this.saveCycle} enableSaveBtn={!this.state.validForm} onCancel={this.checkIsDirty} /> + onSubmit={this.saveCycle} disableSaveBtn={!this.state.validForm} onCancel={this.checkIsDirty} /> </div> </> } diff --git a/SAS/TMSS/frontend/tmss_webapp/src/routes/Cycle/create.test.js b/SAS/TMSS/frontend/tmss_webapp/src/routes/Cycle/create.test.js index 7f25455ed1af520262e72d80ab38f6c3fe542ad6..74ea3bbcc509fe05ae4dc575ba18184001f173f6 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/routes/Cycle/create.test.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/routes/Cycle/create.test.js @@ -37,7 +37,7 @@ const setMockSpy = (() => { }); saveCycleSpy = jest.spyOn(CycleService, 'saveCycle'); - saveCycleSpy.mockImplementation((cycle, cycleQuota) => { + saveCycleSpy.mockImplementation((cycle ) => { cycle.url = `http://localhost:3000/api/cycle/${cycle.name}`; return Promise.resolve(cycle) }); diff --git a/SAS/TMSS/frontend/tmss_webapp/src/routes/Cycle/edit.js b/SAS/TMSS/frontend/tmss_webapp/src/routes/Cycle/edit.js index f68637fc3eca9f36403cce10049e77b1e2f81245..03b37c334f7bb35f8d306bb68a48622bcca90817 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/routes/Cycle/edit.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/routes/Cycle/edit.js @@ -529,7 +529,7 @@ export class CycleEdit extends Component { </div> </div> <div className="p-breadcrumb footer-long-div actions" > - <FormActionbar onSubmit={this.saveCycle} enableSaveBtn={!this.state.validForm} onCancel={this.checkIsDirty} /> + <FormActionbar onSubmit={this.saveCycle} disableSaveBtn={!this.state.validForm} onCancel={this.checkIsDirty} /> </div> </> } 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 21d84310dba230bbfab7ebb8ca174ce84c2a990c..b279955987205ce54b2c7bb7eb50dcefd7bc8819 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/routes/Project/create.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/routes/Project/create.js @@ -653,7 +653,7 @@ export class ProjectCreate extends Component { <div className="p-breadcrumb footer-long-div actions"> <FormActionbar createAnotherCallBack={this.setCreateAnother} createAnother={this.state.createAnother} tooltip="Select checkbox to create another Project after saving this project" - onSubmit={this.saveProject} enableSaveBtn={!this.state.validForm} onCancel={this.checkIsDirty} /> + onSubmit={this.saveProject} disableSaveBtn={!this.state.validForm} onCancel={this.checkIsDirty} /> </div> </> } 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 ba3971421a6e437642123dafe0c13622e392e752..d089246cdb04905a4b9f1a1b2c166708c6a118db 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/routes/Project/edit.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/routes/Project/edit.js @@ -692,7 +692,7 @@ export class ProjectEdit extends Component { </div> </div> <div className="p-breadcrumb footer-long-div actions" > - <FormActionbar onSubmit={this.saveProject} enableSaveBtn={!this.state.validForm} onCancel={this.checkIsDirty} /> + <FormActionbar onSubmit={this.saveProject} disableSaveBtn={!this.state.validForm} onCancel={this.checkIsDirty} /> </div> </> } diff --git a/SAS/TMSS/frontend/tmss_webapp/src/routes/Reservation/reservation.create.js b/SAS/TMSS/frontend/tmss_webapp/src/routes/Reservation/reservation.create.js index 64a443d942187484d2ae06d70240302bd400ab9a..ff6aa0153fc6ca67d704fa55ee71726967819616 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/routes/Reservation/reservation.create.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/routes/Reservation/reservation.create.js @@ -690,7 +690,7 @@ export class ReservationCreate extends Component { <div className="p-breadcrumb footer-long-div actions" > <FormActionbar createAnotherCallBack={this.setCreateAnother} createAnother={this.state.createAnother} tooltip="Select checkbox to create another reservation after saving this reservation" - onSubmit={this.saveReservation} enableSaveBtn={!this.state.validEditor || !this.state.validForm} onCancel={this.checkIsDirty} /> + onSubmit={this.saveReservation} disableSaveBtn={!this.state.validEditor || !this.state.validForm} onCancel={this.checkIsDirty} /> </div> </> } diff --git a/SAS/TMSS/frontend/tmss_webapp/src/routes/Reservation/reservation.edit.js b/SAS/TMSS/frontend/tmss_webapp/src/routes/Reservation/reservation.edit.js index 78633d5548f2b924faf3f81da9082f754f597a3f..ad6a95e1d3aa18db2c110005b85aefbd3ad19d7e 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/routes/Reservation/reservation.edit.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/routes/Reservation/reservation.edit.js @@ -619,7 +619,7 @@ export class ReservationEdit extends Component { </div> </div> <div className="p-breadcrumb footer-long-div actions" > - <FormActionbar onSubmit={this.saveReservation} enableSaveBtn={!this.state.validEditor || !this.state.validForm} onCancel={this.checkIsDirty} /> + <FormActionbar onSubmit={this.saveReservation} disableSaveBtn={!this.state.validEditor || !this.state.validForm} onCancel={this.checkIsDirty} /> </div> </div> </React.Fragment> diff --git a/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/create.js b/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/create.js index 3e37d2876bdf8cf07be76967514453f995428794..4eab0edb2c01e5afe4d83203175e131ace3bbf04 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/create.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/create.js @@ -1160,7 +1160,7 @@ export class SchedulingUnitCreate extends Component { tooltip="Select checkbox to create another Scheduling Unit after saving this Scheduling Unit" submitTitle={(!this.state.constraintValidEditor || !this.state.validEditor || !this.state.validForm || !this.state.validConstraints || !this.state.validSpecification) ? "" : "Save Scheduling Unit"} onSubmit={this.saveSchedulingUnit} - enableSaveBtn={!this.state.constraintValidEditor || !this.state.validEditor || !this.state.validForm || !this.state.validConstraints || !this.state.validSpecification} + disableSaveBtn={!this.state.constraintValidEditor || !this.state.validEditor || !this.state.validForm || !this.state.validConstraints || !this.state.validSpecification} onCancel={this.checkIsDirty}/> </div> <ReactTooltip id="reacttooltip" place={'left'} type={'dark'} effect={'solid'} multiline={true}/> diff --git a/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/edit.js b/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/edit.js index 6a335a1b574195fd4f1595d29035713cb8928be9..168ecb0f6159addf438f7ac9908dbd6203a4a711 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/edit.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/edit.js @@ -883,7 +883,7 @@ export class EditSchedulingUnit extends Component { <ReactTooltip id="reacttooltip" place={'left'} type={'dark'} effect={'solid'} multiline={true} /> <div className="p-breadcrumb footer-long-div actions" > <FormActionbar onSubmit={this.saveSchedulingUnit} - enableSaveBtn={!this.state.constraintValidEditor || !this.state.validEditor || !this.state.validForm || !this.state.validConstraints || !this.state.validSpecification} onCancel={this.checkIsDirty} /> + disableSaveBtn={!this.state.constraintValidEditor || !this.state.validEditor || !this.state.validForm || !this.state.validConstraints || !this.state.validSpecification} onCancel={this.checkIsDirty} /> </div> <div className="p-grid" data-testid="confirm_dialog"> diff --git a/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/excelview.schedulingset.test.js b/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/excelview.schedulingset.test.js index 944945c09f8445e4e106465011b4a7bd896e380f..338bb3ea8d404f6c559e6202a3a011301608c5b7 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/excelview.schedulingset.test.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/excelview.schedulingset.test.js @@ -21,7 +21,7 @@ let utcSpy; //Jest issue: https://github.com/jestjs/jest/issues/9709: Cannot be called in beforeXX test method const OBSERVATION_STRATEGY_TEMPLATES = SUServiceMock.getObservStrategies() -jest.setTimeout(120000); +jest.setTimeout(12000); removeReact18ConsoleErrors(); /** diff --git a/SAS/TMSS/frontend/tmss_webapp/src/routes/Station/StationConstraintImage.js b/SAS/TMSS/frontend/tmss_webapp/src/routes/Station/StationConstraintImage.js new file mode 100644 index 0000000000000000000000000000000000000000..719b1085d0c5e9982a0316a5c8f85eaa10a2b24a --- /dev/null +++ b/SAS/TMSS/frontend/tmss_webapp/src/routes/Station/StationConstraintImage.js @@ -0,0 +1,47 @@ +import PropTypes from 'prop-types'; +import ScheduleService from "../../services/schedule.service"; +import { useEffect, useState } from "react"; +import { ProgressSpinner } from 'primereact/progressspinner'; +export default function StationConstraintImage(props) { + const { + station, + startTime, + blueprintId + } = props + + + const [constraintImage, setConstraintImage] = useState() + + const fetchImage = async () => { + setConstraintImage(null); + let constraintImage = await ScheduleService.getConstraintImgForStationAndSchedulingUnitOnDate(station, blueprintId, startTime); + + setConstraintImage(constraintImage); + }; + + + + + useEffect(() => { + fetchImage(); + }, [station, blueprintId, startTime]); + + + return ( + + <div> + {constraintImage === null ? ( + <ProgressSpinner /> + ) : ( + <img src={constraintImage} alt="Constraint" /> + )} + </div> + ) +} + + +StationConstraintImage.propTypes = { + station: PropTypes.string, + startTime: PropTypes.string, + blueprintId: PropTypes.string, +}; \ No newline at end of file diff --git a/SAS/TMSS/frontend/tmss_webapp/src/routes/Station/StationConstraintView.js b/SAS/TMSS/frontend/tmss_webapp/src/routes/Station/StationConstraintView.js new file mode 100644 index 0000000000000000000000000000000000000000..208fc9fd45f721ff42bd8b2049b99d0a4171ba60 --- /dev/null +++ b/SAS/TMSS/frontend/tmss_webapp/src/routes/Station/StationConstraintView.js @@ -0,0 +1,27 @@ +import PropTypes from 'prop-types'; + + +import StationConstraintImage from './StationConstraintImage' + +export default function StationConstraintView(props) { + const { + station, + selectedBluePrint, + selectedBluePrintId, + startTime + } = props + return <div className='ConstraintsStart'> + {selectedBluePrint ? ( + <StationConstraintImage blueprintId={selectedBluePrintId} station={station} startTime={startTime} ></StationConstraintImage>) + : (<div></div> + )} + </div> + +} + +StationConstraintView.propTypes = { + station: PropTypes.string, + selectedBluePrint: PropTypes.array, + selectedBluePrintId: PropTypes.string, + startTime: PropTypes.string +}; \ No newline at end of file diff --git a/SAS/TMSS/frontend/tmss_webapp/src/routes/Station/StationConstraintsview.js b/SAS/TMSS/frontend/tmss_webapp/src/routes/Station/StationConstraintsview.js deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/SAS/TMSS/frontend/tmss_webapp/src/routes/Station/StationGeoView.js b/SAS/TMSS/frontend/tmss_webapp/src/routes/Station/StationGeoView.js index a8208728051ed1c2a642542432468deb12dcfd35..ee3e27f5e1a623581236f22ea708555ae8fd4839 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/routes/Station/StationGeoView.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/routes/Station/StationGeoView.js @@ -1,7 +1,7 @@ import 'leaflet/dist/leaflet.css' -import {MapContainer, Marker, Popup, TileLayer } from 'react-leaflet' +import {MapContainer, Marker, TileLayer } from 'react-leaflet' import L from 'leaflet' -import { useMap } from 'react-leaflet/hooks' +import { useMap } from 'react-leaflet' diff --git a/SAS/TMSS/frontend/tmss_webapp/src/routes/Station/StationView.js b/SAS/TMSS/frontend/tmss_webapp/src/routes/Station/StationView.js index b034c5032bdc5296d83780bf9478b962ce7e93b1..1ee557480775698cacbd8f51d66453b8e895ced2 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/routes/Station/StationView.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/routes/Station/StationView.js @@ -1,102 +1,209 @@ -import { TabView,TabPanel } from "primereact/tabview"; +import { TabView, TabPanel } from "primereact/tabview"; import PropTypes from 'prop-types'; - +import PageHeader from "../../layout/components/PageHeader"; import UtilService from "../../services/util.service"; import { ListBox } from 'primereact/listbox'; -import {useEffect, useState} from "react"; -import StationGeoView from './StationGeoView' - +import { useEffect, useState } from "react"; +import StationGeoView from './StationGeoView' +import StationConstraintView from './StationConstraintView' +import moment from "moment"; +import ScheduleService from "../../services/schedule.service"; +import UIConstants from "../../utils/ui.constants"; +import PageHeaderActions from "../../utils/pageheaderactions.util.js"; -import PageHeader from '../../layout/components/PageHeader'; // see https://react-leaflet.js.org/docs/api-map/ -export default function StationView(props) { - const { - location - } = props +export default function StationView(props) { + const { + location + } = props - const [stations, setStations] = useState() - const [stationsGeo, setStationsGeo] = useState([]) - const [selectedStation, setSelectedStation] = useState() + const [stations, setStations] = useState() + const [stationsGeo, setStationsGeo] = useState([]) + const [selectedStation, setSelectedStation] = useState("CS002") + const [bluePrints, setBluePrints] = useState() + const [flatBluePrints, setFlatBluePrints] = useState() + const [selectedBluePrint, setSelectedBluePrint] = useState() + const [selectedBluePrintId, setSelectedBluePrintId] = useState() + const [startTime, setStartTime] = useState(moment().startOf('day').toDate() ) + const [endTime, setEndTime] = useState(moment().endOf('day').add(UIConstants.WEEKVIEW_SHOW_NUMBER_OF_DAYS, 'days').toDate()) + const [map, setMap] = useState() - const [map, setMap] = useState() + async function fetchStations() { + let stationlist = await UtilService.getStations(); + if (stationlist === null) return; + let flatstationList = Object.entries(stationlist) + setStations(flatstationList); + let geostations = MakeGeoJson(stationlist); + setStationsGeo(geostations); + } - async function fetchStations() { - let stationlist = await UtilService.getStations(); - let flatstationList = Object.entries(stationlist) - setStations(flatstationList); - let geostations = MakeGeoJson(stationlist); - setStationsGeo(geostations); + function GetFlatBluePrints() { + return flatBluePrints; + } + + function MakeLabel(prints) { + for (const element of prints) { + const print = element; + print[0] = print[1].name + " - " + print[1].id + " - " + print[1].status } - - - - function generateGeoJson(station, coordinates) { - let name = station; - let longitude = coordinates.longitude; - let latitude = coordinates.latitude; - - return { - type: "Feature", - properties: { - name: name - }, - "geometry": { - "type": "Point", - "coordinates": [ - longitude, - latitude - ] - }, - id: name - } + } + + useEffect(() => { + console.log("startTime", startTime, "endTime", endTime); + + }, [startTime, endTime]); + + + useEffect(() => { + if (selectedBluePrint?.[1]?.id) { + setSelectedBluePrintId("" + selectedBluePrint[1].id) } + }, [selectedBluePrint]); + + function SortBluePrints(prints) { + return prints.sort((a, b) => { + // Compare names + if (a.name < b.name) { + return -1; + } + if (a.name > b.name) { + return 1; + } + // Names are equal + return 0; + }); + + } + + async function fetchBluePrints() { + const from = moment(startTime).format(UIConstants.CALENDAR_DATETIME_FORMAT); + const until = moment(endTime).format(UIConstants.CALENDAR_DATETIME_FORMAT); + const schedulingUnits = await ScheduleService.getTimelineSlimBlueprints(from, until); + let sortedbluePrints = SortBluePrints(schedulingUnits); + setBluePrints(sortedbluePrints); + let flattedBluePrints = Object.entries(sortedbluePrints) + MakeLabel(flattedBluePrints); + setFlatBluePrints(flattedBluePrints); + + } + + function getBluePrintActions() { + return [ + PageHeaderActions.actionDropDownObject("Blue print ", GetFlatBluePrints(), + { callback: (blueprint) => setSelectedBluePrint(blueprint) }, + selectedBluePrint, "station-blueprint-dropdown", undefined, "0","select Blue print" + ), + ] + } + + function navigateToDay(addingDays) { + let newStartTime = new Date(startTime); + newStartTime.setDate(startTime.getDate() + addingDays); + let NewEndTime = new Date(endTime) + NewEndTime.setDate(endTime + addingDays); + setStartTime(newStartTime); + setEndTime(NewEndTime); + } + function getNavigationActions(AddDays) { + return [ + PageHeaderActions.actionButtonObject( + "previous day", + "pi pi-angle-left", + "", + { callback: () => AddDays(-1) } + ), + + PageHeaderActions.actionCalendarObject( + "", + { callback: (date) => setStartTime(date) }, + startTime, + "NoOverride" + ), + PageHeaderActions.actionButtonObject( + "next day", + "pi pi-angle-right", + "", + { callback: () => AddDays(1) } + ), + ]; + } + + + function generateGeoJson(station, coordinates) { + let name = station; + let longitude = coordinates.longitude; + let latitude = coordinates.latitude; - function MakeGeoJson(stations) { - let StationgeojsonArray = [] - for (let station in stations){ - const geostationJson = generateGeoJson(station,stations[station]); - StationgeojsonArray.push(geostationJson); - } - return StationgeojsonArray; - } - - - - function ZoomTo(station) { - let longitude = station[1].longitude; + return { + type: "Feature", + properties: { + name: name + }, + "geometry": { + "type": "Point", + "coordinates": [ + longitude, + latitude + ] + }, + id: name + } + } + + function MakeGeoJson(stations) { + let StationgeojsonArray = [] + for (let station in stations) { + const geostationJson = generateGeoJson(station, stations[station]); + StationgeojsonArray.push(geostationJson); + } + return StationgeojsonArray; + } + + + + function ZoomTo(station) { + let longitude = station[1].longitude; let latitude = station[1].latitude; - map?.setView([latitude,longitude],14); - } - useEffect ( () => { - fetchStations(); - }, []); - - - return <> - - <PageHeader location={location} title={'Stations - List '} - /> - - <TabView> - <TabPanel header="Station Geo Map" className="TabStation"> - <div className="StationListWrap" > - <ListBox options={stations} optionLabel="0" className="StationListbox" onChange={(e) => ZoomTo(e.value)}/> - <StationGeoView stations={stationsGeo } selected={selectedStation} mapRef={ setMap} ></StationGeoView > - </div> - </TabPanel> - <TabPanel header="Station Constraints Plot"> - <div className="StationListWrap" > - <ListBox options={stations} optionLabel="0" className="StationListbox" onChange={(e) => ZoomTo(e.value)}/> - <div> A Contraints view will be implemnted here soon. </div> - </div> - - </TabPanel> - </TabView> + map?.setView([latitude, longitude], 14); + } + + + useEffect(() => { + fetchStations(); + fetchBluePrints(); + }, []); + + + function constrainsSelect(station) { + console.log(station); + + setSelectedStation(...station) + } + + + return <> + + <PageHeader location={location} title={'Stations - List '} actions={getBluePrintActions().concat(getNavigationActions(navigateToDay))} className="defaultpageHeader" /> + <TabView> + <TabPanel header="Station Geo Map" className="TabStation"> + <div className="StationListWrap" > + <ListBox options={stations} optionLabel="0" className="StationListbox" onChange={(e) => ZoomTo(e.value)} /> + <StationGeoView stations={stationsGeo} selected={selectedStation} mapRef={setMap} ></StationGeoView > + </div> + </TabPanel> + <TabPanel header="Station Constraints Plot"> + <div className="StationListWrap" > + <ListBox options={stations} optionLabel="0" className="StationListbox" onChange={(e) => constrainsSelect(e.value)} selected={selectedStation} /> + <StationConstraintView station={selectedStation} stations={stations} selectedBluePrint={selectedBluePrint} selectedBluePrintId={selectedBluePrintId} startTime={moment(startTime).format(UIConstants.CALENDAR_DEFAULTDATE_FORMAT)} ></StationConstraintView> + </div> + + </TabPanel> + </TabView> </> } -StationView.propTypes = { - title: PropTypes.string, + StationView.propTypes = { + title: PropTypes.string, - }; \ No newline at end of file + } \ No newline at end of file diff --git a/SAS/TMSS/frontend/tmss_webapp/src/routes/SystemEvent/system.event.create.js b/SAS/TMSS/frontend/tmss_webapp/src/routes/SystemEvent/system.event.create.js index dfdf9439dc2cbb8f2e45a27b01a81d56c0290009..1c8e5d55499c3f81fb1fc06a666f99466d92275c 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/routes/SystemEvent/system.event.create.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/routes/SystemEvent/system.event.create.js @@ -931,7 +931,7 @@ export class SystemEventCreate extends Component { <div className="p-breadcrumb footer-long-div actions" > <FormActionbar createAnotherCallBack={this.setCreateAnother} createAnother={this.state.createAnother} tooltip="Select checkbox to create another system event after saving this system event" - onSubmit={this.saveSystemEvent} enableSaveBtn={!this.state.validEditor || !this.state.validForm} onCancel={this.checkIsDirty} /> + onSubmit={this.saveSystemEvent} disableSaveBtn={!this.state.validEditor || !this.state.validForm} onCancel={this.checkIsDirty} /> </div> </> } diff --git a/SAS/TMSS/frontend/tmss_webapp/src/routes/SystemEvent/system.event.edit.js b/SAS/TMSS/frontend/tmss_webapp/src/routes/SystemEvent/system.event.edit.js index 98c9701c4e23847fa4175b11a893175df3f60939..4bd37b2f0cc302e94484b19f089fb4716be167d6 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/routes/SystemEvent/system.event.edit.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/routes/SystemEvent/system.event.edit.js @@ -786,7 +786,7 @@ export class SystemEventEdit extends Component { </div> <div className="p-breadcrumb footer-long-div actions" > <FormActionbar onSubmit={this.updateSystemEvent} - enableSaveBtn={!this.state.validEditor || !this.state.validForm} onCancel={this.checkIsDirty} /> + disableSaveBtn={!this.state.validEditor || !this.state.validForm} onCancel={this.checkIsDirty} /> </div> </div> </React.Fragment> diff --git a/SAS/TMSS/frontend/tmss_webapp/src/routes/Task/edit.js b/SAS/TMSS/frontend/tmss_webapp/src/routes/Task/edit.js index f3e4c38fe4389a6d3cc5ac7fb9fede6ca9614feb..29055b226820eea384b877c1dbe4bf7553d12699 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/routes/Task/edit.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/routes/Task/edit.js @@ -283,9 +283,11 @@ export class TaskEdit extends Component { }); } + + const isSaveDisabled = !this.state.validEditor || !this.state.validForm || !this.state.validDocument; return ( <React.Fragment> - {this.state.userrole[this.state.taskId] && this.state.userrole[this.state.taskId].edit ? + {this.state.userrole[this.state.taskId]?.edit ? <> <Toast ref={(el) => this.growl = el} /> <PageHeader location={this.props.location} title={'Task - Edit'} actions={[{ @@ -360,7 +362,7 @@ export class TaskEdit extends Component { </div> <div className="p-breadcrumb footer-long-div actions"> <FormActionbar onSubmit={this.saveTask} - enableSaveBtn={!this.state.validEditor || !this.state.validForm || !this.state.validDocument} onCancel={this.checkIsDirty} /> + disableSaveBtn={isSaveDisabled} onCancel={this.checkIsDirty} /> </div> <div className="p-grid" data-testid="confirm_dialog"> <CustomDialog type="confirmation" visible={this.state.showDialog} width="40vw" diff --git a/SAS/TMSS/frontend/tmss_webapp/src/routes/Task/edit.test.js b/SAS/TMSS/frontend/tmss_webapp/src/routes/Task/edit.test.js index 56100573a50883e7b32b0d965ec5b3d55b3498b9..a3feb9fba1f88c183b49aa00a05a35c6792fe468 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/routes/Task/edit.test.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/routes/Task/edit.test.js @@ -6,7 +6,6 @@ import mockConsole from 'jest-mock-console' import _ from 'lodash'; import { TaskEdit } from './edit'; import TaskService from '../../services/task.service'; -import UtilService from '../../services/util.service'; import TaskServiceMock from '../../__mocks__/task.service.data'; import AuthService from '../../services/auth.service'; import AuthServiceMock from '../../__mocks__/auth.service.data'; @@ -63,11 +62,10 @@ const setMockSpy = ( () => { taskTemplateSpy = jest.spyOn(TaskService, 'getTaskTemplate'); taskTemplateSpy.mockImplementation((templateId) => { let template = _.find(TaskServiceMock.getTaskTemplates(), {"id":templateId}); - return Promise.resolve(template); - //let resolvedtemplate = UtilService.resolveSchema(template); + template.definitions = template.ref_resolved_schema.definitions; + template.properties = template.ref_resolved_schema?.properties; - //return resolvedtemplate - // + return Promise.resolve(template); }); taskTemplatesSpy = jest.spyOn(TaskService, 'getTaskTemplates'); @@ -76,7 +74,7 @@ const setMockSpy = ( () => { }); schedulingUnitSpy = jest.spyOn(TaskService, "getSchedulingUnit"); - schedulingUnitSpy.mockImplementation((type, id, loadTasks) => { + schedulingUnitSpy.mockImplementation((type, id ) => { if (type === "draft") { return Promise.resolve(_.find(TaskServiceMock.schedulingUnitDrafts, {"id": id})); } else { diff --git a/SAS/TMSS/frontend/tmss_webapp/src/routes/Timeline/helpers/week.view.helper.js b/SAS/TMSS/frontend/tmss_webapp/src/routes/Timeline/helpers/week.view.helper.js index e4e175cd86e8fb54bddfe57975aceb110d5d6f54..0b99eb87947619cf9b4ed27bf798a03affbb6e9e 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/routes/Timeline/helpers/week.view.helper.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/routes/Timeline/helpers/week.view.helper.js @@ -3,6 +3,7 @@ import moment from "moment/moment"; import UtilService from "../../../services/util.service"; import { getTimelineGroups } from "../business/timelinegroupingbusiness.js"; import UIConstants from "../../../utils/ui.constants.js"; +import PageHeaderActions from "../../../utils/pageheaderactions.util.js"; import { fetchLSTStationShift } from "../data/week.view.data.js" @@ -28,57 +29,30 @@ export async function updateSchedulerStatuses(switchValue, status, setSchedulerS } } -const actionObject = (title, icon, classes, className, callbackProp, content, type, actOn, options, selected) => ({ - title: title, - icon: icon, - classes: classes, - className: className, - content: content, - type: type, - actOn: actOn, - props: callbackProp, - options: options, - selected: selected -}) - -const actionButtonObject = (title, icon, classes, callbackProp) => ( - actionObject(title, icon, classes, undefined, callbackProp, undefined, "buttonv2", "click", undefined, undefined) -) - -const actionTagObject = (title, content, className) => ( - actionObject(title, undefined, undefined, className, undefined, content, "tagv2", "click", undefined, undefined) -) - -const actionDropDownObject = (title, options, callbackProp, selected, classes) => ( - actionObject(title, undefined, classes, undefined, callbackProp, undefined, "dropdown", "select", options, selected) -) - -const actionDivider = (title) => ( - actionObject(title, undefined, undefined, undefined, undefined, undefined, "divider", undefined, undefined, undefined) -) + export function getHeaderActions(isLoading, setRefetchToggle, actionsMenuRef, isExpanded, setIsExpanded, isLegendVisible, setIsLegendVisable) { return [ - actionButtonObject( + PageHeaderActions.actionButtonObject( isLoading ? "System is already reloading the timeline data" : "Reload the timeline data", (isLoading ? "pi-spin pi-hourglass " : "pi-sync"), `subsystem subsystem--${isLoading ? "on" : "standard"}`, { callback: () => setRefetchToggle(prevState => !prevState) } ), - actionButtonObject( + PageHeaderActions.actionButtonObject( "Options", "pi-bars", "", { callback: (ev) => actionsMenuRef.current.toggle(ev) } ), - actionButtonObject( + PageHeaderActions.actionButtonObject( (isLegendVisible ? "Hide Legend" : "Show Legend"), (isLegendVisible ? "pi-bookmark" : "pi-bookmark-fill"), (isLegendVisible ? "" : "color:grey"), { callback: () => setIsLegendVisable(prevState => !prevState) } ), - actionButtonObject( + PageHeaderActions.actionButtonObject( (isExpanded ? "Hide Filters" : "Show Filter"), (isExpanded ? "pi-chevron-up" : "pi-chevron-down"), "", @@ -95,12 +69,12 @@ export function getHeaderActions(isLoading, setRefetchToggle, actionsMenuRef, is */ export function getGroupedByActions(selected, setGroupedBy) { return [ - actionDropDownObject( + PageHeaderActions.actionDropDownObject( "Group By", getTimelineGroups(), { callback: (groupingby) => setGroupedBy(groupingby) }, selected, - "timeline-header-dropdown" + "timeline-header-dropdown","value","label" ), ] @@ -108,36 +82,36 @@ export function getGroupedByActions(selected, setGroupedBy) { export function getNavigationActions(AddWeeks) { return [ - actionButtonObject( + PageHeaderActions.actionButtonObject( "previous 7 days", "pi pi-angle-double-left", "", { callback: () => AddWeeks(-1) } ), - actionButtonObject( + PageHeaderActions.actionButtonObject( "next 7 days", "pi pi-angle-double-right", "", { callback: () => AddWeeks(1) } ), - actionDivider("navigationbreaker") + PageHeaderActions.actionDivider("navigationbreaker") ]; } export function getSchedulerActions(schedulerSettings, setShowSchedulerSettingsDialog) { return [ - actionTagObject( + PageHeaderActions.actionTagObject( schedulerSettings.isDynamicSchedulerOn ? "Dynamic Scheduling is On" : "Dynamic Scheduling is Off", "D", "tag tag--" + (schedulerSettings.isDynamicSchedulerOn ? "on" : "off") ), - actionTagObject( + PageHeaderActions.actionTagObject( schedulerSettings.isFixedTimeSchedulerOn ? "Fixed time Scheduling is On" : "Fixed time Scheduling is Off", "F", "tag tag--" + (schedulerSettings.isFixedTimeSchedulerOn ? "on" : "off") ), - actionButtonObject( + PageHeaderActions.actionButtonObject( (schedulerSettings.isDynamicSchedulerActive ? "Dynamic Scheduler is Active" : (schedulerSettings.isDynamicSchedulerOn ? "Dynamic Scheduler is Idle" : "Dynamic Scheduler is stopped")) + ". Click to change the scheduler", "pi-" + (schedulerSettings.isDynamicSchedulerActive ? "play" : (schedulerSettings.isDynamicSchedulerOn ? "pause" : "stop")), diff --git a/SAS/TMSS/frontend/tmss_webapp/src/services/schedule.service.js b/SAS/TMSS/frontend/tmss_webapp/src/services/schedule.service.js index df3f61cfee17c77170a0f9ef7ccfbdfc9da50a47..4b49d2ac503919b2673ca827621ed320937a2cf6 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/services/schedule.service.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/services/schedule.service.js @@ -65,6 +65,36 @@ const SU_FETCH_FIELDS = ["id", "task_blueprints.subtasks.primary"]; const ScheduleService = { + + + /** + * Function to give back a scheduling constraint url + * @param {string} station - The Station + * @param {string} schedulingUnit - the Unit we are looking at + * @param {string} onDate - 2023-02-14 formatedf formated of the date + * @returns string with the url + */ + getConstraintImgForStationAndSchedulingUnitOnDate : async function(station,schedulingUnit,onDate) { + + if (station===undefined) return; + if (schedulingUnit===undefined) return; + if (onDate===undefined) return; + try { + let imageurl = "/api/scheduling_unit_blueprint/" + schedulingUnit + "/scheduling_constraints_plot/" + station + "/" + onDate + const response = await axios.get( + imageurl, + { + responseType: "blob", + } + ); + // Convert the blob to a data URL + const dataUrl = URL.createObjectURL(response.data); + return dataUrl; + } catch (error) { + console.error("Error fetching image:", error); + } + + }, getExpandedSchedulingUnit: async function (type, id, expand, fields) { let schedulingUnit = null; try { @@ -1107,6 +1137,7 @@ const ScheduleService = { console.error(error); } }, + } export default ScheduleService; diff --git a/SAS/TMSS/frontend/tmss_webapp/src/utils/externalurls.js b/SAS/TMSS/frontend/tmss_webapp/src/utils/externalurls.js index f36ccd799e7ac500a687b1d8417713fb53b3c4f6..dad2b8e386eb2f2bf933a110a2377d2352813787 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/utils/externalurls.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/utils/externalurls.js @@ -4,16 +4,7 @@ const ExternalUrlsUtils = { BaseLofarMonitorUrl : "https://proxy.lofar.eu/lofmonitor/station_overview?station=", - /** - * Function to give back a scheduling constraint url - * @param {string} Station - The Station - * @param {string} schedulingUnit - the Unit we are looking at - * @param {string} onDate - 2023-02-14 formatedf formated of the date - * @returns string with the url - */ - getUserRolePermissionForStationAndSchedulingUnitOnDate(station,schedulingUnit,onDate) { - return "/api/scheduling_unit_blueprint/" + schedulingUnit + "/scheduling_constraints_plot/" + station + "/" + onDate - }, + /** * Function to give back the Lofar Monitoring Url diff --git a/SAS/TMSS/frontend/tmss_webapp/src/utils/externalurls.test.js b/SAS/TMSS/frontend/tmss_webapp/src/utils/externalurls.test.js index 356d6d89fe33b739d40c50f3fac83fab1a049959..b0ef3d9f1f4848f34bb33bbe436f61c0e7bb8753 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/utils/externalurls.test.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/utils/externalurls.test.js @@ -7,10 +7,3 @@ describe('getLofarMontitorUrlForStation', () => { }) }); -describe('getUserRolePermissionForStationAndSchedulingUnitOnDate', () => { - it('should return the correct url', () => { - const subbandString = externalUrls.getUserRolePermissionForStationAndSchedulingUnitOnDate("CS003", 21, "1976-08-06") - expect(subbandString).toEqual("/api/scheduling_unit_blueprint/21/scheduling_constraints_plot/CS003/1976-08-06") - - }) -}); \ No newline at end of file diff --git a/SAS/TMSS/frontend/tmss_webapp/src/utils/pageheaderactions.util.js b/SAS/TMSS/frontend/tmss_webapp/src/utils/pageheaderactions.util.js new file mode 100644 index 0000000000000000000000000000000000000000..0aa516fbe336e1aef8214fb77ad38e2ad949c0fd --- /dev/null +++ b/SAS/TMSS/frontend/tmss_webapp/src/utils/pageheaderactions.util.js @@ -0,0 +1,46 @@ +const PageHeaderActions = { + actionObject(title, icon, classes, className, callbackProp, content, type, actOn, options, selected,optionvalue,optionlabel,optionSelectionLabel) { + return { + title: title, + icon: icon, + classes: classes, + className: className, + content: content, + type: type, + actOn: actOn, + props: callbackProp, + options: options, + selected: selected, + optionvalue: optionvalue, + optionlabel:optionlabel, + optionSelectionLabel:optionSelectionLabel + } + }, + + +actionButtonObject(title, icon, classes, callbackProp) { + return this.actionObject(title, icon, classes, undefined, callbackProp, undefined, "buttonv2", "click", undefined, undefined,undefined,undefined); +}, + + +actionTagObject(title, content, className) { + return this.actionObject(title, undefined, undefined, className, undefined, content, "tagv2", "click", undefined, undefined,undefined,undefined); +}, + + +actionDropDownObject(title, options, callbackProp, selected, classes,optionvalue ,optionlabel ,optionSelectionLabel) { + + + return this.actionObject(title, undefined, classes, undefined, callbackProp, undefined, "dropdown", "select", options, selected,optionvalue,optionlabel,optionSelectionLabel); +}, + +actionCalendarObject(title, callbackProp, selected, classes) { + return this.actionObject(title, undefined, classes, classes, callbackProp, undefined, "calendar", "select", undefined, selected,undefined,undefined); +}, +actionDivider(title) { + return this.actionObject(title, undefined, undefined, undefined, undefined, undefined, "divider", undefined, undefined, undefined,undefined,undefined); +} + +}; + +export default PageHeaderActions; \ No newline at end of file