Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow configuration of table columns in config.js #238

Open
mudinthewater opened this issue Dec 1, 2024 · 3 comments
Open

Allow configuration of table columns in config.js #238

mudinthewater opened this issue Dec 1, 2024 · 3 comments

Comments

@mudinthewater
Copy link
Contributor

mudinthewater commented Dec 1, 2024

Is your feature request related to a problem? Please describe.

SMAP queries by SCET, but SCLK has 2 more digits of precision. Example:
scet: 2000-001T00:00.000
sclk: 0.00000

EVRS on SMAP are expected to be sorted by the higher precision column (sclk) while queried by the lower-precision column (SCET).
Unfortunately, in OMM today, the only way to enable the 'sclk' column is to enable the 'sclk' time system, which does not work on SMAP.

Describe the solution you'd like

I would like a better way to specify optional or arbitrary columns for EVR and channel tables. Additionally I'd like to have a way to remove default or arbitrary columns by configuration. For example, I really couldn't care less about the 'Record Type' column on an EVR view given that I already know what record it is by clicking on it.

Testing Instructions

  1. Set the timeSystems field to 'scet' only.
  2. Observe that on channel tables and EVR tables, sclk is not available as a viewable field despite being returned as part of the channel return.

Additional context

This is additionally good practice anyways, as the csv_mcws output velocity template can be modified to include arbitrary fields, so OMM should also be able to be custom-configured for them. These fields are currently set in constants.js

@mudinthewater
Copy link
Contributor Author

mudinthewater commented Dec 2, 2024

I tested out the quick and dirty method of doing this, which is just moving the EVR_RANGES object into config.js and adding
EVR_RANGES:window.openmctMCWSConfig.EVR_RANGES,

But that makes the config.js kind of ugly so now I'm testing a change where only the difference is kept. i.e. constants.js will have the EVR_RANGES but config.js has the option to remove/change the field. Thinking something like:

overrideEVRColums: [
                {
                    action:"add",
                    name:"SCLK",
                    key: "sclk",
                    format: 'sclk.float64',
                    hints:{}
                },
                {
                     action:"remove",
                     key:"dss_id"
                 }
            ]

@mudinthewater
Copy link
Contributor Author

Okay yeah I made a simple anon function that can update the EVR columns using a new config option in MCT config.

Function (For now I stuck it in constants.js but that feels wrong - not sure where it'd be better placed though).

First the results:

image

And the anon function:

` /**

  • This anonymous function adds a new configuration to config.js, overrideEVRColumns that can
  • add, remove, or modify the EVR_RANGES constant to customize the look of EVR tables to the mission.

*/

(function () {
        var evrOverride= window.openmctMCWSConfig.overrideEVRColumns  === undefined;
        if(!evrOverride){
            var overRide=window.openmctMCWSConfig.overrideEVRColumns;
            for (const column of overRide) {
                switch (column.action) {
                    case 'add':
                        var usepos=column.position===undefined;
                        if(!usepos){
                           idx=column.position;
                           CONSTANTS.EVR_RANGES.splice(idx,0,column.value);
                           break;
                           }
                        else
                           {
                            CONSTANTS.EVR_RANGES.push(column.value);
                            break;
                           }
                    case 'update':
                        for (const [newkey, newvalue] of Object.entries(column.value)) {
                            var index=CONSTANTS.EVR_RANGES.findIndex(item =>item.key===column.key);
                            CONSTANTS.EVR_RANGES[index][newkey]=newvalue;
                        };
                        break;
                    case 'remove':
                       CONSTANTS.EVR_RANGES.splice(CONSTANTS.EVR_RANGES.findIndex(item =>item.key===column.key),1);
                       break;
                }
            };
        }
})();`

And finally the associated configuration inside of config.js:

     /**
     * EVR Column Override. Allows customization of columns in EVR tables. Via three actions:
     * 1. 'add'. Adds a new column matching 'key'. Requires 'key','name','format',and 'hint' keys.
     * 2. 'remove'. Removes column matching key from view.
     * 3. 'update'. Updates the specific keys in the value object. (i.e. rename a column)
     */
       overrideEVRColumns: [
            {
              key:'sclk',
              action:'add',
              position:0,
              value:{
                      key:'sclk',
                      name:'SCLK',
                      format:'sclk.float64',
                      hints:{}
              }
            },
            {
              key:'record_type',
              action:'remove'
            },
            {
              key:'dss_id',
              action:'remove'
            },
            {
              key:'realtime',
              action:'remove'
            },
            {
              key:'session_host',
              action:'remove'
            },
            {
              key:'from_sse',
              action:'remove'
            },
            {
              key:'vcid',
              action:'remove'
            },
            {
              key:'lst',
              action:'remove'
            },
            {
              key:'rct',
              action:'remove'
            }
    ],

@mudinthewater
Copy link
Contributor Author

This is just a demo that we can do it - if you lmk where you'd want that function to exist (constants.js?) I could clean it up and fully document it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant