@denevads/dnv-smo 1.0.4 → 1.0.6

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.
@@ -31,3 +31,18 @@ export interface Notify {
31
31
  destion: string;
32
32
  value: any;
33
33
  }
34
+ export interface VideoClips {
35
+ codigo: number;
36
+ fechaInicio: Date;
37
+ fechaFin: Date;
38
+ recursos: Recurso[];
39
+ }
40
+ export interface VideoClipsRelleno {
41
+ codigo: number;
42
+ recursos: Recurso[];
43
+ }
44
+ export interface Recurso {
45
+ codigo: number;
46
+ url: string;
47
+ duracion: number;
48
+ }
package/dist/smo.d.ts CHANGED
@@ -1,8 +1,10 @@
1
- import { setDatasource, variable, location, DataSalida, ExecFunction, Notify, start } from "./interfaces/callbacks";
1
+ import { setDatasource, variable, location, DataSalida, ExecFunction, Notify, start, VideoClips, VideoClipsRelleno } from "./interfaces/callbacks";
2
2
  import { Subject } from 'rxjs';
3
3
  export declare class SMO {
4
4
  vars: any;
5
5
  id: string;
6
+ private intervalsubscriptionDataSource;
7
+ intervalDataSource$: import("rxjs").Observable<number>;
6
8
  smoCallBacks: smoCallBacks;
7
9
  utils: Utils;
8
10
  events: SmoEvents;
@@ -16,6 +18,9 @@ export declare class SMO {
16
18
  infoCurrentLocation(location: location): void;
17
19
  setSalidaData(data: DataSalida): void;
18
20
  updatefromsalida(data: any): void;
21
+ getVideoClips(data: VideoClips): void;
22
+ getVideosRelleno(data: VideoClipsRelleno): void;
23
+ getVariableStorage(variable: variable): void;
19
24
  }
20
25
  declare class SmoEvents {
21
26
  start: Subject<start>;
@@ -26,6 +31,9 @@ declare class SmoEvents {
26
31
  infoCurrentLocation: Subject<location>;
27
32
  setSalidaData: Subject<DataSalida>;
28
33
  updatefromsalida: Subject<any>;
34
+ getVideoClips: Subject<VideoClips>;
35
+ getVideosRelleno: Subject<VideoClipsRelleno>;
36
+ getVariableStorage: Subject<variable>;
29
37
  constructor(smo: SMO);
30
38
  }
31
39
  declare class smoCallBacks {
@@ -59,6 +67,10 @@ declare class smoCallBacks {
59
67
  playOnceChannel(codigoCanal: string): void;
60
68
  stopPlayChannel(): void;
61
69
  editWrapperStyle(obj: any): void;
70
+ getVideoClips(): void;
71
+ getVideosRelleno(): void;
72
+ setVariableStorage(variable: string, valor: string): void;
73
+ getVariableStorage(variable: string): void;
62
74
  }
63
75
  declare class Utils {
64
76
  smo: SMO;
@@ -68,8 +80,6 @@ declare class Utils {
68
80
  jsonToStr(js_obj: any): string;
69
81
  setJsonObj(xml: any): any;
70
82
  dataToJSON(data: setDatasource): any;
71
- getDatasource(): void;
72
- startCheckDatasource(timeout?: number): void;
73
83
  }
74
84
  export declare enum SMO_EVENT_TYPE {
75
85
  start = "start",
@@ -79,7 +89,10 @@ export declare enum SMO_EVENT_TYPE {
79
89
  infoCurrentLocation = "infoCurrentLocation",
80
90
  setSalidaData = "setSalidaData",
81
91
  updatefromsalida = "updatefromsalida",
82
- setDatasourceJson = "setDatasourceJson"
92
+ setDatasourceJson = "setDatasourceJson",
93
+ getVideoClips = "getVideoClips",
94
+ getVideosRelleno = "getVideosRelleno",
95
+ getVariableStorage = "getVariableStorage"
83
96
  }
84
97
  export declare enum LogLevel {
85
98
  Debug = 0,
package/dist/smo.js CHANGED
@@ -6,27 +6,41 @@ var SMO = /** @class */ (function () {
6
6
  function SMO() {
7
7
  this.vars = {};
8
8
  this.id = "";
9
- this.init();
9
+ this.intervalDataSource$ = (0, rxjs_1.interval)(5 * 60 * 1000);
10
10
  this.initOnMessage();
11
11
  this.smoCallBacks = new smoCallBacks(this);
12
12
  this.utils = new Utils(this, this.smoCallBacks);
13
13
  this.events = new SmoEvents(this);
14
+ this.init();
14
15
  }
15
16
  SMO.prototype.init = function () {
17
+ var _this = this;
16
18
  var match, pl = /\+/g, search = /([^&=]+)=?([^&]*)/g, decode = function (s) {
17
19
  return decodeURIComponent(s.replace(pl, " "));
18
20
  }, query = window.location.search.substring(1);
19
21
  while (match = search.exec(query)) {
20
22
  this.vars[decode(match[1])] = decode(match[2]);
21
23
  }
22
- /* let hash;
23
- let hashes = window.location.href.slice(window.location.href.indexOf("?") + 1).split("&");
24
- for (var i = 0; i < hashes.length; i++) {
25
- hash = hashes[i].split("=");
26
- this.vars[hash[0]] = hash[1];
27
- }*/
28
24
  if (this.vars.idSmo) {
29
25
  this.id = this.vars.idSmo;
26
+ if (this.vars["LowPower"] == "true" && (this.vars["url"] != undefined || this.vars["LocalData"] != undefined)) {
27
+ this.smoCallBacks.onSmoLoad();
28
+ return;
29
+ }
30
+ if (this.vars["url"] != undefined) {
31
+ this.smoCallBacks.getFile(this.vars["url"]);
32
+ this.intervalsubscriptionDataSource = this.intervalDataSource$.subscribe(function () {
33
+ _this.smoCallBacks.getFile(_this.vars["url"]);
34
+ });
35
+ return;
36
+ }
37
+ if (this.vars["LocalData"] != undefined) {
38
+ this.smoCallBacks.getLocalData(this.vars["LocalData"]);
39
+ this.intervalsubscriptionDataSource = this.intervalDataSource$.subscribe(function () {
40
+ _this.smoCallBacks.getLocalData(_this.vars["LocalData"]);
41
+ });
42
+ return;
43
+ }
30
44
  return;
31
45
  }
32
46
  console.warn("No idSmo found in URL");
@@ -65,6 +79,17 @@ var SMO = /** @class */ (function () {
65
79
  selft.updatefromsalida(e.data.objdata);
66
80
  return;
67
81
  }
82
+ if (func == SMO_EVENT_TYPE.getVideoClips) {
83
+ selft.getVideoClips(e.data.objData);
84
+ }
85
+ if (func == SMO_EVENT_TYPE.getVideosRelleno) {
86
+ selft.getVideosRelleno(e.data.objData);
87
+ return;
88
+ }
89
+ if (func == SMO_EVENT_TYPE.getVariableStorage) {
90
+ selft.getVariableStorage(e.data.objData);
91
+ return;
92
+ }
68
93
  console.warn("message not implemented!!" + func);
69
94
  }
70
95
  };
@@ -91,6 +116,15 @@ var SMO = /** @class */ (function () {
91
116
  SMO.prototype.updatefromsalida = function (data) {
92
117
  this.events.updatefromsalida.next(data);
93
118
  };
119
+ SMO.prototype.getVideoClips = function (data) {
120
+ this.events.getVideoClips.next(data);
121
+ };
122
+ SMO.prototype.getVideosRelleno = function (data) {
123
+ this.events.getVideosRelleno.next(data);
124
+ };
125
+ SMO.prototype.getVariableStorage = function (variable) {
126
+ this.events.getVariableStorage.next(variable);
127
+ };
94
128
  return SMO;
95
129
  }());
96
130
  exports.SMO = SMO;
@@ -104,6 +138,9 @@ var SmoEvents = /** @class */ (function () {
104
138
  this.infoCurrentLocation = new rxjs_1.Subject();
105
139
  this.setSalidaData = new rxjs_1.Subject();
106
140
  this.updatefromsalida = new rxjs_1.Subject();
141
+ this.getVideoClips = new rxjs_1.Subject();
142
+ this.getVideosRelleno = new rxjs_1.Subject();
143
+ this.getVariableStorage = new rxjs_1.Subject();
107
144
  }
108
145
  return SmoEvents;
109
146
  }());
@@ -336,6 +373,38 @@ var smoCallBacks = /** @class */ (function () {
336
373
  idSmo: this.smo.id
337
374
  }, "*");
338
375
  };
376
+ smoCallBacks.prototype.getVideoClips = function () {
377
+ parent.postMessage({
378
+ target: "Dnv.smoCallbacks.getVideoClips",
379
+ idSmo: this.smo.id
380
+ }, "*");
381
+ };
382
+ smoCallBacks.prototype.getVideosRelleno = function () {
383
+ parent.postMessage({
384
+ target: "Dnv.smoCallbacks.getVideosRelleno",
385
+ idSmo: this.smo.id
386
+ }, "*");
387
+ };
388
+ smoCallBacks.prototype.setVariableStorage = function (variable, valor) {
389
+ window.parent.postMessage({
390
+ target: "Dnv.smoCallbacks.setVariableStorage",
391
+ objData: {
392
+ variable: variable,
393
+ valor: valor
394
+ },
395
+ idSmo: this.smo.id
396
+ }, "*");
397
+ };
398
+ smoCallBacks.prototype.getVariableStorage = function (variable) {
399
+ window.parent.postMessage({
400
+ target: "Dnv.smoCallbacks.getVariableStorage",
401
+ objData: {
402
+ variable: variable
403
+ },
404
+ idSmo: this.smo.id
405
+ }, "*");
406
+ /* MIRAR SMO.getVariable */
407
+ };
339
408
  return smoCallBacks;
340
409
  }());
341
410
  var Utils = /** @class */ (function () {
@@ -404,21 +473,6 @@ var Utils = /** @class */ (function () {
404
473
  return {};
405
474
  }
406
475
  };
407
- Utils.prototype.getDatasource = function () {
408
- if (this.smo.vars.url == undefined) {
409
- this.smoCallBacks.getFile(this.smo.vars.LocalData);
410
- return;
411
- }
412
- this.smoCallBacks.getFile(this.smo.vars.url);
413
- };
414
- Utils.prototype.startCheckDatasource = function (timeout) {
415
- if (timeout === void 0) { timeout = 10; }
416
- this.getDatasource();
417
- var self = this;
418
- setInterval(function () {
419
- self.getDatasource();
420
- }, timeout * 1000);
421
- };
422
476
  return Utils;
423
477
  }());
424
478
  var SMO_EVENT_TYPE;
@@ -431,29 +485,10 @@ var SMO_EVENT_TYPE;
431
485
  SMO_EVENT_TYPE["setSalidaData"] = "setSalidaData";
432
486
  SMO_EVENT_TYPE["updatefromsalida"] = "updatefromsalida";
433
487
  SMO_EVENT_TYPE["setDatasourceJson"] = "setDatasourceJson";
488
+ SMO_EVENT_TYPE["getVideoClips"] = "getVideoClips";
489
+ SMO_EVENT_TYPE["getVideosRelleno"] = "getVideosRelleno";
490
+ SMO_EVENT_TYPE["getVariableStorage"] = "getVariableStorage";
434
491
  })(SMO_EVENT_TYPE = exports.SMO_EVENT_TYPE || (exports.SMO_EVENT_TYPE = {}));
435
- /* start():void{
436
- this.emit("start");
437
- }
438
- setDatasource(datasource:setDatasource):void {
439
- this.emit("setDatasource",datasource);
440
- }
441
- getVariable(variable:variable):void{
442
- this.emit("getVariable",variable);
443
- }
444
- setCurrentStream(stream:string):void{
445
- this.emit("setCurrentStream",stream);
446
- }
447
- infoCurrentLocation(location:location):void{
448
- this.emit("infoCurrentLocation",location);
449
- }
450
- setSalidaData(data:DataSalida):void{
451
- this.emit("setSalidaData",data);
452
- }
453
-
454
- updatefromsalida(data:any):void{
455
- this.emit("updatefromsalida",data);
456
- } */
457
492
  var LogLevel;
458
493
  (function (LogLevel) {
459
494
  LogLevel[LogLevel["Debug"] = 0] = "Debug";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@denevads/dnv-smo",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "SMO module",
5
5
  "main": "./src/index.js",
6
6
  "types": "./src/index.d.ts",
@@ -33,4 +33,22 @@ export interface ExecFunction{
33
33
  export interface Notify{
34
34
  destion:string,
35
35
  value:any
36
- }
36
+ }
37
+
38
+ export interface VideoClips {
39
+ codigo: number;
40
+ fechaInicio: Date;
41
+ fechaFin: Date;
42
+ recursos: Recurso[];
43
+ }
44
+ export interface VideoClipsRelleno {
45
+ codigo: number;
46
+ recursos: Recurso[];
47
+ }
48
+
49
+ export interface Recurso {
50
+ codigo: number;
51
+ url: string;
52
+ duracion: number;
53
+ }
54
+
package/src/smo.ts CHANGED
@@ -1,17 +1,29 @@
1
- import { setDatasource,variable,location,DataSalida, ExecFunction, Notify, start } from "./interfaces/callbacks";
2
- import { Subject} from 'rxjs';
1
+ import {
2
+ setDatasource,
3
+ variable,
4
+ location,
5
+ DataSalida,
6
+ ExecFunction,
7
+ Notify,
8
+ start,
9
+ VideoClips, VideoClipsRelleno
10
+ } from "./interfaces/callbacks";
11
+ import {interval, Subject, Subscription} from 'rxjs';
3
12
  export class SMO {
4
13
  public vars:any = {};
5
14
  public id:string = "";
15
+ private intervalsubscriptionDataSource!: Subscription;
16
+ intervalDataSource$ = interval(5 * 60 * 1000);
6
17
  public smoCallBacks:smoCallBacks;
7
18
  public utils:Utils;
8
19
  public events:SmoEvents;
9
20
  constructor(){
10
- this.init();
21
+
11
22
  this.initOnMessage();
12
23
  this.smoCallBacks = new smoCallBacks(this);
13
24
  this.utils = new Utils(this,this.smoCallBacks);
14
25
  this.events =new SmoEvents(this);
26
+ this.init();
15
27
  }
16
28
  public init():void{
17
29
  let match,
@@ -24,14 +36,26 @@ export class SMO {
24
36
  while (match = search.exec(query)) {
25
37
  this.vars[decode(match[1])] = decode(match[2]);
26
38
  }
27
- /* let hash;
28
- let hashes = window.location.href.slice(window.location.href.indexOf("?") + 1).split("&");
29
- for (var i = 0; i < hashes.length; i++) {
30
- hash = hashes[i].split("=");
31
- this.vars[hash[0]] = hash[1];
32
- }*/
33
39
  if (this.vars.idSmo) {
34
40
  this.id = this.vars.idSmo;
41
+ if(this.vars["LowPower"] == "true" && (this.vars["url"] != undefined || this.vars["LocalData"] != undefined)){
42
+ this.smoCallBacks.onSmoLoad();
43
+ return;
44
+ }
45
+ if(this.vars["url"] != undefined ){
46
+ this.smoCallBacks.getFile(this.vars["url"]);
47
+ this.intervalsubscriptionDataSource = this.intervalDataSource$.subscribe(() => {
48
+ this.smoCallBacks.getFile(this.vars["url"]);
49
+ });
50
+ return;
51
+ }
52
+ if(this.vars["LocalData"] != undefined ){
53
+ this.smoCallBacks.getLocalData(this.vars["LocalData"]);
54
+ this.intervalsubscriptionDataSource = this.intervalDataSource$.subscribe(() => {
55
+ this.smoCallBacks.getLocalData(this.vars["LocalData"]);
56
+ });
57
+ return;
58
+ }
35
59
  return;
36
60
  }
37
61
  console.warn("No idSmo found in URL");
@@ -70,6 +94,17 @@ export class SMO {
70
94
  selft.updatefromsalida(e.data.objdata);
71
95
  return;
72
96
  }
97
+ if(func == SMO_EVENT_TYPE.getVideoClips){
98
+ selft.getVideoClips(e.data.objData);
99
+ }
100
+ if(func == SMO_EVENT_TYPE.getVideosRelleno){
101
+ selft.getVideosRelleno(e.data.objData);
102
+ return;
103
+ }
104
+ if(func == SMO_EVENT_TYPE.getVariableStorage){
105
+ selft.getVariableStorage(e.data.objData);
106
+ return;
107
+ }
73
108
  console.warn("message not implemented!!" +func);
74
109
  }
75
110
  }
@@ -97,6 +132,15 @@ export class SMO {
97
132
  updatefromsalida(data:any):void{
98
133
  this.events.updatefromsalida.next(data);
99
134
  }
135
+ getVideoClips(data:VideoClips):void{
136
+ this.events.getVideoClips.next(data);
137
+ }
138
+ getVideosRelleno(data:VideoClipsRelleno):void{
139
+ this.events.getVideosRelleno.next(data);
140
+ }
141
+ getVariableStorage(variable:variable):void{
142
+ this.events.getVariableStorage.next(variable);
143
+ }
100
144
 
101
145
  }
102
146
 
@@ -109,6 +153,9 @@ class SmoEvents{
109
153
  public infoCurrentLocation: Subject<location> = new Subject<location>();
110
154
  public setSalidaData: Subject<DataSalida> = new Subject<DataSalida>();
111
155
  public updatefromsalida: Subject<any> = new Subject<any>();
156
+ public getVideoClips: Subject<VideoClips> = new Subject<VideoClips>();
157
+ public getVideosRelleno: Subject<VideoClipsRelleno> = new Subject<VideoClipsRelleno>();
158
+ public getVariableStorage: Subject<variable> = new Subject<variable>();
112
159
  constructor(smo:SMO){}
113
160
  }
114
161
  class smoCallBacks{
@@ -345,6 +392,40 @@ class smoCallBacks{
345
392
  idSmo: this.smo.id
346
393
  }, "*");
347
394
  }
395
+ getVideoClips():void{
396
+ parent.postMessage({
397
+ target: "Dnv.smoCallbacks.getVideoClips",
398
+ idSmo: this.smo.id
399
+ }, "*");
400
+ }
401
+ getVideosRelleno():void{
402
+ parent.postMessage({
403
+ target: "Dnv.smoCallbacks.getVideosRelleno",
404
+ idSmo: this.smo.id
405
+ }, "*");
406
+ }
407
+ setVariableStorage(variable:string, valor:string) {
408
+ window.parent.postMessage({
409
+ target: "Dnv.smoCallbacks.setVariableStorage",
410
+ objData: {
411
+ variable: variable,
412
+ valor: valor
413
+ },
414
+ idSmo: this.smo.id
415
+ }, "*");
416
+ }
417
+ getVariableStorage(variable:string):void {
418
+ window.parent.postMessage({
419
+ target: "Dnv.smoCallbacks.getVariableStorage",
420
+ objData: {
421
+ variable: variable
422
+ },
423
+ idSmo: this.smo.id
424
+ }, "*");
425
+ /* MIRAR SMO.getVariable */
426
+ }
427
+
428
+
348
429
  }
349
430
  class Utils{
350
431
  smo:SMO;
@@ -410,7 +491,7 @@ class Utils{
410
491
  return {};
411
492
  }
412
493
  }
413
- getDatasource():void{
494
+ /*getDatasource():void{
414
495
  if(this.smo.vars.url == undefined){
415
496
  this.smoCallBacks.getFile(this.smo.vars.LocalData);
416
497
  return;
@@ -424,7 +505,7 @@ class Utils{
424
505
  setInterval(function() {
425
506
  self.getDatasource();
426
507
  }, timeout * 1000);
427
- }
508
+ }*/
428
509
  }
429
510
  export enum SMO_EVENT_TYPE{
430
511
  start = "start",
@@ -434,30 +515,11 @@ export enum SMO_EVENT_TYPE{
434
515
  infoCurrentLocation = "infoCurrentLocation",
435
516
  setSalidaData ="setSalidaData",
436
517
  updatefromsalida = "updatefromsalida",
437
- setDatasourceJson = "setDatasourceJson"
518
+ setDatasourceJson = "setDatasourceJson",
519
+ getVideoClips = "getVideoClips",
520
+ getVideosRelleno = "getVideosRelleno",
521
+ getVariableStorage = "getVariableStorage"
438
522
  }
439
- /* start():void{
440
- this.emit("start");
441
- }
442
- setDatasource(datasource:setDatasource):void {
443
- this.emit("setDatasource",datasource);
444
- }
445
- getVariable(variable:variable):void{
446
- this.emit("getVariable",variable);
447
- }
448
- setCurrentStream(stream:string):void{
449
- this.emit("setCurrentStream",stream);
450
- }
451
- infoCurrentLocation(location:location):void{
452
- this.emit("infoCurrentLocation",location);
453
- }
454
- setSalidaData(data:DataSalida):void{
455
- this.emit("setSalidaData",data);
456
- }
457
-
458
- updatefromsalida(data:any):void{
459
- this.emit("updatefromsalida",data);
460
- } */
461
523
  export enum LogLevel {
462
524
  Debug= 0,
463
525
  Info= 1,