PlotFunctionIntervalSelection.js 1.82 KB
Ext.define('amdaPlotComp.intervalSelection.PlotFunctionIntervalSelection', {
    extend: 'amdaPlotComp.intervalSelection.IntervalSelection', // This class extends from amdaPlotComp.intervalSelection.IntervalSelection
    requires: ['amdaPlotComp.plotFunction.FunctionType'], // This class requires the FunctionType class from amdaPlotComp.plotFunction

    title: "Plot Function", // The title of the window
    plotFunctionType: null, // An instance of the FunctionType class, initially set to null

    /**
     * Initializes the component.
     * It calls the parent's initComponent method, then creates a new instance of FunctionType and adds it to the form.
     */
    initComponent: function () {
        this.callParent(arguments);
        this.plotFunctionType = new amdaPlotComp.plotFunction.FunctionType();
        this.form.add(this.plotFunctionType);
    },

    /**
     * Applies the plot function based on the values of the fields.
     * If the values are not valid, it shows a warning message.
     * Otherwise, it calls the interactive plot with the plotFunction action and resets the host component selection.
     */
    _apply: function () {
        if (this._notValidValues()) {
            myDesktopApp.warningMsg('Please note that either the Start Time or the Stop Time has not been defined. To proceed, ensure both times are properly set.');
        } else {
            const request_to_send = Object.assign({}, this.plotFunctionType.getValues(), {
                'action': 'plotFunction',
                'interactiveId': this.interactiveId,
                'panelId': this.panelId,
                'starttime': this.getField1Value(),
                'stoptime': this.getField2Value(),
            });

            this.hostCmp.callInteractivePlot(request_to_send);
            this._resetHostCmpSelection();
        }
    },

});