coer-elements 1.0.15 → 1.0.16
Sign up to get free protection for your applications and to get access to all the features.
- package/package.json +5 -2
- package/dist_browser/Tools/Breadcrumbs.class.js +0 -66
- package/dist_browser/Tools/ControlValue.js +0 -49
- package/dist_browser/Tools/DateTime.class.js +0 -25
- package/dist_browser/Tools/Files.class.js +0 -99
- package/dist_browser/Tools/Page.class.js +0 -213
- package/dist_browser/Tools/Screen.class.js +0 -68
- package/dist_browser/Tools/Source.class.js +0 -83
- package/dist_browser/Tools/Tools.js +0 -227
- package/dist_browser/components/coer-alert/coer-alert.component.js +0 -314
- package/dist_browser/index.js +0 -8
- package/dist_node/Tools/Breadcrumbs.class.js +0 -69
- package/dist_node/Tools/ControlValue.js +0 -53
- package/dist_node/Tools/DateTime.class.js +0 -28
- package/dist_node/Tools/Files.class.js +0 -102
- package/dist_node/Tools/Page.class.js +0 -216
- package/dist_node/Tools/Screen.class.js +0 -71
- package/dist_node/Tools/Source.class.js +0 -86
- package/dist_node/Tools/Tools.js +0 -230
- package/dist_node/components/coer-alert/coer-alert.component.js +0 -317
- package/dist_node/index.js +0 -24
- package/dist_node/interfaces/index.js +0 -2
@@ -1,28 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.DateTime = void 0;
|
4
|
-
var moment_1 = require("moment");
|
5
|
-
var DateTime = /** @class */ (function () {
|
6
|
-
function DateTime() {
|
7
|
-
}
|
8
|
-
/** Get UTC Offset */
|
9
|
-
DateTime.GetUTCOffset = function () {
|
10
|
-
return (0, moment_1.default)().utcOffset();
|
11
|
-
};
|
12
|
-
/** Convert UTC Date to Local Zone */
|
13
|
-
DateTime.ToLocalZone = function (utcDate) {
|
14
|
-
return (0, moment_1.default)(utcDate).add(DateTime.GetUTCOffset(), 'minutes').format('YYYY-MM-DD HH:mm:ss');
|
15
|
-
};
|
16
|
-
/** Convert Local Zone Date to UTC */
|
17
|
-
DateTime.ToUTC = function (utcDate) {
|
18
|
-
return (0, moment_1.default)(utcDate).subtract(DateTime.GetUTCOffset(), 'minutes').format('YYYY-MM-DD HH:mm:ss');
|
19
|
-
};
|
20
|
-
/** DD MMM YYYY */
|
21
|
-
DateTime.GetDateFormat = function (date) {
|
22
|
-
if ((typeof date === 'string'))
|
23
|
-
date = date.replaceAll('/', '-');
|
24
|
-
return (0, moment_1.default)(date).parseZone().local(true).format('DD MMM YYYY');
|
25
|
-
};
|
26
|
-
return DateTime;
|
27
|
-
}());
|
28
|
-
exports.DateTime = DateTime;
|
@@ -1,102 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.Files = void 0;
|
4
|
-
var Tools_1 = require("./Tools");
|
5
|
-
var XLSX = require("xlsx");
|
6
|
-
var Files = /** @class */ (function () {
|
7
|
-
function Files() {
|
8
|
-
}
|
9
|
-
/** Get Extension File */
|
10
|
-
Files.GetExtension = function (file) {
|
11
|
-
var fileName = file.name;
|
12
|
-
if (fileName.includes('.')) {
|
13
|
-
var worlds = fileName.split('.');
|
14
|
-
if (worlds.length > 0) {
|
15
|
-
var extension = worlds.pop();
|
16
|
-
extension = extension.trim().toLowerCase();
|
17
|
-
if (extension.length > 0)
|
18
|
-
return extension;
|
19
|
-
}
|
20
|
-
}
|
21
|
-
return null;
|
22
|
-
};
|
23
|
-
/** Is Excel File */
|
24
|
-
Files.IsExcel = function (file) {
|
25
|
-
var EXTENSION = Files.GetExtension(file);
|
26
|
-
return Tools_1.Tools.IsNotNull(EXTENSION)
|
27
|
-
? this.EXCEL_EXTENSIONS.includes(EXTENSION)
|
28
|
-
: false;
|
29
|
-
};
|
30
|
-
/** Read excel file */
|
31
|
-
Files.ReadExcel = function (file) {
|
32
|
-
return new Promise(function (Resolve) {
|
33
|
-
var columns = [];
|
34
|
-
var rows = [];
|
35
|
-
var reader = new FileReader();
|
36
|
-
reader.readAsArrayBuffer(file);
|
37
|
-
reader.onload = function () {
|
38
|
-
var dataBytes = new Uint8Array(reader.result);
|
39
|
-
if (dataBytes) {
|
40
|
-
var workbook = XLSX.read(dataBytes, {});
|
41
|
-
var sheet = workbook.Sheets[workbook.SheetNames[0]];
|
42
|
-
var dataSheet = XLSX.utils.sheet_to_json(sheet, {
|
43
|
-
header: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
|
44
|
-
});
|
45
|
-
//Get Headers
|
46
|
-
for (var column in dataSheet[0]) {
|
47
|
-
columns.push(Tools_1.Tools.FirstCharToLower(String(dataSheet[0][column]).replaceAll(' ', '')));
|
48
|
-
}
|
49
|
-
//Get Rows
|
50
|
-
rows = XLSX.utils.sheet_to_json(sheet, { header: columns });
|
51
|
-
rows.shift();
|
52
|
-
rows = rows.map(function (row) {
|
53
|
-
var item = Tools_1.Tools.BreakReference(row);
|
54
|
-
delete item['__rowNum__'];
|
55
|
-
return item;
|
56
|
-
});
|
57
|
-
}
|
58
|
-
Resolve({ columns: columns, rows: rows });
|
59
|
-
};
|
60
|
-
reader.onerror = function () { Resolve({ columns: columns, rows: rows }); };
|
61
|
-
});
|
62
|
-
};
|
63
|
-
/** Export to excel file */
|
64
|
-
Files.ExportExcel = function (data, fileName, sheetName) {
|
65
|
-
if (fileName === void 0) { fileName = 'coer_report'; }
|
66
|
-
if (sheetName === void 0) { sheetName = 'Sheet1'; }
|
67
|
-
sheetName = Tools_1.Tools.CleanUpBlanks(sheetName);
|
68
|
-
fileName = Tools_1.Tools.CleanUpBlanks(fileName);
|
69
|
-
if (fileName.endsWith('.xls') || fileName.endsWith('.xlsx') || fileName.endsWith('.csv')) {
|
70
|
-
if (fileName.includes('.xls')) {
|
71
|
-
fileName = fileName.replaceAll('.xls', '.xlsx');
|
72
|
-
}
|
73
|
-
if (fileName.includes('.csv')) {
|
74
|
-
fileName = fileName.replaceAll('.csv', '.xlsx');
|
75
|
-
}
|
76
|
-
}
|
77
|
-
else {
|
78
|
-
fileName += '.xlsx';
|
79
|
-
}
|
80
|
-
var WORK_SHEET = XLSX.utils.json_to_sheet(data);
|
81
|
-
var WORK_BOOK = XLSX.utils.book_new();
|
82
|
-
XLSX.utils.book_append_sheet(WORK_BOOK, WORK_SHEET, 'Sheet1');
|
83
|
-
XLSX.writeFile(WORK_BOOK, fileName);
|
84
|
-
};
|
85
|
-
/** Convert file to string base64 */
|
86
|
-
Files.ConvertToBase64 = function (file) {
|
87
|
-
return new Promise(function (Resolve) {
|
88
|
-
var reader = new FileReader();
|
89
|
-
reader.readAsDataURL(file);
|
90
|
-
reader.onload = function () {
|
91
|
-
var _a;
|
92
|
-
Resolve(((_a = reader.result) === null || _a === void 0 ? void 0 : _a.toString()) || '');
|
93
|
-
};
|
94
|
-
reader.onerror = function () {
|
95
|
-
Resolve('');
|
96
|
-
};
|
97
|
-
});
|
98
|
-
};
|
99
|
-
Files.EXCEL_EXTENSIONS = ['xls', 'xlsx', 'csv'];
|
100
|
-
return Files;
|
101
|
-
}());
|
102
|
-
exports.Files = Files;
|
@@ -1,216 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
3
|
-
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
4
|
-
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
5
|
-
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
6
|
-
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
7
|
-
var _, done = false;
|
8
|
-
for (var i = decorators.length - 1; i >= 0; i--) {
|
9
|
-
var context = {};
|
10
|
-
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
11
|
-
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
12
|
-
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
13
|
-
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
14
|
-
if (kind === "accessor") {
|
15
|
-
if (result === void 0) continue;
|
16
|
-
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
17
|
-
if (_ = accept(result.get)) descriptor.get = _;
|
18
|
-
if (_ = accept(result.set)) descriptor.set = _;
|
19
|
-
if (_ = accept(result.init)) initializers.unshift(_);
|
20
|
-
}
|
21
|
-
else if (_ = accept(result)) {
|
22
|
-
if (kind === "field") initializers.unshift(_);
|
23
|
-
else descriptor[key] = _;
|
24
|
-
}
|
25
|
-
}
|
26
|
-
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
27
|
-
done = true;
|
28
|
-
};
|
29
|
-
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
30
|
-
var useValue = arguments.length > 2;
|
31
|
-
for (var i = 0; i < initializers.length; i++) {
|
32
|
-
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
33
|
-
}
|
34
|
-
return useValue ? value : void 0;
|
35
|
-
};
|
36
|
-
var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
|
37
|
-
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
|
38
|
-
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
|
39
|
-
};
|
40
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
41
|
-
exports.Page = void 0;
|
42
|
-
var core_1 = require("@angular/core");
|
43
|
-
var Breadcrumbs_class_1 = require("./Breadcrumbs.class");
|
44
|
-
var Source_class_1 = require("./Source.class");
|
45
|
-
var coer_alert_component_1 = require("../components/coer-alert/coer-alert.component");
|
46
|
-
var router_1 = require("@angular/router");
|
47
|
-
var Tools_1 = require("./Tools");
|
48
|
-
var Page = function () {
|
49
|
-
var _classDecorators = [(0, core_1.Component)({ template: '' })];
|
50
|
-
var _classDescriptor;
|
51
|
-
var _classExtraInitializers = [];
|
52
|
-
var _classThis;
|
53
|
-
var Page = _classThis = /** @class */ (function () {
|
54
|
-
function Page_1(page) {
|
55
|
-
//Injection
|
56
|
-
this.alert = (0, core_1.inject)(coer_alert_component_1.CoerAlert);
|
57
|
-
this.router = (0, core_1.inject)(router_1.Router);
|
58
|
-
this.activatedRoute = (0, core_1.inject)(router_1.ActivatedRoute);
|
59
|
-
/** */
|
60
|
-
this.isUpdate = false;
|
61
|
-
/** */
|
62
|
-
this.isLoading = false;
|
63
|
-
/** */
|
64
|
-
this.isReady = false;
|
65
|
-
/** */
|
66
|
-
this.enableAnimations = false;
|
67
|
-
/** */
|
68
|
-
this.breadcrumbs = [];
|
69
|
-
/** */
|
70
|
-
this.pageResponse = null;
|
71
|
-
/** */
|
72
|
-
this.goBack = { show: false };
|
73
|
-
//Private Variables
|
74
|
-
this._page = '';
|
75
|
-
this._source = null;
|
76
|
-
this._preventDestroy = false;
|
77
|
-
/** */
|
78
|
-
this.GoBack = function (path) { return (function () {
|
79
|
-
if (path)
|
80
|
-
Breadcrumbs_class_1.Breadcrumbs.Remove(path);
|
81
|
-
else
|
82
|
-
Breadcrumbs_class_1.Breadcrumbs.RemoveLast();
|
83
|
-
}); };
|
84
|
-
/** Returns true if the value is null or undefined, false otherwise */
|
85
|
-
this.IsNotNull = Tools_1.Tools.IsNotNull;
|
86
|
-
/** Returns true if the value is null or undefined, false otherwise */
|
87
|
-
this.IsNull = Tools_1.Tools.IsNull;
|
88
|
-
/** Returns true if the value is null or undefined or contains only whitespace, false otherwise */
|
89
|
-
this.IsOnlyWhiteSpace = Tools_1.Tools.IsOnlyWhiteSpace;
|
90
|
-
this.SetPageName(page);
|
91
|
-
this.SetSource();
|
92
|
-
this.GetSource();
|
93
|
-
this.GetNavigation();
|
94
|
-
this.SetGoBack();
|
95
|
-
this.GetPageResponse();
|
96
|
-
}
|
97
|
-
Page_1.prototype.ngAfterViewInit = function () {
|
98
|
-
var _this = this;
|
99
|
-
this.routeParams = this.activatedRoute.snapshot.params;
|
100
|
-
this.queryParams = this.activatedRoute.snapshot.queryParams;
|
101
|
-
setTimeout(function () {
|
102
|
-
_this.isReady = true;
|
103
|
-
_this.RunPage();
|
104
|
-
setTimeout(function () { _this.enableAnimations = true; }, 1000);
|
105
|
-
});
|
106
|
-
};
|
107
|
-
Page_1.prototype.ngOnDestroy = function () {
|
108
|
-
if (!this._preventDestroy)
|
109
|
-
Source_class_1.Source.ClearPageResponse();
|
110
|
-
};
|
111
|
-
/** Main method. Starts after ngAfterViewInit() */
|
112
|
-
Page_1.prototype.RunPage = function () { };
|
113
|
-
;
|
114
|
-
/** Rename the last breadcrumb and update the url id */
|
115
|
-
Page_1.prototype.SetPageName = function (name, id) {
|
116
|
-
if (id === void 0) { id = null; }
|
117
|
-
this._page = name;
|
118
|
-
var path = this.router.url;
|
119
|
-
if (path.includes('?'))
|
120
|
-
path = path.split('?')[0];
|
121
|
-
if (id) {
|
122
|
-
var PATH_ARRAY = path.split('/');
|
123
|
-
var PATH_ID = Tools_1.Tools.BreakReference(PATH_ARRAY).pop();
|
124
|
-
if (PATH_ID) {
|
125
|
-
PATH_ARRAY[PATH_ARRAY.length - 1] = String(id);
|
126
|
-
path = PATH_ARRAY.join('/');
|
127
|
-
}
|
128
|
-
}
|
129
|
-
if (this.breadcrumbs.length > 0) {
|
130
|
-
this.breadcrumbs[this.breadcrumbs.length - 1].page = name;
|
131
|
-
this.breadcrumbs[this.breadcrumbs.length - 1].path = path;
|
132
|
-
Breadcrumbs_class_1.Breadcrumbs.SetLast(name, path);
|
133
|
-
}
|
134
|
-
this.router.navigateByUrl(path);
|
135
|
-
};
|
136
|
-
/** */
|
137
|
-
Page_1.prototype.SetSource = function () {
|
138
|
-
Source_class_1.Source.Set(this._page);
|
139
|
-
};
|
140
|
-
/** */
|
141
|
-
Page_1.prototype.GetSource = function () {
|
142
|
-
this._source = Source_class_1.Source.Get();
|
143
|
-
};
|
144
|
-
/** */
|
145
|
-
Page_1.prototype.GetPageResponse = function () {
|
146
|
-
this.pageResponse = Source_class_1.Source.GetPageResponse();
|
147
|
-
};
|
148
|
-
/** */
|
149
|
-
Page_1.prototype.GetNavigation = function () {
|
150
|
-
var _this = this;
|
151
|
-
if (this._source) {
|
152
|
-
this.breadcrumbs = Breadcrumbs_class_1.Breadcrumbs.Get().map(function (item) { return Object.assign({
|
153
|
-
page: item.page,
|
154
|
-
path: item.path,
|
155
|
-
click: _this.GoBack(item.path)
|
156
|
-
}); });
|
157
|
-
}
|
158
|
-
else
|
159
|
-
this.breadcrumbs = [{ page: this._page }];
|
160
|
-
};
|
161
|
-
/** */
|
162
|
-
Page_1.prototype.SetGoBack = function () {
|
163
|
-
if (this._source) {
|
164
|
-
this.goBack = {
|
165
|
-
show: true,
|
166
|
-
path: this._source.path,
|
167
|
-
click: this.GoBack()
|
168
|
-
};
|
169
|
-
}
|
170
|
-
};
|
171
|
-
/** Navigate to previous page */
|
172
|
-
Page_1.prototype.GoToSource = function (pageResponse) {
|
173
|
-
var _this = this;
|
174
|
-
if (pageResponse === void 0) { pageResponse = null; }
|
175
|
-
if (this._source) {
|
176
|
-
Breadcrumbs_class_1.Breadcrumbs.RemoveLast();
|
177
|
-
this.SetPageResponse(pageResponse);
|
178
|
-
Tools_1.Tools.Sleep().then(function (_) { return _this.router.navigateByUrl(_this._source.path); });
|
179
|
-
}
|
180
|
-
};
|
181
|
-
;
|
182
|
-
/** */
|
183
|
-
Page_1.prototype.SetPageResponse = function (pageResponse) {
|
184
|
-
if (pageResponse === void 0) { pageResponse = null; }
|
185
|
-
if (Tools_1.Tools.IsNotNull(pageResponse)) {
|
186
|
-
this._preventDestroy = true;
|
187
|
-
Source_class_1.Source.SetPageResponse(pageResponse);
|
188
|
-
}
|
189
|
-
};
|
190
|
-
;
|
191
|
-
/** */
|
192
|
-
Page_1.prototype.ReloadPage = function () {
|
193
|
-
Breadcrumbs_class_1.Breadcrumbs.RemoveLast();
|
194
|
-
Tools_1.Tools.Sleep().then(function (_) { return window.location.reload(); });
|
195
|
-
};
|
196
|
-
/** */
|
197
|
-
Page_1.prototype.Log = function (value, log) {
|
198
|
-
if (log === void 0) { log = null; }
|
199
|
-
if (Tools_1.Tools.IsNotNull(log))
|
200
|
-
console.log({ log: log, value: value });
|
201
|
-
else
|
202
|
-
console.log(value);
|
203
|
-
};
|
204
|
-
return Page_1;
|
205
|
-
}());
|
206
|
-
__setFunctionName(_classThis, "Page");
|
207
|
-
(function () {
|
208
|
-
var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
209
|
-
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
210
|
-
Page = _classThis = _classDescriptor.value;
|
211
|
-
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
212
|
-
__runInitializers(_classThis, _classExtraInitializers);
|
213
|
-
})();
|
214
|
-
return Page = _classThis;
|
215
|
-
}();
|
216
|
-
exports.Page = Page;
|
@@ -1,71 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.Screen = void 0;
|
4
|
-
var rxjs_1 = require("rxjs");
|
5
|
-
var Screen = /** @class */ (function () {
|
6
|
-
function Screen() {
|
7
|
-
}
|
8
|
-
Object.defineProperty(Screen, "WINDOW_WIDTH", {
|
9
|
-
get: function () {
|
10
|
-
return window.innerWidth;
|
11
|
-
},
|
12
|
-
enumerable: false,
|
13
|
-
configurable: true
|
14
|
-
});
|
15
|
-
Object.defineProperty(Screen, "WINDOW_HEIGHT", {
|
16
|
-
get: function () {
|
17
|
-
return window.innerHeight;
|
18
|
-
},
|
19
|
-
enumerable: false,
|
20
|
-
configurable: true
|
21
|
-
});
|
22
|
-
Object.defineProperty(Screen, "DEVICE_WIDTH", {
|
23
|
-
get: function () {
|
24
|
-
return window.screen.width;
|
25
|
-
},
|
26
|
-
enumerable: false,
|
27
|
-
configurable: true
|
28
|
-
});
|
29
|
-
Object.defineProperty(Screen, "DEVICE_HEIGHT", {
|
30
|
-
get: function () {
|
31
|
-
return window.screen.height;
|
32
|
-
},
|
33
|
-
enumerable: false,
|
34
|
-
configurable: true
|
35
|
-
});
|
36
|
-
Object.defineProperty(Screen, "BREAKPOINT", {
|
37
|
-
get: function () {
|
38
|
-
if (window.innerWidth < 576)
|
39
|
-
return 'xs';
|
40
|
-
else if (window.innerWidth >= 576 && window.innerWidth < 768)
|
41
|
-
return 'sm';
|
42
|
-
else if (window.innerWidth >= 768 && window.innerWidth < 992)
|
43
|
-
return 'md';
|
44
|
-
else if (window.innerWidth >= 992 && window.innerWidth < 1200)
|
45
|
-
return 'lg';
|
46
|
-
else if (window.innerWidth >= 1200 && window.innerWidth < 1400)
|
47
|
-
return 'xl';
|
48
|
-
else
|
49
|
-
return 'xxl';
|
50
|
-
},
|
51
|
-
enumerable: false,
|
52
|
-
configurable: true
|
53
|
-
});
|
54
|
-
var _a;
|
55
|
-
_a = Screen;
|
56
|
-
/** */
|
57
|
-
Screen.Resize = new rxjs_1.Observable(function (subscriber) {
|
58
|
-
window.addEventListener("load", function () {
|
59
|
-
window.dispatchEvent(new Event('resize'));
|
60
|
-
});
|
61
|
-
window.onresize = function () {
|
62
|
-
subscriber.next({
|
63
|
-
width: window.innerWidth,
|
64
|
-
height: window.innerHeight,
|
65
|
-
breakpoin: _a.BREAKPOINT
|
66
|
-
});
|
67
|
-
};
|
68
|
-
});
|
69
|
-
return Screen;
|
70
|
-
}());
|
71
|
-
exports.Screen = Screen;
|
@@ -1,86 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.Source = void 0;
|
4
|
-
var Breadcrumbs_class_1 = require("./Breadcrumbs.class");
|
5
|
-
var router_1 = require("@angular/router");
|
6
|
-
var core_1 = require("@angular/core");
|
7
|
-
var Tools_1 = require("./Tools");
|
8
|
-
var Source = /** @class */ (function () {
|
9
|
-
function Source() {
|
10
|
-
}
|
11
|
-
/** */
|
12
|
-
Source.Set = function (page) {
|
13
|
-
var ROUTER = (0, core_1.inject)(router_1.Router);
|
14
|
-
var path = ROUTER.url;
|
15
|
-
if (path.includes('?'))
|
16
|
-
path = path.split('?')[0];
|
17
|
-
Breadcrumbs_class_1.Breadcrumbs.Add(page, path);
|
18
|
-
var breadcrumbs = Breadcrumbs_class_1.Breadcrumbs.Get();
|
19
|
-
if (breadcrumbs.length >= 2) {
|
20
|
-
breadcrumbs.pop();
|
21
|
-
var breadcrumb = breadcrumbs.pop();
|
22
|
-
this.Save({ page: breadcrumb.page, path: breadcrumb.path });
|
23
|
-
}
|
24
|
-
else
|
25
|
-
this.Save(null);
|
26
|
-
};
|
27
|
-
/** */
|
28
|
-
Source.Save = function (source) {
|
29
|
-
var storage = sessionStorage.getItem(this.storage);
|
30
|
-
if (storage)
|
31
|
-
storage = JSON.parse(storage);
|
32
|
-
storage = Object.assign({}, storage, { source: source });
|
33
|
-
sessionStorage.setItem(this.storage, JSON.stringify(storage));
|
34
|
-
};
|
35
|
-
/** */
|
36
|
-
Source.Get = function () {
|
37
|
-
var storage = sessionStorage.getItem(this.storage);
|
38
|
-
if (storage) {
|
39
|
-
storage = JSON.parse(storage);
|
40
|
-
if (storage.hasOwnProperty('source')) {
|
41
|
-
return storage.source;
|
42
|
-
}
|
43
|
-
}
|
44
|
-
return null;
|
45
|
-
};
|
46
|
-
/** */
|
47
|
-
Source.GetRoot = function () {
|
48
|
-
var breadcrumbs = Breadcrumbs_class_1.Breadcrumbs.Get();
|
49
|
-
return (breadcrumbs.length > 0) ? breadcrumbs.shift() : null;
|
50
|
-
};
|
51
|
-
/** */
|
52
|
-
Source.SetPageResponse = function (pageResponse) {
|
53
|
-
var storage = sessionStorage.getItem(this.storage);
|
54
|
-
storage = JSON.parse(storage);
|
55
|
-
storage = Object.assign({}, storage, { pageResponse: pageResponse });
|
56
|
-
sessionStorage.setItem(this.storage, JSON.stringify(storage));
|
57
|
-
};
|
58
|
-
/** */
|
59
|
-
Source.GetPageResponse = function () {
|
60
|
-
var storage = sessionStorage.getItem(this.storage);
|
61
|
-
if (storage) {
|
62
|
-
storage = JSON.parse(storage);
|
63
|
-
if (storage.hasOwnProperty('pageResponse')) {
|
64
|
-
return Tools_1.Tools.BreakReference(storage.pageResponse);
|
65
|
-
}
|
66
|
-
}
|
67
|
-
return null;
|
68
|
-
};
|
69
|
-
/** */
|
70
|
-
Source.ClearPageResponse = function () {
|
71
|
-
var storage = sessionStorage.getItem(this.storage);
|
72
|
-
storage = JSON.parse(storage);
|
73
|
-
if (storage.hasOwnProperty('pageResponse')) {
|
74
|
-
delete storage.pageResponse;
|
75
|
-
}
|
76
|
-
storage = Object.assign({}, storage);
|
77
|
-
sessionStorage.setItem(this.storage, JSON.stringify(storage));
|
78
|
-
};
|
79
|
-
/** Clear Source */
|
80
|
-
Source.Reset = function () {
|
81
|
-
sessionStorage.removeItem(this.storage);
|
82
|
-
};
|
83
|
-
Source.storage = 'COER-System';
|
84
|
-
return Source;
|
85
|
-
}());
|
86
|
-
exports.Source = Source;
|