diff options
Diffstat (limited to 'sdnr/wt/odlux/apps/configurationApp/src/models/uiModels.ts')
-rw-r--r-- | sdnr/wt/odlux/apps/configurationApp/src/models/uiModels.ts | 160 |
1 files changed, 106 insertions, 54 deletions
diff --git a/sdnr/wt/odlux/apps/configurationApp/src/models/uiModels.ts b/sdnr/wt/odlux/apps/configurationApp/src/models/uiModels.ts index 69a807a3c..441d1281d 100644 --- a/sdnr/wt/odlux/apps/configurationApp/src/models/uiModels.ts +++ b/sdnr/wt/odlux/apps/configurationApp/src/models/uiModels.ts @@ -1,90 +1,142 @@ -/** - * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt odlux - * ================================================================================================= - * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved. - * ================================================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - * ============LICENSE_END========================================================================== - */ -export interface AccessFlags { - "read": boolean, - "write": boolean, - "create": boolean -} - -export interface ViewElementBase { +export type ViewElementBase = { "id": string; "label": string; - "viewId": string; - "leafrefPath": string; - "accessFlags": AccessFlags; - "description": string; + "config": boolean; + "ifFeature"?: string; + "when"?: string; + "mandatory"?: boolean; + "description"?: string; + "isList"?: boolean; + "default"?: string; + "status"?: "current" | "deprecated" | "obsolete", + "reference"?: string, // https://tools.ietf.org/html/rfc7950#section-7.21.4 +} + +// https://tools.ietf.org/html/rfc7950#section-9.8 +export type ViewElementBinary = ViewElementBase & { + "uiType": "binary"; + "length"?: number; // number of octets +} + +// https://tools.ietf.org/html/rfc7950#section-9.7.4 +export type ViewElementBits = ViewElementBase & { + "uiType": "bits"; + "flags": { + [name: string]: number | undefined; // 0 - 4294967295 + } } -export interface ViewElementString extends ViewElementBase { +// https://tools.ietf.org/html/rfc7950#section-9 +export type ViewElementString = ViewElementBase & { "uiType": "string"; + "pattern"?: string[]; + "length"?: string; + "invertMatch"?: true; } -export interface ViewElementNumber extends ViewElementBase { +// https://tools.ietf.org/html/rfc7950#section-9.3 +export type ViewElementNumber = ViewElementBase & { "uiType": "number"; "min"?: number; "max"?: number; - "unit"?: string; + "units"?: string; "format"?: string; + "fDigits"?: number; } -export interface ViewElementBoolean extends ViewElementBase { +// https://tools.ietf.org/html/rfc7950#section-9.5 +export type ViewElementBoolean = ViewElementBase & { "uiType": "boolean"; "trueValue"?: string; "falseValue"?: string; } -export interface ViewElementObject extends ViewElementBase { - "uiType": "object"; - "viewId": string; -} - -export interface ViewElementSelection extends ViewElementBase { +// https://tools.ietf.org/html/rfc7950#section-9.6.4 +export type ViewElementSelection = ViewElementBase & { "uiType": "selection"; "multiSelect"?: boolean "options": { - "key": string, - "value": string, - "description": string - }[], + "key": string; + "value": string; + "description"?: string, + "status"?: "current" | "deprecated" | "obsolete", + "reference"?: string, + }[]; } -export interface ViewElementList extends ViewElementBase { - "uiType": "list", - "listType": "object" | "string" | "number", - "viewId": string, +// is a list if isList is true ;-) +export type ViewElementObject = ViewElementBase & { + "uiType": "object"; + "isList"?: false; + "viewId": string; +} + +// Hint: read only lists do not need a key +export type ViewElementList = (ViewElementBase & { + "uiType": "object"; + "isList": true; + "viewId": string; + "key"?: string; +}); + +export type ViewElementReference = ViewElementBase & { + "uiType": "reference"; + "referencePath": string; + "ref": (currentPath: string) => ViewElement | null; } export type ViewElement = + | ViewElementBits + | ViewElementBinary | ViewElementString | ViewElementNumber | ViewElementBoolean | ViewElementObject + | ViewElementList | ViewElementSelection - | ViewElementList; + | ViewElementReference; + +export const isViewElementString = (viewElement: ViewElement): viewElement is ViewElementString => { + return viewElement && viewElement.uiType === "string"; +} -export interface ViewSpecification { +export const isViewElementNumber = (viewElement: ViewElement): viewElement is ViewElementNumber => { + return viewElement && viewElement.uiType === "number" ; +} + +export const isViewElementBoolean = (viewElement: ViewElement): viewElement is ViewElementBoolean => { + return viewElement && viewElement.uiType === "boolean"; +} + +export const isViewElementObject = (viewElement: ViewElement): viewElement is ViewElementObject => { + return viewElement && viewElement.uiType === "object" && viewElement.isList === false; +} + +export const isViewElementList = (viewElement: ViewElement): viewElement is ViewElementList => { + return viewElement && viewElement.uiType === "object" && viewElement.isList === true; +} + +export const isViewElementObjectOrList = (viewElement: ViewElement): viewElement is ViewElementObject | ViewElementList => { + return viewElement && viewElement.uiType === "object"; +} + +export const isViewElementSelection = (viewElement: ViewElement): viewElement is ViewElementSelection => { + return viewElement && viewElement.uiType === "selection"; +} + +export const isViewElementReference = (viewElement: ViewElement): viewElement is ViewElementReference => { + return viewElement && viewElement.uiType === "reference"; +} + +export type ViewSpecification = { "id": string; - "parentView": string; "name": string; - "language": string; "title"?: string; - "url": string; - "dataPath": string; - "elements": ViewElement[]; + "parentView"?: string; + "language": string; + "ifFeature"?: string; + "when"?: string; + "uses"?: string[]; + "elements": { [name: string]: ViewElement }; + readonly "canEdit": boolean; } - |