@yomotech/view-toolkit 0.0.79 → 0.0.81
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.
|
@@ -1035,9 +1035,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.2", ngImpor
|
|
|
1035
1035
|
|
|
1036
1036
|
class Couchdb {
|
|
1037
1037
|
utilityService;
|
|
1038
|
+
platform;
|
|
1038
1039
|
couchDbBaseUrl = 'https://couchdb.yomotech.de';
|
|
1039
|
-
constructor(utilityService) {
|
|
1040
|
+
constructor(utilityService, platform) {
|
|
1040
1041
|
this.utilityService = utilityService;
|
|
1042
|
+
this.platform = platform;
|
|
1041
1043
|
}
|
|
1042
1044
|
async getTenantDatabases(tenantKey) {
|
|
1043
1045
|
if (!tenantKey || !tenantKey.trim()) {
|
|
@@ -1051,9 +1053,11 @@ class Couchdb {
|
|
|
1051
1053
|
},
|
|
1052
1054
|
});
|
|
1053
1055
|
const data = await this.parseJsonOrText(response);
|
|
1054
|
-
if (!response.ok) {
|
|
1055
|
-
|
|
1056
|
-
}
|
|
1056
|
+
// if (!response.ok) {
|
|
1057
|
+
// throw new Error(
|
|
1058
|
+
// `GET /tenant-dbs -> ${response.status} ${this.stringifyErrorDetails(data)}`
|
|
1059
|
+
// );
|
|
1060
|
+
// }
|
|
1057
1061
|
return data;
|
|
1058
1062
|
}
|
|
1059
1063
|
async parseJsonOrText(response) {
|
|
@@ -1217,25 +1221,27 @@ class Couchdb {
|
|
|
1217
1221
|
};
|
|
1218
1222
|
}
|
|
1219
1223
|
async buildTenantHeaders() {
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
throw new Error('Missing tenantKey');
|
|
1226
|
-
}
|
|
1227
|
-
return {
|
|
1228
|
-
'X-Tenant-Key': tenantKey.trim(),
|
|
1229
|
-
};
|
|
1224
|
+
let tenantKey = "";
|
|
1225
|
+
let tenantName = "";
|
|
1226
|
+
if (this.platform.ANDROID || this.platform.IOS) {
|
|
1227
|
+
tenantKey = await this.utilityService.getLocalStorage('tenantKey');
|
|
1228
|
+
tenantName = await this.utilityService.getLocalStorage('tenantName');
|
|
1230
1229
|
}
|
|
1231
1230
|
else {
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
};
|
|
1231
|
+
tenantKey = await this.utilityService.getStorage('tenantKey');
|
|
1232
|
+
tenantName = await this.utilityService.getStorage('tenantName');
|
|
1233
|
+
}
|
|
1234
|
+
const selectedTenant = await this.utilityService.getLocalStorage('selectedTenant');
|
|
1235
|
+
if (typeof tenantKey === 'string' && tenantKey.trim()) {
|
|
1236
|
+
return { 'X-Tenant-Key': tenantKey.trim() };
|
|
1237
|
+
}
|
|
1238
|
+
const normalizedTenantName = typeof tenantName === 'string' ? tenantName.trim() : '';
|
|
1239
|
+
const normalizedSelectedTenant = typeof selectedTenant === 'string' ? selectedTenant.trim() : '';
|
|
1240
|
+
const tenant = normalizedTenantName || normalizedSelectedTenant;
|
|
1241
|
+
if (!tenant) {
|
|
1242
|
+
throw new Error('Missing tenantKey, tenantName, ' + 'or selectedTenant');
|
|
1238
1243
|
}
|
|
1244
|
+
return { 'X-Tenant': tenant, };
|
|
1239
1245
|
}
|
|
1240
1246
|
async getImageSrcFromCouchDb(couchDbName, filePath) {
|
|
1241
1247
|
const dbName = couchDbName?.toLowerCase();
|
|
@@ -1257,7 +1263,7 @@ class Couchdb {
|
|
|
1257
1263
|
const mimeType = doc.contentType || 'image/png';
|
|
1258
1264
|
return `data:${mimeType};base64,${doc.data}`;
|
|
1259
1265
|
}
|
|
1260
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.2", ngImport: i0, type: Couchdb, deps: [{ token: UtilityService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1266
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.2", ngImport: i0, type: Couchdb, deps: [{ token: UtilityService }, { token: i1.Platform }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1261
1267
|
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.2", ngImport: i0, type: Couchdb, providedIn: 'root' });
|
|
1262
1268
|
}
|
|
1263
1269
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.2", ngImport: i0, type: Couchdb, decorators: [{
|
|
@@ -1265,7 +1271,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.2", ngImpor
|
|
|
1265
1271
|
args: [{
|
|
1266
1272
|
providedIn: 'root',
|
|
1267
1273
|
}]
|
|
1268
|
-
}], ctorParameters: () => [{ type: UtilityService }] });
|
|
1274
|
+
}], ctorParameters: () => [{ type: UtilityService }, { type: i1.Platform }] });
|
|
1269
1275
|
|
|
1270
1276
|
class ConfigService {
|
|
1271
1277
|
couchdbService;
|