@denevads/dnv-smo 1.0.27 → 1.0.29

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.
@@ -0,0 +1,6 @@
1
+ <component name="InspectionProjectProfileManager">
2
+ <profile version="1.0">
3
+ <option name="myName" value="Project Default" />
4
+ <inspection_tool class="JSConstantReassignment" enabled="false" level="ERROR" enabled_by_default="false" />
5
+ </profile>
6
+ </component>
package/README.md CHANGED
@@ -1,84 +1,84 @@
1
- #Introducción
2
- Librería de interfaz de comunicaciones entre un objeto HTML5 y las funciones de un player de DenevaDS.
1
+ # Introduction
2
+ Communication interface library between an HTML5 object and the functions of a Digital Signage Player from DenevaDS CMS.
3
3
 
4
- Aquí definiremos el uso de la librería y las funciones que la misma provee
4
+ Here we define the use of the library and the functions provided by the library
5
5
 
6
6
 
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.
7
+ # Instalation
8
+ The library is intended to be used together with Angular, so if we do not have the Angular CLI in the system it is convenient to install it to initialize the project.
9
9
  ```sh
10
10
  npm install -g @angular/cli
11
11
  ```
12
- Inicializamos un proyecto de prueba llamado html-deneva en la ruta en la que estemos.
12
+ We start a test project called html-deneva in the path we are in.
13
13
  ```sh
14
14
  ng new html-deneva
15
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:
16
+ Once we have the basic structure of the project we can install the library in the project by executing the following line inside the project folder:
17
17
  ```sh
18
18
  npm install @denevads/dnv-smo
19
19
  ```
20
20
 
21
- # Inicialización
21
+ # Initialization
22
22
 
23
- Una vez que tengamos el proyecto de angular inicializado, procedemos importar el módulo.
23
+ Once we have the Angular project initialized, we proceed to import the module.
24
24
 
25
- Dentro de la definición del app.module en la carpeta app, importamos la librería.
25
+ Inside the app.module definition in the app folder, we import the library.
26
26
  ```ts
27
27
  import { SMO } from '@denevads/dnv-smo/dist/smo';
28
28
  ```
29
- y lo añadimos como provider en @NgModule
29
+ and then add it as a provider in @NgModule
30
30
  ```ts
31
31
  providers: [SMO]
32
32
  ```
33
33
 
34
- Ahora ya solo bastaría con añadirlo al componente del angular y empezar a usarlo.
34
+ Now all you have to do is add it to the Angular component and start using it.
35
35
 
36
- De nuevo en app.component importamos la librería
36
+ Again in app.component we import the library
37
37
  ```js
38
38
  import { LogLevel, SMO } from '@denevads/dnv-smo/dist/smo'
39
39
  ```
40
- Y en la exportación de la clase AppComponent añadimos el constructor
40
+ And in the export of the AppComponent class, we add the constructor
41
41
  ```js
42
42
  constructor(private smo:SMO){ }
43
43
  ```
44
- De esta manera ya tendríamos disponible para su uso todas las llamadas que aporta la librería usando
44
+ In this way we would already have available for use all the calls provided by the library using
45
45
  ```js
46
46
  this.smo.
47
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.
48
+ Also in the import we have brought the enumeration of the log levels, which are used to log in the local storage.
49
+ The usage would be as follows:
50
50
  ```js
51
- this.smo.smoCallBacks.smoLog('Mensaje de prueba',LogLevel.Info);
51
+ this.smo.smoCallBacks.smoLog('Test Message',LogLevel.Info);
52
52
  ```
53
53
 
54
- # Compilación y empaquetado.
54
+ # Compilation and packaging.
55
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.
56
+ In order for the project to run on a computer without problems, a couple of changes must be made to the default project code.
57
57
 
58
- El primero de ellos es modificar el tsconfig.json para que el "target" sea "ES5" en lugar de "ES2022"
58
+ The first one is to modify the tsconfig.json so that the "target" is "ES5" instead of "ES2022".
59
59
 
60
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
61
+ And the second change is in the index file. Here we will do two things:
62
+ -Delete the favicon import (in addition to deleting it from the file folder).
63
+ -And we change the line
64
64
  ```html
65
65
  <base href="/">
66
66
  ```
67
- por
67
+ to
68
68
  ```html
69
69
  <script>document.write('<base href="' + document.location + '" />');</script>
70
70
  ```
71
- Con estos cambios hechos, podemos compilar el proyecto ejecutando la línea
71
+ With these changes made, we can compile the project by executing the command line
72
72
  ```sh
73
73
  ng b
74
74
  ```
75
- Esto nos generara una carpeta dist, con el contenido de nuestro HTML5 compilado.
75
+ This will generate a dist folder with the content of our compiled HTML5.
76
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
77
+ In order to upload it to the deneva player, we simply have to create a zip with the content in the root, and change the extension to
78
78
  ```sh
79
79
  .wgt
80
80
  ```
81
81
 
82
82
  npm run build
83
83
  npm login
84
- npm publish
84
+ npm publish
package/dist/smo.js CHANGED
@@ -23,7 +23,9 @@ var SMO = /** @class */ (function () {
23
23
  this.vars[decode(match[1])] = decode(match[2]);
24
24
  }
25
25
  // @ts-ignore
26
- if (window.objJS) {
26
+ if (window.objJS != undefined && window !== window.parent && this.vars.ontop != undefined && this.vars.ontop != "") {
27
+ // @ts-ignore
28
+ console.log("Existe objJS en window -->" + JSON.stringify(window.objJS));
27
29
  // @ts-ignore
28
30
  window.sendToIframefromNet = function (target, iframeID, objData) {
29
31
  console.log("sendToIframefromNet->", JSON.stringify(target));
@@ -36,6 +38,7 @@ var SMO = /** @class */ (function () {
36
38
  break;
37
39
  }
38
40
  };
41
+ // @ts-ignore
39
42
  window.external = {
40
43
  // @ts-ignore
41
44
  URLNext: window.objJS.urlNext,
@@ -104,6 +107,7 @@ var SMO = /** @class */ (function () {
104
107
  };
105
108
  }
106
109
  else {
110
+ console.log("No existe objJS en window");
107
111
  if (this.vars.idSmo) {
108
112
  this.id = this.vars.idSmo;
109
113
  if (this.vars["LowPower"] == "true" && (this.vars["url"] != undefined || this.vars["LocalData"] != undefined)) {
@@ -127,6 +131,7 @@ var SMO = /** @class */ (function () {
127
131
  return;
128
132
  }
129
133
  console.warn("No idSmo found in URL");
134
+ return;
130
135
  }
131
136
  if (this.vars.idSmo) {
132
137
  this.id = this.vars.idSmo;
@@ -711,40 +716,44 @@ var Utils = /** @class */ (function () {
711
716
  window.parent.postMessage(obj, dest);
712
717
  };
713
718
  Utils.prototype.setJsonObj = function (xml) {
714
- var js_obj = {};
719
+ var jsonObj = {};
715
720
  if (xml.nodeType == 1) { // Element
716
721
  if (xml.attributes.length > 0) {
717
- js_obj["@attributes"] = {};
722
+ jsonObj["ATTRIBUTES"] = {};
718
723
  for (var j = 0; j < xml.attributes.length; j++) {
719
724
  var attribute = xml.attributes.item(j);
720
- js_obj["@attributes"][attribute.nodeName] = attribute.nodeValue;
725
+ jsonObj["ATTRIBUTES"][attribute.nodeName] = attribute.nodeValue;
721
726
  }
722
727
  }
723
728
  }
724
729
  else if (xml.nodeType == 3) { // Text
725
- js_obj = xml.nodeValue;
730
+ jsonObj = xml.nodeValue.trim();
726
731
  }
727
732
  else if (xml.nodeType == 4) { // CDATA
728
- js_obj = xml.nodeValue;
733
+ jsonObj = xml.nodeValue.trim();
729
734
  }
730
735
  if (xml.hasChildNodes()) {
731
736
  for (var i = 0; i < xml.childNodes.length; i++) {
732
- var item = xml.childNodes.item(i);
737
+ var item = xml.childNodes[i];
733
738
  var nodeName = item.nodeName;
734
- if (typeof (js_obj[nodeName]) == "undefined") {
735
- js_obj[nodeName] = this.setJsonObj(item);
739
+ if (nodeName == "#text" && item.nodeType == 3) {
740
+ jsonObj = item.nodeValue.trim();
741
+ }
742
+ else if (nodeName == "#cdata-section" && (item.nodeType == 4 || item.nodeType == 3)) { //Para que quede bonito
743
+ jsonObj["CDATA"] = this.setJsonObj(item);
744
+ }
745
+ else if (typeof jsonObj[nodeName] === "undefined") {
746
+ jsonObj[nodeName] = this.setJsonObj(item);
736
747
  }
737
748
  else {
738
- if (typeof (js_obj[nodeName].push) == "undefined") {
739
- var old = js_obj[nodeName];
740
- js_obj[nodeName] = [];
741
- js_obj[nodeName].push(old);
749
+ if (!Array.isArray(jsonObj[nodeName])) {
750
+ jsonObj[nodeName] = [jsonObj[nodeName]];
742
751
  }
743
- js_obj[nodeName].push(this.setJsonObj(item));
752
+ jsonObj[nodeName].push(this.setJsonObj(item));
744
753
  }
745
754
  }
746
755
  }
747
- return js_obj;
756
+ return jsonObj;
748
757
  };
749
758
  Utils.prototype.dataToJSON = function (data) {
750
759
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@denevads/dnv-smo",
3
- "version": "1.0.27",
3
+ "version": "1.0.29",
4
4
  "description": "SMO module",
5
5
  "main": "./src/index.js",
6
6
  "types": "./src/index.d.ts",
package/src/smo.ts CHANGED
@@ -11,10 +11,7 @@ import {
11
11
  GetRecursosRelleno
12
12
  } from "./interfaces/callbacks";
13
13
  import {interval, Subject, Subscription} from 'rxjs';
14
- interface Window {
15
- external:ObjJSType;
16
- objJS:ObjJSType;
17
- }
14
+
18
15
  // @ts-ignore
19
16
 
20
17
  export class SMO {
@@ -46,7 +43,9 @@ export class SMO {
46
43
  this.vars[decode(match[1])] = decode(match[2]);
47
44
  }
48
45
  // @ts-ignore
49
- if(window.objJS){
46
+ if(window.objJS != undefined && window !== window.parent && this.vars.ontop != undefined && this.vars.ontop != ""){
47
+ // @ts-ignore
48
+ console.log("Existe objJS en window -->" + JSON.stringify(window.objJS));
50
49
  // @ts-ignore
51
50
  window.sendToIframefromNet = (target, iframeID, objData) => {
52
51
  console.log("sendToIframefromNet->",JSON.stringify(target));
@@ -58,10 +57,8 @@ export class SMO {
58
57
  this.events.checkHealthPrinter.next(objData);
59
58
  break;
60
59
  }
61
-
62
-
63
60
  }
64
-
61
+ // @ts-ignore
65
62
  window.external = {
66
63
  // @ts-ignore
67
64
  URLNext: window.objJS.urlNext,
@@ -129,6 +126,7 @@ export class SMO {
129
126
  CheckHealth: window.objJS.checkHealth
130
127
  };
131
128
  }else{
129
+ console.log("No existe objJS en window");
132
130
  if (this.vars.idSmo) {
133
131
  this.id = this.vars.idSmo;
134
132
  if(this.vars["LowPower"] == "true" && (this.vars["url"] != undefined || this.vars["LocalData"] != undefined)){
@@ -152,6 +150,7 @@ export class SMO {
152
150
  return;
153
151
  }
154
152
  console.warn("No idSmo found in URL");
153
+ return;
155
154
  }
156
155
 
157
156
  if (this.vars.idSmo) {
@@ -743,38 +742,45 @@ class Utils{
743
742
  window.parent.postMessage(obj, dest);
744
743
  }
745
744
  setJsonObj(xml: any) {
746
- let js_obj = {} as any;
745
+ let jsonObj = {} as any;
746
+
747
747
  if (xml.nodeType == 1) { // Element
748
748
  if (xml.attributes.length > 0) {
749
- js_obj["@attributes"] = {};
749
+ jsonObj["ATTRIBUTES"] = {};
750
750
  for (let j = 0; j < xml.attributes.length; j++) {
751
751
  let attribute = xml.attributes.item(j);
752
- js_obj["@attributes"][attribute.nodeName] = attribute.nodeValue;
752
+ jsonObj["ATTRIBUTES"][attribute.nodeName] = attribute.nodeValue;
753
753
  }
754
754
  }
755
755
  } else if (xml.nodeType == 3) { // Text
756
- js_obj = xml.nodeValue;
756
+ jsonObj = xml.nodeValue.trim();
757
757
  } else if (xml.nodeType == 4) { // CDATA
758
- js_obj = xml.nodeValue;
758
+ jsonObj = xml.nodeValue.trim();
759
759
  }
760
+
760
761
  if (xml.hasChildNodes()) {
761
762
  for (let i = 0; i < xml.childNodes.length; i++) {
762
- let item = xml.childNodes.item(i);
763
+ let item = xml.childNodes[i];
763
764
  let nodeName = item.nodeName;
764
- if (typeof (js_obj[nodeName]) == "undefined") {
765
- js_obj[nodeName] = this.setJsonObj(item);
765
+
766
+ if (nodeName == "#text" && item.nodeType == 3) {
767
+ jsonObj = item.nodeValue.trim();
768
+ }else if (nodeName == "#cdata-section" && (item.nodeType == 4 || item.nodeType == 3)) { //Para que quede bonito
769
+ jsonObj["CDATA"] = this.setJsonObj(item);
770
+ } else if (typeof jsonObj[nodeName] === "undefined") {
771
+ jsonObj[nodeName] = this.setJsonObj(item);
766
772
  } else {
767
- if (typeof (js_obj[nodeName].push) == "undefined") {
768
- let old = js_obj[nodeName];
769
- js_obj[nodeName] = [];
770
- js_obj[nodeName].push(old);
773
+ if (!Array.isArray(jsonObj[nodeName])) {
774
+ jsonObj[nodeName] = [jsonObj[nodeName]];
771
775
  }
772
- js_obj[nodeName].push(this.setJsonObj(item));
776
+ jsonObj[nodeName].push(this.setJsonObj(item));
773
777
  }
774
778
  }
775
779
  }
776
- return js_obj;
780
+
781
+ return jsonObj;
777
782
  }
783
+
778
784
  dataToJSON(data:setDatasource):any {
779
785
  try {
780
786
  var parser = new DOMParser();