@denevads/dnv-smo 1.1.1 → 1.1.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@denevads/dnv-smo",
3
- "version": "1.1.1",
3
+ "version": "1.1.3",
4
4
  "description": "SMO module",
5
5
  "main": "./src/index.js",
6
6
  "types": "./src/index.d.ts",
@@ -15,7 +15,8 @@
15
15
  "author": "Xavier",
16
16
  "license": "MIT",
17
17
  "devDependencies": {
18
- "@types/node": "^20.1.4"
18
+ "@types/node": "^20.1.4",
19
+ "typescript": "^6.0.3"
19
20
  },
20
21
  "dependencies": {
21
22
  "mitt": "^3.0.0",
@@ -2,6 +2,12 @@
2
2
  export interface setDatasource{
3
3
  xml:string
4
4
  }
5
+ export interface setBorradoAviso{
6
+ args:any
7
+ }
8
+ export interface setAviso{
9
+ args:any
10
+ }
5
11
  export interface start{
6
12
 
7
13
  }
package/src/smo.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  import {
2
2
  setDatasource,
3
+ setAviso,
4
+ setBorradoAviso,
3
5
  variable,
4
6
  location,
5
7
  DataSalida,
@@ -32,6 +34,7 @@ export class SMO {
32
34
  this.utils = new Utils(this,this.smoCallBacks);
33
35
  this.events =new SmoEvents(this);
34
36
  this.init();
37
+ this.utils.writeVars();
35
38
  }
36
39
  public init():void{
37
40
  let match,
@@ -40,12 +43,10 @@ export class SMO {
40
43
  decode = function(s:string) {
41
44
  return decodeURIComponent(s.replace(pl, " "));
42
45
  },
43
- query = window.location.href.slice(window.location.href.indexOf("?") + 1);
44
-
46
+ query = window.location.search.substring(1);
45
47
  while (match = search.exec(query)) {
46
48
  this.vars[decode(match[1])] = decode(match[2]);
47
49
  }
48
-
49
50
  //console.log("vars->",JSON.stringify(this.vars));
50
51
  // @ts-ignore
51
52
  //console.log( "resultados " +window.objJS != undefined + " " + window !== window.parent + " " + this.vars.ontop != undefined + " " + this.vars.ontop != "");
@@ -57,6 +58,12 @@ export class SMO {
57
58
  window.sendToIframefromNet = (target, iframeID, objData) => {
58
59
  console.log("sendToIframefromNet->",JSON.stringify(target));
59
60
  switch (target) {
61
+ case "SMO.setAvisos":
62
+ this.events.setAvisos.next(objData)
63
+ break;
64
+ case "SMO.setBorradoAviso":
65
+ this.events.setBorradoAviso.next(objData)
66
+ break;
60
67
  case "SMO.setDatasource":
61
68
  this.events.setDatasource.next(objData)
62
69
  break;
@@ -78,6 +85,8 @@ export class SMO {
78
85
  // @ts-ignore
79
86
  FinAviso: window.objJS.finAviso,
80
87
  // @ts-ignore
88
+ SetEstadoAviso: window.objJS.setEstadoAviso,
89
+ // @ts-ignore
81
90
  ExitInteractivity: window.objJS.exitInteractivity,
82
91
  // @ts-ignore
83
92
  LogWeb: window.objJS.logWeb,
@@ -189,23 +198,34 @@ export class SMO {
189
198
  selft.setDatasource(e.data.objData);
190
199
  return;
191
200
  }
201
+ /* METODOS DE AVISOS */
202
+ if(func == SMO_EVENT_TYPE.setAvisoArgs || func == SMO_EVENT_TYPE.setAvisoDuracionArgs || func == SMO_EVENT_TYPE.setAvisoLogotipoArgs){
203
+ selft.setAvisos(e.data.objData);
204
+ return;
205
+ }
206
+ if(func == SMO_EVENT_TYPE.setBorradoAviso){
207
+ selft.setBorradoAviso(e.data.objData);
208
+ return;
209
+ }
210
+ /* ----------------------------------- */
211
+
192
212
  if(func == SMO_EVENT_TYPE.getVariable){
193
213
  selft.getVariable(e.data.objData);
194
214
  return;
195
215
  }
196
- if(func ==SMO_EVENT_TYPE.setCurrentStream){
216
+ if(func == SMO_EVENT_TYPE.setCurrentStream){
197
217
  selft.setCurrentStream(e.data.objData);
198
218
  return;
199
219
  }
200
- if(func==SMO_EVENT_TYPE.infoCurrentLocation){
220
+ if(func == SMO_EVENT_TYPE.infoCurrentLocation){
201
221
  selft.infoCurrentLocation(e.data.objData);
202
222
  return;
203
223
  }
204
- if(func==SMO_EVENT_TYPE.setSalidaData){
224
+ if(func == SMO_EVENT_TYPE.setSalidaData){
205
225
  selft.setSalidaData(e.data.objData);
206
226
  return;
207
227
  }
208
- if(func ==SMO_EVENT_TYPE.updatefromsalida){
228
+ if(func == SMO_EVENT_TYPE.updatefromsalida){
209
229
  selft.updatefromsalida(e.data.objData);
210
230
  return;
211
231
  }
@@ -267,6 +287,12 @@ export class SMO {
267
287
  this.events.setDatasource.next(datasource);
268
288
  this.events.setDatasourceJson.next(this.utils.xmlToJSON(datasource.xml));
269
289
  }
290
+ setAvisos(aviso:setAviso):void {
291
+ this.events.setAvisos.next(aviso);
292
+ }
293
+ setBorradoAviso(aviso:setBorradoAviso):void {
294
+ this.events.setBorradoAviso.next(aviso);
295
+ }
270
296
  getVariable(variable:variable):void{
271
297
  this.events.getVariable.next(variable);
272
298
  }
@@ -322,6 +348,8 @@ class SmoEvents{
322
348
  public start: Subject<start> = new Subject<start>();
323
349
  public dispose: Subject<start> = new Subject<dispose>();
324
350
  public setDatasource: Subject<setDatasource> = new Subject<setDatasource>();
351
+ public setAvisos: Subject<setAviso> = new Subject<setAviso>();
352
+ public setBorradoAviso: Subject<setBorradoAviso> = new Subject<setBorradoAviso>();
325
353
  public setDatasourceJson: Subject<any> = new Subject<any>();
326
354
  public getVariable: Subject<variable> = new Subject<variable>();
327
355
  public setCurrentStream: Subject<string> = new Subject<string>();
@@ -374,7 +402,7 @@ class smoCallBacks{
374
402
  if (level == LogLevel.Warning) {
375
403
  console.warn(msn);
376
404
  }
377
- if (level == LogLevel.Error) {
405
+ if (level == LogLevel.Error || level == LogLevel.Fatal) {
378
406
  console.error(msn);
379
407
  }
380
408
  if (window.parent != window) {
@@ -511,6 +539,13 @@ class smoCallBacks{
511
539
  idSmo: this.smo.id
512
540
  }, this.smo.vars.idSmo);
513
541
  }
542
+ setEstadoAviso(params:string):void {
543
+ this.smo.utils.sendToParent({
544
+ target: "Dnv.smoCallbacks.setEstadoAviso",
545
+ objData: params, // id del aviso
546
+ idSmo: this.smo.id
547
+ }, this.smo.vars.idSmo);
548
+ }
514
549
  refreshDatasource(codigo:string):void {
515
550
  this.smo.utils.sendToParent({
516
551
  target: "Dnv.smoCallbacks.refreshDatasource",
@@ -751,6 +786,15 @@ class Utils{
751
786
  this.smo = _smo;
752
787
  this.smoCallBacks =_smoCallBacks;
753
788
  }
789
+
790
+ writeVars(): void {
791
+ let out = "";
792
+ for (const k in this.smo.vars) {
793
+ if (this.smo.vars.hasOwnProperty(k)) out += k + "=" + this.smo.vars[k] + "&";
794
+ }
795
+ if (out) this.smoCallBacks.smoLog(out, LogLevel.Debug);
796
+ }
797
+
754
798
  // Funciones para XML to JSON
755
799
  xmlToJSON(xml:string) {
756
800
  let getxml = new DOMParser();
@@ -919,6 +963,10 @@ export enum SMO_EVENT_TYPE{
919
963
  start = "start",
920
964
  dispose = "dispose",
921
965
  setDatasource = "setDatasource",
966
+ setAvisoArgs = "setAvisoArgs",
967
+ setAvisoLogotipoArgs = "setAvisoLogotipoArgs",
968
+ setAvisoDuracionArgs = "setAvisoDuracionArgs",
969
+ setBorradoAviso = "setBorradoAviso",
922
970
  getVariable = "getVariable",
923
971
  setCurrentStream = "setCurrentStream",
924
972
  infoCurrentLocation = "infoCurrentLocation",
@@ -941,7 +989,8 @@ export enum LogLevel {
941
989
  Debug= 0,
942
990
  Info= 1,
943
991
  Warning= 2,
944
- Error= 3
992
+ Error= 3,
993
+ Fatal= 4
945
994
  }
946
995
  export enum AlarmaLevel {
947
996
  Ok_off= 0,
@@ -957,6 +1006,7 @@ export interface ObjJSType {
957
1006
  logFlash: () => void;
958
1007
  pageInit: () => void;
959
1008
  finAviso: () => void;
1009
+ setEstadoAviso: () => void;
960
1010
  exitInteractivity: () => void;
961
1011
  logWeb: () => void;
962
1012
  refreshPage: () => void;
package/tsconfig.json CHANGED
@@ -12,6 +12,7 @@
12
12
  "declaration": true,
13
13
  /* Language and Environment */
14
14
  "target": "es5", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
15
+ "ignoreDeprecations": "6.0",
15
16
  // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
16
17
  // "jsx": "preserve", /* Specify what JSX code is generated. */
17
18
  // "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
@@ -25,7 +26,7 @@
25
26
 
26
27
  /* Modules */
27
28
  "module": "commonjs", /* Specify what module code is generated. */
28
- // "rootDir": "./", /* Specify the root folder within your source files. */
29
+ "rootDir": "./src", /* Specify the root folder within your source files. */
29
30
  // "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
30
31
  // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
31
32
  // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
@@ -1,12 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <module type="WEB_MODULE" version="4">
3
- <component name="NewModuleRootManager">
4
- <content url="file://$MODULE_DIR$">
5
- <excludeFolder url="file://$MODULE_DIR$/.tmp" />
6
- <excludeFolder url="file://$MODULE_DIR$/temp" />
7
- <excludeFolder url="file://$MODULE_DIR$/tmp" />
8
- </content>
9
- <orderEntry type="inheritedJdk" />
10
- <orderEntry type="sourceFolder" forTests="false" />
11
- </component>
12
- </module>
package/.idea/modules.xml DELETED
@@ -1,8 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="ProjectModuleManager">
4
- <modules>
5
- <module fileurl="file://$PROJECT_DIR$/.idea/denevads_dnv-smo.iml" filepath="$PROJECT_DIR$/.idea/denevads_dnv-smo.iml" />
6
- </modules>
7
- </component>
8
- </project>
package/.idea/vcs.xml DELETED
@@ -1,6 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="VcsDirectoryMappings">
4
- <mapping directory="" vcs="Git" />
5
- </component>
6
- </project>