@denevads/dnv-smo 1.1.0 → 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.0",
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
  }
@@ -37,6 +43,10 @@ export interface Notify{
37
43
  destion:string,
38
44
  value:any
39
45
  }
46
+ export interface NotifyEditor{
47
+ formInputs?: any[],
48
+ behaviors?:any[]
49
+ }
40
50
  export interface GetRecursosByCodigo {
41
51
  recursos?: Recurso[];
42
52
  }
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,
@@ -7,6 +9,7 @@ import {
7
9
  Notify,
8
10
  start,
9
11
  dispose,
12
+ NotifyEditor,
10
13
  GetRecursosByCodigo,
11
14
  GetRecursos,
12
15
  GetRecursosRelleno, GetRecursosMetadatos, RecursosMetadato, Datasource, DatasourceMap, ValorCalendario
@@ -31,6 +34,7 @@ export class SMO {
31
34
  this.utils = new Utils(this,this.smoCallBacks);
32
35
  this.events =new SmoEvents(this);
33
36
  this.init();
37
+ this.utils.writeVars();
34
38
  }
35
39
  public init():void{
36
40
  let match,
@@ -54,6 +58,12 @@ export class SMO {
54
58
  window.sendToIframefromNet = (target, iframeID, objData) => {
55
59
  console.log("sendToIframefromNet->",JSON.stringify(target));
56
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;
57
67
  case "SMO.setDatasource":
58
68
  this.events.setDatasource.next(objData)
59
69
  break;
@@ -75,6 +85,8 @@ export class SMO {
75
85
  // @ts-ignore
76
86
  FinAviso: window.objJS.finAviso,
77
87
  // @ts-ignore
88
+ SetEstadoAviso: window.objJS.setEstadoAviso,
89
+ // @ts-ignore
78
90
  ExitInteractivity: window.objJS.exitInteractivity,
79
91
  // @ts-ignore
80
92
  LogWeb: window.objJS.logWeb,
@@ -186,23 +198,34 @@ export class SMO {
186
198
  selft.setDatasource(e.data.objData);
187
199
  return;
188
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
+
189
212
  if(func == SMO_EVENT_TYPE.getVariable){
190
213
  selft.getVariable(e.data.objData);
191
214
  return;
192
215
  }
193
- if(func ==SMO_EVENT_TYPE.setCurrentStream){
216
+ if(func == SMO_EVENT_TYPE.setCurrentStream){
194
217
  selft.setCurrentStream(e.data.objData);
195
218
  return;
196
219
  }
197
- if(func==SMO_EVENT_TYPE.infoCurrentLocation){
220
+ if(func == SMO_EVENT_TYPE.infoCurrentLocation){
198
221
  selft.infoCurrentLocation(e.data.objData);
199
222
  return;
200
223
  }
201
- if(func==SMO_EVENT_TYPE.setSalidaData){
224
+ if(func == SMO_EVENT_TYPE.setSalidaData){
202
225
  selft.setSalidaData(e.data.objData);
203
226
  return;
204
227
  }
205
- if(func ==SMO_EVENT_TYPE.updatefromsalida){
228
+ if(func == SMO_EVENT_TYPE.updatefromsalida){
206
229
  selft.updatefromsalida(e.data.objData);
207
230
  return;
208
231
  }
@@ -264,6 +287,12 @@ export class SMO {
264
287
  this.events.setDatasource.next(datasource);
265
288
  this.events.setDatasourceJson.next(this.utils.xmlToJSON(datasource.xml));
266
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
+ }
267
296
  getVariable(variable:variable):void{
268
297
  this.events.getVariable.next(variable);
269
298
  }
@@ -319,6 +348,8 @@ class SmoEvents{
319
348
  public start: Subject<start> = new Subject<start>();
320
349
  public dispose: Subject<start> = new Subject<dispose>();
321
350
  public setDatasource: Subject<setDatasource> = new Subject<setDatasource>();
351
+ public setAvisos: Subject<setAviso> = new Subject<setAviso>();
352
+ public setBorradoAviso: Subject<setBorradoAviso> = new Subject<setBorradoAviso>();
322
353
  public setDatasourceJson: Subject<any> = new Subject<any>();
323
354
  public getVariable: Subject<variable> = new Subject<variable>();
324
355
  public setCurrentStream: Subject<string> = new Subject<string>();
@@ -371,7 +402,7 @@ class smoCallBacks{
371
402
  if (level == LogLevel.Warning) {
372
403
  console.warn(msn);
373
404
  }
374
- if (level == LogLevel.Error) {
405
+ if (level == LogLevel.Error || level == LogLevel.Fatal) {
375
406
  console.error(msn);
376
407
  }
377
408
  if (window.parent != window) {
@@ -508,6 +539,13 @@ class smoCallBacks{
508
539
  idSmo: this.smo.id
509
540
  }, this.smo.vars.idSmo);
510
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
+ }
511
549
  refreshDatasource(codigo:string):void {
512
550
  this.smo.utils.sendToParent({
513
551
  target: "Dnv.smoCallbacks.refreshDatasource",
@@ -563,6 +601,17 @@ class smoCallBacks{
563
601
 
564
602
  }, this.smo.vars.idSmo);
565
603
  }
604
+ notifyEditor(data:NotifyEditor):void {
605
+ /*data ={
606
+ destino: "fruta",
607
+ value: "{'fruta':'manzana', 'color':'roja'}"
608
+ } */
609
+ parent.postMessage({
610
+ target: "Dnv.smoCallbacks.notifyEditor",
611
+ objData: data,
612
+ idSmo: this.smo.id
613
+ }, "*");
614
+ }
566
615
  playOnceChannelByTrigger(trigger:string):void {
567
616
  this.smo.utils.sendToParent({
568
617
  target: "Dnv.smoCallbacks.playOnceChannelByTrigger",
@@ -737,6 +786,15 @@ class Utils{
737
786
  this.smo = _smo;
738
787
  this.smoCallBacks =_smoCallBacks;
739
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
+
740
798
  // Funciones para XML to JSON
741
799
  xmlToJSON(xml:string) {
742
800
  let getxml = new DOMParser();
@@ -905,6 +963,10 @@ export enum SMO_EVENT_TYPE{
905
963
  start = "start",
906
964
  dispose = "dispose",
907
965
  setDatasource = "setDatasource",
966
+ setAvisoArgs = "setAvisoArgs",
967
+ setAvisoLogotipoArgs = "setAvisoLogotipoArgs",
968
+ setAvisoDuracionArgs = "setAvisoDuracionArgs",
969
+ setBorradoAviso = "setBorradoAviso",
908
970
  getVariable = "getVariable",
909
971
  setCurrentStream = "setCurrentStream",
910
972
  infoCurrentLocation = "infoCurrentLocation",
@@ -927,7 +989,8 @@ export enum LogLevel {
927
989
  Debug= 0,
928
990
  Info= 1,
929
991
  Warning= 2,
930
- Error= 3
992
+ Error= 3,
993
+ Fatal= 4
931
994
  }
932
995
  export enum AlarmaLevel {
933
996
  Ok_off= 0,
@@ -943,6 +1006,7 @@ export interface ObjJSType {
943
1006
  logFlash: () => void;
944
1007
  pageInit: () => void;
945
1008
  finAviso: () => void;
1009
+ setEstadoAviso: () => void;
946
1010
  exitInteractivity: () => void;
947
1011
  logWeb: () => void;
948
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>