All files / src index.ts

75% Statements 6/8
75% Branches 3/4
50% Functions 1/2
75% Lines 6/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95                  1x   1x                                                                                                                     1x                         1x     1x     1x          
import type { OctopusHost } from '@ska-octopus-widget-sdk/widget-sdk';
import {
  INPUT_STRINGS,
  VARIABLES_SCHEMA_TYPE,
  makeWidgetDef
} from '@ska-octopus-widget-sdk/widget-sdk';
import VariableSelectorWidget from './VariableSelectorWidget';
import pkg from '../package.json';
 
const { version } = pkg;
 
const schema = {
  type: 'object',
  properties: {
    values: {
      title: 'Allowed values',
      type: INPUT_STRINGS,
      propertyType: 'functionality',
      level: 2,
      default: [
        's8-1',
        's8-2',
        's8-3',
        's8-4',
        's8-5',
        's8-6',
        's9-1',
        's9-2',
        's9-3',
        's9-4',
        's9-5',
        's9-6',
        's10-1',
        's10-2',
        's10-3',
        's10-4',
        's10-5',
        's10-6'
      ]
    },
    allowedVars: {
      title: 'Variables to display',
      description: 'Only this variable will appear in the selector; leave empty to show all',
      type: VARIABLES_SCHEMA_TYPE,
      propertyType: 'css',
      level: 2,
      default: 'STATION_ID'
    },
    labelPosition: {
      type: 'select',
      title: 'Label Position',
      propertyType: 'css',
      level: 2,
      description: 'Where to place each variable label relative to its selector.',
      options: ['left', 'right', 'top', 'bottom'],
      default: 'left'
    },
    fontSize: {
      type: 'string',
      title: 'Font Size',
      propertyType: 'css',
      level: 2,
      description: 'Base font size used for labels and dropdowns (e.g. 12px, 0.85rem).',
      default: '12px'
    }
  },
  required: ['values']
};
 
/* ---------- definition & self-registration ----------------------- */
export const widgetDef = makeWidgetDef({
  key: 'variableSelector',
  label: 'Variable Selector',
  component: VariableSelectorWidget,
  layout: { x: 0, y: 0, w: 20, h: 7 },
  requiredStreams: [],
  config: { schema },
  version,
  docsUrl: 'https://developer.skao.int/projects/ska-octopus-variable-selector-widget/en/latest/'
});
 
function register(O: OctopusHost) {
  O.registerWidget(widgetDef as any);
}
 
(function wait(h: any) {
  Iif (typeof h.registerWidget === 'function') {
    register(h as OctopusHost);
  } else {
    setTimeout(wait, 50, h);
  }
})((globalThis as any).Octopus || ((globalThis as any).Octopus = {}));
 
export { VariableSelectorWidget };