@universis/ngx-tables 0.8.0 → 0.8.2
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 +484 -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/esm2015/lib/tables.activated-table.service.js +16 -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/esm5/lib/tables.activated-table.service.js +16 -2
- package/fesm2015/universis-ngx-tables.js +427 -262
- package/fesm2015/universis-ngx-tables.js.map +1 -1
- package/fesm5/universis-ngx-tables.js +481 -307
- 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/lib/tables.activated-table.service.d.ts +11 -0
- package/package.json +4 -4
- package/universis-ngx-tables.metadata.json +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('iso-639-1/build'), require('
|
|
3
|
-
typeof define === 'function' && define.amd ? define('@universis/ngx-tables', ['exports', 'iso-639-1/build', '
|
|
4
|
-
(factory((global.universis = global.universis || {}, global.universis['ngx-tables'] = {}),global.ISO6391,global.
|
|
5
|
-
}(this, (function (exports,ISO6391,
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('iso-639-1/build'), require('jquery'), require('datatables.net'), require('datatables.net-scroller'), require('datatables.net-colreorder'), require('datatables.net-buttons'), require('rxjs'), require('rxjs/add/observable/combineLatest'), require('@angular/common/http'), require('@themost/client'), require('@themost/angular'), require('@angular/common'), require('@ngx-translate/core'), require('@angular/forms'), require('@universis/common'), require('@universis/common/routing'), require('@universis/forms'), require('angular-formio'), require('ngx-bootstrap/modal'), require('ngx-bootstrap/progressbar'), require('ngx-pipes'), require('lodash'), require('@angular/core'), require('@angular/router'), require('@ngrx/store'), require('rxjs/operators')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define('@universis/ngx-tables', ['exports', 'iso-639-1/build', 'jquery', 'datatables.net', 'datatables.net-scroller', 'datatables.net-colreorder', 'datatables.net-buttons', 'rxjs', 'rxjs/add/observable/combineLatest', '@angular/common/http', '@themost/client', '@themost/angular', '@angular/common', '@ngx-translate/core', '@angular/forms', '@universis/common', '@universis/common/routing', '@universis/forms', 'angular-formio', 'ngx-bootstrap/modal', 'ngx-bootstrap/progressbar', 'ngx-pipes', 'lodash', '@angular/core', '@angular/router', '@ngrx/store', 'rxjs/operators'], factory) :
|
|
4
|
+
(factory((global.universis = global.universis || {}, global.universis['ngx-tables'] = {}),global.ISO6391,global.jQuery_,null,null,null,null,global.rxjs,global.rxjs['add/observable/combineLatest'],global.ng.common.http,global.client,global.i1,global.ng.common,global.core,global.ng.forms,global.i2,global.routing,global.forms$1,global.angularFormio,global.modal,global.progressbar,global.ngxPipes,global.lodash,global.ng.core,global.ng.router,global.store,global.rxjs.operators));
|
|
5
|
+
}(this, (function (exports,ISO6391,jQuery_,datatables_net,datatables_netScroller,datatables_netColreorder,datatables_netButtons,rxjs,combineLatest,http,client,i1,common,core,forms,i2,routing,forms$1,angularFormio,modal,progressbar,ngxPipes,lodash,i0,i1$1,store,operators) { 'use strict';
|
|
6
6
|
|
|
7
7
|
/*! *****************************************************************************
|
|
8
8
|
Copyright (c) Microsoft Corporation.
|
|
@@ -1029,6 +1029,319 @@
|
|
|
1029
1029
|
return ColumnSelectorService;
|
|
1030
1030
|
}());
|
|
1031
1031
|
|
|
1032
|
+
var ActivatedTableService = /** @class */ (function () {
|
|
1033
|
+
function ActivatedTableService(_router, _activatedRoute) {
|
|
1034
|
+
var _this = this;
|
|
1035
|
+
this._router = _router;
|
|
1036
|
+
this._activatedRoute = _activatedRoute;
|
|
1037
|
+
/**
|
|
1038
|
+
* Get the last table that was set as active
|
|
1039
|
+
* Note: Emitted value may be null (e.g. reset on route changes)
|
|
1040
|
+
*/
|
|
1041
|
+
this.lastActiveTable = new rxjs.BehaviorSubject(null);
|
|
1042
|
+
/**
|
|
1043
|
+
* Omit the last emitted value to observe only new active table changes
|
|
1044
|
+
* Note: Emitted value may be null (e.g. reset on route changes)
|
|
1045
|
+
*/
|
|
1046
|
+
this.nextActiveTable = this.lastActiveTable.pipe(operators.skip(1));
|
|
1047
|
+
_router.events.forEach(function (event) {
|
|
1048
|
+
if (event instanceof i1$1.NavigationStart) {
|
|
1049
|
+
if (_this._activeTable) {
|
|
1050
|
+
_this.activeTable = null;
|
|
1051
|
+
}
|
|
1052
|
+
}
|
|
1053
|
+
});
|
|
1054
|
+
}
|
|
1055
|
+
Object.defineProperty(ActivatedTableService.prototype, "activeTable", {
|
|
1056
|
+
get: function () {
|
|
1057
|
+
return this._activeTable;
|
|
1058
|
+
},
|
|
1059
|
+
set: function (tableComponent) {
|
|
1060
|
+
this._activeTable = tableComponent;
|
|
1061
|
+
// provide change to observers
|
|
1062
|
+
this.lastActiveTable.next(this._activeTable);
|
|
1063
|
+
},
|
|
1064
|
+
enumerable: true,
|
|
1065
|
+
configurable: true
|
|
1066
|
+
});
|
|
1067
|
+
ActivatedTableService.decorators = [
|
|
1068
|
+
{ type: i0.Injectable, args: [{
|
|
1069
|
+
providedIn: 'root'
|
|
1070
|
+
},] }
|
|
1071
|
+
];
|
|
1072
|
+
/** @nocollapse */
|
|
1073
|
+
ActivatedTableService.ctorParameters = function () {
|
|
1074
|
+
return [
|
|
1075
|
+
{ type: i1$1.Router },
|
|
1076
|
+
{ type: i1$1.ActivatedRoute }
|
|
1077
|
+
];
|
|
1078
|
+
};
|
|
1079
|
+
ActivatedTableService.ngInjectableDef = i0.defineInjectable({ factory: function ActivatedTableService_Factory() { return new ActivatedTableService(i0.inject(i1$1.Router), i0.inject(i1$1.ActivatedRoute)); }, token: ActivatedTableService, providedIn: "root" });
|
|
1080
|
+
return ActivatedTableService;
|
|
1081
|
+
}());
|
|
1082
|
+
|
|
1083
|
+
var MAX_EXPORT_ITEMS = 500;
|
|
1084
|
+
var BtnExpDirective = /** @class */ (function () {
|
|
1085
|
+
function BtnExpDirective(_activatedTable, _context, _config, _translate, _loadingService, _errorService) {
|
|
1086
|
+
this._activatedTable = _activatedTable;
|
|
1087
|
+
this._context = _context;
|
|
1088
|
+
this._config = _config;
|
|
1089
|
+
this._translate = _translate;
|
|
1090
|
+
this._loadingService = _loadingService;
|
|
1091
|
+
this._errorService = _errorService;
|
|
1092
|
+
}
|
|
1093
|
+
BtnExpDirective.prototype.clickEvent = function (event) {
|
|
1094
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1095
|
+
return __generator(this, function (_a) {
|
|
1096
|
+
event.preventDefault();
|
|
1097
|
+
event.stopPropagation();
|
|
1098
|
+
if (this._activatedTable.activeTable) {
|
|
1099
|
+
return [2 /*return*/, this._activatedTable.activeTable.exportView()];
|
|
1100
|
+
/*
|
|
1101
|
+
const lastQuery = this._activatedTable.activeTable.lastQuery;
|
|
1102
|
+
const tableConfig = this._activatedTable.activeTable.config;
|
|
1103
|
+
const serviceHeaders = this._context.getService().getHeaders();
|
|
1104
|
+
const queryModel = lastQuery.getModel();
|
|
1105
|
+
let query = this._context.model(queryModel).asQueryable();
|
|
1106
|
+
const queryParams = lastQuery.getParams();
|
|
1107
|
+
query = this.constructQuery(query, queryParams, tableConfig, serviceHeaders);
|
|
1108
|
+
// get export settings
|
|
1109
|
+
const exportSettings = this._config.settings as ExportLimitConfiguration;
|
|
1110
|
+
// get export limit
|
|
1111
|
+
const maxExportItems = exportSettings && exportSettings.tables && exportSettings.tables.exportLimit;
|
|
1112
|
+
if (maxExportItems && typeof maxExportItems === 'number' && maxExportItems > 0) {
|
|
1113
|
+
query.skip(0).take(maxExportItems);
|
|
1114
|
+
} else {
|
|
1115
|
+
query.skip(0).take(MAX_EXPORT_ITEMS);
|
|
1116
|
+
}
|
|
1117
|
+
// This constructs the URI based on the way @themost does
|
|
1118
|
+
const url = this.constructURL(query);
|
|
1119
|
+
this.downloadFile(url, query.getService().getHeaders(), query.getModel()); */
|
|
1120
|
+
}
|
|
1121
|
+
return [2 /*return*/];
|
|
1122
|
+
});
|
|
1123
|
+
});
|
|
1124
|
+
};
|
|
1125
|
+
/**
|
|
1126
|
+
* Sets the parameters to the query based on
|
|
1127
|
+
* the active filters of the activated table
|
|
1128
|
+
* @param {ClientDataQueryable} query
|
|
1129
|
+
* @param params: The filters of the last query of the activated table
|
|
1130
|
+
* @return ClientDataQueryable
|
|
1131
|
+
*/
|
|
1132
|
+
BtnExpDirective.prototype.setParams = function (query, params) {
|
|
1133
|
+
if (params && typeof params === 'object') {
|
|
1134
|
+
Object.keys(params).forEach(function (key) {
|
|
1135
|
+
query.setParam(key, params[key]);
|
|
1136
|
+
});
|
|
1137
|
+
}
|
|
1138
|
+
return query;
|
|
1139
|
+
};
|
|
1140
|
+
/**
|
|
1141
|
+
* Sets the headers to the query based on
|
|
1142
|
+
* the default headers of the DataContext
|
|
1143
|
+
* and appending the accept header to get
|
|
1144
|
+
* an xlsx file from the API
|
|
1145
|
+
* @param {ClientDataQueryable} query
|
|
1146
|
+
* @param {Headers} headers: The headers to append to the query
|
|
1147
|
+
* @return ClientDataQueryable
|
|
1148
|
+
*/
|
|
1149
|
+
BtnExpDirective.prototype.setHeaders = function (query, headers) {
|
|
1150
|
+
Object.keys(headers).forEach(function (key) {
|
|
1151
|
+
if (headers.hasOwnProperty(key)) {
|
|
1152
|
+
query.getService().setHeader(key, headers[key]);
|
|
1153
|
+
}
|
|
1154
|
+
});
|
|
1155
|
+
// sets a header to accept xlsx files
|
|
1156
|
+
query.getService().setHeader('Accept', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
|
|
1157
|
+
return query;
|
|
1158
|
+
};
|
|
1159
|
+
/**
|
|
1160
|
+
* Constructs the select parameter of the
|
|
1161
|
+
* ClientDataQuery by replacing the target name
|
|
1162
|
+
* of the field based on the localized translation
|
|
1163
|
+
* of that property on the advanced tabled
|
|
1164
|
+
* @param {ClientDataQueryable} query
|
|
1165
|
+
* @param tableConfig: The configuration of the activated table
|
|
1166
|
+
* @return ClientDataQueryable
|
|
1167
|
+
*/
|
|
1168
|
+
BtnExpDirective.prototype.constructQueryParam = function (query, tableConfig) {
|
|
1169
|
+
var _this = this;
|
|
1170
|
+
var selectQuery = query.getParams().$select;
|
|
1171
|
+
var selectQueryArray = selectQuery.split(',');
|
|
1172
|
+
selectQueryArray = selectQueryArray.map(function (select) {
|
|
1173
|
+
var e_1, _a, e_2, _b;
|
|
1174
|
+
var words = select.split(' ');
|
|
1175
|
+
if (words.length === 3) {
|
|
1176
|
+
if (tableConfig && tableConfig.columns) {
|
|
1177
|
+
try {
|
|
1178
|
+
for (var _c = __values(tableConfig.columns), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
1179
|
+
var column = _d.value;
|
|
1180
|
+
if (column.property === words[2] && column.title) {
|
|
1181
|
+
words[2] = "\"" + _this._translate.instant(column.title) + "\"";
|
|
1182
|
+
}
|
|
1183
|
+
else if (column.property === words[2]) {
|
|
1184
|
+
words[2] = "\"" + _this._translate.instant(words[2]) + "\"";
|
|
1185
|
+
}
|
|
1186
|
+
}
|
|
1187
|
+
}
|
|
1188
|
+
catch (e_1_1) {
|
|
1189
|
+
e_1 = { error: e_1_1 };
|
|
1190
|
+
}
|
|
1191
|
+
finally {
|
|
1192
|
+
try {
|
|
1193
|
+
if (_d && !_d.done && (_a = _c.return))
|
|
1194
|
+
_a.call(_c);
|
|
1195
|
+
}
|
|
1196
|
+
finally {
|
|
1197
|
+
if (e_1)
|
|
1198
|
+
throw e_1.error;
|
|
1199
|
+
}
|
|
1200
|
+
}
|
|
1201
|
+
}
|
|
1202
|
+
}
|
|
1203
|
+
if (words.length === 1) {
|
|
1204
|
+
if (tableConfig && tableConfig.columns) {
|
|
1205
|
+
try {
|
|
1206
|
+
for (var _e = __values(tableConfig.columns), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
1207
|
+
var column = _f.value;
|
|
1208
|
+
if (column.name === words[0] && column.title) {
|
|
1209
|
+
words[0] = words[0] + " as \"" + _this._translate.instant(column.title) + "\"";
|
|
1210
|
+
break;
|
|
1211
|
+
}
|
|
1212
|
+
else if (column.name === words[0] && column.property) {
|
|
1213
|
+
words[0] = words[0] + " as \"" + _this._translate.instant(column.property) + "\"";
|
|
1214
|
+
break;
|
|
1215
|
+
}
|
|
1216
|
+
else if (words[0] === column.name && words[0] === "id" && column.hidden) {
|
|
1217
|
+
break;
|
|
1218
|
+
}
|
|
1219
|
+
else if (words[0] == column.name || words[0] === column.property) {
|
|
1220
|
+
words[0] = words[0] + " as \"" + _this._translate.instant(words[0]) + "\"";
|
|
1221
|
+
}
|
|
1222
|
+
}
|
|
1223
|
+
}
|
|
1224
|
+
catch (e_2_1) {
|
|
1225
|
+
e_2 = { error: e_2_1 };
|
|
1226
|
+
}
|
|
1227
|
+
finally {
|
|
1228
|
+
try {
|
|
1229
|
+
if (_f && !_f.done && (_b = _e.return))
|
|
1230
|
+
_b.call(_e);
|
|
1231
|
+
}
|
|
1232
|
+
finally {
|
|
1233
|
+
if (e_2)
|
|
1234
|
+
throw e_2.error;
|
|
1235
|
+
}
|
|
1236
|
+
}
|
|
1237
|
+
}
|
|
1238
|
+
return words[0];
|
|
1239
|
+
}
|
|
1240
|
+
return words.join(' ');
|
|
1241
|
+
});
|
|
1242
|
+
selectQuery = selectQueryArray.join(',');
|
|
1243
|
+
query.setParam('$select', selectQuery);
|
|
1244
|
+
return query;
|
|
1245
|
+
};
|
|
1246
|
+
/**
|
|
1247
|
+
* Constructs the fetch URL based the query parameters
|
|
1248
|
+
* @param {ClientDataQueryable} query
|
|
1249
|
+
* @return String
|
|
1250
|
+
*/
|
|
1251
|
+
BtnExpDirective.prototype.constructURL = function (query) {
|
|
1252
|
+
var baseURL = query.getService().getBase();
|
|
1253
|
+
var url = baseURL.endsWith('/') ? (baseURL + query.getModel() + '?') : (baseURL + '/' + query.getModel() + '?');
|
|
1254
|
+
Object.keys(query.getParams()).forEach(function (key, index) {
|
|
1255
|
+
if (index === 0) {
|
|
1256
|
+
url += key + '=' + query.getParams()[key];
|
|
1257
|
+
}
|
|
1258
|
+
else {
|
|
1259
|
+
url += '&' + key + '=' + query.getParams()[key];
|
|
1260
|
+
}
|
|
1261
|
+
});
|
|
1262
|
+
return url;
|
|
1263
|
+
};
|
|
1264
|
+
/**
|
|
1265
|
+
* Constructs the query by setting the parameters of the
|
|
1266
|
+
* advanced table's active filters, sets the necessary headers
|
|
1267
|
+
* and build the select parameter of the query
|
|
1268
|
+
* @param {ClientDataQueryable} query
|
|
1269
|
+
* @param params: The filters of the last query of the activated table
|
|
1270
|
+
* @param tableConfig: The configuration of the activated table
|
|
1271
|
+
* @param {Headers} headers: The headers to append to the query
|
|
1272
|
+
* @return ClientDataQueryable
|
|
1273
|
+
*/
|
|
1274
|
+
BtnExpDirective.prototype.constructQuery = function (query, params, tableConfig, headers) {
|
|
1275
|
+
var _query = this.setParams(query, params);
|
|
1276
|
+
_query = this.setHeaders(_query, headers);
|
|
1277
|
+
_query = this.constructQueryParam(_query, tableConfig);
|
|
1278
|
+
return _query;
|
|
1279
|
+
};
|
|
1280
|
+
/**
|
|
1281
|
+
* Fetches and saves the xlsx file
|
|
1282
|
+
* @param {String} url
|
|
1283
|
+
* @param {Headers} serviceHeaders: The headers to append to the query
|
|
1284
|
+
* @param modelName: The model name of the advanced table
|
|
1285
|
+
*/
|
|
1286
|
+
BtnExpDirective.prototype.downloadFile = function (url, serviceHeaders, modelName) {
|
|
1287
|
+
var _this = this;
|
|
1288
|
+
this._loadingService.showLoading();
|
|
1289
|
+
fetch(encodeURI(url), {
|
|
1290
|
+
headers: serviceHeaders,
|
|
1291
|
+
credentials: 'include'
|
|
1292
|
+
}).then(function (response) {
|
|
1293
|
+
if (response && !response.ok) {
|
|
1294
|
+
throw new client.ResponseError(response.statusText, response.status);
|
|
1295
|
+
}
|
|
1296
|
+
return response.blob();
|
|
1297
|
+
}).then(function (blob) {
|
|
1298
|
+
var objectUrl = window.URL.createObjectURL(blob);
|
|
1299
|
+
var a = document.createElement('a');
|
|
1300
|
+
document.body.appendChild(a);
|
|
1301
|
+
a.setAttribute('style', 'display: none');
|
|
1302
|
+
a.href = objectUrl;
|
|
1303
|
+
var downloadName = modelName + ".xlsx";
|
|
1304
|
+
a.download = downloadName;
|
|
1305
|
+
// this adds support for IE and MS Edge (up to version 44.19041)
|
|
1306
|
+
if (window.navigator && window.navigator.msSaveOrOpenBlob) {
|
|
1307
|
+
window.navigator.msSaveOrOpenBlob(blob, downloadName);
|
|
1308
|
+
}
|
|
1309
|
+
else {
|
|
1310
|
+
// for all other browsers
|
|
1311
|
+
a.click();
|
|
1312
|
+
}
|
|
1313
|
+
window.URL.revokeObjectURL(objectUrl);
|
|
1314
|
+
a.remove();
|
|
1315
|
+
_this._loadingService.hideLoading();
|
|
1316
|
+
}).catch(function (err) {
|
|
1317
|
+
_this._loadingService.hideLoading();
|
|
1318
|
+
_this._errorService.showError(err, {
|
|
1319
|
+
continueLink: '.'
|
|
1320
|
+
});
|
|
1321
|
+
});
|
|
1322
|
+
};
|
|
1323
|
+
BtnExpDirective.decorators = [
|
|
1324
|
+
{ type: i0.Directive, args: [{
|
|
1325
|
+
selector: '.universis-btn-export'
|
|
1326
|
+
},] }
|
|
1327
|
+
];
|
|
1328
|
+
/** @nocollapse */
|
|
1329
|
+
BtnExpDirective.ctorParameters = function () {
|
|
1330
|
+
return [
|
|
1331
|
+
{ type: ActivatedTableService },
|
|
1332
|
+
{ type: i1.AngularDataContext },
|
|
1333
|
+
{ type: i2.ConfigurationService },
|
|
1334
|
+
{ type: core.TranslateService },
|
|
1335
|
+
{ type: i2.LoadingService },
|
|
1336
|
+
{ type: i2.ErrorService }
|
|
1337
|
+
];
|
|
1338
|
+
};
|
|
1339
|
+
BtnExpDirective.propDecorators = {
|
|
1340
|
+
clickEvent: [{ type: i0.HostListener, args: ['click', ['$event'],] }]
|
|
1341
|
+
};
|
|
1342
|
+
return BtnExpDirective;
|
|
1343
|
+
}());
|
|
1344
|
+
|
|
1032
1345
|
// restore jquery import to avoid Cannot call a namespace ('jquery') error
|
|
1033
1346
|
var jQuery = jQuery_;
|
|
1034
1347
|
var DataTablesApi = jQuery.fn.dataTable.Api;
|
|
@@ -1061,6 +1374,15 @@
|
|
|
1061
1374
|
return TableTranslationChangeDetector;
|
|
1062
1375
|
}(i0.ChangeDetectorRef));
|
|
1063
1376
|
var COLUMN_FORMATTERS = new i0.InjectionToken('column.formatters');
|
|
1377
|
+
var ExportLimitExceededError = /** @class */ (function (_super) {
|
|
1378
|
+
__extends(ExportLimitExceededError, _super);
|
|
1379
|
+
function ExportLimitExceededError(message) {
|
|
1380
|
+
var _this = _super.call(this, message) || this;
|
|
1381
|
+
_this.name = 'ExportLimitExceededError';
|
|
1382
|
+
return _this;
|
|
1383
|
+
}
|
|
1384
|
+
return ExportLimitExceededError;
|
|
1385
|
+
}(RangeError));
|
|
1064
1386
|
var ColumnFormatter = /** @class */ (function (_super) {
|
|
1065
1387
|
__extends(ColumnFormatter, _super);
|
|
1066
1388
|
function ColumnFormatter(injector) {
|
|
@@ -1091,7 +1413,7 @@
|
|
|
1091
1413
|
return (Number(String(Math.random()).slice(2))).toString(36);
|
|
1092
1414
|
}
|
|
1093
1415
|
var AdvancedTableComponent = /** @class */ (function () {
|
|
1094
|
-
function AdvancedTableComponent(_context, _columnFormatters, _activatedRoute, _translateService, _injector, _advancedFilterValueProvider, _element, _template, _loading, _http, _columnSelector) {
|
|
1416
|
+
function AdvancedTableComponent(_context, _columnFormatters, _activatedRoute, _translateService, _injector, _advancedFilterValueProvider, _element, _template, _loading, _http, _columnSelector, _configuration, _exportSpreadsheet, _modalService, _errorService) {
|
|
1095
1417
|
var _this = this;
|
|
1096
1418
|
this._context = _context;
|
|
1097
1419
|
this._columnFormatters = _columnFormatters;
|
|
@@ -1104,6 +1426,10 @@
|
|
|
1104
1426
|
this._loading = _loading;
|
|
1105
1427
|
this._http = _http;
|
|
1106
1428
|
this._columnSelector = _columnSelector;
|
|
1429
|
+
this._configuration = _configuration;
|
|
1430
|
+
this._exportSpreadsheet = _exportSpreadsheet;
|
|
1431
|
+
this._modalService = _modalService;
|
|
1432
|
+
this._errorService = _errorService;
|
|
1107
1433
|
this._firstLoad = true;
|
|
1108
1434
|
this._showFooter = false;
|
|
1109
1435
|
this._showHeader = true;
|
|
@@ -1147,6 +1473,7 @@
|
|
|
1147
1473
|
this.customSelect = false;
|
|
1148
1474
|
this.selected = [];
|
|
1149
1475
|
this.unselected = [];
|
|
1476
|
+
this._lastQueryTotalItems = 0;
|
|
1150
1477
|
// initialize translate pipe
|
|
1151
1478
|
this.translator = new core.TranslatePipe(this._translateService, new TableTranslationChangeDetector());
|
|
1152
1479
|
jQuery.fn.dataTable.ext.classes.sPageButton = 'btn';
|
|
@@ -1170,6 +1497,13 @@
|
|
|
1170
1497
|
enumerable: true,
|
|
1171
1498
|
configurable: true
|
|
1172
1499
|
});
|
|
1500
|
+
Object.defineProperty(AdvancedTableComponent.prototype, "lastQueryTotalItems", {
|
|
1501
|
+
get: function () {
|
|
1502
|
+
return this._lastQueryTotalItems;
|
|
1503
|
+
},
|
|
1504
|
+
enumerable: true,
|
|
1505
|
+
configurable: true
|
|
1506
|
+
});
|
|
1173
1507
|
Object.defineProperty(AdvancedTableComponent.prototype, "showFooter", {
|
|
1174
1508
|
get: function () {
|
|
1175
1509
|
return this._showFooter;
|
|
@@ -1796,6 +2130,7 @@
|
|
|
1796
2130
|
recordsFiltered: 0,
|
|
1797
2131
|
data: [],
|
|
1798
2132
|
};
|
|
2133
|
+
self._lastQueryTotalItems = 0;
|
|
1799
2134
|
// emit empty data
|
|
1800
2135
|
self.load.emit(emptyDataSet);
|
|
1801
2136
|
// return empty data
|
|
@@ -1890,6 +2225,7 @@
|
|
|
1890
2225
|
recordsFiltered: items.total,
|
|
1891
2226
|
data: items.value,
|
|
1892
2227
|
};
|
|
2228
|
+
self._lastQueryTotalItems = items.total;
|
|
1893
2229
|
if (items.total === 0) {
|
|
1894
2230
|
self.resetEmptyTable();
|
|
1895
2231
|
}
|
|
@@ -1903,6 +2239,7 @@
|
|
|
1903
2239
|
console.error('TABLES', err);
|
|
1904
2240
|
// show error
|
|
1905
2241
|
self.toggleError(err);
|
|
2242
|
+
self._lastQueryTotalItems = 0;
|
|
1906
2243
|
// by returning empty dataset
|
|
1907
2244
|
self.load.emit(EMPTY_DATASET);
|
|
1908
2245
|
return fnCallback(EMPTY_DATASET);
|
|
@@ -1915,6 +2252,7 @@
|
|
|
1915
2252
|
recordsFiltered: items.total,
|
|
1916
2253
|
data: items.value,
|
|
1917
2254
|
};
|
|
2255
|
+
self._lastQueryTotalItems = items.total;
|
|
1918
2256
|
if (items.total === 0) {
|
|
1919
2257
|
self.resetEmptyTable();
|
|
1920
2258
|
}
|
|
@@ -2298,6 +2636,126 @@
|
|
|
2298
2636
|
}
|
|
2299
2637
|
});
|
|
2300
2638
|
};
|
|
2639
|
+
/**
|
|
2640
|
+
*
|
|
2641
|
+
* @param options to pass an errorHandler callback, if desired
|
|
2642
|
+
* @returns void
|
|
2643
|
+
*/
|
|
2644
|
+
AdvancedTableComponent.prototype.exportView = function (options) {
|
|
2645
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2646
|
+
var exportSettings, exportLimit, totalDisplayedItems, _a, body, header, previousDataState, targetDataState, _b, body, header, err_1;
|
|
2647
|
+
return __generator(this, function (_c) {
|
|
2648
|
+
switch (_c.label) {
|
|
2649
|
+
case 0:
|
|
2650
|
+
_c.trys.push([0, 4, 5, 6]);
|
|
2651
|
+
this._loading.showLoading();
|
|
2652
|
+
// validate query items and config
|
|
2653
|
+
if (!(this._lastQueryTotalItems && this.config)) {
|
|
2654
|
+
// do nothing
|
|
2655
|
+
return [2 /*return*/];
|
|
2656
|
+
}
|
|
2657
|
+
exportSettings = this._configuration.settings;
|
|
2658
|
+
exportLimit = (exportSettings && exportSettings.tables && exportSettings.tables.exportLimit > 0)
|
|
2659
|
+
? exportSettings.tables.exportLimit : MAX_EXPORT_ITEMS;
|
|
2660
|
+
// and validate it
|
|
2661
|
+
if (this._lastQueryTotalItems > exportLimit) {
|
|
2662
|
+
// call error handler
|
|
2663
|
+
// provide a recognizible error type
|
|
2664
|
+
if (options && options.errorHandler) {
|
|
2665
|
+
options.errorHandler(new ExportLimitExceededError('Export limit exceeded'));
|
|
2666
|
+
return [2 /*return*/];
|
|
2667
|
+
}
|
|
2668
|
+
// or show warning modal and exit
|
|
2669
|
+
this._modalService.showWarningDialog(this._translateService.instant('Tables.ExportList'), this._translateService.instant('Tables.ExportLimitExceeded', { dataLength: this._lastQueryTotalItems, exportLimit: exportLimit }), i2.DIALOG_BUTTONS.Ok);
|
|
2670
|
+
return [2 /*return*/];
|
|
2671
|
+
}
|
|
2672
|
+
totalDisplayedItems = Array.from(this.dataTable.context[0].aiDisplay).length;
|
|
2673
|
+
if (!(totalDisplayedItems === this._lastQueryTotalItems))
|
|
2674
|
+
return [3 /*break*/, 1];
|
|
2675
|
+
_a = this.getExportableData(), body = _a.body, header = _a.header;
|
|
2676
|
+
// and export them to excel
|
|
2677
|
+
this._exportSpreadsheet.export(body, this._translateService.instant(this.config.title || 'Tables.ExportResults') + ".xlsx", {
|
|
2678
|
+
header: header,
|
|
2679
|
+
skipHeader: false
|
|
2680
|
+
});
|
|
2681
|
+
return [3 /*break*/, 3];
|
|
2682
|
+
case 1:
|
|
2683
|
+
previousDataState = this.dataTable.rows().data().toArray();
|
|
2684
|
+
return [4 /*yield*/, this.lastQuery.take(exportLimit).getItems()];
|
|
2685
|
+
case 2:
|
|
2686
|
+
targetDataState = _c.sent();
|
|
2687
|
+
// change table data on the fly, but do not redraw
|
|
2688
|
+
this.dataTable.clear().rows.add(targetDataState);
|
|
2689
|
+
_b = this.getExportableData(), body = _b.body, header = _b.header;
|
|
2690
|
+
// reset table data
|
|
2691
|
+
this.dataTable.clear().rows.add(previousDataState);
|
|
2692
|
+
// and export target data to excel
|
|
2693
|
+
this._exportSpreadsheet.export(body, this._translateService.instant(this.config.title || 'Tables.ExportResults') + ".xlsx", {
|
|
2694
|
+
header: header,
|
|
2695
|
+
skipHeader: false
|
|
2696
|
+
});
|
|
2697
|
+
_c.label = 3;
|
|
2698
|
+
case 3:
|
|
2699
|
+
// exit
|
|
2700
|
+
return [2 /*return*/];
|
|
2701
|
+
case 4:
|
|
2702
|
+
err_1 = _c.sent();
|
|
2703
|
+
// log error
|
|
2704
|
+
console.error(err_1);
|
|
2705
|
+
// call error handler, if defined
|
|
2706
|
+
if (options && options.errorHandler) {
|
|
2707
|
+
options.errorHandler(err_1);
|
|
2708
|
+
}
|
|
2709
|
+
else {
|
|
2710
|
+
// use default error service
|
|
2711
|
+
this._errorService.showError(err_1, {
|
|
2712
|
+
continueLink: '.'
|
|
2713
|
+
});
|
|
2714
|
+
}
|
|
2715
|
+
return [3 /*break*/, 6];
|
|
2716
|
+
case 5:
|
|
2717
|
+
this._loading.hideLoading();
|
|
2718
|
+
return [7 /*endfinally*/];
|
|
2719
|
+
case 6: return [2 /*return*/];
|
|
2720
|
+
}
|
|
2721
|
+
});
|
|
2722
|
+
});
|
|
2723
|
+
};
|
|
2724
|
+
AdvancedTableComponent.prototype.getExportableData = function () {
|
|
2725
|
+
var _this = this;
|
|
2726
|
+
if (!(this.dataTable && this.dataTable.buttons
|
|
2727
|
+
&& typeof this.dataTable.buttons.exportData === 'function' && this.config)) {
|
|
2728
|
+
return { body: [], header: [] };
|
|
2729
|
+
}
|
|
2730
|
+
// fetch exportable excel data
|
|
2731
|
+
var _a = this.dataTable.buttons.exportData(), body = _a.body, header = _a.header;
|
|
2732
|
+
var cleanupIndexes = [];
|
|
2733
|
+
// clean up headers
|
|
2734
|
+
header = header.filter(function (headerItem, index) {
|
|
2735
|
+
// exclude empty headers
|
|
2736
|
+
if (headerItem.trim().length === 0) {
|
|
2737
|
+
cleanupIndexes.push(index);
|
|
2738
|
+
return false;
|
|
2739
|
+
}
|
|
2740
|
+
// find item by title
|
|
2741
|
+
var findItem = _this.config.columns.find(function (column) {
|
|
2742
|
+
return column.title && column.title.length && _this._translateService.instant(column.title) === headerItem;
|
|
2743
|
+
});
|
|
2744
|
+
// exclude hidden columns
|
|
2745
|
+
if (findItem && findItem.hidden === true) {
|
|
2746
|
+
cleanupIndexes.push(index);
|
|
2747
|
+
return false;
|
|
2748
|
+
}
|
|
2749
|
+
return true;
|
|
2750
|
+
});
|
|
2751
|
+
// clean up body
|
|
2752
|
+
body = body.map(function (row) {
|
|
2753
|
+
return row.filter(function (_, rowIndex) {
|
|
2754
|
+
return cleanupIndexes.indexOf(rowIndex) === -1;
|
|
2755
|
+
});
|
|
2756
|
+
});
|
|
2757
|
+
return { body: body, header: header };
|
|
2758
|
+
};
|
|
2301
2759
|
AdvancedTableComponent.decorators = [
|
|
2302
2760
|
{ type: i0.Component, args: [{
|
|
2303
2761
|
// tslint:disable-next-line: component-selector
|
|
@@ -2320,7 +2778,11 @@
|
|
|
2320
2778
|
{ type: i2.TemplatePipe },
|
|
2321
2779
|
{ type: i2.LoadingService },
|
|
2322
2780
|
{ type: http.HttpClient },
|
|
2323
|
-
{ type: ColumnSelectorService }
|
|
2781
|
+
{ type: ColumnSelectorService },
|
|
2782
|
+
{ type: i2.ConfigurationService },
|
|
2783
|
+
{ type: i2.ExportSpreadsheetService },
|
|
2784
|
+
{ type: i2.ModalService },
|
|
2785
|
+
{ type: i2.ErrorService }
|
|
2324
2786
|
];
|
|
2325
2787
|
};
|
|
2326
2788
|
AdvancedTableComponent.propDecorators = {
|
|
@@ -3334,49 +3796,10 @@
|
|
|
3334
3796
|
/** @nocollapse */
|
|
3335
3797
|
AdvancedSearchConfigurationResolver.ctorParameters = function () {
|
|
3336
3798
|
return [
|
|
3337
|
-
{ type: http.HttpClient }
|
|
3338
|
-
];
|
|
3339
|
-
};
|
|
3340
|
-
return AdvancedSearchConfigurationResolver;
|
|
3341
|
-
}());
|
|
3342
|
-
|
|
3343
|
-
var ActivatedTableService = /** @class */ (function () {
|
|
3344
|
-
function ActivatedTableService(_router, _activatedRoute) {
|
|
3345
|
-
var _this = this;
|
|
3346
|
-
this._router = _router;
|
|
3347
|
-
this._activatedRoute = _activatedRoute;
|
|
3348
|
-
_router.events.forEach(function (event) {
|
|
3349
|
-
if (event instanceof i1$1.NavigationStart) {
|
|
3350
|
-
if (_this._activeTable) {
|
|
3351
|
-
_this._activeTable = null;
|
|
3352
|
-
}
|
|
3353
|
-
}
|
|
3354
|
-
});
|
|
3355
|
-
}
|
|
3356
|
-
Object.defineProperty(ActivatedTableService.prototype, "activeTable", {
|
|
3357
|
-
get: function () {
|
|
3358
|
-
return this._activeTable;
|
|
3359
|
-
},
|
|
3360
|
-
set: function (tableComponent) {
|
|
3361
|
-
this._activeTable = tableComponent;
|
|
3362
|
-
},
|
|
3363
|
-
enumerable: true,
|
|
3364
|
-
configurable: true
|
|
3365
|
-
});
|
|
3366
|
-
ActivatedTableService.decorators = [
|
|
3367
|
-
{ type: i0.Injectable, args: [{
|
|
3368
|
-
providedIn: 'root'
|
|
3369
|
-
},] }
|
|
3370
|
-
];
|
|
3371
|
-
/** @nocollapse */
|
|
3372
|
-
ActivatedTableService.ctorParameters = function () {
|
|
3373
|
-
return [
|
|
3374
|
-
{ type: i1$1.Router },
|
|
3375
|
-
{ type: i1$1.ActivatedRoute }
|
|
3799
|
+
{ type: http.HttpClient }
|
|
3376
3800
|
];
|
|
3377
3801
|
};
|
|
3378
|
-
|
|
3379
|
-
return ActivatedTableService;
|
|
3802
|
+
return AdvancedSearchConfigurationResolver;
|
|
3380
3803
|
}());
|
|
3381
3804
|
|
|
3382
3805
|
var AdvancedTableSettingsComponent = /** @class */ (function () {
|
|
@@ -4314,265 +4737,6 @@
|
|
|
4314
4737
|
return AdvancedTableEditorDirective;
|
|
4315
4738
|
}());
|
|
4316
4739
|
|
|
4317
|
-
var MAX_EXPORT_ITEMS = 500;
|
|
4318
|
-
var BtnExpDirective = /** @class */ (function () {
|
|
4319
|
-
function BtnExpDirective(_activatedTable, _context, _config, _translate, _loadingService, _errorService) {
|
|
4320
|
-
this._activatedTable = _activatedTable;
|
|
4321
|
-
this._context = _context;
|
|
4322
|
-
this._config = _config;
|
|
4323
|
-
this._translate = _translate;
|
|
4324
|
-
this._loadingService = _loadingService;
|
|
4325
|
-
this._errorService = _errorService;
|
|
4326
|
-
}
|
|
4327
|
-
BtnExpDirective.prototype.clickEvent = function (event) {
|
|
4328
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
4329
|
-
var lastQuery, tableConfig, serviceHeaders, queryModel, query, queryParams, exportSettings, maxExportItems, url;
|
|
4330
|
-
return __generator(this, function (_a) {
|
|
4331
|
-
event.preventDefault();
|
|
4332
|
-
event.stopPropagation();
|
|
4333
|
-
if (this._activatedTable.activeTable) {
|
|
4334
|
-
lastQuery = this._activatedTable.activeTable.lastQuery;
|
|
4335
|
-
tableConfig = this._activatedTable.activeTable.config;
|
|
4336
|
-
serviceHeaders = this._context.getService().getHeaders();
|
|
4337
|
-
queryModel = lastQuery.getModel();
|
|
4338
|
-
query = this._context.model(queryModel).asQueryable();
|
|
4339
|
-
queryParams = lastQuery.getParams();
|
|
4340
|
-
query = this.constructQuery(query, queryParams, tableConfig, serviceHeaders);
|
|
4341
|
-
exportSettings = this._config.settings;
|
|
4342
|
-
maxExportItems = exportSettings && exportSettings.tables && exportSettings.tables.exportLimit;
|
|
4343
|
-
if (maxExportItems && typeof maxExportItems === 'number' && maxExportItems > 0) {
|
|
4344
|
-
query.skip(0).take(maxExportItems);
|
|
4345
|
-
}
|
|
4346
|
-
else {
|
|
4347
|
-
query.skip(0).take(MAX_EXPORT_ITEMS);
|
|
4348
|
-
}
|
|
4349
|
-
url = this.constructURL(query);
|
|
4350
|
-
this.downloadFile(url, query.getService().getHeaders(), query.getModel());
|
|
4351
|
-
}
|
|
4352
|
-
return [2 /*return*/];
|
|
4353
|
-
});
|
|
4354
|
-
});
|
|
4355
|
-
};
|
|
4356
|
-
/**
|
|
4357
|
-
* Sets the parameters to the query based on
|
|
4358
|
-
* the active filters of the activated table
|
|
4359
|
-
* @param {ClientDataQueryable} query
|
|
4360
|
-
* @param params: The filters of the last query of the activated table
|
|
4361
|
-
* @return ClientDataQueryable
|
|
4362
|
-
*/
|
|
4363
|
-
BtnExpDirective.prototype.setParams = function (query, params) {
|
|
4364
|
-
if (params && typeof params === 'object') {
|
|
4365
|
-
Object.keys(params).forEach(function (key) {
|
|
4366
|
-
query.setParam(key, params[key]);
|
|
4367
|
-
});
|
|
4368
|
-
}
|
|
4369
|
-
return query;
|
|
4370
|
-
};
|
|
4371
|
-
/**
|
|
4372
|
-
* Sets the headers to the query based on
|
|
4373
|
-
* the default headers of the DataContext
|
|
4374
|
-
* and appending the accept header to get
|
|
4375
|
-
* an xlsx file from the API
|
|
4376
|
-
* @param {ClientDataQueryable} query
|
|
4377
|
-
* @param {Headers} headers: The headers to append to the query
|
|
4378
|
-
* @return ClientDataQueryable
|
|
4379
|
-
*/
|
|
4380
|
-
BtnExpDirective.prototype.setHeaders = function (query, headers) {
|
|
4381
|
-
Object.keys(headers).forEach(function (key) {
|
|
4382
|
-
if (headers.hasOwnProperty(key)) {
|
|
4383
|
-
query.getService().setHeader(key, headers[key]);
|
|
4384
|
-
}
|
|
4385
|
-
});
|
|
4386
|
-
// sets a header to accept xlsx files
|
|
4387
|
-
query.getService().setHeader('Accept', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
|
|
4388
|
-
return query;
|
|
4389
|
-
};
|
|
4390
|
-
/**
|
|
4391
|
-
* Constructs the select parameter of the
|
|
4392
|
-
* ClientDataQuery by replacing the target name
|
|
4393
|
-
* of the field based on the localized translation
|
|
4394
|
-
* of that property on the advanced tabled
|
|
4395
|
-
* @param {ClientDataQueryable} query
|
|
4396
|
-
* @param tableConfig: The configuration of the activated table
|
|
4397
|
-
* @return ClientDataQueryable
|
|
4398
|
-
*/
|
|
4399
|
-
BtnExpDirective.prototype.constructQueryParam = function (query, tableConfig) {
|
|
4400
|
-
var _this = this;
|
|
4401
|
-
var selectQuery = query.getParams().$select;
|
|
4402
|
-
var selectQueryArray = selectQuery.split(',');
|
|
4403
|
-
selectQueryArray = selectQueryArray.map(function (select) {
|
|
4404
|
-
var e_1, _a, e_2, _b;
|
|
4405
|
-
var words = select.split(' ');
|
|
4406
|
-
if (words.length === 3) {
|
|
4407
|
-
if (tableConfig && tableConfig.columns) {
|
|
4408
|
-
try {
|
|
4409
|
-
for (var _c = __values(tableConfig.columns), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
4410
|
-
var column = _d.value;
|
|
4411
|
-
if (column.property === words[2] && column.title) {
|
|
4412
|
-
words[2] = "\"" + _this._translate.instant(column.title) + "\"";
|
|
4413
|
-
}
|
|
4414
|
-
else if (column.property === words[2]) {
|
|
4415
|
-
words[2] = "\"" + _this._translate.instant(words[2]) + "\"";
|
|
4416
|
-
}
|
|
4417
|
-
}
|
|
4418
|
-
}
|
|
4419
|
-
catch (e_1_1) {
|
|
4420
|
-
e_1 = { error: e_1_1 };
|
|
4421
|
-
}
|
|
4422
|
-
finally {
|
|
4423
|
-
try {
|
|
4424
|
-
if (_d && !_d.done && (_a = _c.return))
|
|
4425
|
-
_a.call(_c);
|
|
4426
|
-
}
|
|
4427
|
-
finally {
|
|
4428
|
-
if (e_1)
|
|
4429
|
-
throw e_1.error;
|
|
4430
|
-
}
|
|
4431
|
-
}
|
|
4432
|
-
}
|
|
4433
|
-
}
|
|
4434
|
-
if (words.length === 1) {
|
|
4435
|
-
if (tableConfig && tableConfig.columns) {
|
|
4436
|
-
try {
|
|
4437
|
-
for (var _e = __values(tableConfig.columns), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
4438
|
-
var column = _f.value;
|
|
4439
|
-
if (column.name === words[0] && column.title) {
|
|
4440
|
-
words[0] = words[0] + " as \"" + _this._translate.instant(column.title) + "\"";
|
|
4441
|
-
break;
|
|
4442
|
-
}
|
|
4443
|
-
else if (column.name === words[0] && column.property) {
|
|
4444
|
-
words[0] = words[0] + " as \"" + _this._translate.instant(column.property) + "\"";
|
|
4445
|
-
break;
|
|
4446
|
-
}
|
|
4447
|
-
else if (words[0] === column.name && words[0] === "id" && column.hidden) {
|
|
4448
|
-
break;
|
|
4449
|
-
}
|
|
4450
|
-
else if (words[0] == column.name || words[0] === column.property) {
|
|
4451
|
-
words[0] = words[0] + " as \"" + _this._translate.instant(words[0]) + "\"";
|
|
4452
|
-
}
|
|
4453
|
-
}
|
|
4454
|
-
}
|
|
4455
|
-
catch (e_2_1) {
|
|
4456
|
-
e_2 = { error: e_2_1 };
|
|
4457
|
-
}
|
|
4458
|
-
finally {
|
|
4459
|
-
try {
|
|
4460
|
-
if (_f && !_f.done && (_b = _e.return))
|
|
4461
|
-
_b.call(_e);
|
|
4462
|
-
}
|
|
4463
|
-
finally {
|
|
4464
|
-
if (e_2)
|
|
4465
|
-
throw e_2.error;
|
|
4466
|
-
}
|
|
4467
|
-
}
|
|
4468
|
-
}
|
|
4469
|
-
return words[0];
|
|
4470
|
-
}
|
|
4471
|
-
return words.join(' ');
|
|
4472
|
-
});
|
|
4473
|
-
selectQuery = selectQueryArray.join(',');
|
|
4474
|
-
query.setParam('$select', selectQuery);
|
|
4475
|
-
return query;
|
|
4476
|
-
};
|
|
4477
|
-
/**
|
|
4478
|
-
* Constructs the fetch URL based the query parameters
|
|
4479
|
-
* @param {ClientDataQueryable} query
|
|
4480
|
-
* @return String
|
|
4481
|
-
*/
|
|
4482
|
-
BtnExpDirective.prototype.constructURL = function (query) {
|
|
4483
|
-
var baseURL = query.getService().getBase();
|
|
4484
|
-
var url = baseURL.endsWith('/') ? (baseURL + query.getModel() + '?') : (baseURL + '/' + query.getModel() + '?');
|
|
4485
|
-
Object.keys(query.getParams()).forEach(function (key, index) {
|
|
4486
|
-
if (index === 0) {
|
|
4487
|
-
url += key + '=' + query.getParams()[key];
|
|
4488
|
-
}
|
|
4489
|
-
else {
|
|
4490
|
-
url += '&' + key + '=' + query.getParams()[key];
|
|
4491
|
-
}
|
|
4492
|
-
});
|
|
4493
|
-
return url;
|
|
4494
|
-
};
|
|
4495
|
-
/**
|
|
4496
|
-
* Constructs the query by setting the parameters of the
|
|
4497
|
-
* advanced table's active filters, sets the necessary headers
|
|
4498
|
-
* and build the select parameter of the query
|
|
4499
|
-
* @param {ClientDataQueryable} query
|
|
4500
|
-
* @param params: The filters of the last query of the activated table
|
|
4501
|
-
* @param tableConfig: The configuration of the activated table
|
|
4502
|
-
* @param {Headers} headers: The headers to append to the query
|
|
4503
|
-
* @return ClientDataQueryable
|
|
4504
|
-
*/
|
|
4505
|
-
BtnExpDirective.prototype.constructQuery = function (query, params, tableConfig, headers) {
|
|
4506
|
-
var _query = this.setParams(query, params);
|
|
4507
|
-
_query = this.setHeaders(_query, headers);
|
|
4508
|
-
_query = this.constructQueryParam(_query, tableConfig);
|
|
4509
|
-
return _query;
|
|
4510
|
-
};
|
|
4511
|
-
/**
|
|
4512
|
-
* Fetches and saves the xlsx file
|
|
4513
|
-
* @param {String} url
|
|
4514
|
-
* @param {Headers} serviceHeaders: The headers to append to the query
|
|
4515
|
-
* @param modelName: The model name of the advanced table
|
|
4516
|
-
*/
|
|
4517
|
-
BtnExpDirective.prototype.downloadFile = function (url, serviceHeaders, modelName) {
|
|
4518
|
-
var _this = this;
|
|
4519
|
-
this._loadingService.showLoading();
|
|
4520
|
-
fetch(encodeURI(url), {
|
|
4521
|
-
headers: serviceHeaders,
|
|
4522
|
-
credentials: 'include'
|
|
4523
|
-
}).then(function (response) {
|
|
4524
|
-
if (response && !response.ok) {
|
|
4525
|
-
throw new client.ResponseError(response.statusText, response.status);
|
|
4526
|
-
}
|
|
4527
|
-
return response.blob();
|
|
4528
|
-
}).then(function (blob) {
|
|
4529
|
-
var objectUrl = window.URL.createObjectURL(blob);
|
|
4530
|
-
var a = document.createElement('a');
|
|
4531
|
-
document.body.appendChild(a);
|
|
4532
|
-
a.setAttribute('style', 'display: none');
|
|
4533
|
-
a.href = objectUrl;
|
|
4534
|
-
var downloadName = modelName + ".xlsx";
|
|
4535
|
-
a.download = downloadName;
|
|
4536
|
-
// this adds support for IE and MS Edge (up to version 44.19041)
|
|
4537
|
-
if (window.navigator && window.navigator.msSaveOrOpenBlob) {
|
|
4538
|
-
window.navigator.msSaveOrOpenBlob(blob, downloadName);
|
|
4539
|
-
}
|
|
4540
|
-
else {
|
|
4541
|
-
// for all other browsers
|
|
4542
|
-
a.click();
|
|
4543
|
-
}
|
|
4544
|
-
window.URL.revokeObjectURL(objectUrl);
|
|
4545
|
-
a.remove();
|
|
4546
|
-
_this._loadingService.hideLoading();
|
|
4547
|
-
}).catch(function (err) {
|
|
4548
|
-
_this._loadingService.hideLoading();
|
|
4549
|
-
_this._errorService.showError(err, {
|
|
4550
|
-
continueLink: '.'
|
|
4551
|
-
});
|
|
4552
|
-
});
|
|
4553
|
-
};
|
|
4554
|
-
BtnExpDirective.decorators = [
|
|
4555
|
-
{ type: i0.Directive, args: [{
|
|
4556
|
-
selector: '.universis-btn-export'
|
|
4557
|
-
},] }
|
|
4558
|
-
];
|
|
4559
|
-
/** @nocollapse */
|
|
4560
|
-
BtnExpDirective.ctorParameters = function () {
|
|
4561
|
-
return [
|
|
4562
|
-
{ type: ActivatedTableService },
|
|
4563
|
-
{ type: i1.AngularDataContext },
|
|
4564
|
-
{ type: i2.ConfigurationService },
|
|
4565
|
-
{ type: core.TranslateService },
|
|
4566
|
-
{ type: i2.LoadingService },
|
|
4567
|
-
{ type: i2.ErrorService }
|
|
4568
|
-
];
|
|
4569
|
-
};
|
|
4570
|
-
BtnExpDirective.propDecorators = {
|
|
4571
|
-
clickEvent: [{ type: i0.HostListener, args: ['click', ['$event'],] }]
|
|
4572
|
-
};
|
|
4573
|
-
return BtnExpDirective;
|
|
4574
|
-
}());
|
|
4575
|
-
|
|
4576
4740
|
var AdvancedAggregatorService = /** @class */ (function () {
|
|
4577
4741
|
function AdvancedAggregatorService(_context, _template) {
|
|
4578
4742
|
this._context = _context;
|
|
@@ -5157,6 +5321,8 @@
|
|
|
5157
5321
|
return ParseTitlePipe;
|
|
5158
5322
|
}());
|
|
5159
5323
|
|
|
5324
|
+
// tslint:disable: quotemark
|
|
5325
|
+
// tslint:disable: max-line-length
|
|
5160
5326
|
var TABLES_EL = {
|
|
5161
5327
|
"Tables": {
|
|
5162
5328
|
"Export": "Εξαγωγή",
|
|
@@ -5240,7 +5406,10 @@
|
|
|
5240
5406
|
"DataError": {
|
|
5241
5407
|
"Title": "Σφάλμα κατά την παραλαβή των δεδομένων",
|
|
5242
5408
|
"Message": "Συνέβη σφάλμα κατά την παραλαβή των δεδομένων. Προσπαθήστε ξανά ή τροποποιήστε τα στοιχεία αναζήτησης."
|
|
5243
|
-
}
|
|
5409
|
+
},
|
|
5410
|
+
"ExportList": "Εξαγωγή λίστας",
|
|
5411
|
+
"ExportLimitExceeded": "Το πλήθος των στοιχείων προς εξαγωγή ({{dataLength}}) ξεπερνάει το μέγιστο επιτρεπτό ({{exportLimit}}). Παρακαλούμε προσαρμόστε τα φίλτρα της αναζήτησης και προσπαθήστε ξανά.",
|
|
5412
|
+
"ExportResults": "Δεδομένα λίστας"
|
|
5244
5413
|
},
|
|
5245
5414
|
"TrueFalse": {
|
|
5246
5415
|
"long": {
|
|
@@ -5281,6 +5450,8 @@
|
|
|
5281
5450
|
}
|
|
5282
5451
|
};
|
|
5283
5452
|
|
|
5453
|
+
// tslint:disable: quotemark
|
|
5454
|
+
// tslint:disable: max-line-length
|
|
5284
5455
|
var TABLES_EN = {
|
|
5285
5456
|
"Tables": {
|
|
5286
5457
|
"Export": "Export",
|
|
@@ -5363,7 +5534,10 @@
|
|
|
5363
5534
|
"DataError": {
|
|
5364
5535
|
"Title": "Error while getting data",
|
|
5365
5536
|
"Message": "An error occurred while getting data. Please try again or change your criteria."
|
|
5366
|
-
}
|
|
5537
|
+
},
|
|
5538
|
+
"ExportList": "Export list",
|
|
5539
|
+
"ExportLimitExceeded": "The number of items that are to be exported ({{dataLength}}) exceeds the export limit ({{exportLimit}}). Please apply more specific filters to the search.",
|
|
5540
|
+
"ExportResults": "Exported list"
|
|
5367
5541
|
},
|
|
5368
5542
|
"TrueFalse": {
|
|
5369
5543
|
"long": {
|
|
@@ -5829,6 +6003,7 @@
|
|
|
5829
6003
|
exports.NgClassFormatter = NgClassFormatter;
|
|
5830
6004
|
exports.LanguageFormatter = LanguageFormatter;
|
|
5831
6005
|
exports.COLUMN_FORMATTERS = COLUMN_FORMATTERS;
|
|
6006
|
+
exports.ExportLimitExceededError = ExportLimitExceededError;
|
|
5832
6007
|
exports.AdvancedTableConfiguration = AdvancedTableConfiguration;
|
|
5833
6008
|
exports.AdvancedTableComponent = AdvancedTableComponent;
|
|
5834
6009
|
exports.ɵ0 = ɵ0;
|
|
@@ -5843,6 +6018,7 @@
|
|
|
5843
6018
|
exports.TableSimpleHeaderComponent = TableSimpleHeaderComponent;
|
|
5844
6019
|
exports.AdvancedTableNotNullError = AdvancedTableNotNullError;
|
|
5845
6020
|
exports.AdvancedTableEditorDirective = AdvancedTableEditorDirective;
|
|
6021
|
+
exports.MAX_EXPORT_ITEMS = MAX_EXPORT_ITEMS;
|
|
5846
6022
|
exports.BtnExpDirective = BtnExpDirective;
|
|
5847
6023
|
exports.AdvancedAggregatorComponent = AdvancedAggregatorComponent;
|
|
5848
6024
|
exports.AdvancedAggregatorListComponent = AdvancedAggregatorListComponent;
|