Skip to content
Snippets Groups Projects
Select Git revision
  • 2d38e1217d064be122133fb61b7bc56e591bade6
  • master default protected
  • L2SS-1914-fix_job_dispatch
  • TMSS-3170
  • TMSS-3167
  • TMSS-3161
  • TMSS-3158-Front-End-Only-Allow-Changing-Again
  • TMSS-3133
  • TMSS-3319-Fix-Templates
  • test-fix-deploy
  • TMSS-3134
  • TMSS-2872
  • defer-state
  • add-custom-monitoring-points
  • TMSS-3101-Front-End-Only
  • TMSS-984-choices
  • SDC-1400-Front-End-Only
  • TMSS-3079-PII
  • TMSS-2936
  • check-for-max-244-subbands
  • TMSS-2927---Front-End-Only-PXII
  • Before-Remove-TMSS
  • LOFAR-Release-4_4_318 protected
  • LOFAR-Release-4_4_317 protected
  • LOFAR-Release-4_4_316 protected
  • LOFAR-Release-4_4_315 protected
  • LOFAR-Release-4_4_314 protected
  • LOFAR-Release-4_4_313 protected
  • LOFAR-Release-4_4_312 protected
  • LOFAR-Release-4_4_311 protected
  • LOFAR-Release-4_4_310 protected
  • LOFAR-Release-4_4_309 protected
  • LOFAR-Release-4_4_308 protected
  • LOFAR-Release-4_4_307 protected
  • LOFAR-Release-4_4_306 protected
  • LOFAR-Release-4_4_304 protected
  • LOFAR-Release-4_4_303 protected
  • LOFAR-Release-4_4_302 protected
  • LOFAR-Release-4_4_301 protected
  • LOFAR-Release-4_4_300 protected
  • LOFAR-Release-4_4_299 protected
41 results

common.utils.js

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    common.utils.js 5.24 KiB
    import _ from 'lodash';
    import ScheduleService from '../../services/schedule.service';
    import WorkflowService from '../../services/workflow.service';
    
    /**
     * Class with common functions used by both Timeline View and Week Overview components.
     */
    class TimelineCommonUtils {
    
        constructor() {
            this.STATUS_BEFORE_SCHEDULED = ['defining', 'defined', 'schedulable'];  // Statuses before scheduled to get station_group
            this.loadMainStationGroups();
            this.loadSUWorkflowTasks();
        }
    
        /**
         * To group the stations under CS,RS,IS to show the count in Popover
         */
        async loadMainStationGroups() {
            this.mainStationGroups = await ScheduleService.getMainGroupStations();
        }
    
        /**
         * TO get the main station groups (Core, Remote, International)
         * @returns Array - main station groups
         */
        getMainStationGroups() {
            return this.mainStationGroups;
        }
    
        /**
         * Function to fetch all Workflow processes and tasks to get the workflow status column
         * in the SU List table.
         */
         async loadSUWorkflowTasks() {
            this.worflowProcesses = await WorkflowService.getWorkflowProcesses();
            this.workflowTasks = await WorkflowService.getWorkflowTasks();
        }
                    
        /**
         * Get all stations of the SU bleprint from the observation task or subtask based on the SU status.
         * @param {Object} suBlueprint
         */
         getSUStations(suBlueprint) {
            let stations = [];
            /* Get all observation tasks */
            const observationTasks = _.filter(suBlueprint.tasks, (task) => { return task.task_type.toLowerCase() === "observation" });
            for (const observationTask of observationTasks) {
                /** If the status of SU is before scheduled, get all stations from the station_groups from the task specification_docs */
                if (this.STATUS_BEFORE_SCHEDULED.indexOf(suBlueprint.status.toLowerCase()) >= 0
                    && observationTask.specifications_doc.station_groups) {
                    for (const grpStations of _.map(observationTask.specifications_doc.station_groups, "stations")) {
                        stations = _.concat(stations, grpStations);
                    }
                } else if (this.STATUS_BEFORE_SCHEDULED.indexOf(suBlueprint.status.toLowerCase()) < 0
                    && observationTask.subtasks) {
                    /** If the status of SU is scheduled or after get the stations from the subtask specification tasks */
                    for (const subtask of observationTask.subtasks) {
                        if (subtask.specifications_doc.stations) {
                            stations = _.concat(stations, subtask.specifications_doc.stations.station_list);
                        }
                    }
                }
            }
            return _.uniq(stations);
        }
    
        /**
         * Group the SU stations to main groups Core, Remote, International
         * @param {Object} stationList