@denevads/dnv-smo 1.0.15 → 1.0.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,80 +1,18 @@
1
- #Introducción
2
- Librería de interfaz de comunicaciones entre un objeto HTML5 y las funciones de un player de DenevaDS.
1
+ # DnvSMO
2
+ Libreria de conexión con la API de la salida.
3
3
 
4
- Aquí definiremos el uso de la librería y las funciones que la misma provee
4
+ ## Conexión con NPM
5
5
 
6
+ Para conexión con NPM se deben de ejecutar los siguientes comandos. La cuenta de login es denevads
6
7
 
7
- # Instalación
8
- La librería esta pensada para ser usada junto con Angular, de manera que si no contamos con el cli de angular en el sistema conviene instalarlo para inicializar el proyecto.
9
- ```sh
10
- npm install -g @angular/cli
11
- ```
12
- Inicializamos un proyecto de prueba llamado html-deneva en la ruta en la que estemos.
13
- ```sh
14
- ng new html-deneva
15
- ```
16
- Una vez que ya tenemos la estructura básica del proyecto podemos instalar la librería en el proyecto ejecutando la siguiente liena dentro de la carpeta del mismo:
17
- ```sh
18
- npm install @denevads/dnv-smo
19
- ```
20
8
 
21
- # Inicialización
9
+ npm run build
22
10
 
23
- Una vez que tengamos el proyecto de angular inicializado, procedemos importar el módulo.
11
+ npm login
24
12
 
25
- Dentro de la definición del app.module en la carpeta app, importamos la librería.
26
- ```ts
27
- import { SMO } from '@denevads/dnv-smo/dist/smo';
28
- ```
29
- y lo añadimos como provider en @NgModule
30
- ```ts
31
- providers: [SMO]
32
- ```
13
+ npm publish
33
14
 
34
- Ahora ya solo bastaría con añadirlo al componente del angular y empezar a usarlo.
15
+ ## Instalación.
35
16
 
36
- De nuevo en app.component importamos la librería
37
- ```js
38
- import { LogLevel, SMO } from '@denevads/dnv-smo/dist/smo'
39
- ```
40
- Y en la exportación de la clase AppComponent añadimos el constructor
41
- ```js
42
- constructor(private smo:SMO){ }
43
- ```
44
- De esta manera ya tendríamos disponible para su uso todas las llamadas que aporta la librería usando
45
- ```js
46
- this.smo.
47
- ```
48
- También en la importacion hemos traído la enumeración de los niveles de log, que sirven para loggear en el disco del equipo.
49
- El uso sería de la siguiente forma.
50
- ```js
51
- this.smo.smoCallBacks.smoLog('Mensaje de prueba',LogLevel.Info);
52
- ```
17
+ Para instalar la librería hay que ejecutar: npm install @denevads/dnv-smo
53
18
 
54
- # Compilación y empaquetado.
55
-
56
- Para que el proyecto pueda funcionar en un equipo sin problemas hay que hacer un par de cambios en el código del proyecto por defecto.
57
-
58
- El primero de ellos es modificar el tsconfig.json para que el "target" sea "ES5" en lugar de "ES2022"
59
-
60
-
61
- Y el segundo cambio es en archivo de index. Aquí haremos dos cosas.
62
- -Borraremos la importación del favicon (además de borrarlo de la carpeta de archivos).
63
- -Y cambiamos la línea
64
- ```html
65
- <base href="/">
66
- ```
67
- por
68
- ```html
69
- <script>document.write('<base href="' + document.location + '" />');</script>
70
- ```
71
- Con estos cambios hechos, podemos compilar el proyecto ejecutando la línea
72
- ```sh
73
- ng b
74
- ```
75
- Esto nos generara una carpeta dist, con el contenido de nuestro HTML5 compilado.
76
-
77
- Para poder subirlo al player de deneva, simplemente tenemos que crear un zip con el contenido en la raíz, y le cambiaremos la extensión por
78
- ```sh
79
- .wgt
80
- ```
@@ -35,6 +35,12 @@ export interface GetRecursos {
35
35
  codigo: number;
36
36
  fechaInicio: string;
37
37
  fechaFin: string;
38
+ recursos?: [];
39
+ canales?: Canal[];
40
+ }
41
+ export interface Canal {
42
+ codigo: number;
43
+ pases: number;
38
44
  recursos: Recurso[];
39
45
  }
40
46
  export interface GetRecursosRelleno {
package/dist/smo.d.ts CHANGED
@@ -126,4 +126,38 @@ export declare enum AlarmaLevel {
126
126
  Warning = 4,
127
127
  Error = 5
128
128
  }
129
+ export interface ObjJSType {
130
+ urlNext: () => void;
131
+ limpiaCapa: () => void;
132
+ logFlash: () => void;
133
+ pageInit: () => void;
134
+ finAviso: () => void;
135
+ exitInteractivity: () => void;
136
+ logWeb: () => void;
137
+ refreshPage: () => void;
138
+ refreshPageByError: () => void;
139
+ refreshPageByVideoEvent: () => void;
140
+ auditarRecurso: () => void;
141
+ initSMO: () => void;
142
+ getFile: () => void;
143
+ showBrowser: () => void;
144
+ closeBrowser: () => void;
145
+ refreshDataSource: () => void;
146
+ setVariable: () => void;
147
+ getVariable: () => void;
148
+ getLocation: () => void;
149
+ salirApp: () => void;
150
+ setLocalData: () => void;
151
+ getLocalData: () => void;
152
+ getSalidaData: () => void;
153
+ ejecutaFuncion: () => void;
154
+ addObserver: () => void;
155
+ notifyToObservers: () => void;
156
+ printTextLine: () => void;
157
+ printBarcode: () => void;
158
+ cutPaper: () => void;
159
+ printImage: () => void;
160
+ checkHealthPrinter: () => void;
161
+ checkHealth: () => void;
162
+ }
129
163
  export {};
package/dist/smo.js CHANGED
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AlarmaLevel = exports.LogLevel = exports.SMO_EVENT_TYPE = exports.SMO = void 0;
4
4
  var rxjs_1 = require("rxjs");
5
+ // @ts-ignore
5
6
  var SMO = /** @class */ (function () {
6
7
  function SMO() {
7
8
  this.vars = {};
@@ -21,6 +22,120 @@ var SMO = /** @class */ (function () {
21
22
  while (match = search.exec(query)) {
22
23
  this.vars[decode(match[1])] = decode(match[2]);
23
24
  }
25
+ // @ts-ignore
26
+ if (window.objJS) {
27
+ // @ts-ignore
28
+ window.sendToIframefromNet = function (target, iframeID, objData) {
29
+ console.log("sendToIframefromNet->", target);
30
+ switch (target) {
31
+ case "SMO.setDatasource":
32
+ break;
33
+ case "SMO.checkHealthPrinter":
34
+ _this.events.checkHealthPrinter.next(objData);
35
+ break;
36
+ }
37
+ // @ts-ignore
38
+ window.parent.postMessage = function (target, objData, idSmo) {
39
+ switch (target.target) {
40
+ case "Dnv.smoCallbacks.onSmoLoad":
41
+ // @ts-ignore
42
+ window.objJS.onSmoLoad();
43
+ break;
44
+ case "Dnv.smoCallbacks.printTextLine":
45
+ // @ts-ignore
46
+ window.objJS.printTextLine(objData.txt);
47
+ break;
48
+ case "Dnv.smoCallbacks.printBarcode":
49
+ // @ts-ignore
50
+ window.objJS.printBarcode(objData.code, objData.width, objData.height);
51
+ break;
52
+ case "Dnv.smoCallbacks.cutPaper":
53
+ // @ts-ignore
54
+ window.objJS.cutPaper(objData.percent);
55
+ break;
56
+ case "Dnv.smoCallbacks.printImage":
57
+ // @ts-ignore
58
+ window.objJS.printImage(idSmo, objData.image);
59
+ break;
60
+ case "Dnv.smoCallbacks.checkHealthPrinter":
61
+ console.log('llamo a checkhealthprinter');
62
+ // @ts-ignore
63
+ window.objJS.checkHealthPrinter(idSmo);
64
+ break;
65
+ case "Dnv.smoCallbacks.checkHealth":
66
+ // @ts-ignore
67
+ window.objJS.checkHealth();
68
+ break;
69
+ }
70
+ };
71
+ };
72
+ window.external = {
73
+ // @ts-ignore
74
+ URLNext: window.objJS.urlNext,
75
+ // @ts-ignore
76
+ LimpiaCapa: window.objJS.limpiaCapa,
77
+ // @ts-ignore
78
+ LogFlash: window.objJS.logFlash,
79
+ // @ts-ignore
80
+ PageInit: window.objJS.pageInit,
81
+ // @ts-ignore
82
+ FinAviso: window.objJS.finAviso,
83
+ // @ts-ignore
84
+ ExitInteractivity: window.objJS.exitInteractivity,
85
+ // @ts-ignore
86
+ LogWeb: window.objJS.logWeb,
87
+ // @ts-ignore
88
+ RefreshPage: window.objJS.refreshPage,
89
+ // @ts-ignore
90
+ RefreshPageByError: window.objJS.refreshPageByError,
91
+ // @ts-ignore
92
+ RefreshPageByVideoEvent: window.objJS.refreshPageByVideoEvent,
93
+ // @ts-ignore
94
+ AuditarRecurso: window.objJS.auditarRecurso,
95
+ // @ts-ignore
96
+ InitSMO: window.objJS.initSMO,
97
+ // @ts-ignore
98
+ GetFile: window.objJS.getFile,
99
+ // @ts-ignore
100
+ ShowBrowser: window.objJS.showBrowser,
101
+ // @ts-ignore
102
+ closeBrowser: window.objJS.closeBrowser,
103
+ // @ts-ignore
104
+ RefreshDataSource: window.objJS.refreshDataSource,
105
+ // @ts-ignore
106
+ SetVariable: window.objJS.setVariable,
107
+ // @ts-ignore
108
+ GetVariable: window.objJS.getVariable,
109
+ // @ts-ignore
110
+ GetLocation: window.objJS.getLocation,
111
+ // @ts-ignore
112
+ SalirApp: window.objJS.salirApp,
113
+ // @ts-ignore
114
+ SetLocalData: window.objJS.setLocalData,
115
+ // @ts-ignore
116
+ GetLocalData: window.objJS.getLocalData,
117
+ // @ts-ignore
118
+ GetSalidaData: window.objJS.getSalidaData,
119
+ // @ts-ignore
120
+ EjecutaFuncion: window.objJS.ejecutaFuncion,
121
+ // @ts-ignore
122
+ AddObserver: window.objJS.addObserver,
123
+ // @ts-ignore
124
+ NotifyToObservers: window.objJS.notifyToObservers,
125
+ // @ts-ignore
126
+ PrintTextLine: window.objJS.printTextLine,
127
+ // @ts-ignore
128
+ PrintBarcode: window.objJS.printBarcode,
129
+ // @ts-ignore
130
+ CutPaper: window.objJS.cutPaper,
131
+ // @ts-ignore
132
+ PrintImage: window.objJS.printImage,
133
+ // @ts-ignore
134
+ CheckHealthPrinter: window.objJS.checkHealthPrinter,
135
+ // @ts-ignore
136
+ CheckHealth: window.objJS.checkHealth
137
+ };
138
+ }
24
139
  if (this.vars.idSmo) {
25
140
  this.id = this.vars.idSmo;
26
141
  if (this.vars["LowPower"] == "true" && (this.vars["url"] != undefined || this.vars["LocalData"] != undefined)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@denevads/dnv-smo",
3
- "version": "1.0.15",
3
+ "version": "1.0.17",
4
4
  "description": "SMO module",
5
5
  "main": "./src/index.js",
6
6
  "types": "./src/index.d.ts",
@@ -36,10 +36,16 @@ export interface Notify{
36
36
  }
37
37
 
38
38
  export interface GetRecursos {
39
- codigo: number;
39
+ codigo: number;
40
40
  fechaInicio: string;
41
- fechaFin: string;
42
- recursos: Recurso[];
41
+ fechaFin: string;
42
+ recursos?: [];
43
+ canales?: Canal[];
44
+ }
45
+ export interface Canal {
46
+ codigo: number;
47
+ pases: number;
48
+ recursos: Recurso[];
43
49
  }
44
50
  export interface GetRecursosRelleno {
45
51
  codigo: number;
package/src/smo.ts CHANGED
@@ -9,6 +9,12 @@ import {
9
9
  GetRecursos, GetRecursosRelleno
10
10
  } from "./interfaces/callbacks";
11
11
  import {interval, Subject, Subscription} from 'rxjs';
12
+ interface Window {
13
+ external:ObjJSType;
14
+ objJS:ObjJSType;
15
+ }
16
+ // @ts-ignore
17
+
12
18
  export class SMO {
13
19
  public vars:any = {};
14
20
  public id:string = "";
@@ -17,6 +23,7 @@ export class SMO {
17
23
  public smoCallBacks:smoCallBacks;
18
24
  public utils:Utils;
19
25
  public events:SmoEvents;
26
+
20
27
  constructor(){
21
28
 
22
29
  this.initOnMessage();
@@ -36,6 +43,126 @@ export class SMO {
36
43
  while (match = search.exec(query)) {
37
44
  this.vars[decode(match[1])] = decode(match[2]);
38
45
  }
46
+ // @ts-ignore
47
+ if(window.objJS){
48
+ // @ts-ignore
49
+ window.sendToIframefromNet = (target, iframeID, objData) => {
50
+ console.log("sendToIframefromNet->",target);
51
+ switch (target) {
52
+ case "SMO.setDatasource":
53
+ break;
54
+ case "SMO.checkHealthPrinter":
55
+ this.events.checkHealthPrinter.next(objData);
56
+ break;
57
+ }
58
+ // @ts-ignore
59
+ window.parent.postMessage = (target,objData,idSmo)=> {
60
+ switch (target.target) {
61
+ case "Dnv.smoCallbacks.onSmoLoad":
62
+ // @ts-ignore
63
+ window.objJS.onSmoLoad();
64
+ break;
65
+
66
+ case "Dnv.smoCallbacks.printTextLine":
67
+ // @ts-ignore
68
+ window.objJS.printTextLine(objData.txt);
69
+ break;
70
+ case "Dnv.smoCallbacks.printBarcode":
71
+ // @ts-ignore
72
+ window.objJS.printBarcode(objData.code, objData.width, objData.height);
73
+ break;
74
+ case "Dnv.smoCallbacks.cutPaper":
75
+ // @ts-ignore
76
+ window.objJS.cutPaper(objData.percent);
77
+ break;
78
+ case "Dnv.smoCallbacks.printImage":
79
+ // @ts-ignore
80
+ window.objJS.printImage(idSmo, objData.image);
81
+ break;
82
+ case "Dnv.smoCallbacks.checkHealthPrinter":
83
+ console.log('llamo a checkhealthprinter');
84
+ // @ts-ignore
85
+
86
+ window.objJS.checkHealthPrinter(idSmo);
87
+ break;
88
+ case "Dnv.smoCallbacks.checkHealth":
89
+ // @ts-ignore
90
+ window.objJS.checkHealth();
91
+ break;
92
+
93
+
94
+ }
95
+ }
96
+
97
+ }
98
+
99
+ window.external = {
100
+ // @ts-ignore
101
+ URLNext: window.objJS.urlNext,
102
+ // @ts-ignore
103
+ LimpiaCapa: window.objJS.limpiaCapa,
104
+ // @ts-ignore
105
+ LogFlash: window.objJS.logFlash,
106
+ // @ts-ignore
107
+ PageInit: window.objJS.pageInit,
108
+ // @ts-ignore
109
+ FinAviso: window.objJS.finAviso,
110
+ // @ts-ignore
111
+ ExitInteractivity: window.objJS.exitInteractivity,
112
+ // @ts-ignore
113
+ LogWeb: window.objJS.logWeb,
114
+ // @ts-ignore
115
+ RefreshPage: window.objJS.refreshPage,
116
+ // @ts-ignore
117
+ RefreshPageByError: window.objJS.refreshPageByError,
118
+ // @ts-ignore
119
+ RefreshPageByVideoEvent: window.objJS.refreshPageByVideoEvent,
120
+ // @ts-ignore
121
+ AuditarRecurso: window.objJS.auditarRecurso,
122
+ // @ts-ignore
123
+ InitSMO: window.objJS.initSMO,
124
+ // @ts-ignore
125
+ GetFile: window.objJS.getFile,
126
+ // @ts-ignore
127
+ ShowBrowser: window.objJS.showBrowser,
128
+ // @ts-ignore
129
+ closeBrowser: window.objJS.closeBrowser,
130
+ // @ts-ignore
131
+ RefreshDataSource: window.objJS.refreshDataSource,
132
+ // @ts-ignore
133
+ SetVariable: window.objJS.setVariable,
134
+ // @ts-ignore
135
+ GetVariable: window.objJS.getVariable,
136
+ // @ts-ignore
137
+ GetLocation: window.objJS.getLocation,
138
+ // @ts-ignore
139
+ SalirApp: window.objJS.salirApp,
140
+ // @ts-ignore
141
+ SetLocalData: window.objJS.setLocalData,
142
+ // @ts-ignore
143
+ GetLocalData: window.objJS.getLocalData,
144
+ // @ts-ignore
145
+ GetSalidaData: window.objJS.getSalidaData,
146
+ // @ts-ignore
147
+ EjecutaFuncion: window.objJS.ejecutaFuncion,
148
+ // @ts-ignore
149
+ AddObserver: window.objJS.addObserver,
150
+ // @ts-ignore
151
+ NotifyToObservers: window.objJS.notifyToObservers,
152
+ // @ts-ignore
153
+ PrintTextLine: window.objJS.printTextLine,
154
+ // @ts-ignore
155
+ PrintBarcode: window.objJS.printBarcode,
156
+ // @ts-ignore
157
+ CutPaper: window.objJS.cutPaper,
158
+ // @ts-ignore
159
+ PrintImage: window.objJS.printImage,
160
+ // @ts-ignore
161
+ CheckHealthPrinter: window.objJS.checkHealthPrinter,
162
+ // @ts-ignore
163
+ CheckHealth: window.objJS.checkHealth
164
+ };
165
+ }
39
166
  if (this.vars.idSmo) {
40
167
  this.id = this.vars.idSmo;
41
168
  if(this.vars["LowPower"] == "true" && (this.vars["url"] != undefined || this.vars["LocalData"] != undefined)){
@@ -186,7 +313,6 @@ class smoCallBacks{
186
313
  this.smo =_smo;
187
314
  }
188
315
  public onSmoLoad():void {
189
-
190
316
  window.parent.postMessage({
191
317
  target: "Dnv.smoCallbacks.onSmoLoad",
192
318
  objData: undefined,
@@ -630,3 +756,38 @@ Timeout= 3,
630
756
  Warning= 4,
631
757
  Error= 5
632
758
  }
759
+ export interface ObjJSType {
760
+ urlNext: () => void;
761
+ limpiaCapa: () => void;
762
+ logFlash: () => void;
763
+ pageInit: () => void;
764
+ finAviso: () => void;
765
+ exitInteractivity: () => void;
766
+ logWeb: () => void;
767
+ refreshPage: () => void;
768
+ refreshPageByError: () => void;
769
+ refreshPageByVideoEvent: () => void;
770
+ auditarRecurso: () => void;
771
+ initSMO: () => void;
772
+ getFile: () => void;
773
+ showBrowser: () => void;
774
+ closeBrowser: () => void;
775
+ refreshDataSource: () => void;
776
+ setVariable: () => void;
777
+ getVariable: () => void;
778
+ getLocation: () => void;
779
+ salirApp: () => void;
780
+ setLocalData: () => void;
781
+ getLocalData: () => void;
782
+ getSalidaData: () => void;
783
+ ejecutaFuncion: () => void;
784
+ addObserver: () => void;
785
+ notifyToObservers: () => void;
786
+ printTextLine: () => void;
787
+ printBarcode: () => void;
788
+ cutPaper: () => void;
789
+ printImage: () => void;
790
+ checkHealthPrinter: () => void;
791
+ checkHealth: () => void;
792
+ }
793
+