summaryrefslogtreecommitdiffstats
path: root/sdnr/wt/odlux/framework/src/models
diff options
context:
space:
mode:
authorHerbert Eiselt <herbert.eiselt@highstreet-technologies.com>2019-02-11 14:54:12 +0100
committerHerbert Eiselt <herbert.eiselt@highstreet-technologies.com>2019-02-11 14:54:53 +0100
commit3d202a04b99f0e61b6ccf8b7a5610e1a15ca58e7 (patch)
treeab756cfa8de5eced886d3947423d198be8c0ce62 /sdnr/wt/odlux/framework/src/models
parent12a8c669f52c0e84d580c078cee849b25133b585 (diff)
Add sdnr wt odlux
Add complete sdnr wireless transport app odlux core and apps Change-Id: I5dcbfb8f3b790e3bda7c8df67bd69d81958f65e5 Issue-ID: SDNC-576 Signed-off-by: Herbert Eiselt <herbert.eiselt@highstreet-technologies.com>
Diffstat (limited to 'sdnr/wt/odlux/framework/src/models')
-rw-r--r--sdnr/wt/odlux/framework/src/models/applicationInfo.ts31
-rw-r--r--sdnr/wt/odlux/framework/src/models/authentication.ts50
-rw-r--r--sdnr/wt/odlux/framework/src/models/elasticSearch.ts22
-rw-r--r--sdnr/wt/odlux/framework/src/models/errorInfo.ts11
-rw-r--r--sdnr/wt/odlux/framework/src/models/iconDefinition.ts4
-rw-r--r--sdnr/wt/odlux/framework/src/models/index.ts1
-rw-r--r--sdnr/wt/odlux/framework/src/models/restService.ts30
-rw-r--r--sdnr/wt/odlux/framework/src/models/snackbarItem.ts3
8 files changed, 152 insertions, 0 deletions
diff --git a/sdnr/wt/odlux/framework/src/models/applicationInfo.ts b/sdnr/wt/odlux/framework/src/models/applicationInfo.ts
new file mode 100644
index 000000000..d2076591e
--- /dev/null
+++ b/sdnr/wt/odlux/framework/src/models/applicationInfo.ts
@@ -0,0 +1,31 @@
+import { ComponentType } from 'react';
+import { IconType } from './iconDefinition';
+
+import { IActionHandler } from '../flux/action';
+import { Middleware } from '../flux/middleware';
+
+/** Represents the information needed about an application to integrate. */
+export class ApplicationInfo {
+ /** The name of the application. */
+ name: string;
+ /** Optional: The title of the application, if null ot undefined the name will be used. */
+ title?: string;
+ /** Optional: The icon of the application for the navigation and title bar. */
+ icon?: IconType;
+ /** Optional: The description of the application. */
+ description?: string;
+ /** The root component of the application. */
+ rootComponent: ComponentType;
+ /** Optional: The root action handler of the application. */
+ rootActionHandler?: IActionHandler<{ [key: string]: any }>;
+ /** Optional: Application speciffic middlewares. */
+ middlewares?: Middleware<{ [key: string]: any }>[];
+ /** Optional: A mapping object with the exported components. */
+ exportedComponents?: { [key: string]: ComponentType }
+ /** Optional: The entry to be shown in the menu. If undefiened the name will be used. */
+ menuEntry?: string | React.ComponentType;
+ /** Optional: A component to be shown in the menu when this app is active below the main entry. If undefiened the name will be used. */
+ subMenuEntry?: React.ComponentType;
+ /** Optional: The pasth for this application. If undefined the name will be use as path. */
+ path?: string;
+}
diff --git a/sdnr/wt/odlux/framework/src/models/authentication.ts b/sdnr/wt/odlux/framework/src/models/authentication.ts
new file mode 100644
index 000000000..44b5ae436
--- /dev/null
+++ b/sdnr/wt/odlux/framework/src/models/authentication.ts
@@ -0,0 +1,50 @@
+import * as JWT from 'jsonwebtoken';
+
+export interface IUserInfo {
+ iss: string,
+ iat: number,
+ exp: number,
+ aud: string,
+ sub: string,
+ firstName: string,
+ lastName: string,
+ email: string,
+ role: string[]
+}
+
+
+export class User {
+
+ public _userInfo: IUserInfo | null;
+
+ constructor(private _bearerToken: string) {
+ //const pem = require('raw-loader!../assets/publicKey.pem');
+ const pem = "kFfAgpf806IKa4z88EEk6Lim7NMGicrw99OmIB38myM9CS44nEmMNJxnFu3ImViS248wSwkuZ3HvrhsPrA1ZFRNb1a6CEtGN4DaPJbfuo35qMp50tIEpy8nsSFpayOBE";
+
+ try {
+ const dec = (JWT.verify(_bearerToken, pem)) as IUserInfo;
+ this._userInfo = dec;
+ } catch (ex) {
+ this._userInfo = null;
+ }
+ }
+
+ public get user(): string | null {
+ return this._userInfo && this._userInfo.email;
+ };
+
+ public get roles(): string[] | null {
+ return this._userInfo && this._userInfo.role;
+ }
+ public get token(): string | null {
+ return this._userInfo && this._bearerToken;
+ }
+
+ public isInRole(role: string | string[]): boolean {
+ return false;
+ }
+
+}
+
+// key:kFfAgpf806IKa4z88EEk6Lim7NMGicrw99OmIB38myM9CS44nEmMNJxnFu3ImViS248wSwkuZ3HvrhsPrA1ZFRNb1a6CEtGN4DaPJbfuo35qMp50tIEpy8nsSFpayOBE
+// token: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJPRExVWCIsImlhdCI6MTUzODQ2NDMyMCwiZXhwIjoxNTcwMDAwMzIwLCJhdWQiOiJsb2NhbGhvc3QiLCJzdWIiOiJsb2NhbGhvc3QiLCJmaXJzdE5hbWUiOiJNYXgiLCJsYXN0TmFtZSI6Ik11c3Rlcm1hbm4iLCJlbWFpbCI6Im1heEBvZGx1eC5jb20iLCJyb2xlIjpbInVzZXIiLCJhZG1pbiJdfQ.9e5hDi2uxmIXNwHkJoScBZsHBk0jQ8CcZ7YIcZhDtuI \ No newline at end of file
diff --git a/sdnr/wt/odlux/framework/src/models/elasticSearch.ts b/sdnr/wt/odlux/framework/src/models/elasticSearch.ts
new file mode 100644
index 000000000..504b2cf21
--- /dev/null
+++ b/sdnr/wt/odlux/framework/src/models/elasticSearch.ts
@@ -0,0 +1,22 @@
+export type Result<TSource extends {}> = {
+ took: number;
+ timed_out: boolean;
+ _shards: {
+ total: number;
+ successful: number;
+ failed: number;
+ };
+ hits: {
+ total: number;
+ max_score: number;
+ hits?: (HitEntry<TSource>)[] | null;
+ };
+}
+
+export type HitEntry<TSource extends {}> = {
+ _index: string;
+ _type: string;
+ _id: string;
+ _score: number;
+ _source: TSource;
+}
diff --git a/sdnr/wt/odlux/framework/src/models/errorInfo.ts b/sdnr/wt/odlux/framework/src/models/errorInfo.ts
new file mode 100644
index 000000000..f07145500
--- /dev/null
+++ b/sdnr/wt/odlux/framework/src/models/errorInfo.ts
@@ -0,0 +1,11 @@
+export type ErrorInfo = {
+ error?: Error | null,
+ url?: string,
+ line?: number,
+ col?: number,
+ info?: {
+ extra?: string,
+ componentStack?: string
+ },
+ message?: string
+} \ No newline at end of file
diff --git a/sdnr/wt/odlux/framework/src/models/iconDefinition.ts b/sdnr/wt/odlux/framework/src/models/iconDefinition.ts
new file mode 100644
index 000000000..6fef9dbc7
--- /dev/null
+++ b/sdnr/wt/odlux/framework/src/models/iconDefinition.ts
@@ -0,0 +1,4 @@
+
+import { IconDefinition } from '@fortawesome/free-solid-svg-icons';
+
+export type IconType = IconDefinition; \ No newline at end of file
diff --git a/sdnr/wt/odlux/framework/src/models/index.ts b/sdnr/wt/odlux/framework/src/models/index.ts
new file mode 100644
index 000000000..a8a7ca032
--- /dev/null
+++ b/sdnr/wt/odlux/framework/src/models/index.ts
@@ -0,0 +1 @@
+export * from './elasticSearch'; \ No newline at end of file
diff --git a/sdnr/wt/odlux/framework/src/models/restService.ts b/sdnr/wt/odlux/framework/src/models/restService.ts
new file mode 100644
index 000000000..053c29b8e
--- /dev/null
+++ b/sdnr/wt/odlux/framework/src/models/restService.ts
@@ -0,0 +1,30 @@
+/**
+ * The PlainObject type is a JavaScript object containing zero or more key-value pairs.
+ */
+export interface PlainObject<T = any> {
+ [key: string]: T;
+}
+
+export interface AjaxParameter {
+ /**
+ * The HTTP method to use for the request (e.g. "POST", "GET", "PUT").
+ */
+ method?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'OPTIONS' | 'PATCH';
+ /**
+ * An object of additional header key/value pairs to send along with requests using the XMLHttpRequest
+ * transport. The header X-Requested-With: XMLHttpRequest is always added, but its default
+ * XMLHttpRequest value can be changed here. Values in the headers setting can also be overwritten from
+ * within the beforeSend function.
+ */
+ headers?: PlainObject<string | null | undefined>;
+ /**
+ * Data to be sent to the server. It is converted to a query string, if not already a string. It's
+ * appended to the url for GET-requests. See processData option to prevent this automatic processing.
+ * Object must be Key/Value pairs. If value is an Array, jQuery serializes multiple values with same
+ * key based on the value of the traditional setting (described below).
+ */
+ data?: PlainObject | string;
+}
+
+
+
diff --git a/sdnr/wt/odlux/framework/src/models/snackbarItem.ts b/sdnr/wt/odlux/framework/src/models/snackbarItem.ts
new file mode 100644
index 000000000..5aa4dd78a
--- /dev/null
+++ b/sdnr/wt/odlux/framework/src/models/snackbarItem.ts
@@ -0,0 +1,3 @@
+import { OptionsObject } from "notistack";
+
+export type SnackbarItem = { key: number, message: string, options?: OptionsObject }; \ No newline at end of file