@universis/ngx-tables 0.8.0 → 0.8.1
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/universis-ngx-tables.umd.js +472 -308
- package/bundles/universis-ngx-tables.umd.js.map +1 -1
- package/bundles/universis-ngx-tables.umd.min.js +1 -1
- package/bundles/universis-ngx-tables.umd.min.js.map +1 -1
- package/esm2015/lib/components/advanced-table/advanced-table.component.js +148 -4
- package/esm2015/lib/directives/btnexp.directive.js +9 -8
- package/esm2015/lib/i18n/tables.el.js +7 -2
- package/esm2015/lib/i18n/tables.en.js +7 -2
- package/esm5/lib/components/advanced-table/advanced-table.component.js +155 -4
- package/esm5/lib/directives/btnexp.directive.js +20 -17
- package/esm5/lib/i18n/tables.el.js +7 -2
- package/esm5/lib/i18n/tables.en.js +7 -2
- package/fesm2015/universis-ngx-tables.js +412 -259
- package/fesm2015/universis-ngx-tables.js.map +1 -1
- package/fesm5/universis-ngx-tables.js +466 -304
- package/fesm5/universis-ngx-tables.js.map +1 -1
- package/lib/components/advanced-table/advanced-table.component.d.ts +24 -2
- package/lib/directives/btnexp.directive.d.ts +6 -0
- package/lib/i18n/tables.el.d.ts +3 -0
- package/lib/i18n/tables.en.d.ts +3 -0
- package/package.json +4 -4
- package/universis-ngx-tables.metadata.json +1 -1
|
@@ -3,15 +3,16 @@ import * as jQuery_ from 'jquery';
|
|
|
3
3
|
import 'datatables.net';
|
|
4
4
|
import 'datatables.net-scroller';
|
|
5
5
|
import 'datatables.net-colreorder';
|
|
6
|
+
import 'datatables.net-buttons';
|
|
6
7
|
import 'rxjs/add/observable/combineLatest';
|
|
7
8
|
import { HttpClient } from '@angular/common/http';
|
|
8
|
-
import {
|
|
9
|
+
import { ResponseError, ClientDataQueryable, TextUtils } from '@themost/client';
|
|
9
10
|
import { BehaviorSubject } from 'rxjs';
|
|
10
11
|
import { AngularDataContext } from '@themost/angular';
|
|
11
12
|
import { DatePipe, CommonModule } from '@angular/common';
|
|
12
13
|
import { TranslateService, TranslatePipe, TranslateModule } from '@ngx-translate/core';
|
|
13
14
|
import { FormControl, FormArray, FormBuilder, FormsModule, ReactiveFormsModule } from '@angular/forms';
|
|
14
|
-
import { TemplatePipe, ModalService,
|
|
15
|
+
import { TemplatePipe, ModalService, ConfigurationService, ErrorService, LoadingService, DIALOG_BUTTONS, ExportSpreadsheetService, UserActivityService, ToastService, AppEventService, UserStorageService, SharedModule } from '@universis/common';
|
|
15
16
|
import { RouterModalOkCancel, RouterModalModule } from '@universis/common/routing';
|
|
16
17
|
import { ServiceUrlPreProcessor, TranslatePreProcessor, AdvancedFormsModule } from '@universis/forms';
|
|
17
18
|
import { FormioModule } from 'angular-formio';
|
|
@@ -819,6 +820,291 @@ var ColumnSelectorService = /** @class */ (function () {
|
|
|
819
820
|
return ColumnSelectorService;
|
|
820
821
|
}());
|
|
821
822
|
|
|
823
|
+
var ActivatedTableService = /** @class */ (function () {
|
|
824
|
+
function ActivatedTableService(_router, _activatedRoute) {
|
|
825
|
+
var _this = this;
|
|
826
|
+
this._router = _router;
|
|
827
|
+
this._activatedRoute = _activatedRoute;
|
|
828
|
+
_router.events.forEach(function (event) {
|
|
829
|
+
if (event instanceof NavigationStart) {
|
|
830
|
+
if (_this._activeTable) {
|
|
831
|
+
_this._activeTable = null;
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
});
|
|
835
|
+
}
|
|
836
|
+
Object.defineProperty(ActivatedTableService.prototype, "activeTable", {
|
|
837
|
+
get: function () {
|
|
838
|
+
return this._activeTable;
|
|
839
|
+
},
|
|
840
|
+
set: function (tableComponent) {
|
|
841
|
+
this._activeTable = tableComponent;
|
|
842
|
+
},
|
|
843
|
+
enumerable: true,
|
|
844
|
+
configurable: true
|
|
845
|
+
});
|
|
846
|
+
ActivatedTableService.decorators = [
|
|
847
|
+
{ type: Injectable, args: [{
|
|
848
|
+
providedIn: 'root'
|
|
849
|
+
},] }
|
|
850
|
+
];
|
|
851
|
+
/** @nocollapse */
|
|
852
|
+
ActivatedTableService.ctorParameters = function () { return [
|
|
853
|
+
{ type: Router },
|
|
854
|
+
{ type: ActivatedRoute }
|
|
855
|
+
]; };
|
|
856
|
+
ActivatedTableService.ngInjectableDef = defineInjectable({ factory: function ActivatedTableService_Factory() { return new ActivatedTableService(inject(Router), inject(ActivatedRoute)); }, token: ActivatedTableService, providedIn: "root" });
|
|
857
|
+
return ActivatedTableService;
|
|
858
|
+
}());
|
|
859
|
+
|
|
860
|
+
var MAX_EXPORT_ITEMS = 500;
|
|
861
|
+
var BtnExpDirective = /** @class */ (function () {
|
|
862
|
+
function BtnExpDirective(_activatedTable, _context, _config, _translate, _loadingService, _errorService) {
|
|
863
|
+
this._activatedTable = _activatedTable;
|
|
864
|
+
this._context = _context;
|
|
865
|
+
this._config = _config;
|
|
866
|
+
this._translate = _translate;
|
|
867
|
+
this._loadingService = _loadingService;
|
|
868
|
+
this._errorService = _errorService;
|
|
869
|
+
}
|
|
870
|
+
BtnExpDirective.prototype.clickEvent = function (event) {
|
|
871
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
872
|
+
return __generator(this, function (_a) {
|
|
873
|
+
event.preventDefault();
|
|
874
|
+
event.stopPropagation();
|
|
875
|
+
if (this._activatedTable.activeTable) {
|
|
876
|
+
return [2 /*return*/, this._activatedTable.activeTable.exportView()];
|
|
877
|
+
/*
|
|
878
|
+
const lastQuery = this._activatedTable.activeTable.lastQuery;
|
|
879
|
+
const tableConfig = this._activatedTable.activeTable.config;
|
|
880
|
+
const serviceHeaders = this._context.getService().getHeaders();
|
|
881
|
+
const queryModel = lastQuery.getModel();
|
|
882
|
+
let query = this._context.model(queryModel).asQueryable();
|
|
883
|
+
const queryParams = lastQuery.getParams();
|
|
884
|
+
query = this.constructQuery(query, queryParams, tableConfig, serviceHeaders);
|
|
885
|
+
// get export settings
|
|
886
|
+
const exportSettings = this._config.settings as ExportLimitConfiguration;
|
|
887
|
+
// get export limit
|
|
888
|
+
const maxExportItems = exportSettings && exportSettings.tables && exportSettings.tables.exportLimit;
|
|
889
|
+
if (maxExportItems && typeof maxExportItems === 'number' && maxExportItems > 0) {
|
|
890
|
+
query.skip(0).take(maxExportItems);
|
|
891
|
+
} else {
|
|
892
|
+
query.skip(0).take(MAX_EXPORT_ITEMS);
|
|
893
|
+
}
|
|
894
|
+
// This constructs the URI based on the way @themost does
|
|
895
|
+
const url = this.constructURL(query);
|
|
896
|
+
this.downloadFile(url, query.getService().getHeaders(), query.getModel()); */
|
|
897
|
+
}
|
|
898
|
+
return [2 /*return*/];
|
|
899
|
+
});
|
|
900
|
+
});
|
|
901
|
+
};
|
|
902
|
+
/**
|
|
903
|
+
* Sets the parameters to the query based on
|
|
904
|
+
* the active filters of the activated table
|
|
905
|
+
* @param {ClientDataQueryable} query
|
|
906
|
+
* @param params: The filters of the last query of the activated table
|
|
907
|
+
* @return ClientDataQueryable
|
|
908
|
+
*/
|
|
909
|
+
BtnExpDirective.prototype.setParams = function (query, params) {
|
|
910
|
+
if (params && typeof params === 'object') {
|
|
911
|
+
Object.keys(params).forEach(function (key) {
|
|
912
|
+
query.setParam(key, params[key]);
|
|
913
|
+
});
|
|
914
|
+
}
|
|
915
|
+
return query;
|
|
916
|
+
};
|
|
917
|
+
/**
|
|
918
|
+
* Sets the headers to the query based on
|
|
919
|
+
* the default headers of the DataContext
|
|
920
|
+
* and appending the accept header to get
|
|
921
|
+
* an xlsx file from the API
|
|
922
|
+
* @param {ClientDataQueryable} query
|
|
923
|
+
* @param {Headers} headers: The headers to append to the query
|
|
924
|
+
* @return ClientDataQueryable
|
|
925
|
+
*/
|
|
926
|
+
BtnExpDirective.prototype.setHeaders = function (query, headers) {
|
|
927
|
+
Object.keys(headers).forEach(function (key) {
|
|
928
|
+
if (headers.hasOwnProperty(key)) {
|
|
929
|
+
query.getService().setHeader(key, headers[key]);
|
|
930
|
+
}
|
|
931
|
+
});
|
|
932
|
+
// sets a header to accept xlsx files
|
|
933
|
+
query.getService().setHeader('Accept', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
|
|
934
|
+
return query;
|
|
935
|
+
};
|
|
936
|
+
/**
|
|
937
|
+
* Constructs the select parameter of the
|
|
938
|
+
* ClientDataQuery by replacing the target name
|
|
939
|
+
* of the field based on the localized translation
|
|
940
|
+
* of that property on the advanced tabled
|
|
941
|
+
* @param {ClientDataQueryable} query
|
|
942
|
+
* @param tableConfig: The configuration of the activated table
|
|
943
|
+
* @return ClientDataQueryable
|
|
944
|
+
*/
|
|
945
|
+
BtnExpDirective.prototype.constructQueryParam = function (query, tableConfig) {
|
|
946
|
+
var _this = this;
|
|
947
|
+
var selectQuery = query.getParams().$select;
|
|
948
|
+
var selectQueryArray = selectQuery.split(',');
|
|
949
|
+
selectQueryArray = selectQueryArray.map(function (select$$1) {
|
|
950
|
+
var e_1, _a, e_2, _b;
|
|
951
|
+
var words = select$$1.split(' ');
|
|
952
|
+
if (words.length === 3) {
|
|
953
|
+
if (tableConfig && tableConfig.columns) {
|
|
954
|
+
try {
|
|
955
|
+
for (var _c = __values(tableConfig.columns), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
956
|
+
var column = _d.value;
|
|
957
|
+
if (column.property === words[2] && column.title) {
|
|
958
|
+
words[2] = "\"" + _this._translate.instant(column.title) + "\"";
|
|
959
|
+
}
|
|
960
|
+
else if (column.property === words[2]) {
|
|
961
|
+
words[2] = "\"" + _this._translate.instant(words[2]) + "\"";
|
|
962
|
+
}
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
966
|
+
finally {
|
|
967
|
+
try {
|
|
968
|
+
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
969
|
+
}
|
|
970
|
+
finally { if (e_1) throw e_1.error; }
|
|
971
|
+
}
|
|
972
|
+
}
|
|
973
|
+
}
|
|
974
|
+
if (words.length === 1) {
|
|
975
|
+
if (tableConfig && tableConfig.columns) {
|
|
976
|
+
try {
|
|
977
|
+
for (var _e = __values(tableConfig.columns), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
978
|
+
var column = _f.value;
|
|
979
|
+
if (column.name === words[0] && column.title) {
|
|
980
|
+
words[0] = words[0] + " as \"" + _this._translate.instant(column.title) + "\"";
|
|
981
|
+
break;
|
|
982
|
+
}
|
|
983
|
+
else if (column.name === words[0] && column.property) {
|
|
984
|
+
words[0] = words[0] + " as \"" + _this._translate.instant(column.property) + "\"";
|
|
985
|
+
break;
|
|
986
|
+
}
|
|
987
|
+
else if (words[0] === column.name && words[0] === "id" && column.hidden) {
|
|
988
|
+
break;
|
|
989
|
+
}
|
|
990
|
+
else if (words[0] == column.name || words[0] === column.property) {
|
|
991
|
+
words[0] = words[0] + " as \"" + _this._translate.instant(words[0]) + "\"";
|
|
992
|
+
}
|
|
993
|
+
}
|
|
994
|
+
}
|
|
995
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
996
|
+
finally {
|
|
997
|
+
try {
|
|
998
|
+
if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
|
|
999
|
+
}
|
|
1000
|
+
finally { if (e_2) throw e_2.error; }
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
1003
|
+
return words[0];
|
|
1004
|
+
}
|
|
1005
|
+
return words.join(' ');
|
|
1006
|
+
});
|
|
1007
|
+
selectQuery = selectQueryArray.join(',');
|
|
1008
|
+
query.setParam('$select', selectQuery);
|
|
1009
|
+
return query;
|
|
1010
|
+
};
|
|
1011
|
+
/**
|
|
1012
|
+
* Constructs the fetch URL based the query parameters
|
|
1013
|
+
* @param {ClientDataQueryable} query
|
|
1014
|
+
* @return String
|
|
1015
|
+
*/
|
|
1016
|
+
BtnExpDirective.prototype.constructURL = function (query) {
|
|
1017
|
+
var baseURL = query.getService().getBase();
|
|
1018
|
+
var url = baseURL.endsWith('/') ? (baseURL + query.getModel() + '?') : (baseURL + '/' + query.getModel() + '?');
|
|
1019
|
+
Object.keys(query.getParams()).forEach(function (key, index) {
|
|
1020
|
+
if (index === 0) {
|
|
1021
|
+
url += key + '=' + query.getParams()[key];
|
|
1022
|
+
}
|
|
1023
|
+
else {
|
|
1024
|
+
url += '&' + key + '=' + query.getParams()[key];
|
|
1025
|
+
}
|
|
1026
|
+
});
|
|
1027
|
+
return url;
|
|
1028
|
+
};
|
|
1029
|
+
/**
|
|
1030
|
+
* Constructs the query by setting the parameters of the
|
|
1031
|
+
* advanced table's active filters, sets the necessary headers
|
|
1032
|
+
* and build the select parameter of the query
|
|
1033
|
+
* @param {ClientDataQueryable} query
|
|
1034
|
+
* @param params: The filters of the last query of the activated table
|
|
1035
|
+
* @param tableConfig: The configuration of the activated table
|
|
1036
|
+
* @param {Headers} headers: The headers to append to the query
|
|
1037
|
+
* @return ClientDataQueryable
|
|
1038
|
+
*/
|
|
1039
|
+
BtnExpDirective.prototype.constructQuery = function (query, params, tableConfig, headers) {
|
|
1040
|
+
var _query = this.setParams(query, params);
|
|
1041
|
+
_query = this.setHeaders(_query, headers);
|
|
1042
|
+
_query = this.constructQueryParam(_query, tableConfig);
|
|
1043
|
+
return _query;
|
|
1044
|
+
};
|
|
1045
|
+
/**
|
|
1046
|
+
* Fetches and saves the xlsx file
|
|
1047
|
+
* @param {String} url
|
|
1048
|
+
* @param {Headers} serviceHeaders: The headers to append to the query
|
|
1049
|
+
* @param modelName: The model name of the advanced table
|
|
1050
|
+
*/
|
|
1051
|
+
BtnExpDirective.prototype.downloadFile = function (url, serviceHeaders, modelName) {
|
|
1052
|
+
var _this = this;
|
|
1053
|
+
this._loadingService.showLoading();
|
|
1054
|
+
fetch(encodeURI(url), {
|
|
1055
|
+
headers: serviceHeaders,
|
|
1056
|
+
credentials: 'include'
|
|
1057
|
+
}).then(function (response) {
|
|
1058
|
+
if (response && !response.ok) {
|
|
1059
|
+
throw new ResponseError(response.statusText, response.status);
|
|
1060
|
+
}
|
|
1061
|
+
return response.blob();
|
|
1062
|
+
}).then(function (blob) {
|
|
1063
|
+
var objectUrl = window.URL.createObjectURL(blob);
|
|
1064
|
+
var a = document.createElement('a');
|
|
1065
|
+
document.body.appendChild(a);
|
|
1066
|
+
a.setAttribute('style', 'display: none');
|
|
1067
|
+
a.href = objectUrl;
|
|
1068
|
+
var downloadName = modelName + ".xlsx";
|
|
1069
|
+
a.download = downloadName;
|
|
1070
|
+
// this adds support for IE and MS Edge (up to version 44.19041)
|
|
1071
|
+
if (window.navigator && window.navigator.msSaveOrOpenBlob) {
|
|
1072
|
+
window.navigator.msSaveOrOpenBlob(blob, downloadName);
|
|
1073
|
+
}
|
|
1074
|
+
else {
|
|
1075
|
+
// for all other browsers
|
|
1076
|
+
a.click();
|
|
1077
|
+
}
|
|
1078
|
+
window.URL.revokeObjectURL(objectUrl);
|
|
1079
|
+
a.remove();
|
|
1080
|
+
_this._loadingService.hideLoading();
|
|
1081
|
+
}).catch(function (err) {
|
|
1082
|
+
_this._loadingService.hideLoading();
|
|
1083
|
+
_this._errorService.showError(err, {
|
|
1084
|
+
continueLink: '.'
|
|
1085
|
+
});
|
|
1086
|
+
});
|
|
1087
|
+
};
|
|
1088
|
+
BtnExpDirective.decorators = [
|
|
1089
|
+
{ type: Directive, args: [{
|
|
1090
|
+
selector: '.universis-btn-export'
|
|
1091
|
+
},] }
|
|
1092
|
+
];
|
|
1093
|
+
/** @nocollapse */
|
|
1094
|
+
BtnExpDirective.ctorParameters = function () { return [
|
|
1095
|
+
{ type: ActivatedTableService },
|
|
1096
|
+
{ type: AngularDataContext },
|
|
1097
|
+
{ type: ConfigurationService },
|
|
1098
|
+
{ type: TranslateService },
|
|
1099
|
+
{ type: LoadingService },
|
|
1100
|
+
{ type: ErrorService }
|
|
1101
|
+
]; };
|
|
1102
|
+
BtnExpDirective.propDecorators = {
|
|
1103
|
+
clickEvent: [{ type: HostListener, args: ['click', ['$event'],] }]
|
|
1104
|
+
};
|
|
1105
|
+
return BtnExpDirective;
|
|
1106
|
+
}());
|
|
1107
|
+
|
|
822
1108
|
// restore jquery import to avoid Cannot call a namespace ('jquery') error
|
|
823
1109
|
var jQuery = jQuery_;
|
|
824
1110
|
var DataTablesApi = jQuery.fn.dataTable.Api;
|
|
@@ -851,6 +1137,15 @@ var TableTranslationChangeDetector = /** @class */ (function (_super) {
|
|
|
851
1137
|
return TableTranslationChangeDetector;
|
|
852
1138
|
}(ChangeDetectorRef));
|
|
853
1139
|
var COLUMN_FORMATTERS = new InjectionToken('column.formatters');
|
|
1140
|
+
var ExportLimitExceededError = /** @class */ (function (_super) {
|
|
1141
|
+
__extends(ExportLimitExceededError, _super);
|
|
1142
|
+
function ExportLimitExceededError(message) {
|
|
1143
|
+
var _this = _super.call(this, message) || this;
|
|
1144
|
+
_this.name = 'ExportLimitExceededError';
|
|
1145
|
+
return _this;
|
|
1146
|
+
}
|
|
1147
|
+
return ExportLimitExceededError;
|
|
1148
|
+
}(RangeError));
|
|
854
1149
|
var ColumnFormatter = /** @class */ (function (_super) {
|
|
855
1150
|
__extends(ColumnFormatter, _super);
|
|
856
1151
|
function ColumnFormatter(injector) {
|
|
@@ -881,7 +1176,7 @@ function getRandomIdentifier() {
|
|
|
881
1176
|
return (Number(String(Math.random()).slice(2))).toString(36);
|
|
882
1177
|
}
|
|
883
1178
|
var AdvancedTableComponent = /** @class */ (function () {
|
|
884
|
-
function AdvancedTableComponent(_context, _columnFormatters, _activatedRoute, _translateService, _injector, _advancedFilterValueProvider, _element, _template, _loading, _http, _columnSelector) {
|
|
1179
|
+
function AdvancedTableComponent(_context, _columnFormatters, _activatedRoute, _translateService, _injector, _advancedFilterValueProvider, _element, _template, _loading, _http, _columnSelector, _configuration, _exportSpreadsheet, _modalService, _errorService) {
|
|
885
1180
|
var _this = this;
|
|
886
1181
|
this._context = _context;
|
|
887
1182
|
this._columnFormatters = _columnFormatters;
|
|
@@ -894,6 +1189,10 @@ var AdvancedTableComponent = /** @class */ (function () {
|
|
|
894
1189
|
this._loading = _loading;
|
|
895
1190
|
this._http = _http;
|
|
896
1191
|
this._columnSelector = _columnSelector;
|
|
1192
|
+
this._configuration = _configuration;
|
|
1193
|
+
this._exportSpreadsheet = _exportSpreadsheet;
|
|
1194
|
+
this._modalService = _modalService;
|
|
1195
|
+
this._errorService = _errorService;
|
|
897
1196
|
this._firstLoad = true;
|
|
898
1197
|
this._showFooter = false;
|
|
899
1198
|
this._showHeader = true;
|
|
@@ -937,6 +1236,7 @@ var AdvancedTableComponent = /** @class */ (function () {
|
|
|
937
1236
|
this.customSelect = false;
|
|
938
1237
|
this.selected = [];
|
|
939
1238
|
this.unselected = [];
|
|
1239
|
+
this._lastQueryTotalItems = 0;
|
|
940
1240
|
// initialize translate pipe
|
|
941
1241
|
this.translator = new TranslatePipe(this._translateService, new TableTranslationChangeDetector());
|
|
942
1242
|
jQuery.fn.dataTable.ext.classes.sPageButton = 'btn';
|
|
@@ -960,6 +1260,13 @@ var AdvancedTableComponent = /** @class */ (function () {
|
|
|
960
1260
|
enumerable: true,
|
|
961
1261
|
configurable: true
|
|
962
1262
|
});
|
|
1263
|
+
Object.defineProperty(AdvancedTableComponent.prototype, "lastQueryTotalItems", {
|
|
1264
|
+
get: function () {
|
|
1265
|
+
return this._lastQueryTotalItems;
|
|
1266
|
+
},
|
|
1267
|
+
enumerable: true,
|
|
1268
|
+
configurable: true
|
|
1269
|
+
});
|
|
963
1270
|
Object.defineProperty(AdvancedTableComponent.prototype, "showFooter", {
|
|
964
1271
|
get: function () {
|
|
965
1272
|
return this._showFooter;
|
|
@@ -1586,6 +1893,7 @@ var AdvancedTableComponent = /** @class */ (function () {
|
|
|
1586
1893
|
recordsFiltered: 0,
|
|
1587
1894
|
data: [],
|
|
1588
1895
|
};
|
|
1896
|
+
self._lastQueryTotalItems = 0;
|
|
1589
1897
|
// emit empty data
|
|
1590
1898
|
self.load.emit(emptyDataSet);
|
|
1591
1899
|
// return empty data
|
|
@@ -1680,6 +1988,7 @@ var AdvancedTableComponent = /** @class */ (function () {
|
|
|
1680
1988
|
recordsFiltered: items.total,
|
|
1681
1989
|
data: items.value,
|
|
1682
1990
|
};
|
|
1991
|
+
self._lastQueryTotalItems = items.total;
|
|
1683
1992
|
if (items.total === 0) {
|
|
1684
1993
|
self.resetEmptyTable();
|
|
1685
1994
|
}
|
|
@@ -1693,6 +2002,7 @@ var AdvancedTableComponent = /** @class */ (function () {
|
|
|
1693
2002
|
console.error('TABLES', err);
|
|
1694
2003
|
// show error
|
|
1695
2004
|
self.toggleError(err);
|
|
2005
|
+
self._lastQueryTotalItems = 0;
|
|
1696
2006
|
// by returning empty dataset
|
|
1697
2007
|
self.load.emit(EMPTY_DATASET);
|
|
1698
2008
|
return fnCallback(EMPTY_DATASET);
|
|
@@ -1705,6 +2015,7 @@ var AdvancedTableComponent = /** @class */ (function () {
|
|
|
1705
2015
|
recordsFiltered: items.total,
|
|
1706
2016
|
data: items.value,
|
|
1707
2017
|
};
|
|
2018
|
+
self._lastQueryTotalItems = items.total;
|
|
1708
2019
|
if (items.total === 0) {
|
|
1709
2020
|
self.resetEmptyTable();
|
|
1710
2021
|
}
|
|
@@ -2088,6 +2399,125 @@ var AdvancedTableComponent = /** @class */ (function () {
|
|
|
2088
2399
|
}
|
|
2089
2400
|
});
|
|
2090
2401
|
};
|
|
2402
|
+
/**
|
|
2403
|
+
*
|
|
2404
|
+
* @param options to pass an errorHandler callback, if desired
|
|
2405
|
+
* @returns void
|
|
2406
|
+
*/
|
|
2407
|
+
AdvancedTableComponent.prototype.exportView = function (options) {
|
|
2408
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2409
|
+
var exportSettings, exportLimit, totalDisplayedItems, _a, body, header, previousDataState, targetDataState, _b, body, header, err_1;
|
|
2410
|
+
return __generator(this, function (_c) {
|
|
2411
|
+
switch (_c.label) {
|
|
2412
|
+
case 0:
|
|
2413
|
+
_c.trys.push([0, 4, 5, 6]);
|
|
2414
|
+
this._loading.showLoading();
|
|
2415
|
+
// validate query items and config
|
|
2416
|
+
if (!(this._lastQueryTotalItems && this.config)) {
|
|
2417
|
+
// do nothing
|
|
2418
|
+
return [2 /*return*/];
|
|
2419
|
+
}
|
|
2420
|
+
exportSettings = this._configuration.settings;
|
|
2421
|
+
exportLimit = (exportSettings && exportSettings.tables && exportSettings.tables.exportLimit > 0)
|
|
2422
|
+
? exportSettings.tables.exportLimit : MAX_EXPORT_ITEMS;
|
|
2423
|
+
// and validate it
|
|
2424
|
+
if (this._lastQueryTotalItems > exportLimit) {
|
|
2425
|
+
// call error handler
|
|
2426
|
+
// provide a recognizible error type
|
|
2427
|
+
if (options && options.errorHandler) {
|
|
2428
|
+
options.errorHandler(new ExportLimitExceededError('Export limit exceeded'));
|
|
2429
|
+
return [2 /*return*/];
|
|
2430
|
+
}
|
|
2431
|
+
// or show warning modal and exit
|
|
2432
|
+
this._modalService.showWarningDialog(this._translateService.instant('Tables.ExportList'), this._translateService.instant('Tables.ExportLimitExceeded', { dataLength: this._lastQueryTotalItems, exportLimit: exportLimit }), DIALOG_BUTTONS.Ok);
|
|
2433
|
+
return [2 /*return*/];
|
|
2434
|
+
}
|
|
2435
|
+
totalDisplayedItems = Array.from(this.dataTable.context[0].aiDisplay).length;
|
|
2436
|
+
if (!(totalDisplayedItems === this._lastQueryTotalItems)) return [3 /*break*/, 1];
|
|
2437
|
+
_a = this.getExportableData(), body = _a.body, header = _a.header;
|
|
2438
|
+
// and export them to excel
|
|
2439
|
+
this._exportSpreadsheet.export(body, this._translateService.instant(this.config.title || 'Tables.ExportResults') + ".xlsx", {
|
|
2440
|
+
header: header,
|
|
2441
|
+
skipHeader: false
|
|
2442
|
+
});
|
|
2443
|
+
return [3 /*break*/, 3];
|
|
2444
|
+
case 1:
|
|
2445
|
+
previousDataState = this.dataTable.rows().data().toArray();
|
|
2446
|
+
return [4 /*yield*/, this.lastQuery.take(exportLimit).getItems()];
|
|
2447
|
+
case 2:
|
|
2448
|
+
targetDataState = _c.sent();
|
|
2449
|
+
// change table data on the fly, but do not redraw
|
|
2450
|
+
this.dataTable.clear().rows.add(targetDataState);
|
|
2451
|
+
_b = this.getExportableData(), body = _b.body, header = _b.header;
|
|
2452
|
+
// reset table data
|
|
2453
|
+
this.dataTable.clear().rows.add(previousDataState);
|
|
2454
|
+
// and export target data to excel
|
|
2455
|
+
this._exportSpreadsheet.export(body, this._translateService.instant(this.config.title || 'Tables.ExportResults') + ".xlsx", {
|
|
2456
|
+
header: header,
|
|
2457
|
+
skipHeader: false
|
|
2458
|
+
});
|
|
2459
|
+
_c.label = 3;
|
|
2460
|
+
case 3:
|
|
2461
|
+
// exit
|
|
2462
|
+
return [2 /*return*/];
|
|
2463
|
+
case 4:
|
|
2464
|
+
err_1 = _c.sent();
|
|
2465
|
+
// log error
|
|
2466
|
+
console.error(err_1);
|
|
2467
|
+
// call error handler, if defined
|
|
2468
|
+
if (options && options.errorHandler) {
|
|
2469
|
+
options.errorHandler(err_1);
|
|
2470
|
+
}
|
|
2471
|
+
else {
|
|
2472
|
+
// use default error service
|
|
2473
|
+
this._errorService.showError(err_1, {
|
|
2474
|
+
continueLink: '.'
|
|
2475
|
+
});
|
|
2476
|
+
}
|
|
2477
|
+
return [3 /*break*/, 6];
|
|
2478
|
+
case 5:
|
|
2479
|
+
this._loading.hideLoading();
|
|
2480
|
+
return [7 /*endfinally*/];
|
|
2481
|
+
case 6: return [2 /*return*/];
|
|
2482
|
+
}
|
|
2483
|
+
});
|
|
2484
|
+
});
|
|
2485
|
+
};
|
|
2486
|
+
AdvancedTableComponent.prototype.getExportableData = function () {
|
|
2487
|
+
var _this = this;
|
|
2488
|
+
if (!(this.dataTable && this.dataTable.buttons
|
|
2489
|
+
&& typeof this.dataTable.buttons.exportData === 'function' && this.config)) {
|
|
2490
|
+
return { body: [], header: [] };
|
|
2491
|
+
}
|
|
2492
|
+
// fetch exportable excel data
|
|
2493
|
+
var _a = this.dataTable.buttons.exportData(), body = _a.body, header = _a.header;
|
|
2494
|
+
var cleanupIndexes = [];
|
|
2495
|
+
// clean up headers
|
|
2496
|
+
header = header.filter(function (headerItem, index) {
|
|
2497
|
+
// exclude empty headers
|
|
2498
|
+
if (headerItem.trim().length === 0) {
|
|
2499
|
+
cleanupIndexes.push(index);
|
|
2500
|
+
return false;
|
|
2501
|
+
}
|
|
2502
|
+
// find item by title
|
|
2503
|
+
var findItem = _this.config.columns.find(function (column) {
|
|
2504
|
+
return column.title && column.title.length && _this._translateService.instant(column.title) === headerItem;
|
|
2505
|
+
});
|
|
2506
|
+
// exclude hidden columns
|
|
2507
|
+
if (findItem && findItem.hidden === true) {
|
|
2508
|
+
cleanupIndexes.push(index);
|
|
2509
|
+
return false;
|
|
2510
|
+
}
|
|
2511
|
+
return true;
|
|
2512
|
+
});
|
|
2513
|
+
// clean up body
|
|
2514
|
+
body = body.map(function (row) {
|
|
2515
|
+
return row.filter(function (_, rowIndex) {
|
|
2516
|
+
return cleanupIndexes.indexOf(rowIndex) === -1;
|
|
2517
|
+
});
|
|
2518
|
+
});
|
|
2519
|
+
return { body: body, header: header };
|
|
2520
|
+
};
|
|
2091
2521
|
AdvancedTableComponent.decorators = [
|
|
2092
2522
|
{ type: Component, args: [{
|
|
2093
2523
|
// tslint:disable-next-line: component-selector
|
|
@@ -2109,7 +2539,11 @@ var AdvancedTableComponent = /** @class */ (function () {
|
|
|
2109
2539
|
{ type: TemplatePipe },
|
|
2110
2540
|
{ type: LoadingService },
|
|
2111
2541
|
{ type: HttpClient },
|
|
2112
|
-
{ type: ColumnSelectorService }
|
|
2542
|
+
{ type: ColumnSelectorService },
|
|
2543
|
+
{ type: ConfigurationService },
|
|
2544
|
+
{ type: ExportSpreadsheetService },
|
|
2545
|
+
{ type: ModalService },
|
|
2546
|
+
{ type: ErrorService }
|
|
2113
2547
|
]; };
|
|
2114
2548
|
AdvancedTableComponent.propDecorators = {
|
|
2115
2549
|
table: [{ type: ViewChild, args: ['table',] }],
|
|
@@ -3090,61 +3524,24 @@ var AdvancedTableConfigurationResolver = /** @class */ (function () {
|
|
|
3090
3524
|
}());
|
|
3091
3525
|
var AdvancedSearchConfigurationResolver = /** @class */ (function () {
|
|
3092
3526
|
function AdvancedSearchConfigurationResolver(_http) {
|
|
3093
|
-
this._http = _http;
|
|
3094
|
-
}
|
|
3095
|
-
AdvancedSearchConfigurationResolver.prototype.resolve = function (route, state) {
|
|
3096
|
-
// get list
|
|
3097
|
-
var list = route.data.list || route.params.list;
|
|
3098
|
-
// get model
|
|
3099
|
-
var model = route.data.model || route.params.model;
|
|
3100
|
-
// get configuration
|
|
3101
|
-
return this._http.get("assets/lists/" + model + "/search." + list + ".json").toPromise();
|
|
3102
|
-
};
|
|
3103
|
-
AdvancedSearchConfigurationResolver.decorators = [
|
|
3104
|
-
{ type: Injectable }
|
|
3105
|
-
];
|
|
3106
|
-
/** @nocollapse */
|
|
3107
|
-
AdvancedSearchConfigurationResolver.ctorParameters = function () { return [
|
|
3108
|
-
{ type: HttpClient }
|
|
3109
|
-
]; };
|
|
3110
|
-
return AdvancedSearchConfigurationResolver;
|
|
3111
|
-
}());
|
|
3112
|
-
|
|
3113
|
-
var ActivatedTableService = /** @class */ (function () {
|
|
3114
|
-
function ActivatedTableService(_router, _activatedRoute) {
|
|
3115
|
-
var _this = this;
|
|
3116
|
-
this._router = _router;
|
|
3117
|
-
this._activatedRoute = _activatedRoute;
|
|
3118
|
-
_router.events.forEach(function (event) {
|
|
3119
|
-
if (event instanceof NavigationStart) {
|
|
3120
|
-
if (_this._activeTable) {
|
|
3121
|
-
_this._activeTable = null;
|
|
3122
|
-
}
|
|
3123
|
-
}
|
|
3124
|
-
});
|
|
3125
|
-
}
|
|
3126
|
-
Object.defineProperty(ActivatedTableService.prototype, "activeTable", {
|
|
3127
|
-
get: function () {
|
|
3128
|
-
return this._activeTable;
|
|
3129
|
-
},
|
|
3130
|
-
set: function (tableComponent) {
|
|
3131
|
-
this._activeTable = tableComponent;
|
|
3132
|
-
},
|
|
3133
|
-
enumerable: true,
|
|
3134
|
-
configurable: true
|
|
3135
|
-
});
|
|
3136
|
-
ActivatedTableService.decorators = [
|
|
3137
|
-
{ type: Injectable, args: [{
|
|
3138
|
-
providedIn: 'root'
|
|
3139
|
-
},] }
|
|
3527
|
+
this._http = _http;
|
|
3528
|
+
}
|
|
3529
|
+
AdvancedSearchConfigurationResolver.prototype.resolve = function (route, state) {
|
|
3530
|
+
// get list
|
|
3531
|
+
var list = route.data.list || route.params.list;
|
|
3532
|
+
// get model
|
|
3533
|
+
var model = route.data.model || route.params.model;
|
|
3534
|
+
// get configuration
|
|
3535
|
+
return this._http.get("assets/lists/" + model + "/search." + list + ".json").toPromise();
|
|
3536
|
+
};
|
|
3537
|
+
AdvancedSearchConfigurationResolver.decorators = [
|
|
3538
|
+
{ type: Injectable }
|
|
3140
3539
|
];
|
|
3141
3540
|
/** @nocollapse */
|
|
3142
|
-
|
|
3143
|
-
{ type:
|
|
3144
|
-
{ type: ActivatedRoute }
|
|
3541
|
+
AdvancedSearchConfigurationResolver.ctorParameters = function () { return [
|
|
3542
|
+
{ type: HttpClient }
|
|
3145
3543
|
]; };
|
|
3146
|
-
|
|
3147
|
-
return ActivatedTableService;
|
|
3544
|
+
return AdvancedSearchConfigurationResolver;
|
|
3148
3545
|
}());
|
|
3149
3546
|
|
|
3150
3547
|
var AdvancedTableSettingsComponent = /** @class */ (function () {
|
|
@@ -4058,251 +4455,6 @@ var AdvancedTableEditorDirective = /** @class */ (function () {
|
|
|
4058
4455
|
return AdvancedTableEditorDirective;
|
|
4059
4456
|
}());
|
|
4060
4457
|
|
|
4061
|
-
var MAX_EXPORT_ITEMS = 500;
|
|
4062
|
-
var BtnExpDirective = /** @class */ (function () {
|
|
4063
|
-
function BtnExpDirective(_activatedTable, _context, _config, _translate, _loadingService, _errorService) {
|
|
4064
|
-
this._activatedTable = _activatedTable;
|
|
4065
|
-
this._context = _context;
|
|
4066
|
-
this._config = _config;
|
|
4067
|
-
this._translate = _translate;
|
|
4068
|
-
this._loadingService = _loadingService;
|
|
4069
|
-
this._errorService = _errorService;
|
|
4070
|
-
}
|
|
4071
|
-
BtnExpDirective.prototype.clickEvent = function (event) {
|
|
4072
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
4073
|
-
var lastQuery, tableConfig, serviceHeaders, queryModel, query, queryParams, exportSettings, maxExportItems, url;
|
|
4074
|
-
return __generator(this, function (_a) {
|
|
4075
|
-
event.preventDefault();
|
|
4076
|
-
event.stopPropagation();
|
|
4077
|
-
if (this._activatedTable.activeTable) {
|
|
4078
|
-
lastQuery = this._activatedTable.activeTable.lastQuery;
|
|
4079
|
-
tableConfig = this._activatedTable.activeTable.config;
|
|
4080
|
-
serviceHeaders = this._context.getService().getHeaders();
|
|
4081
|
-
queryModel = lastQuery.getModel();
|
|
4082
|
-
query = this._context.model(queryModel).asQueryable();
|
|
4083
|
-
queryParams = lastQuery.getParams();
|
|
4084
|
-
query = this.constructQuery(query, queryParams, tableConfig, serviceHeaders);
|
|
4085
|
-
exportSettings = this._config.settings;
|
|
4086
|
-
maxExportItems = exportSettings && exportSettings.tables && exportSettings.tables.exportLimit;
|
|
4087
|
-
if (maxExportItems && typeof maxExportItems === 'number' && maxExportItems > 0) {
|
|
4088
|
-
query.skip(0).take(maxExportItems);
|
|
4089
|
-
}
|
|
4090
|
-
else {
|
|
4091
|
-
query.skip(0).take(MAX_EXPORT_ITEMS);
|
|
4092
|
-
}
|
|
4093
|
-
url = this.constructURL(query);
|
|
4094
|
-
this.downloadFile(url, query.getService().getHeaders(), query.getModel());
|
|
4095
|
-
}
|
|
4096
|
-
return [2 /*return*/];
|
|
4097
|
-
});
|
|
4098
|
-
});
|
|
4099
|
-
};
|
|
4100
|
-
/**
|
|
4101
|
-
* Sets the parameters to the query based on
|
|
4102
|
-
* the active filters of the activated table
|
|
4103
|
-
* @param {ClientDataQueryable} query
|
|
4104
|
-
* @param params: The filters of the last query of the activated table
|
|
4105
|
-
* @return ClientDataQueryable
|
|
4106
|
-
*/
|
|
4107
|
-
BtnExpDirective.prototype.setParams = function (query, params) {
|
|
4108
|
-
if (params && typeof params === 'object') {
|
|
4109
|
-
Object.keys(params).forEach(function (key) {
|
|
4110
|
-
query.setParam(key, params[key]);
|
|
4111
|
-
});
|
|
4112
|
-
}
|
|
4113
|
-
return query;
|
|
4114
|
-
};
|
|
4115
|
-
/**
|
|
4116
|
-
* Sets the headers to the query based on
|
|
4117
|
-
* the default headers of the DataContext
|
|
4118
|
-
* and appending the accept header to get
|
|
4119
|
-
* an xlsx file from the API
|
|
4120
|
-
* @param {ClientDataQueryable} query
|
|
4121
|
-
* @param {Headers} headers: The headers to append to the query
|
|
4122
|
-
* @return ClientDataQueryable
|
|
4123
|
-
*/
|
|
4124
|
-
BtnExpDirective.prototype.setHeaders = function (query, headers) {
|
|
4125
|
-
Object.keys(headers).forEach(function (key) {
|
|
4126
|
-
if (headers.hasOwnProperty(key)) {
|
|
4127
|
-
query.getService().setHeader(key, headers[key]);
|
|
4128
|
-
}
|
|
4129
|
-
});
|
|
4130
|
-
// sets a header to accept xlsx files
|
|
4131
|
-
query.getService().setHeader('Accept', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
|
|
4132
|
-
return query;
|
|
4133
|
-
};
|
|
4134
|
-
/**
|
|
4135
|
-
* Constructs the select parameter of the
|
|
4136
|
-
* ClientDataQuery by replacing the target name
|
|
4137
|
-
* of the field based on the localized translation
|
|
4138
|
-
* of that property on the advanced tabled
|
|
4139
|
-
* @param {ClientDataQueryable} query
|
|
4140
|
-
* @param tableConfig: The configuration of the activated table
|
|
4141
|
-
* @return ClientDataQueryable
|
|
4142
|
-
*/
|
|
4143
|
-
BtnExpDirective.prototype.constructQueryParam = function (query, tableConfig) {
|
|
4144
|
-
var _this = this;
|
|
4145
|
-
var selectQuery = query.getParams().$select;
|
|
4146
|
-
var selectQueryArray = selectQuery.split(',');
|
|
4147
|
-
selectQueryArray = selectQueryArray.map(function (select$$1) {
|
|
4148
|
-
var e_1, _a, e_2, _b;
|
|
4149
|
-
var words = select$$1.split(' ');
|
|
4150
|
-
if (words.length === 3) {
|
|
4151
|
-
if (tableConfig && tableConfig.columns) {
|
|
4152
|
-
try {
|
|
4153
|
-
for (var _c = __values(tableConfig.columns), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
4154
|
-
var column = _d.value;
|
|
4155
|
-
if (column.property === words[2] && column.title) {
|
|
4156
|
-
words[2] = "\"" + _this._translate.instant(column.title) + "\"";
|
|
4157
|
-
}
|
|
4158
|
-
else if (column.property === words[2]) {
|
|
4159
|
-
words[2] = "\"" + _this._translate.instant(words[2]) + "\"";
|
|
4160
|
-
}
|
|
4161
|
-
}
|
|
4162
|
-
}
|
|
4163
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
4164
|
-
finally {
|
|
4165
|
-
try {
|
|
4166
|
-
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
4167
|
-
}
|
|
4168
|
-
finally { if (e_1) throw e_1.error; }
|
|
4169
|
-
}
|
|
4170
|
-
}
|
|
4171
|
-
}
|
|
4172
|
-
if (words.length === 1) {
|
|
4173
|
-
if (tableConfig && tableConfig.columns) {
|
|
4174
|
-
try {
|
|
4175
|
-
for (var _e = __values(tableConfig.columns), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
4176
|
-
var column = _f.value;
|
|
4177
|
-
if (column.name === words[0] && column.title) {
|
|
4178
|
-
words[0] = words[0] + " as \"" + _this._translate.instant(column.title) + "\"";
|
|
4179
|
-
break;
|
|
4180
|
-
}
|
|
4181
|
-
else if (column.name === words[0] && column.property) {
|
|
4182
|
-
words[0] = words[0] + " as \"" + _this._translate.instant(column.property) + "\"";
|
|
4183
|
-
break;
|
|
4184
|
-
}
|
|
4185
|
-
else if (words[0] === column.name && words[0] === "id" && column.hidden) {
|
|
4186
|
-
break;
|
|
4187
|
-
}
|
|
4188
|
-
else if (words[0] == column.name || words[0] === column.property) {
|
|
4189
|
-
words[0] = words[0] + " as \"" + _this._translate.instant(words[0]) + "\"";
|
|
4190
|
-
}
|
|
4191
|
-
}
|
|
4192
|
-
}
|
|
4193
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
4194
|
-
finally {
|
|
4195
|
-
try {
|
|
4196
|
-
if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
|
|
4197
|
-
}
|
|
4198
|
-
finally { if (e_2) throw e_2.error; }
|
|
4199
|
-
}
|
|
4200
|
-
}
|
|
4201
|
-
return words[0];
|
|
4202
|
-
}
|
|
4203
|
-
return words.join(' ');
|
|
4204
|
-
});
|
|
4205
|
-
selectQuery = selectQueryArray.join(',');
|
|
4206
|
-
query.setParam('$select', selectQuery);
|
|
4207
|
-
return query;
|
|
4208
|
-
};
|
|
4209
|
-
/**
|
|
4210
|
-
* Constructs the fetch URL based the query parameters
|
|
4211
|
-
* @param {ClientDataQueryable} query
|
|
4212
|
-
* @return String
|
|
4213
|
-
*/
|
|
4214
|
-
BtnExpDirective.prototype.constructURL = function (query) {
|
|
4215
|
-
var baseURL = query.getService().getBase();
|
|
4216
|
-
var url = baseURL.endsWith('/') ? (baseURL + query.getModel() + '?') : (baseURL + '/' + query.getModel() + '?');
|
|
4217
|
-
Object.keys(query.getParams()).forEach(function (key, index) {
|
|
4218
|
-
if (index === 0) {
|
|
4219
|
-
url += key + '=' + query.getParams()[key];
|
|
4220
|
-
}
|
|
4221
|
-
else {
|
|
4222
|
-
url += '&' + key + '=' + query.getParams()[key];
|
|
4223
|
-
}
|
|
4224
|
-
});
|
|
4225
|
-
return url;
|
|
4226
|
-
};
|
|
4227
|
-
/**
|
|
4228
|
-
* Constructs the query by setting the parameters of the
|
|
4229
|
-
* advanced table's active filters, sets the necessary headers
|
|
4230
|
-
* and build the select parameter of the query
|
|
4231
|
-
* @param {ClientDataQueryable} query
|
|
4232
|
-
* @param params: The filters of the last query of the activated table
|
|
4233
|
-
* @param tableConfig: The configuration of the activated table
|
|
4234
|
-
* @param {Headers} headers: The headers to append to the query
|
|
4235
|
-
* @return ClientDataQueryable
|
|
4236
|
-
*/
|
|
4237
|
-
BtnExpDirective.prototype.constructQuery = function (query, params, tableConfig, headers) {
|
|
4238
|
-
var _query = this.setParams(query, params);
|
|
4239
|
-
_query = this.setHeaders(_query, headers);
|
|
4240
|
-
_query = this.constructQueryParam(_query, tableConfig);
|
|
4241
|
-
return _query;
|
|
4242
|
-
};
|
|
4243
|
-
/**
|
|
4244
|
-
* Fetches and saves the xlsx file
|
|
4245
|
-
* @param {String} url
|
|
4246
|
-
* @param {Headers} serviceHeaders: The headers to append to the query
|
|
4247
|
-
* @param modelName: The model name of the advanced table
|
|
4248
|
-
*/
|
|
4249
|
-
BtnExpDirective.prototype.downloadFile = function (url, serviceHeaders, modelName) {
|
|
4250
|
-
var _this = this;
|
|
4251
|
-
this._loadingService.showLoading();
|
|
4252
|
-
fetch(encodeURI(url), {
|
|
4253
|
-
headers: serviceHeaders,
|
|
4254
|
-
credentials: 'include'
|
|
4255
|
-
}).then(function (response) {
|
|
4256
|
-
if (response && !response.ok) {
|
|
4257
|
-
throw new ResponseError(response.statusText, response.status);
|
|
4258
|
-
}
|
|
4259
|
-
return response.blob();
|
|
4260
|
-
}).then(function (blob) {
|
|
4261
|
-
var objectUrl = window.URL.createObjectURL(blob);
|
|
4262
|
-
var a = document.createElement('a');
|
|
4263
|
-
document.body.appendChild(a);
|
|
4264
|
-
a.setAttribute('style', 'display: none');
|
|
4265
|
-
a.href = objectUrl;
|
|
4266
|
-
var downloadName = modelName + ".xlsx";
|
|
4267
|
-
a.download = downloadName;
|
|
4268
|
-
// this adds support for IE and MS Edge (up to version 44.19041)
|
|
4269
|
-
if (window.navigator && window.navigator.msSaveOrOpenBlob) {
|
|
4270
|
-
window.navigator.msSaveOrOpenBlob(blob, downloadName);
|
|
4271
|
-
}
|
|
4272
|
-
else {
|
|
4273
|
-
// for all other browsers
|
|
4274
|
-
a.click();
|
|
4275
|
-
}
|
|
4276
|
-
window.URL.revokeObjectURL(objectUrl);
|
|
4277
|
-
a.remove();
|
|
4278
|
-
_this._loadingService.hideLoading();
|
|
4279
|
-
}).catch(function (err) {
|
|
4280
|
-
_this._loadingService.hideLoading();
|
|
4281
|
-
_this._errorService.showError(err, {
|
|
4282
|
-
continueLink: '.'
|
|
4283
|
-
});
|
|
4284
|
-
});
|
|
4285
|
-
};
|
|
4286
|
-
BtnExpDirective.decorators = [
|
|
4287
|
-
{ type: Directive, args: [{
|
|
4288
|
-
selector: '.universis-btn-export'
|
|
4289
|
-
},] }
|
|
4290
|
-
];
|
|
4291
|
-
/** @nocollapse */
|
|
4292
|
-
BtnExpDirective.ctorParameters = function () { return [
|
|
4293
|
-
{ type: ActivatedTableService },
|
|
4294
|
-
{ type: AngularDataContext },
|
|
4295
|
-
{ type: ConfigurationService },
|
|
4296
|
-
{ type: TranslateService },
|
|
4297
|
-
{ type: LoadingService },
|
|
4298
|
-
{ type: ErrorService }
|
|
4299
|
-
]; };
|
|
4300
|
-
BtnExpDirective.propDecorators = {
|
|
4301
|
-
clickEvent: [{ type: HostListener, args: ['click', ['$event'],] }]
|
|
4302
|
-
};
|
|
4303
|
-
return BtnExpDirective;
|
|
4304
|
-
}());
|
|
4305
|
-
|
|
4306
4458
|
var AdvancedAggregatorService = /** @class */ (function () {
|
|
4307
4459
|
function AdvancedAggregatorService(_context, _template) {
|
|
4308
4460
|
this._context = _context;
|
|
@@ -4865,6 +5017,8 @@ var ParseTitlePipe = /** @class */ (function () {
|
|
|
4865
5017
|
return ParseTitlePipe;
|
|
4866
5018
|
}());
|
|
4867
5019
|
|
|
5020
|
+
// tslint:disable: quotemark
|
|
5021
|
+
// tslint:disable: max-line-length
|
|
4868
5022
|
var TABLES_EL = {
|
|
4869
5023
|
"Tables": {
|
|
4870
5024
|
"Export": "Εξαγωγή",
|
|
@@ -4948,7 +5102,10 @@ var TABLES_EL = {
|
|
|
4948
5102
|
"DataError": {
|
|
4949
5103
|
"Title": "Σφάλμα κατά την παραλαβή των δεδομένων",
|
|
4950
5104
|
"Message": "Συνέβη σφάλμα κατά την παραλαβή των δεδομένων. Προσπαθήστε ξανά ή τροποποιήστε τα στοιχεία αναζήτησης."
|
|
4951
|
-
}
|
|
5105
|
+
},
|
|
5106
|
+
"ExportList": "Εξαγωγή λίστας",
|
|
5107
|
+
"ExportLimitExceeded": "Το πλήθος των στοιχείων προς εξαγωγή ({{dataLength}}) ξεπερνάει το μέγιστο επιτρεπτό ({{exportLimit}}). Παρακαλούμε προσαρμόστε τα φίλτρα της αναζήτησης και προσπαθήστε ξανά.",
|
|
5108
|
+
"ExportResults": "Δεδομένα λίστας"
|
|
4952
5109
|
},
|
|
4953
5110
|
"TrueFalse": {
|
|
4954
5111
|
"long": {
|
|
@@ -4989,6 +5146,8 @@ var TABLES_EL = {
|
|
|
4989
5146
|
}
|
|
4990
5147
|
};
|
|
4991
5148
|
|
|
5149
|
+
// tslint:disable: quotemark
|
|
5150
|
+
// tslint:disable: max-line-length
|
|
4992
5151
|
var TABLES_EN = {
|
|
4993
5152
|
"Tables": {
|
|
4994
5153
|
"Export": "Export",
|
|
@@ -5071,7 +5230,10 @@ var TABLES_EN = {
|
|
|
5071
5230
|
"DataError": {
|
|
5072
5231
|
"Title": "Error while getting data",
|
|
5073
5232
|
"Message": "An error occurred while getting data. Please try again or change your criteria."
|
|
5074
|
-
}
|
|
5233
|
+
},
|
|
5234
|
+
"ExportList": "Export list",
|
|
5235
|
+
"ExportLimitExceeded": "The number of items that are to be exported ({{dataLength}}) exceeds the export limit ({{exportLimit}}). Please apply more specific filters to the search.",
|
|
5236
|
+
"ExportResults": "Exported list"
|
|
5075
5237
|
},
|
|
5076
5238
|
"TrueFalse": {
|
|
5077
5239
|
"long": {
|
|
@@ -5502,6 +5664,6 @@ var TablesModule = /** @class */ (function () {
|
|
|
5502
5664
|
* Generated bundle index. Do not edit.
|
|
5503
5665
|
*/
|
|
5504
5666
|
|
|
5505
|
-
export { AdvancedSearchState as ɵa, AdvancedTableState as ɵc, AdvancedSearchRouterState as ɵd, AdvancedListComponent, AdvancedRowActionComponent, AdvancedSearchFormComponent, AdvancedSelectComponent, AdvancedSelectService, AdvancedTableConfigurationResolver, AdvancedSearchConfigurationResolver, AdvancedColumnFormatter, NestedPropertyFormatter, ButtonFormatter, LinkFormatter, ActionLinkFormatter, ActionButtonFormatter, ActionSplitButtonFormatter, SelectRowFormatter, TemplateFormatter, TrueFalseFormatter, TranslationFormatter, DateTimeFormatter, NgClassFormatter, LanguageFormatter, COLUMN_FORMATTERS, AdvancedTableConfiguration, AdvancedTableComponent, ɵ0, AdvancedTableSettingsComponent, AdvancedTableSearchBaseComponent, AdvancedTableSearchComponent, FORMATTERS, AdvancedFilterValueProvider, AdvancedTableModalBaseTemplate, AdvancedTableModalBaseComponent, SimpleHeaderToolsComponent, TableSimpleHeaderComponent, AdvancedTableNotNullError, AdvancedTableEditorDirective, BtnExpDirective, AdvancedAggregatorComponent, AdvancedAggregatorListComponent, AddItemsComponent, AdvancedAggregatorPipe, ParseTitlePipe, AdvancedAggregatorService, TablesModule, ActivatedTableService, ColumnSelectorService, ColumnSelectorComponent, initialState, tableInitialState, tableReducer, tableReducers, featureName, getTablesState, selectTable };
|
|
5667
|
+
export { AdvancedSearchState as ɵa, AdvancedTableState as ɵc, AdvancedSearchRouterState as ɵd, AdvancedListComponent, AdvancedRowActionComponent, AdvancedSearchFormComponent, AdvancedSelectComponent, AdvancedSelectService, AdvancedTableConfigurationResolver, AdvancedSearchConfigurationResolver, AdvancedColumnFormatter, NestedPropertyFormatter, ButtonFormatter, LinkFormatter, ActionLinkFormatter, ActionButtonFormatter, ActionSplitButtonFormatter, SelectRowFormatter, TemplateFormatter, TrueFalseFormatter, TranslationFormatter, DateTimeFormatter, NgClassFormatter, LanguageFormatter, COLUMN_FORMATTERS, ExportLimitExceededError, AdvancedTableConfiguration, AdvancedTableComponent, ɵ0, AdvancedTableSettingsComponent, AdvancedTableSearchBaseComponent, AdvancedTableSearchComponent, FORMATTERS, AdvancedFilterValueProvider, AdvancedTableModalBaseTemplate, AdvancedTableModalBaseComponent, SimpleHeaderToolsComponent, TableSimpleHeaderComponent, AdvancedTableNotNullError, AdvancedTableEditorDirective, MAX_EXPORT_ITEMS, BtnExpDirective, AdvancedAggregatorComponent, AdvancedAggregatorListComponent, AddItemsComponent, AdvancedAggregatorPipe, ParseTitlePipe, AdvancedAggregatorService, TablesModule, ActivatedTableService, ColumnSelectorService, ColumnSelectorComponent, initialState, tableInitialState, tableReducer, tableReducers, featureName, getTablesState, selectTable };
|
|
5506
5668
|
|
|
5507
5669
|
//# sourceMappingURL=universis-ngx-tables.js.map
|