@sumaris-net/ngx-components 1.20.3 → 1.20.4
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.
- package/bundles/sumaris-net.ngx-components.umd.js +203 -23
- package/bundles/sumaris-net.ngx-components.umd.js.map +1 -1
- package/bundles/sumaris-net.ngx-components.umd.min.js +2 -2
- package/bundles/sumaris-net.ngx-components.umd.min.js.map +1 -1
- package/doc/changelog.md +5 -0
- package/esm2015/public_api.js +7 -3
- package/esm2015/src/app/core/install/install-upgrade-card.component.js +3 -2
- package/esm2015/src/app/core/services/platform.service.js +3 -2
- package/esm2015/src/app/shared/directives/autotitle.directive.js +27 -0
- package/esm2015/src/app/shared/directives/directives.module.js +6 -3
- package/esm2015/src/app/shared/file/csv.utils.js +90 -0
- package/esm2015/src/app/shared/file/file.utils.js +63 -0
- package/esm2015/src/app/shared/file/uri.utils.js +23 -0
- package/esm2015/src/app/shared/functions.js +3 -1
- package/esm2015/src/app/shared/pipes/pipes.module.js +7 -4
- package/esm2015/src/app/shared/pipes/property.pipes.js +74 -0
- package/esm2015/src/app/shared/upload-file/testing/upload-file.testing.js +2 -2
- package/fesm2015/sumaris-net.ngx-components.js +193 -21
- package/fesm2015/sumaris-net.ngx-components.js.map +1 -1
- package/package.json +1 -1
- package/public_api.d.ts +6 -2
- package/src/app/shared/directives/autotitle.directive.d.ts +7 -0
- package/src/app/shared/file/csv.utils.d.ts +18 -0
- package/src/app/shared/{files.d.ts → file/file.utils.d.ts} +3 -9
- package/src/app/shared/file/uri.utils.d.ts +7 -0
- package/src/app/shared/pipes/property.pipes.d.ts +14 -0
- package/sumaris-net.ngx-components.metadata.json +1 -1
- package/esm2015/src/app/shared/files.js +0 -84
- package/esm2015/src/app/shared/pipes/properties.pipe.js +0 -20
- package/src/app/shared/pipes/properties.pipe.d.ts +0 -7
|
@@ -576,6 +576,8 @@
|
|
|
576
576
|
function joinPropertiesPath(obj, properties, separator) {
|
|
577
577
|
if (!obj)
|
|
578
578
|
throw new Error('Could not display an undefined entity.');
|
|
579
|
+
if (!properties)
|
|
580
|
+
throw new Error('Missing \'properties\' argument');
|
|
579
581
|
return properties
|
|
580
582
|
.map(function (path) { return getPropertyByPath(obj, path); })
|
|
581
583
|
.filter(isNotNilOrBlank)
|
|
@@ -3344,26 +3346,6 @@
|
|
|
3344
3346
|
{ type: i0.Injectable }
|
|
3345
3347
|
];
|
|
3346
3348
|
|
|
3347
|
-
var PropertyGetPipe = /** @class */ (function () {
|
|
3348
|
-
function PropertyGetPipe() {
|
|
3349
|
-
}
|
|
3350
|
-
PropertyGetPipe.prototype.transform = function (obj, args) {
|
|
3351
|
-
return getPropertyByPath(obj,
|
|
3352
|
-
// Path
|
|
3353
|
-
args && (typeof args === 'string' ? args : args.key),
|
|
3354
|
-
// Default value
|
|
3355
|
-
args && args.defaultValue);
|
|
3356
|
-
};
|
|
3357
|
-
return PropertyGetPipe;
|
|
3358
|
-
}());
|
|
3359
|
-
PropertyGetPipe.ɵprov = i0.ɵɵdefineInjectable({ factory: function PropertyGetPipe_Factory() { return new PropertyGetPipe(); }, token: PropertyGetPipe, providedIn: "root" });
|
|
3360
|
-
PropertyGetPipe.decorators = [
|
|
3361
|
-
{ type: i0.Pipe, args: [{
|
|
3362
|
-
name: 'propertyGet'
|
|
3363
|
-
},] },
|
|
3364
|
-
{ type: i0.Injectable, args: [{ providedIn: 'root' },] }
|
|
3365
|
-
];
|
|
3366
|
-
|
|
3367
3349
|
var NgInitDirective = /** @class */ (function () {
|
|
3368
3350
|
function NgInitDirective() {
|
|
3369
3351
|
this.ngInit = new i0.EventEmitter();
|
|
@@ -4882,6 +4864,79 @@
|
|
|
4882
4864
|
{ type: i0.ChangeDetectorRef }
|
|
4883
4865
|
]; };
|
|
4884
4866
|
|
|
4867
|
+
var PropertyGetPipe = /** @class */ (function () {
|
|
4868
|
+
function PropertyGetPipe() {
|
|
4869
|
+
}
|
|
4870
|
+
PropertyGetPipe.prototype.transform = function (obj, args) {
|
|
4871
|
+
return getPropertyByPath(obj,
|
|
4872
|
+
// Path
|
|
4873
|
+
args && (typeof args === 'string' ? args : args.key),
|
|
4874
|
+
// Default value
|
|
4875
|
+
args && args.defaultValue);
|
|
4876
|
+
};
|
|
4877
|
+
return PropertyGetPipe;
|
|
4878
|
+
}());
|
|
4879
|
+
PropertyGetPipe.decorators = [
|
|
4880
|
+
{ type: i0.Pipe, args: [{
|
|
4881
|
+
name: 'propertyGet'
|
|
4882
|
+
},] }
|
|
4883
|
+
];
|
|
4884
|
+
var PropertyFormatPipe = /** @class */ (function () {
|
|
4885
|
+
function PropertyFormatPipe(dateFormat) {
|
|
4886
|
+
this.dateFormat = dateFormat;
|
|
4887
|
+
}
|
|
4888
|
+
PropertyFormatPipe.prototype.transform = function (obj, keyOrDefinition) {
|
|
4889
|
+
var _a, _b;
|
|
4890
|
+
if (!obj)
|
|
4891
|
+
return '';
|
|
4892
|
+
var definition = keyOrDefinition && (typeof keyOrDefinition === 'object') && keyOrDefinition;
|
|
4893
|
+
var key = (definition === null || definition === void 0 ? void 0 : definition.key) || keyOrDefinition;
|
|
4894
|
+
if (!key) {
|
|
4895
|
+
// Should never occur
|
|
4896
|
+
console.warn('Invalid use of pipe \'formatProperty\': missing key or definition');
|
|
4897
|
+
return '';
|
|
4898
|
+
}
|
|
4899
|
+
var value = obj[key];
|
|
4900
|
+
if (isNil(value))
|
|
4901
|
+
return value;
|
|
4902
|
+
var type = (definition === null || definition === void 0 ? void 0 : definition.type) || typeof value;
|
|
4903
|
+
switch (type) {
|
|
4904
|
+
case 'date':
|
|
4905
|
+
return this.dateFormat.transform(value);
|
|
4906
|
+
case 'dateTime':
|
|
4907
|
+
return this.dateFormat.transform(value, { time: true });
|
|
4908
|
+
case 'enum':
|
|
4909
|
+
{
|
|
4910
|
+
// DEBUG
|
|
4911
|
+
// console.debug('formatProperty by definition (type='enum', key=' +definition.key+ '):', value );
|
|
4912
|
+
var item = (definition.values || [value]).find(function (item) { return (isNotNil(item.key) ? item.key : item) === value; });
|
|
4913
|
+
return item.value || item;
|
|
4914
|
+
}
|
|
4915
|
+
case 'entity':
|
|
4916
|
+
{
|
|
4917
|
+
if ((_a = definition.autocomplete) === null || _a === void 0 ? void 0 : _a.displayWith) {
|
|
4918
|
+
return definition.autocomplete.displayWith(value);
|
|
4919
|
+
}
|
|
4920
|
+
return joinPropertiesPath(obj, ((_b = definition.autocomplete) === null || _b === void 0 ? void 0 : _b.attributes) || ['label', 'name']) || undefined;
|
|
4921
|
+
}
|
|
4922
|
+
case 'string':
|
|
4923
|
+
default:
|
|
4924
|
+
return value;
|
|
4925
|
+
}
|
|
4926
|
+
};
|
|
4927
|
+
return PropertyFormatPipe;
|
|
4928
|
+
}());
|
|
4929
|
+
PropertyFormatPipe.ɵprov = i0.ɵɵdefineInjectable({ factory: function PropertyFormatPipe_Factory() { return new PropertyFormatPipe(i0.ɵɵinject(DateFormatPipe)); }, token: PropertyFormatPipe, providedIn: "root" });
|
|
4930
|
+
PropertyFormatPipe.decorators = [
|
|
4931
|
+
{ type: i0.Pipe, args: [{
|
|
4932
|
+
name: 'propertyFormat'
|
|
4933
|
+
},] },
|
|
4934
|
+
{ type: i0.Injectable, args: [{ providedIn: 'root' },] }
|
|
4935
|
+
];
|
|
4936
|
+
PropertyFormatPipe.ctorParameters = function () { return [
|
|
4937
|
+
{ type: DateFormatPipe }
|
|
4938
|
+
]; };
|
|
4939
|
+
|
|
4885
4940
|
var SharedPipesModule = /** @class */ (function () {
|
|
4886
4941
|
function SharedPipesModule() {
|
|
4887
4942
|
}
|
|
@@ -4896,6 +4951,7 @@
|
|
|
4896
4951
|
],
|
|
4897
4952
|
declarations: [
|
|
4898
4953
|
PropertyGetPipe,
|
|
4954
|
+
PropertyFormatPipe,
|
|
4899
4955
|
DateFormatPipe,
|
|
4900
4956
|
DateDiffDurationPipe,
|
|
4901
4957
|
DurationPipe,
|
|
@@ -4932,10 +4988,12 @@
|
|
|
4932
4988
|
FormGetControlPipe,
|
|
4933
4989
|
FormGetArrayPipe,
|
|
4934
4990
|
FormGetGroupPipe,
|
|
4935
|
-
FormGetValuePipe
|
|
4991
|
+
FormGetValuePipe,
|
|
4992
|
+
PropertyFormatPipe
|
|
4936
4993
|
],
|
|
4937
4994
|
exports: [
|
|
4938
4995
|
PropertyGetPipe,
|
|
4996
|
+
PropertyFormatPipe,
|
|
4939
4997
|
DateFormatPipe,
|
|
4940
4998
|
DateFromNowPipe,
|
|
4941
4999
|
DateDiffDurationPipe,
|
|
@@ -5143,6 +5201,33 @@
|
|
|
5143
5201
|
ondrop: [{ type: i0.HostListener, args: ['drop', ['$event'],] }]
|
|
5144
5202
|
};
|
|
5145
5203
|
|
|
5204
|
+
var compatibleTagNames = ['ion-label', 'mat-label'];
|
|
5205
|
+
var AutoTitleDirective = /** @class */ (function () {
|
|
5206
|
+
function AutoTitleDirective(elementRef) {
|
|
5207
|
+
var _a;
|
|
5208
|
+
this.elementRef = elementRef;
|
|
5209
|
+
// Check compatible tag
|
|
5210
|
+
if (compatibleTagNames.includes((_a = elementRef.nativeElement.tagName) === null || _a === void 0 ? void 0 : _a.toLowerCase())) {
|
|
5211
|
+
this.element = elementRef.nativeElement;
|
|
5212
|
+
}
|
|
5213
|
+
}
|
|
5214
|
+
AutoTitleDirective.prototype.ngAfterContentChecked = function () {
|
|
5215
|
+
// Update title if different
|
|
5216
|
+
if (this.element && this.element.title !== this.element.textContent) {
|
|
5217
|
+
this.element.title = this.element.textContent;
|
|
5218
|
+
}
|
|
5219
|
+
};
|
|
5220
|
+
return AutoTitleDirective;
|
|
5221
|
+
}());
|
|
5222
|
+
AutoTitleDirective.decorators = [
|
|
5223
|
+
{ type: i0.Directive, args: [{
|
|
5224
|
+
selector: '[appAutoTitle]',
|
|
5225
|
+
},] }
|
|
5226
|
+
];
|
|
5227
|
+
AutoTitleDirective.ctorParameters = function () { return [
|
|
5228
|
+
{ type: i0.ElementRef, decorators: [{ type: i0.Inject, args: [i0.ElementRef,] }] }
|
|
5229
|
+
]; };
|
|
5230
|
+
|
|
5146
5231
|
var SharedDirectivesModule = /** @class */ (function () {
|
|
5147
5232
|
function SharedDirectivesModule() {
|
|
5148
5233
|
}
|
|
@@ -5157,12 +5242,14 @@
|
|
|
5157
5242
|
declarations: [
|
|
5158
5243
|
AutofocusDirective,
|
|
5159
5244
|
NgVarDirective,
|
|
5160
|
-
DragAndDropDirective
|
|
5245
|
+
DragAndDropDirective,
|
|
5246
|
+
AutoTitleDirective
|
|
5161
5247
|
],
|
|
5162
5248
|
exports: [
|
|
5163
5249
|
AutofocusDirective,
|
|
5164
5250
|
NgVarDirective,
|
|
5165
|
-
DragAndDropDirective
|
|
5251
|
+
DragAndDropDirective,
|
|
5252
|
+
AutoTitleDirective
|
|
5166
5253
|
]
|
|
5167
5254
|
},] }
|
|
5168
5255
|
];
|
|
@@ -18241,6 +18328,8 @@
|
|
|
18241
18328
|
};
|
|
18242
18329
|
return FilesUtils;
|
|
18243
18330
|
}());
|
|
18331
|
+
FilesUtils.UTF8_BOM_CHAR = new Uint8Array([0xEF, 0xBB, 0xBF]); // UTF-8 BOM
|
|
18332
|
+
|
|
18244
18333
|
var UriUtils = /** @class */ (function () {
|
|
18245
18334
|
function UriUtils() {
|
|
18246
18335
|
}
|
|
@@ -20755,6 +20844,94 @@
|
|
|
20755
20844
|
return JobUtils;
|
|
20756
20845
|
}());
|
|
20757
20846
|
|
|
20847
|
+
//@dynamic
|
|
20848
|
+
var CsvUtils = /** @class */ (function () {
|
|
20849
|
+
function CsvUtils() {
|
|
20850
|
+
}
|
|
20851
|
+
CsvUtils.exportToFile = function (rows, opts) {
|
|
20852
|
+
if (!rows || !rows.length)
|
|
20853
|
+
return; // Skip if empty
|
|
20854
|
+
var filename = (opts === null || opts === void 0 ? void 0 : opts.filename) || 'export.csv';
|
|
20855
|
+
var charset = ((opts === null || opts === void 0 ? void 0 : opts.encoding) || 'utf-8').toLowerCase();
|
|
20856
|
+
var separator = (opts === null || opts === void 0 ? void 0 : opts.separator) || ',';
|
|
20857
|
+
var protectCellRegexp = new RegExp("/(\"|" + separator + "|\n)/g");
|
|
20858
|
+
var keys = Object.keys(rows[0]);
|
|
20859
|
+
var headers = (opts === null || opts === void 0 ? void 0 : opts.headers) || keys;
|
|
20860
|
+
var csvContent =
|
|
20861
|
+
// Header row
|
|
20862
|
+
headers.join(separator) + '\n' +
|
|
20863
|
+
// Data rows
|
|
20864
|
+
rows.map(function (row) {
|
|
20865
|
+
return keys.map(function (k) {
|
|
20866
|
+
var cell = row[k] === null || row[k] === undefined ? '' : row[k];
|
|
20867
|
+
var cellStr = cell instanceof Date
|
|
20868
|
+
? cell.toLocaleString()
|
|
20869
|
+
: cell.toString().replace(/"/g, '""');
|
|
20870
|
+
if (protectCellRegexp.test(cellStr)) {
|
|
20871
|
+
cellStr = "\"" + cellStr + "\"";
|
|
20872
|
+
}
|
|
20873
|
+
return cellStr;
|
|
20874
|
+
}).join(separator);
|
|
20875
|
+
}).join('\n');
|
|
20876
|
+
var blob = new Blob((charset === 'utf-8')
|
|
20877
|
+
// Add UTF-8 BOM character
|
|
20878
|
+
? [FilesUtils.UTF8_BOM_CHAR, csvContent]
|
|
20879
|
+
// Non UTF-8 charset
|
|
20880
|
+
: [csvContent], { type: "text/csv;charset=" + charset + ";" });
|
|
20881
|
+
if (navigator.msSaveBlob) { // IE 10+
|
|
20882
|
+
navigator.msSaveBlob(blob, filename);
|
|
20883
|
+
}
|
|
20884
|
+
else {
|
|
20885
|
+
var link = document.createElement('a');
|
|
20886
|
+
if (link.download !== undefined) {
|
|
20887
|
+
// Browsers that support HTML5 download attribute
|
|
20888
|
+
var url = URL.createObjectURL(blob);
|
|
20889
|
+
link.setAttribute('href', url);
|
|
20890
|
+
link.setAttribute('download', filename);
|
|
20891
|
+
link.style.visibility = 'hidden';
|
|
20892
|
+
document.body.appendChild(link);
|
|
20893
|
+
link.click();
|
|
20894
|
+
document.body.removeChild(link);
|
|
20895
|
+
}
|
|
20896
|
+
}
|
|
20897
|
+
};
|
|
20898
|
+
CsvUtils.parseFile = function (file, opts) {
|
|
20899
|
+
return FilesUtils.readAsText(file, opts === null || opts === void 0 ? void 0 : opts.encoding)
|
|
20900
|
+
.pipe(operators.map(function (e) {
|
|
20901
|
+
if (e.type === i2$1.HttpEventType.UploadProgress) {
|
|
20902
|
+
var loaded = Math.round(e.loaded * 0.8);
|
|
20903
|
+
return Object.assign(Object.assign({}, e), { loaded: loaded });
|
|
20904
|
+
}
|
|
20905
|
+
else if (e instanceof FileResponse) {
|
|
20906
|
+
var body = e.body;
|
|
20907
|
+
var data = CsvUtils.parseCSV(body, opts);
|
|
20908
|
+
return new FileResponse({ body: data });
|
|
20909
|
+
}
|
|
20910
|
+
}), operators.filter(isNotNil));
|
|
20911
|
+
};
|
|
20912
|
+
CsvUtils.parseCSV = function (body, opts) {
|
|
20913
|
+
var separator = (opts === null || opts === void 0 ? void 0 : opts.separator) || ',';
|
|
20914
|
+
var skipEmptyLine = !opts || opts.skipEmptyLine !== false;
|
|
20915
|
+
// Protect special characters (quote and /n)
|
|
20916
|
+
body = body.replace('""', '<quote>') // Protect double quote
|
|
20917
|
+
.replace(/("[^\n"]+)\n\r?/gm, '"$1<br>') // Protect \n inside a quoted expression
|
|
20918
|
+
.replace(/\n\r/gm, '\n'); // Windows CR
|
|
20919
|
+
var headerAndRows = body.split('\n', 2);
|
|
20920
|
+
var headers = headerAndRows[0].split(separator);
|
|
20921
|
+
return body.split('\n') // split into rows
|
|
20922
|
+
.filter(function (line) { return !skipEmptyLine || line.trim().length > 0; }) // Skip empty line
|
|
20923
|
+
.map(function (line) {
|
|
20924
|
+
var cells = line.split(separator, headers.length) // split into cells
|
|
20925
|
+
.map(function (cell) { return cell.replace(/^"([^"]*)"$/, '$1'); }) // Clean trailing quotes
|
|
20926
|
+
.map(function (cell) { return cell.replace('<quote>', '"'); }) // restore protected quote
|
|
20927
|
+
.map(function (cell) { return cell.replace('<br>', '\n'); }) // restore protected br
|
|
20928
|
+
;
|
|
20929
|
+
return cells;
|
|
20930
|
+
});
|
|
20931
|
+
};
|
|
20932
|
+
return CsvUtils;
|
|
20933
|
+
}());
|
|
20934
|
+
|
|
20758
20935
|
/**
|
|
20759
20936
|
* Define here theme colors
|
|
20760
20937
|
*/
|
|
@@ -32204,6 +32381,7 @@
|
|
|
32204
32381
|
exports.AuthForm = AuthForm;
|
|
32205
32382
|
exports.AuthGuardService = AuthGuardService;
|
|
32206
32383
|
exports.AuthModal = AuthModal;
|
|
32384
|
+
exports.AutoTitleDirective = AutoTitleDirective;
|
|
32207
32385
|
exports.AutocompleteTestPage = AutocompleteTestPage;
|
|
32208
32386
|
exports.AutofocusDirective = AutofocusDirective;
|
|
32209
32387
|
exports.Base58 = Base58;
|
|
@@ -32223,6 +32401,7 @@
|
|
|
32223
32401
|
exports.CoreModule = CoreModule;
|
|
32224
32402
|
exports.CoreTestingModule = CoreTestingModule;
|
|
32225
32403
|
exports.CryptoService = CryptoService;
|
|
32404
|
+
exports.CsvUtils = CsvUtils;
|
|
32226
32405
|
exports.DATE_ISO_PATTERN = DATE_ISO_PATTERN;
|
|
32227
32406
|
exports.DATE_UNIX_MS_TIMESTAMP = DATE_UNIX_MS_TIMESTAMP;
|
|
32228
32407
|
exports.DATE_UNIX_TIMESTAMP = DATE_UNIX_TIMESTAMP;
|
|
@@ -32343,6 +32522,7 @@
|
|
|
32343
32522
|
exports.PlatformService = PlatformService;
|
|
32344
32523
|
exports.ProgressBarService = ProgressBarService;
|
|
32345
32524
|
exports.ProgressInterceptor = ProgressInterceptor;
|
|
32525
|
+
exports.PropertyFormatPipe = PropertyFormatPipe;
|
|
32346
32526
|
exports.PropertyGetPipe = PropertyGetPipe;
|
|
32347
32527
|
exports.RESERVED_END_COLUMNS = RESERVED_END_COLUMNS;
|
|
32348
32528
|
exports.RESERVED_START_COLUMNS = RESERVED_START_COLUMNS;
|