widget-common-container 0.0.0

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.
Files changed (87) hide show
  1. package/.angular/cache/19.2.26/ng-packagr/0997d7866dbb7999756bcd6dce071e827244865f4ff149c26d049d1515686b01 +1 -0
  2. package/.angular/cache/19.2.26/ng-packagr/882519e10fb587011272af89a34932495c0e2cc97d0c030536d1033ee55ce561 +1 -0
  3. package/.angular/cache/19.2.26/ng-packagr/8b15b546ec32b4e82b20945f62d23ba911050bdc6a4a60d34875eea6fe236635 +1 -0
  4. package/.angular/cache/19.2.26/ng-packagr/9711df1afdc00e2ac901d2b22d9559a220e74d16c0bf6d3917e410c565aed496 +1 -0
  5. package/.angular/cache/19.2.26/ng-packagr/tsbuildinfo/inspark-widget-common.tsbuildinfo +1 -0
  6. package/.editorconfig +13 -0
  7. package/.eslintrc.json +28 -0
  8. package/README.md +27 -0
  9. package/angular.json +46 -0
  10. package/e2e/protractor.conf.js +28 -0
  11. package/e2e/src/app.e2e-spec.ts +14 -0
  12. package/e2e/src/app.po.ts +11 -0
  13. package/e2e/tsconfig.e2e.json +13 -0
  14. package/package.json +75 -0
  15. package/projects/widget-common/copy.json +8 -0
  16. package/projects/widget-common/karma.conf.js +31 -0
  17. package/projects/widget-common/ng-package.json +7 -0
  18. package/projects/widget-common/package-lock.json +78 -0
  19. package/projects/widget-common/package.json +23 -0
  20. package/projects/widget-common/src/assets/error.svg +6 -0
  21. package/projects/widget-common/src/assets/falsevalue.svg +6 -0
  22. package/projects/widget-common/src/assets/icon.svg +6 -0
  23. package/projects/widget-common/src/assets/none.svg +6 -0
  24. package/projects/widget-common/src/assets/success.svg +6 -0
  25. package/projects/widget-common/src/assets/warning.svg +6 -0
  26. package/projects/widget-common/src/lib/common.ts +23 -0
  27. package/projects/widget-common/src/lib/communication.service.ts +59 -0
  28. package/projects/widget-common/src/lib/echart/echart.component.html +2 -0
  29. package/projects/widget-common/src/lib/echart/echart.component.scss +40 -0
  30. package/projects/widget-common/src/lib/echart/echart.component.ts +703 -0
  31. package/projects/widget-common/src/lib/echart/en.ts +156 -0
  32. package/projects/widget-common/src/lib/echart/ru.ts +156 -0
  33. package/projects/widget-common/src/lib/forge/ParamAssign.ts +187 -0
  34. package/projects/widget-common/src/lib/forge/Script.service.ts +86 -0
  35. package/projects/widget-common/src/lib/forge/extenstion.ts +263 -0
  36. package/projects/widget-common/src/lib/forge/forge.component.html +2 -0
  37. package/projects/widget-common/src/lib/forge/forge.component.scss +6 -0
  38. package/projects/widget-common/src/lib/forge/forge.component.ts +184 -0
  39. package/projects/widget-common/src/lib/forge/forge.interface.ts +4 -0
  40. package/projects/widget-common/src/lib/loader.ts +19 -0
  41. package/projects/widget-common/src/lib/pie-chart/pie-chart.component.html +1 -0
  42. package/projects/widget-common/src/lib/pie-chart/pie-chart.component.scss +3 -0
  43. package/projects/widget-common/src/lib/pie-chart/pie-chart.component.ts +252 -0
  44. package/projects/widget-common/src/lib/shared.module.ts +40 -0
  45. package/projects/widget-common/src/lib/sprintf.ts +212 -0
  46. package/projects/widget-common/src/lib/widget-container/widget-container.component.ts +53 -0
  47. package/projects/widget-common/src/lib/widget.api.ts +24 -0
  48. package/projects/widget-common/src/lib/widget.component.ts +87 -0
  49. package/projects/widget-common/src/lib/widget.dialog.ts +14 -0
  50. package/projects/widget-common/src/lib/widget.generator.ts +1532 -0
  51. package/projects/widget-common/src/lib/widget.interface.ts +871 -0
  52. package/projects/widget-common/src/lib/widget.utils.ts +634 -0
  53. package/projects/widget-common/src/public_api.ts +9 -0
  54. package/projects/widget-common/src/scss/main.scss +24 -0
  55. package/projects/widget-common/src/test.ts +22 -0
  56. package/projects/widget-common/tsconfig.lib.json +38 -0
  57. package/projects/widget-common/tsconfig.lib.prod.json +6 -0
  58. package/projects/widget-common/tsconfig.spec.json +17 -0
  59. package/projects/widget-common/tslint.json +17 -0
  60. package/projects/widget-common/versions/full/copy.json +15 -0
  61. package/projects/widget-common/versions/full/package.json +7 -0
  62. package/projects/widget-common/versions/full/public_api.ts +19 -0
  63. package/projects/widget-common/versions/interfaces/copy.json +15 -0
  64. package/projects/widget-common/versions/interfaces/package.json +7 -0
  65. package/projects/widget-common/versions/interfaces/public_api.ts +9 -0
  66. package/src/app/app.component.html +20 -0
  67. package/src/app/app.component.scss +0 -0
  68. package/src/app/app.component.spec.ts +31 -0
  69. package/src/app/app.component.ts +10 -0
  70. package/src/app/app.module.ts +16 -0
  71. package/src/assets/.gitkeep +0 -0
  72. package/src/browserslist +11 -0
  73. package/src/environments/environment.prod.ts +3 -0
  74. package/src/environments/environment.ts +16 -0
  75. package/src/favicon.ico +0 -0
  76. package/src/index.html +14 -0
  77. package/src/karma.conf.js +31 -0
  78. package/src/main.ts +12 -0
  79. package/src/polyfills.ts +80 -0
  80. package/src/styles.scss +1 -0
  81. package/src/test.ts +20 -0
  82. package/src/tsconfig.app.json +11 -0
  83. package/src/tsconfig.spec.json +18 -0
  84. package/src/tslint.json +17 -0
  85. package/tsconfig.json +34 -0
  86. package/tslint.json +131 -0
  87. package/update_full.js +27 -0
@@ -0,0 +1,252 @@
1
+ import {ChangeDetectionStrategy, ChangeDetectorRef, Component, Input, OnChanges, OnDestroy, OnInit} from '@angular/core';
2
+ import {ItemInterval, ItemSingle, ParamConfigSingle, SiteTheme, ChartTypes} from '../widget.interface';
3
+ import {EChartsOption, SeriesOption} from 'echarts/types/dist/echarts';
4
+
5
+
6
+ @Component({
7
+ selector: 'app-pie-chart',
8
+ templateUrl: './pie-chart.component.html',
9
+ styleUrls: ['./pie-chart.component.scss'],
10
+ changeDetection: ChangeDetectionStrategy.OnPush,
11
+ })
12
+ export class PieChartComponent implements OnInit, OnChanges, OnDestroy {
13
+
14
+
15
+ @Input() values: ItemInterval | ItemSingle;
16
+ @Input() config: ParamConfigSingle;
17
+ @Input() locale = 'en';
18
+ @Input() noDataMessage = 'No data';
19
+ @Input() width = 250;
20
+ @Input() height = 250;
21
+ @Input() margin = {
22
+ top: 25,
23
+ right: 25,
24
+ bottom: 25,
25
+ left: 25
26
+ };
27
+
28
+ @Input() theme: SiteTheme;
29
+
30
+ options: EChartsOption = {
31
+ backgroundColor: 'transparent',
32
+ tooltip: {
33
+ trigger: 'item',
34
+ confine: true,
35
+ appendToBody: true,
36
+ },
37
+ toolbox: {
38
+ feature: {
39
+ // mark: {show: true},
40
+ // dataView: {show: true, readOnly: false},
41
+ // restore: {show: true},
42
+ saveAsImage: {show: true}
43
+ }
44
+ },
45
+ grid: {
46
+ left: `${this.margin.left}px`,
47
+ right: `${this.margin.right}px`,
48
+ bottom: `${this.margin.bottom}px`,
49
+ top: `${this.margin.top}px`,
50
+ containLabel: true
51
+ },
52
+ series: [],
53
+ legend: {
54
+ show: false,
55
+ },
56
+ };
57
+
58
+
59
+ uniqTitles = [];
60
+
61
+ initOpts: any = {
62
+ locale: this.locale.toLocaleUpperCase()
63
+ };
64
+
65
+ darkColor = [
66
+ {'color': '#00FF7F'},
67
+ {'color': '#00E0E0'},
68
+ {'color': '#FF00FF'},
69
+ {'color': '#B2CCE5'},
70
+ {'color': '#F1F227'},
71
+ {'color': '#FDE3A7'},
72
+ {'color': '#F64747'},
73
+ {'color': '#8BB82D'},
74
+ {'color': '#1E90FF'},
75
+ {'color': '#D2527F'},
76
+ {'color': '#91A6BA'}];
77
+
78
+ lightColor = [
79
+ {'color': '#007A4B'},
80
+ {'color': '#3477DB'},
81
+ {'color': '#D252B2'},
82
+ {'color': '#708090'},
83
+ {'color': '#AF851A'},
84
+ {'color': '#BB671C'},
85
+ {'color': '#E00000'},
86
+ {'color': '#005031'},
87
+ {'color': '#34415E'},
88
+ {'color': '#58007E'},
89
+ {'color': '#2E343B'}
90
+ ];
91
+
92
+
93
+ display = false;
94
+ echartsInstance: any;
95
+ constructor(private cdr: ChangeDetectorRef) {
96
+
97
+
98
+ }
99
+
100
+ ngOnChanges(changes) {
101
+ if (changes.locale) {
102
+ this.initOpts = {locale: this.locale};
103
+ this.display = false;
104
+ this.cdr.detectChanges();
105
+ setTimeout(() => {
106
+ this.display = true;
107
+ this.cdr.detectChanges();
108
+ });
109
+ }
110
+ if (this.echartsInstance && (changes.width || changes.height)) {
111
+ this.resizeChart();
112
+ }
113
+ if (changes.config || changes.values || changes.theme) {
114
+ if (this.config && this.values) {
115
+ this.updateData(this.config, this.values);
116
+ }
117
+ }
118
+ }
119
+
120
+ ngOnInit() {
121
+ this.initOpts = {locale: this.locale};
122
+ }
123
+
124
+ ngOnDestroy() {
125
+ }
126
+
127
+ onChartInit(ec) {
128
+ this.echartsInstance = ec;
129
+ }
130
+
131
+ resizeChart() {
132
+ if (this.echartsInstance) {
133
+ this.echartsInstance.resize();
134
+ }
135
+ }
136
+
137
+ updateData(config: ParamConfigSingle, values: ItemInterval | ItemSingle) {
138
+
139
+ const res: SeriesOption[] = [];
140
+
141
+ this.uniqTitles = [];
142
+ const customColors = [];
143
+
144
+ const data = (values.data as any).map((val, indexData) => {
145
+ customColors.push(val.color || this.getChartColor(indexData));
146
+ return {
147
+ value: val.value,
148
+ name: this.findUniqName(val.key)
149
+ };
150
+ });
151
+ if ((this.config as any).legend) {
152
+ this.options.legend = {show: true, bottom: '16px'};
153
+ }
154
+ if ((config as any).charttype === ChartTypes.intervalPieChart) {
155
+ this.options.tooltip = {show: false};
156
+ this.options.legend = {show: false};
157
+ this.options.grid = {show: false};
158
+
159
+
160
+ res.push({
161
+ name: 'Chart',
162
+ type: 'pie',
163
+ radius: '55%',
164
+ center: ['50%', '50%'],
165
+ data: data,
166
+ itemStyle: {
167
+ color: ({seriesIndex, dataIndex}) => customColors[dataIndex],
168
+ },
169
+ label: {
170
+ show: false
171
+ },
172
+ labelLine: {
173
+ show: false
174
+ },
175
+ // itemStyle: {
176
+ // color: '#c23531',
177
+ // shadowBlur: 200,
178
+ // shadowColor: 'rgba(0, 0, 0, 0.5)'
179
+ // },
180
+ animationType: 'scale',
181
+ animationEasing: 'elasticOut',
182
+ animationDelay: function (idx) {
183
+ return Math.random() * 200;
184
+ }
185
+ });
186
+ } else {
187
+
188
+ res.push({
189
+ name: 'Chart',
190
+ type: 'pie',
191
+ radius: ['40%', '70%'],
192
+ center: ['50%', '50%'],
193
+ data: data,
194
+ // roseType: 'radius',
195
+ // roseType: 'area',
196
+ label: {
197
+ color: this.theme === SiteTheme.dark ? 'rgba(255, 255, 255, 0.5)' : 'rgba(0, 0, 0, 0.5)'
198
+ },
199
+ labelLine: {
200
+ lineStyle: {
201
+ color: this.theme === SiteTheme.dark ? 'rgba(255, 255, 255, 0.5)' : 'rgba(0, 0, 0, 0.5)'
202
+ },
203
+ smooth: 0.2,
204
+ length: 10,
205
+ length2: 20
206
+ },
207
+ itemStyle: {
208
+ borderRadius: 4,
209
+ color: ({seriesIndex, dataIndex}) => this.getChartColor(dataIndex),
210
+ },
211
+ // itemStyle: {
212
+ // color: '#c23531',
213
+ // shadowBlur: 200,
214
+ // shadowColor: 'rgba(0, 0, 0, 0.5)'
215
+ // },
216
+ animationType: 'scale',
217
+ animationEasing: 'elasticOut',
218
+ animationDelay: function (idx) {
219
+ return Math.random() * 200;
220
+ }
221
+ });
222
+ }
223
+ this.options = {...this.options, series: res};
224
+ }
225
+
226
+ findUniqName(title, ind = 0) {
227
+
228
+ if (ind === 0) {
229
+ if (this.uniqTitles.indexOf(title) !== -1) {
230
+ return this.findUniqName(title, ind + 1);
231
+ }
232
+ this.uniqTitles.push(title);
233
+ return title;
234
+ } else {
235
+ const newTitle = `${title} (${ind})`;
236
+ if (this.uniqTitles.indexOf(newTitle) !== -1) {
237
+ return this.findUniqName(title, ind + 1);
238
+ }
239
+ this.uniqTitles.push(newTitle);
240
+ return newTitle;
241
+ }
242
+ }
243
+
244
+ getChartColor(seed) {
245
+ if (this.theme === SiteTheme.dark) {
246
+ return this.lightColor[seed % this.darkColor.length].color;
247
+ } else {
248
+ return this.darkColor[seed % this.lightColor.length].color;
249
+ }
250
+
251
+ }
252
+ }
@@ -0,0 +1,40 @@
1
+ import {TranslateModule} from '@ngx-translate/core';
2
+ import {NgModule} from '@angular/core';
3
+ import {ArrayNumberPipe, ChartUrl, FilterIndexOfPipe, MakeChartUrl, MakeIconUrl, MakePictureUrl, PeriodFromDatePipe} from './widget.utils';
4
+ import {InlineSVGModule} from 'ng-inline-svg';
5
+ import {ForgeComponentModule} from './forge/forge.component';
6
+ import {EChartComponentModule} from './echart/echart.component';
7
+
8
+ @NgModule({
9
+ declarations: [
10
+ PeriodFromDatePipe,
11
+ FilterIndexOfPipe,
12
+ ArrayNumberPipe,
13
+ MakePictureUrl,
14
+ MakeIconUrl,
15
+ MakeChartUrl,
16
+ ChartUrl,
17
+ ],
18
+ imports: [
19
+ TranslateModule,
20
+ EChartComponentModule,
21
+ ForgeComponentModule,
22
+ InlineSVGModule.forRoot({ baseUrl: '' }),
23
+ ],
24
+ exports: [
25
+ TranslateModule,
26
+ PeriodFromDatePipe,
27
+ FilterIndexOfPipe,
28
+ ArrayNumberPipe,
29
+ MakePictureUrl,
30
+ MakeIconUrl,
31
+ MakeChartUrl,
32
+ ChartUrl,
33
+ EChartComponentModule,
34
+ ForgeComponentModule,
35
+ InlineSVGModule,
36
+ ]
37
+ })
38
+ export class DashboardSharedModule {
39
+ }
40
+
@@ -0,0 +1,212 @@
1
+ var re = {
2
+ not_string: /[^s]/,
3
+ not_bool: /[^t]/,
4
+ not_type: /[^T]/,
5
+ not_primitive: /[^v]/,
6
+ number: /[diefg]/,
7
+ numeric_arg: /[bcdiefguxX]/,
8
+ json: /[j]/,
9
+ not_json: /[^j]/,
10
+ text: /^[^\x25]+/,
11
+ modulo: /^\x25{2}/,
12
+ placeholder: /^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?((yyyy)|(hh)|(HH)|(mm)|(MM)|(ss)|(dd)|[b-gijostTuvxX])/,
13
+ key: /^([a-z_][a-z_\d]*)/i,
14
+ key_access: /^\.([a-z_][a-z_\d]*)/i,
15
+ index_access: /^\[(\d+)\]/,
16
+ sign: /^[\+\-]/
17
+ }
18
+
19
+ export function sprintf(key, ...args) {
20
+ // `arguments` is not an array, but should be fine for this call
21
+ return sprintf_format(sprintf_parse(key), args);
22
+ }
23
+
24
+ export function vsprintf(fmt, argv) {
25
+ return sprintf.apply(null, [fmt].concat(argv || []));
26
+ }
27
+
28
+ function tsToDate(arg) {
29
+ var n = typeof arg === 'string' ? parseFloat(arg) : +arg;
30
+ return new Date(n < 1e10 ? n * 1000 : n);
31
+ }
32
+
33
+ function sprintf_format(parse_tree, argv) {
34
+ var cursor = 0, tree_length = parse_tree.length, arg, output = '', i, k, match, pad, pad_character, pad_length,
35
+ is_positive, sign
36
+ for (i = 0; i < tree_length; i++) {
37
+ if (typeof parse_tree[i] === 'string') {
38
+ output += parse_tree[i]
39
+ } else if (Array.isArray(parse_tree[i])) {
40
+ match = parse_tree[i] // convenience purposes only
41
+ if (match[2]) { // keyword argument
42
+ arg = argv[cursor]
43
+ for (k = 0; k < match[2].length; k++) {
44
+ if (!arg.hasOwnProperty(match[2][k])) {
45
+ throw new Error(sprintf('[sprintf] property "%s" does not exist', match[2][k]))
46
+ }
47
+ arg = arg[match[2][k]];
48
+ }
49
+ } else if (match[1]) { // positional argument (explicit)
50
+ arg = argv[match[1]];
51
+ } else { // positional argument (implicit)
52
+ arg = argv[cursor++];
53
+ }
54
+
55
+ if (re.not_type.test(match[8]) && re.not_primitive.test(match[8]) && arg instanceof Function) {
56
+ arg = arg();
57
+ }
58
+
59
+ if (re.numeric_arg.test(match[8]) && (typeof arg !== 'number' && isNaN(arg))) {
60
+ throw new TypeError(sprintf('[sprintf] expecting number but found %T', arg));
61
+ }
62
+
63
+ if (re.number.test(match[8])) {
64
+ is_positive = arg >= 0;
65
+ }
66
+ switch (match[8]) {
67
+ case 'b':
68
+ arg = parseInt(arg, 10).toString(2);
69
+ break;
70
+ case 'c':
71
+ arg = String.fromCharCode(parseInt(arg, 10));
72
+ break;
73
+ case 'd':
74
+ arg = match[7] ? parseFloat(arg).toFixed(match[7]) : parseFloat(arg);
75
+ break;
76
+ case 'i':
77
+ arg = parseInt(arg, 10);
78
+ break;
79
+ case 'j':
80
+ arg = JSON.stringify(arg, null, match[6] ? parseInt(match[6]) : 0);
81
+ break
82
+ case 'e':
83
+ arg = match[7] ? parseFloat(arg).toExponential(match[7]) : parseFloat(arg).toExponential()
84
+ break
85
+ case 'f':
86
+ arg = match[7] ? parseFloat(arg).toFixed(match[7]) : parseFloat(arg)
87
+ break
88
+ case 'g':
89
+ arg = match[7] ? String(Number(arg.toPrecision(match[7]))) : parseFloat(arg)
90
+ break
91
+ case 'hh':
92
+ arg = (Math.floor(parseInt(arg) / 60));
93
+ break
94
+ case 'mm':
95
+ arg = parseFloat(arg) > 1e7
96
+ ? ('0' + tsToDate(arg).getMinutes()).slice(-2)
97
+ : ('0' + (parseInt(arg) % 60)).slice(-2);
98
+ break
99
+ case 'ss':
100
+ arg = parseFloat(arg) > 1e7
101
+ ? ('0' + tsToDate(arg).getSeconds()).slice(-2)
102
+ : ('0' + ((parseFloat(arg) - parseInt(arg)) * 60)).slice(-2);
103
+ break
104
+ case 'HH':
105
+ arg = ('0' + tsToDate(arg).getHours()).slice(-2);
106
+ break
107
+ case 'MM':
108
+ arg = ('0' + (tsToDate(arg).getMonth() + 1)).slice(-2);
109
+ break
110
+ case 'dd':
111
+ arg = ('0' + tsToDate(arg).getDate()).slice(-2);
112
+ break
113
+ case 'yyyy':
114
+ arg = tsToDate(arg).getFullYear().toString();
115
+ break
116
+ case 'n':
117
+ arg = match[7] ? parseFloat(arg).toFixed(match[7]) : parseFloat(arg)
118
+ break
119
+ case 'o':
120
+ arg = (parseInt(arg, 10) >>> 0).toString(8)
121
+ break
122
+ case 's':
123
+ arg = String(arg)
124
+ arg = (match[7] ? arg.substring(0, match[7]) : arg)
125
+ break
126
+ case 't':
127
+ arg = String(!!arg)
128
+ arg = (match[7] ? arg.substring(0, match[7]) : arg)
129
+ break
130
+ case 'T':
131
+ arg = Object.prototype.toString.call(arg).slice(8, -1).toLowerCase()
132
+ arg = (match[7] ? arg.substring(0, match[7]) : arg)
133
+ break
134
+ case 'u':
135
+ arg = parseInt(arg, 10) >>> 0
136
+ break
137
+ case 'v':
138
+ arg = arg.valueOf()
139
+ arg = (match[7] ? arg.substring(0, match[7]) : arg)
140
+ break
141
+ case 'x':
142
+ arg = (parseInt(arg, 10) >>> 0).toString(16)
143
+ break
144
+ case 'X':
145
+ arg = (parseInt(arg, 10) >>> 0).toString(16).toUpperCase()
146
+ break
147
+ }
148
+ if (re.json.test(match[8])) {
149
+ output += arg
150
+ } else {
151
+ if (re.number.test(match[8]) && (!is_positive || match[3])) {
152
+ sign = is_positive ? '+' : '-'
153
+ arg = arg.toString().replace(re.sign, '')
154
+ } else {
155
+ sign = ''
156
+ }
157
+ pad_character = match[4] ? match[4] === '0' ? '0' : match[4].charAt(1) : ' '
158
+ pad_length = match[6] - (sign + arg).length
159
+ pad = match[6] ? (pad_length > 0 ? pad_character.repeat(pad_length) : '') : ''
160
+ output += match[5] ? sign + arg + pad : (pad_character === '0' ? sign + pad + arg : pad + sign + arg)
161
+ }
162
+ }
163
+ }
164
+ return output
165
+ }
166
+
167
+ var sprintf_cache = Object.create(null)
168
+
169
+ function sprintf_parse(fmt) {
170
+ if (sprintf_cache[fmt]) {
171
+ return sprintf_cache[fmt]
172
+ }
173
+
174
+ var _fmt = fmt, match, parse_tree = [], arg_names = 0
175
+ while (_fmt) {
176
+ if ((match = re.text.exec(_fmt)) !== null) {
177
+ parse_tree.push(match[0])
178
+ } else if ((match = re.modulo.exec(_fmt)) !== null) {
179
+ parse_tree.push('%')
180
+ } else if ((match = re.placeholder.exec(_fmt)) !== null) {
181
+ if (match[2]) {
182
+ arg_names |= 1
183
+ var field_list = [], replacement_field = match[2], field_match = []
184
+ if ((field_match = re.key.exec(replacement_field)) !== null) {
185
+ field_list.push(field_match[1])
186
+ while ((replacement_field = replacement_field.substring(field_match[0].length)) !== '') {
187
+ if ((field_match = re.key_access.exec(replacement_field)) !== null) {
188
+ field_list.push(field_match[1])
189
+ } else if ((field_match = re.index_access.exec(replacement_field)) !== null) {
190
+ field_list.push(field_match[1])
191
+ } else {
192
+ throw new SyntaxError('[sprintf] failed to parse named argument key')
193
+ }
194
+ }
195
+ } else {
196
+ throw new SyntaxError('[sprintf] failed to parse named argument key')
197
+ }
198
+ match[2] = field_list
199
+ } else {
200
+ arg_names |= 2
201
+ }
202
+ if (arg_names === 3) {
203
+ throw new Error('[sprintf] mixing positional and named placeholders is not (yet) supported')
204
+ }
205
+ parse_tree.push(match)
206
+ } else {
207
+ throw new SyntaxError('[sprintf] unexpected placeholder')
208
+ }
209
+ _fmt = _fmt.substring(match[0].length)
210
+ }
211
+ return sprintf_cache[fmt] = parse_tree
212
+ }
@@ -0,0 +1,53 @@
1
+ import {ItemSingle, IWidget, IWidgetClass, IWidgetParam, SiteTheme} from '../widget.interface';
2
+ import {WidgetPackage} from '../widget.component';
3
+
4
+ export interface WidgetContainerDevOptions {
5
+ widget: IWidget;
6
+ widgetPackage: WidgetPackage;
7
+ setManual: (param: ItemSingle, value: boolean) => {};
8
+ paramEdit: (param: ItemSingle, container?: HTMLElement) => {};
9
+ isDev: boolean;
10
+ theme: SiteTheme;
11
+ element: Element;
12
+ locale: string;
13
+ }
14
+
15
+
16
+ export interface WidgetContainerProduction {
17
+ widget: IWidget;
18
+ widgetClass: IWidgetClass;
19
+ id: string;
20
+ widgetPackage: WidgetPackage;
21
+ sendData: (param: ItemSingle) => {};
22
+ setManual: (param: ItemSingle, value: boolean) => {};
23
+ paramEdit: (param: ItemSingle, container?: HTMLElement) => {};
24
+ isDev: boolean;
25
+ theme: SiteTheme;
26
+ element: Element;
27
+ locale: string;
28
+ }
29
+
30
+
31
+ export class WidgetContainer {
32
+
33
+
34
+ /**
35
+ * @deprecated
36
+ * @param componentType
37
+ */
38
+ public createComponentModule(componentType: any): any {
39
+
40
+ throw new Error('You should implement this method');
41
+ }
42
+
43
+
44
+ /**
45
+ * @deprecated
46
+ * @param opts
47
+ */
48
+ public createNewComponent(opts: WidgetContainerDevOptions | WidgetContainerProduction): any {
49
+
50
+ throw new Error('You should implement this method');
51
+ }
52
+
53
+ }
@@ -0,0 +1,24 @@
1
+ import {ModalOptions, WidgetItem} from './widget.interface';
2
+ import {ChangeDetectorRef, TemplateRef} from '@angular/core';
3
+ import {WidgetDialog} from './widget.dialog';
4
+
5
+
6
+ export interface WidgetApi {
7
+ cdRef: ChangeDetectorRef;
8
+
9
+ paramCancel(par: WidgetItem): void;
10
+
11
+ setManual(param: WidgetItem, value: boolean): void;
12
+
13
+ paramEdit(param: WidgetItem, container?: HTMLElement): void;
14
+
15
+ openModal(component: TemplateRef<any>, opts: ModalOptions): Promise<WidgetDialog>;
16
+
17
+ query<T = any, TOptions = any>(command: string, options?: TOptions): Promise<T>;
18
+
19
+ mutation<T = any, TOptions = any>(command: string, options?: TOptions): Promise<T>;
20
+
21
+ command<T = any, TOptions = any>(command: string, options?: TOptions): Promise<T>;
22
+
23
+ }
24
+
@@ -0,0 +1,87 @@
1
+ import {ChartTypes, SiteTheme, VALUE_TYPE, WidgetCustomField, WidgetItem, WidgetParams, WidgetSize} from './widget.interface';
2
+ import {WidgetApi} from './widget.api';
3
+ import {Type} from '@angular/core';
4
+
5
+ export const _ = (str: string) => str;
6
+
7
+ export class WidgetComponent {
8
+
9
+ API: WidgetApi;
10
+ media: any;
11
+ width: number;
12
+ height: number;
13
+
14
+ container: Element;
15
+
16
+ onInit(container: Element) {
17
+ this.container = container;
18
+ }
19
+
20
+ onDestroy() {
21
+ }
22
+
23
+ onResize(width, height) {
24
+ this.width = width;
25
+ this.height = height;
26
+ }
27
+
28
+ onRender(values) {
29
+
30
+ }
31
+
32
+ onUpdate(values) {
33
+ }
34
+ }
35
+
36
+
37
+ export class WidgetComponentContainer {
38
+
39
+ values: any;
40
+ pictureId: number;
41
+ theme: SiteTheme;
42
+
43
+ readonly CHART_TYPES = ChartTypes;
44
+ readonly VALUE_TYPE = VALUE_TYPE;
45
+
46
+
47
+ urlExport(): string {
48
+ return '';
49
+ }
50
+
51
+ paramCancel(par: WidgetItem) {
52
+ }
53
+
54
+ paramEdit(par: WidgetItem) {
55
+ }
56
+
57
+ paramSave(par: WidgetItem) {
58
+ }
59
+
60
+ getIconUrl(par: WidgetItem): string {
61
+ return '';
62
+ }
63
+
64
+ setManual(par: WidgetItem, value) {
65
+
66
+ }
67
+ }
68
+
69
+
70
+ export interface WidgetPackage {
71
+ template: string;
72
+ component: WidgetComponent;
73
+ params: WidgetParams;
74
+ size: WidgetSize;
75
+ styles: string;
76
+ locales?: { code: string, file: string }[];
77
+ needPicture?: boolean;
78
+ needIcon?: boolean;
79
+ noFullscreen?: boolean;
80
+ fields?: WidgetCustomField[];
81
+ // Для мобильных дашей. Будет ли виджет учитывать высоту заданную в настройках или подстроит автоматически
82
+ autoAdjustHeight?: boolean;
83
+ // Будет ли фрейм вокруг виджета
84
+ showFrame?: boolean;
85
+ imports?: Array<Type<any>>;
86
+ }
87
+
@@ -0,0 +1,14 @@
1
+ export class WidgetDialog {
2
+
3
+ onClose;
4
+
5
+ constructor(opts: { close: Function }) {
6
+ this.onClose = opts.close;
7
+ }
8
+
9
+ close() {
10
+ if (this.onClose) {
11
+ this.onClose();
12
+ }
13
+ }
14
+ }