@gisce/ooui 0.2.2 → 0.2.5

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,9 @@
1
+ import DashboardItem from "./DashboardItem";
2
+ declare class Dashboard {
3
+ _string: string | null;
4
+ get string(): string | null;
5
+ _items: DashboardItem[];
6
+ get items(): DashboardItem[];
7
+ constructor(xml: string);
8
+ }
9
+ export default Dashboard;
@@ -0,0 +1,36 @@
1
+ import DashboardItem from "./DashboardItem";
2
+ import { parseGenericNodes } from "./helpers/nodeParser";
3
+ var Dashboard = /** @class */ (function () {
4
+ function Dashboard(xml) {
5
+ var _this = this;
6
+ this._string = null;
7
+ this._items = [];
8
+ var parser = new DOMParser();
9
+ var view = parser.parseFromString(xml, "text/xml");
10
+ this._string = view.documentElement.getAttribute("string");
11
+ var documentElement = view.documentElement;
12
+ var actionsParsed = parseGenericNodes(documentElement.childNodes);
13
+ actionsParsed.forEach(function (nodeParsed) {
14
+ if (nodeParsed.tag === "dashboard_item") {
15
+ _this._items.push(new DashboardItem(nodeParsed.tagAttributes));
16
+ }
17
+ });
18
+ }
19
+ Object.defineProperty(Dashboard.prototype, "string", {
20
+ get: function () {
21
+ return this._string;
22
+ },
23
+ enumerable: false,
24
+ configurable: true
25
+ });
26
+ Object.defineProperty(Dashboard.prototype, "items", {
27
+ get: function () {
28
+ return this._items;
29
+ },
30
+ enumerable: false,
31
+ configurable: true
32
+ });
33
+ return Dashboard;
34
+ }());
35
+ export default Dashboard;
36
+ //# sourceMappingURL=Dashboard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Dashboard.js","sourceRoot":"","sources":["../src/Dashboard.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD;IAWE,mBAAY,GAAW;QAAvB,iBAaC;QAvBD,YAAO,GAAkB,IAAI,CAAC;QAK9B,WAAM,GAAoB,EAAE,CAAC;QAM3B,IAAM,MAAM,GAAG,IAAI,SAAS,EAAE,CAAC;QAC/B,IAAM,IAAI,GAAa,MAAM,CAAC,eAAe,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;QAC/D,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,eAAe,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;QAC3D,IAAM,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC;QAE7C,IAAM,aAAa,GAAG,iBAAiB,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC;QAEpE,aAAa,CAAC,OAAO,CAAC,UAAC,UAAU;YAC/B,IAAI,UAAU,CAAC,GAAG,KAAK,gBAAgB,EAAE;gBACvC,KAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,aAAa,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC;aAC/D;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAtBD,sBAAI,6BAAM;aAAV;YACE,OAAO,IAAI,CAAC,OAAO,CAAC;QACtB,CAAC;;;OAAA;IAGD,sBAAI,4BAAK;aAAT;YACE,OAAO,IAAI,CAAC,MAAM,CAAC;QACrB,CAAC;;;OAAA;IAgBH,gBAAC;AAAD,CAAC,AAzBD,IAyBC;AAED,eAAe,SAAS,CAAC"}
@@ -0,0 +1,8 @@
1
+ declare class DashboardItem {
2
+ _action_id: string | null;
3
+ get action_id(): string | null;
4
+ _position: string | null;
5
+ get position(): string | null;
6
+ constructor(attributes: any);
7
+ }
8
+ export default DashboardItem;
@@ -0,0 +1,29 @@
1
+ var DashboardItem = /** @class */ (function () {
2
+ function DashboardItem(attributes) {
3
+ this._action_id = null;
4
+ this._position = null;
5
+ if (attributes.action_id) {
6
+ this._action_id = attributes.action_id;
7
+ }
8
+ if (attributes.position) {
9
+ this._position = attributes.position;
10
+ }
11
+ }
12
+ Object.defineProperty(DashboardItem.prototype, "action_id", {
13
+ get: function () {
14
+ return this._action_id;
15
+ },
16
+ enumerable: false,
17
+ configurable: true
18
+ });
19
+ Object.defineProperty(DashboardItem.prototype, "position", {
20
+ get: function () {
21
+ return this._position;
22
+ },
23
+ enumerable: false,
24
+ configurable: true
25
+ });
26
+ return DashboardItem;
27
+ }());
28
+ export default DashboardItem;
29
+ //# sourceMappingURL=DashboardItem.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DashboardItem.js","sourceRoot":"","sources":["../src/DashboardItem.ts"],"names":[],"mappings":"AAAA;IAWE,uBAAY,UAAe;QAV3B,eAAU,GAAkB,IAAI,CAAC;QAKjC,cAAS,GAAkB,IAAI,CAAC;QAM9B,IAAI,UAAU,CAAC,SAAS,EAAE;YACxB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC,SAAS,CAAC;SACxC;QAED,IAAI,UAAU,CAAC,QAAQ,EAAE;YACvB,IAAI,CAAC,SAAS,GAAG,UAAU,CAAC,QAAQ,CAAC;SACtC;IACH,CAAC;IAjBD,sBAAI,oCAAS;aAAb;YACE,OAAO,IAAI,CAAC,UAAU,CAAC;QACzB,CAAC;;;OAAA;IAGD,sBAAI,mCAAQ;aAAZ;YACE,OAAO,IAAI,CAAC,SAAS,CAAC;QACxB,CAAC;;;OAAA;IAWH,oBAAC;AAAD,CAAC,AApBD,IAoBC;AAED,eAAe,aAAa,CAAC"}
@@ -0,0 +1,9 @@
1
+ export declare type GraphType = "indicator";
2
+ declare class Graph {
3
+ _string: string | null;
4
+ get string(): string | null;
5
+ _type?: GraphType;
6
+ get type(): GraphType | undefined;
7
+ constructor(xml: string);
8
+ }
9
+ export default Graph;
package/dist/Graph.js ADDED
@@ -0,0 +1,29 @@
1
+ var Graph = /** @class */ (function () {
2
+ function Graph(xml) {
3
+ this._string = null;
4
+ var parser = new DOMParser();
5
+ var view = parser.parseFromString(xml, "text/xml");
6
+ this._string = view.documentElement.getAttribute("string");
7
+ var type = view.documentElement.getAttribute("type");
8
+ if (type === "indicator") {
9
+ this._type = "indicator";
10
+ }
11
+ }
12
+ Object.defineProperty(Graph.prototype, "string", {
13
+ get: function () {
14
+ return this._string;
15
+ },
16
+ enumerable: false,
17
+ configurable: true
18
+ });
19
+ Object.defineProperty(Graph.prototype, "type", {
20
+ get: function () {
21
+ return this._type;
22
+ },
23
+ enumerable: false,
24
+ configurable: true
25
+ });
26
+ return Graph;
27
+ }());
28
+ export default Graph;
29
+ //# sourceMappingURL=Graph.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Graph.js","sourceRoot":"","sources":["../src/Graph.ts"],"names":[],"mappings":"AAEA;IAWE,eAAY,GAAW;QAVvB,YAAO,GAAkB,IAAI,CAAC;QAW5B,IAAM,MAAM,GAAG,IAAI,SAAS,EAAE,CAAC;QAC/B,IAAM,IAAI,GAAa,MAAM,CAAC,eAAe,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;QAC/D,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,eAAe,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;QAC3D,IAAM,IAAI,GAAG,IAAI,CAAC,eAAe,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;QAEvD,IAAI,IAAI,KAAK,WAAW,EAAE;YACxB,IAAI,CAAC,KAAK,GAAG,WAAW,CAAC;SAC1B;IACH,CAAC;IAlBD,sBAAI,yBAAM;aAAV;YACE,OAAO,IAAI,CAAC,OAAO,CAAC;QACtB,CAAC;;;OAAA;IAGD,sBAAI,uBAAI;aAAR;YACE,OAAO,IAAI,CAAC,KAAK,CAAC;QACpB,CAAC;;;OAAA;IAYH,YAAC;AAAD,CAAC,AArBD,IAqBC;AAED,eAAe,KAAK,CAAC"}
@@ -1,9 +1,15 @@
1
- import Field from "./Field";
2
- declare class Indicator extends Field {
1
+ import Selection from "./Selection";
2
+ declare class Indicator extends Selection {
3
3
  _nolabel: boolean;
4
4
  _card: boolean;
5
5
  get card(): boolean;
6
6
  set card(value: boolean);
7
+ _icon: string;
8
+ get icon(): string;
9
+ set icon(value: string);
10
+ _suffix: string;
11
+ get suffix(): string;
12
+ set suffix(value: string);
7
13
  constructor(props: any);
8
14
  }
9
15
  export default Indicator;
package/dist/Indicator.js CHANGED
@@ -11,15 +11,19 @@ var __extends = (this && this.__extends) || (function () {
11
11
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
12
12
  };
13
13
  })();
14
- import Field from "./Field";
14
+ import Selection from "./Selection";
15
15
  var Indicator = /** @class */ (function (_super) {
16
16
  __extends(Indicator, _super);
17
17
  function Indicator(props) {
18
18
  var _this = _super.call(this, props) || this;
19
19
  _this._nolabel = true;
20
20
  _this._card = false;
21
+ _this._icon = "";
22
+ _this._suffix = "";
21
23
  if (_this._parsedWidgetProps) {
22
- _this._card = _this._parsedWidgetProps.card;
24
+ _this._card = _this._parsedWidgetProps.card || false;
25
+ _this._icon = _this._parsedWidgetProps.icon || "";
26
+ _this._suffix = _this._parsedWidgetProps.suffix || "";
23
27
  }
24
28
  return _this;
25
29
  }
@@ -33,7 +37,27 @@ var Indicator = /** @class */ (function (_super) {
33
37
  enumerable: false,
34
38
  configurable: true
35
39
  });
40
+ Object.defineProperty(Indicator.prototype, "icon", {
41
+ get: function () {
42
+ return this._icon;
43
+ },
44
+ set: function (value) {
45
+ this._icon = value;
46
+ },
47
+ enumerable: false,
48
+ configurable: true
49
+ });
50
+ Object.defineProperty(Indicator.prototype, "suffix", {
51
+ get: function () {
52
+ return this._suffix;
53
+ },
54
+ set: function (value) {
55
+ this._suffix = value;
56
+ },
57
+ enumerable: false,
58
+ configurable: true
59
+ });
36
60
  return Indicator;
37
- }(Field));
61
+ }(Selection));
38
62
  export default Indicator;
39
63
  //# sourceMappingURL=Indicator.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Indicator.js","sourceRoot":"","sources":["../src/Indicator.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,OAAO,KAAK,MAAM,SAAS,CAAC;AAE5B;IAAwB,6BAAK;IAW3B,mBAAY,KAAU;QAAtB,Y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C,KAAK,GAAG,KAAK,CAAC;QACrB,CAAC;;;OAHA;IAKD,sBAAI,2BAAI;aAAR;YACE,OAAO,IAAI,CAAC,KAAK,CAAC;QACpB,CAAC;aACD,UAAS,KAAa;YACpB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACrB,CAAC;;;OAHA;IAKD,sBAAI,6BAAM;aAAV;YACE,OAAO,IAAI,CAAC,OAAO,CAAC;QACtB,CAAC;aACD,UAAW,KAAa;YACtB,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;QACvB,CAAC;;;OAHA;IAgBH,gBAAC;AAAD,CAAC,AApCD,CAAwB,SAAS,GAoChC;AAGD,eAAe,SAAS,CAAC"}
@@ -4,4 +4,5 @@ declare type ParsedNode = {
4
4
  child: Element;
5
5
  };
6
6
  declare const parseNodes: (nodes: NodeListOf<ChildNode>, fields: any) => ParsedNode[];
7
- export { parseNodes };
7
+ declare const parseGenericNodes: (nodes: NodeListOf<ChildNode>) => ParsedNode[];
8
+ export { parseNodes, parseGenericNodes };
@@ -46,5 +46,19 @@ var parseNodes = function (nodes, fields) {
46
46
  });
47
47
  return parsedNodes;
48
48
  };
49
- export { parseNodes };
49
+ var parseGenericNodes = function (nodes) {
50
+ var parsedNodes = [];
51
+ Array.prototype.forEach.call(nodes, function (child) {
52
+ if (child.nodeType === child.ELEMENT_NODE) {
53
+ var tag = child.nodeName;
54
+ var tagAttributes_2 = {};
55
+ Array.prototype.forEach.call(child.attributes, function (attr) {
56
+ tagAttributes_2[attr.name] = attr.value;
57
+ });
58
+ parsedNodes.push({ tag: tag, tagAttributes: tagAttributes_2, child: child });
59
+ }
60
+ });
61
+ return parsedNodes;
62
+ };
63
+ export { parseNodes, parseGenericNodes };
50
64
  //# sourceMappingURL=nodeParser.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"nodeParser.js","sourceRoot":"","sources":["../../src/helpers/nodeParser.ts"],"names":[],"mappings":";;;;;;;;;;;AAMA,IAAM,UAAU,GAAG,UACjB,K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AC;YAC5B,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,UAAC,IAAU;gBACxD,eAAa,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC;YACxC,CAAC,CAAC,CAAC;YAEH,WAAW,CAAC,IAAI,CAAC,EAAE,GAAG,KAAA,EAAE,aAAa,iBAAA,EAAE,KAAK,OAAA,EAAE,CAAC,CAAC;SACjD;IACH,CAAC,CAAC,CAAC;IACH,OAAO,WAAW,CAAC;AACrB,CAAC,CAAC;AAEF,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,CAAC"}
package/dist/index.d.ts CHANGED
@@ -31,4 +31,7 @@ import { parseContext } from "./helpers/contextParser";
31
31
  import { transformDomainForChildWidget } from "./helpers/domainParser";
32
32
  import Timeline from "./Timeline";
33
33
  import Indicator from "./Indicator";
34
- export { Char, Selection, Many2one, Field, Widget, Form, Tree, Boolean, One2many, Integer, Float, FloatTime, Date, DateTime, Many2many, SearchFilter, Container, ContainerWidget, Text, ProgressBar, Notebook, Group, Page, Label, Separator, Button, Reference, Binary, Image, parseContext, transformDomainForChildWidget, Timeline, Indicator, };
34
+ import Dashboard from "./Dashboard";
35
+ import DashboardItem from "./DashboardItem";
36
+ import Graph from "./Graph";
37
+ export { Char, Selection, Many2one, Field, Widget, Form, Tree, Boolean, One2many, Integer, Float, FloatTime, Date, DateTime, Many2many, SearchFilter, Container, ContainerWidget, Text, ProgressBar, Notebook, Group, Page, Label, Separator, Button, Reference, Binary, Image, parseContext, transformDomainForChildWidget, Timeline, Indicator, Dashboard, DashboardItem, Graph };
package/dist/index.js CHANGED
@@ -31,5 +31,8 @@ import { parseContext } from "./helpers/contextParser";
31
31
  import { transformDomainForChildWidget } from "./helpers/domainParser";
32
32
  import Timeline from "./Timeline";
33
33
  import Indicator from "./Indicator";
34
- export { Char, Selection, Many2one, Field, Widget, Form, Tree, Boolean, One2many, Integer, Float, FloatTime, Date, DateTime, Many2many, SearchFilter, Container, ContainerWidget, Text, ProgressBar, Notebook, Group, Page, Label, Separator, Button, Reference, Binary, Image, parseContext, transformDomainForChildWidget, Timeline, Indicator, };
34
+ import Dashboard from "./Dashboard";
35
+ import DashboardItem from "./DashboardItem";
36
+ import Graph from "./Graph";
37
+ export { Char, Selection, Many2one, Field, Widget, Form, Tree, Boolean, One2many, Integer, Float, FloatTime, Date, DateTime, Many2many, SearchFilter, Container, ContainerWidget, Text, ProgressBar, Notebook, Group, Page, Label, Separator, Button, Reference, Binary, Image, parseContext, transformDomainForChildWidget, Timeline, Indicator, Dashboard, DashboardItem, Graph };
35
38
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,QAAQ,CAAC;AAC1B,OAAO,IAAI,MAAM,QAAQ,CAAC;AAC1B,OAAO,IAAI,MAAM,QAAQ,CAAC;AAC1B,OAAO,SAAS,MAAM,aAAa,CAAC;AACpC,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAChD,OAAO,SAAS,MAAM,aAAa,CAAC;AACpC,OAAO,QAAQ,MAAM,YAAY,CAAC;AAClC,OAAO,KAAK,MAAM,SAAS,CAAC;AAC5B,OAAO,MAAM,MAAM,UAAU,CAAC;AAC9B,OAAO,OAAO,MAAM,WAAW,CAAC;AAChC,OAAO,OAAO,MAAM,WAAW,CAAC;AAChC,OAAO,KAAK,MAAM,SAAS,CAAC;AAC5B,OAAO,SAAS,MAAM,aAAa,CAAC;AACpC,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,IAAI,MAAM,QAAQ,CAAC;AAC1B,OAAO,QAAQ,MAAM,YAAY,CAAC;AAClC,OAAO,SAAS,MAAM,aAAa,CAAC;AACpC,OAAO,QAAQ,MAAM,YAAY,CAAC;AAClC,OAAO,YAAY,MAAM,gBAAgB,CAAC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AAI,EACJ,IAAI,EACJ,OAAO,EACP,QAAQ,EACR,OAAO,EACP,KAAK,EACL,SAAS,EACT,IAAI,EACJ,QAAQ,EACR,SAAS,EACT,YAAY,EACZ,SAAS,EACT,eAAe,EACf,IAAI,EACJ,WAAW,EACX,QAAQ,EACR,KAAK,EACL,IAAI,EACJ,KAAK,EACL,SAAS,EACT,MAAM,EACN,SAAS,EACT,MAAM,EACN,KAAK,EACL,YAAY,EACZ,6BAA6B,EAC7B,QAAQ,EACR,SAAS,EACT,SAAS,EACT,aAAa,EACb,KAAK,EACN,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gisce/ooui",
3
- "version": "0.2.2",
3
+ "version": "0.2.5",
4
4
  "dependencies": {},
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -0,0 +1,31 @@
1
+ import DashboardItem from "./DashboardItem";
2
+ import { parseGenericNodes } from "./helpers/nodeParser";
3
+
4
+ class Dashboard {
5
+ _string: string | null = null;
6
+ get string(): string | null {
7
+ return this._string;
8
+ }
9
+
10
+ _items: DashboardItem[] = [];
11
+ get items(): DashboardItem[] {
12
+ return this._items;
13
+ }
14
+
15
+ constructor(xml: string) {
16
+ const parser = new DOMParser();
17
+ const view: Document = parser.parseFromString(xml, "text/xml");
18
+ this._string = view.documentElement.getAttribute("string");
19
+ const documentElement = view.documentElement;
20
+
21
+ const actionsParsed = parseGenericNodes(documentElement.childNodes);
22
+
23
+ actionsParsed.forEach((nodeParsed) => {
24
+ if (nodeParsed.tag === "dashboard_item") {
25
+ this._items.push(new DashboardItem(nodeParsed.tagAttributes));
26
+ }
27
+ });
28
+ }
29
+ }
30
+
31
+ export default Dashboard;
@@ -0,0 +1,23 @@
1
+ class DashboardItem {
2
+ _action_id: string | null = null;
3
+ get action_id(): string | null {
4
+ return this._action_id;
5
+ }
6
+
7
+ _position: string | null = null;
8
+ get position(): string | null {
9
+ return this._position;
10
+ }
11
+
12
+ constructor(attributes: any) {
13
+ if (attributes.action_id) {
14
+ this._action_id = attributes.action_id;
15
+ }
16
+
17
+ if (attributes.position) {
18
+ this._position = attributes.position;
19
+ }
20
+ }
21
+ }
22
+
23
+ export default DashboardItem;
package/src/Graph.ts ADDED
@@ -0,0 +1,26 @@
1
+ export type GraphType = "indicator";
2
+
3
+ class Graph {
4
+ _string: string | null = null;
5
+ get string(): string | null {
6
+ return this._string;
7
+ }
8
+
9
+ _type?: GraphType;
10
+ get type(): GraphType | undefined {
11
+ return this._type;
12
+ }
13
+
14
+ constructor(xml: string) {
15
+ const parser = new DOMParser();
16
+ const view: Document = parser.parseFromString(xml, "text/xml");
17
+ this._string = view.documentElement.getAttribute("string");
18
+ const type = view.documentElement.getAttribute("type");
19
+
20
+ if (type === "indicator") {
21
+ this._type = "indicator";
22
+ }
23
+ }
24
+ }
25
+
26
+ export default Graph;
package/src/Indicator.ts CHANGED
@@ -1,6 +1,6 @@
1
- import Field from "./Field";
1
+ import Selection from "./Selection";
2
2
 
3
- class Indicator extends Field {
3
+ class Indicator extends Selection {
4
4
  _nolabel: boolean = true;
5
5
 
6
6
  _card: boolean;
@@ -10,12 +10,30 @@ class Indicator extends Field {
10
10
  set card(value: boolean) {
11
11
  this._card = value;
12
12
  }
13
+ _icon: string;
14
+ get icon(): string {
15
+ return this._icon;
16
+ }
17
+ set icon(value: string) {
18
+ this._icon = value;
19
+ }
20
+ _suffix: string;
21
+ get suffix(): string {
22
+ return this._suffix;
23
+ }
24
+ set suffix(value: string) {
25
+ this._suffix = value;
26
+ }
13
27
 
14
28
  constructor(props: any) {
15
29
  super(props);
16
30
  this._card = false;
31
+ this._icon = "";
32
+ this._suffix = "";
17
33
  if (this._parsedWidgetProps) {
18
- this._card = this._parsedWidgetProps.card;
34
+ this._card = this._parsedWidgetProps.card || false;
35
+ this._icon = this._parsedWidgetProps.icon || "";
36
+ this._suffix = this._parsedWidgetProps.suffix || "";
19
37
  }
20
38
  }
21
39
  }
@@ -54,4 +54,21 @@ const parseNodes = (
54
54
  return parsedNodes;
55
55
  };
56
56
 
57
- export { parseNodes };
57
+ const parseGenericNodes = (nodes: NodeListOf<ChildNode>): ParsedNode[] => {
58
+ const parsedNodes: ParsedNode[] = [];
59
+ Array.prototype.forEach.call(nodes, (child: Element) => {
60
+ if (child.nodeType === child.ELEMENT_NODE) {
61
+ let tag = child.nodeName;
62
+
63
+ let tagAttributes: any = {};
64
+ Array.prototype.forEach.call(child.attributes, (attr: Attr) => {
65
+ tagAttributes[attr.name] = attr.value;
66
+ });
67
+
68
+ parsedNodes.push({ tag, tagAttributes, child });
69
+ }
70
+ });
71
+ return parsedNodes;
72
+ };
73
+
74
+ export { parseNodes, parseGenericNodes };
package/src/index.ts CHANGED
@@ -31,6 +31,9 @@ import { parseContext } from "./helpers/contextParser";
31
31
  import { transformDomainForChildWidget } from "./helpers/domainParser";
32
32
  import Timeline from "./Timeline";
33
33
  import Indicator from "./Indicator";
34
+ import Dashboard from "./Dashboard";
35
+ import DashboardItem from "./DashboardItem";
36
+ import Graph from "./Graph";
34
37
 
35
38
  export {
36
39
  Char,
@@ -66,4 +69,7 @@ export {
66
69
  transformDomainForChildWidget,
67
70
  Timeline,
68
71
  Indicator,
72
+ Dashboard,
73
+ DashboardItem,
74
+ Graph
69
75
  };
@@ -0,0 +1,28 @@
1
+ import Dashboard from "../Dashboard";
2
+
3
+ describe("A Dashboard", () => {
4
+ it("should parse a basic XML with three actions", () => {
5
+ const xml = `<?xml version="1.0"?>
6
+ <dashboard string="My dashboard">
7
+ <dashboard_item action_id="1497" position="{ x: 0, y: 0, w: 1, h: 2, static: true }" />
8
+ <dashboard_item action_id="1496" position="{ x: 1, y: 0, w: 3, h: 2, minW: 2, maxW: 4 }" />
9
+ <dashboard_item action_id="1321" position="{ x: 4, y: 0, w: 1, h: 2 }" />
10
+ </dashboard>
11
+ `;
12
+
13
+ const dashboard = new Dashboard(xml);
14
+
15
+ expect(dashboard.string).toBe("My dashboard");
16
+ expect(dashboard.items.length).toBe(3);
17
+ expect(dashboard.items[0].action_id).toBe("1497");
18
+ expect(dashboard.items[1].action_id).toBe("1496");
19
+ expect(dashboard.items[2].action_id).toBe("1321");
20
+ expect(dashboard.items[0].position).toBe(
21
+ "{ x: 0, y: 0, w: 1, h: 2, static: true }"
22
+ );
23
+ expect(dashboard.items[1].position).toBe(
24
+ "{ x: 1, y: 0, w: 3, h: 2, minW: 2, maxW: 4 }"
25
+ );
26
+ expect(dashboard.items[2].position).toBe("{ x: 4, y: 0, w: 1, h: 2 }");
27
+ });
28
+ });
@@ -0,0 +1,14 @@
1
+ import Graph from "../Graph";
2
+
3
+ describe("A Graph", () => {
4
+ it("should parse a basic XML title and type indicator", () => {
5
+ const xml = `<?xml version="1.0"?>
6
+ <graph string="My indicator" type="indicator" />
7
+ `;
8
+
9
+ const graph = new Graph(xml);
10
+
11
+ expect(graph.string).toBe("My indicator");
12
+ expect(graph.type).toBe("indicator");
13
+ });
14
+ });
@@ -19,9 +19,28 @@ describe("An Indicator", () => {
19
19
  it('should parse widget props', () => {
20
20
  const widgetFactory = new WidgetFactory();
21
21
  const props = {
22
- widget_props: "{'card': true}"
22
+ widget_props: "{'card': true, 'icon': 'wallet', 'suffix': '€'}"
23
23
  };
24
24
  const widget = widgetFactory.createWidget("indicator", props);
25
25
  expect(widget.card).toBe(true);
26
+ expect(widget.icon).toBe('wallet');
27
+ expect(widget.suffix).toBe('€');
28
+ });
29
+ it('icon and suffix should be an empty string if not defined', () => {
30
+ const widgetFactory = new WidgetFactory();
31
+ const props = {
32
+ widget_props: "{'card': true}"
33
+ };
34
+ const widget = widgetFactory.createWidget("indicator", props);
35
+ expect(widget.icon).toBe("");
36
+ expect(widget.suffix).toBe("");
37
+ });
38
+ it('card should be false if not defined', () => {
39
+ const widgetFactory = new WidgetFactory();
40
+ const props = {
41
+ widget_props: "{'icon': 'wallet'}"
42
+ };
43
+ const widget = widgetFactory.createWidget("indicator", props);
44
+ expect(widget.card).toBe(false);
26
45
  });
27
46
  });