coer-elements 0.0.32 → 0.0.34

Sign up to get free protection for your applications and to get access to all the features.
@@ -1104,173 +1104,333 @@ class Service {
1104
1104
  subscription.unsubscribe();
1105
1105
  }
1106
1106
  /** HTTP GET */
1107
- HTTP_GET(request) {
1107
+ HTTP_GET(request, cancelPrevious = true) {
1108
1108
  return new Promise(Resolve => {
1109
- this.ReleaseSubscription(this._GET$);
1110
- this._GET$ = this.http.request(new HttpRequest("GET", request.url, { params: request.queryParams, headers: request.headers })).subscribe({
1111
- next: (response) => {
1112
- if (response.type > 0) {
1109
+ if (cancelPrevious) {
1110
+ this.ReleaseSubscription(this._GET$);
1111
+ this._GET$ = this.http.request(new HttpRequest("GET", request.url, { params: request.queryParams, headers: request.headers })).subscribe({
1112
+ next: (response) => {
1113
+ if (response.type > 0) {
1114
+ Resolve({
1115
+ body: Tools.BreakReference(response.body),
1116
+ status: response.status,
1117
+ message: response.statusText,
1118
+ ok: true
1119
+ });
1120
+ }
1121
+ },
1122
+ error: (httpError) => {
1123
+ this.ReleaseSubscription(this._GET$);
1124
+ this.AlertError(httpError, request.alertError);
1113
1125
  Resolve({
1114
- body: Tools.BreakReference(response.body),
1115
- status: response.status,
1116
- message: response.statusText,
1117
- ok: true
1126
+ body: {},
1127
+ status: httpError.status,
1128
+ message: httpError.error?.message || httpError.error,
1129
+ ok: false
1118
1130
  });
1131
+ },
1132
+ complete: () => {
1133
+ this.ReleaseSubscription(this._GET$);
1134
+ if (Tools.IsNotOnlyWhiteSpace(request.alertSuccess)) {
1135
+ this.alert.Success(request.alertSuccess);
1136
+ }
1119
1137
  }
1120
- },
1121
- error: (httpError) => {
1122
- this.ReleaseSubscription(this._GET$);
1123
- this.AlertError(httpError, request.alertError);
1124
- Resolve({
1125
- body: {},
1126
- status: httpError.status,
1127
- message: httpError.error?.message || httpError.error,
1128
- ok: false
1129
- });
1130
- },
1131
- complete: () => {
1132
- this.ReleaseSubscription(this._GET$);
1133
- if (Tools.IsNotOnlyWhiteSpace(request.alertSuccess)) {
1134
- this.alert.Success(request.alertSuccess);
1138
+ });
1139
+ }
1140
+ else {
1141
+ const subscription = this.http.request(new HttpRequest("GET", request.url, { params: request.queryParams, headers: request.headers })).subscribe({
1142
+ next: (response) => {
1143
+ if (response.type > 0) {
1144
+ Resolve({
1145
+ body: Tools.BreakReference(response.body),
1146
+ status: response.status,
1147
+ message: response.statusText,
1148
+ ok: true
1149
+ });
1150
+ }
1151
+ },
1152
+ error: (httpError) => {
1153
+ this.ReleaseSubscription(subscription);
1154
+ this.AlertError(httpError, request.alertError);
1155
+ Resolve({
1156
+ body: {},
1157
+ status: httpError.status,
1158
+ message: httpError.error?.message || httpError.error,
1159
+ ok: false
1160
+ });
1161
+ },
1162
+ complete: () => {
1163
+ this.ReleaseSubscription(subscription);
1164
+ if (Tools.IsNotOnlyWhiteSpace(request.alertSuccess)) {
1165
+ this.alert.Success(request.alertSuccess);
1166
+ }
1135
1167
  }
1136
- }
1137
- });
1168
+ });
1169
+ }
1138
1170
  });
1139
1171
  }
1140
1172
  /** HTTP POST */
1141
- HTTP_POST(request) {
1173
+ HTTP_POST(request, cancelPrevious = true) {
1142
1174
  return new Promise(Resolve => {
1143
- this.ReleaseSubscription(this._POST$);
1144
- this._POST$ = this.http.request(new HttpRequest("POST", request.url, request.body, { params: request.queryParams, headers: request.headers })).subscribe({
1145
- next: (response) => {
1146
- if (response.type > 0) {
1175
+ if (cancelPrevious) {
1176
+ this.ReleaseSubscription(this._POST$);
1177
+ this._POST$ = this.http.request(new HttpRequest("POST", request.url, request.body, { params: request.queryParams, headers: request.headers })).subscribe({
1178
+ next: (response) => {
1179
+ if (response.type > 0) {
1180
+ Resolve({
1181
+ body: Tools.BreakReference(response.body),
1182
+ status: response.status,
1183
+ message: response.statusText,
1184
+ ok: true
1185
+ });
1186
+ }
1187
+ },
1188
+ error: (httpError) => {
1189
+ this.ReleaseSubscription(this._POST$);
1190
+ this.AlertError(httpError, request.alertError);
1147
1191
  Resolve({
1148
- body: Tools.BreakReference(response.body),
1149
- status: response.status,
1150
- message: response.statusText,
1151
- ok: true
1192
+ body: {},
1193
+ status: httpError.status,
1194
+ message: httpError.error?.message || httpError.error,
1195
+ ok: false
1152
1196
  });
1197
+ },
1198
+ complete: () => {
1199
+ this.ReleaseSubscription(this._POST$);
1200
+ if (Tools.IsNotOnlyWhiteSpace(request.alertSuccess)) {
1201
+ this.alert.Success(request.alertSuccess);
1202
+ }
1153
1203
  }
1154
- },
1155
- error: (httpError) => {
1156
- this.ReleaseSubscription(this._POST$);
1157
- this.AlertError(httpError, request.alertError);
1158
- Resolve({
1159
- body: {},
1160
- status: httpError.status,
1161
- message: httpError.error?.message || httpError.error,
1162
- ok: false
1163
- });
1164
- },
1165
- complete: () => {
1166
- this.ReleaseSubscription(this._POST$);
1167
- if (Tools.IsNotOnlyWhiteSpace(request.alertSuccess)) {
1168
- this.alert.Success(request.alertSuccess);
1204
+ });
1205
+ }
1206
+ else {
1207
+ const subscription = this.http.request(new HttpRequest("POST", request.url, request.body, { params: request.queryParams, headers: request.headers })).subscribe({
1208
+ next: (response) => {
1209
+ if (response.type > 0) {
1210
+ Resolve({
1211
+ body: Tools.BreakReference(response.body),
1212
+ status: response.status,
1213
+ message: response.statusText,
1214
+ ok: true
1215
+ });
1216
+ }
1217
+ },
1218
+ error: (httpError) => {
1219
+ this.ReleaseSubscription(subscription);
1220
+ this.AlertError(httpError, request.alertError);
1221
+ Resolve({
1222
+ body: {},
1223
+ status: httpError.status,
1224
+ message: httpError.error?.message || httpError.error,
1225
+ ok: false
1226
+ });
1227
+ },
1228
+ complete: () => {
1229
+ this.ReleaseSubscription(subscription);
1230
+ if (Tools.IsNotOnlyWhiteSpace(request.alertSuccess)) {
1231
+ this.alert.Success(request.alertSuccess);
1232
+ }
1169
1233
  }
1170
- }
1171
- });
1234
+ });
1235
+ }
1172
1236
  });
1173
1237
  }
1174
1238
  /** HTTP PUT */
1175
- HTTP_PUT(request) {
1239
+ HTTP_PUT(request, cancelPrevious = true) {
1176
1240
  return new Promise(Resolve => {
1177
- this.ReleaseSubscription(this._PUT$);
1178
- this._PUT$ = this.http.request(new HttpRequest("PUT", request.url, request.body, { params: request.queryParams, headers: request.headers })).subscribe({
1179
- next: (response) => {
1180
- if (response.type > 0) {
1241
+ if (cancelPrevious) {
1242
+ this.ReleaseSubscription(this._PUT$);
1243
+ this._PUT$ = this.http.request(new HttpRequest("PUT", request.url, request.body, { params: request.queryParams, headers: request.headers })).subscribe({
1244
+ next: (response) => {
1245
+ if (response.type > 0) {
1246
+ Resolve({
1247
+ body: {},
1248
+ status: response.status,
1249
+ message: response.statusText,
1250
+ ok: true
1251
+ });
1252
+ }
1253
+ },
1254
+ error: (httpError) => {
1255
+ this.ReleaseSubscription(this._PUT$);
1256
+ this.AlertError(httpError, request.alertError);
1181
1257
  Resolve({
1182
1258
  body: {},
1183
- status: response.status,
1184
- message: response.statusText,
1185
- ok: true
1259
+ status: httpError.status,
1260
+ message: httpError.error?.message || httpError.error,
1261
+ ok: false
1186
1262
  });
1263
+ },
1264
+ complete: () => {
1265
+ this.ReleaseSubscription(this._PUT$);
1266
+ if (Tools.IsNotOnlyWhiteSpace(request.alertSuccess)) {
1267
+ this.alert.Success(request.alertSuccess, 'Updated', 'fa-solid fa-arrows-rotate fa-spin');
1268
+ }
1187
1269
  }
1188
- },
1189
- error: (httpError) => {
1190
- this.ReleaseSubscription(this._PUT$);
1191
- this.AlertError(httpError, request.alertError);
1192
- Resolve({
1193
- body: {},
1194
- status: httpError.status,
1195
- message: httpError.error?.message || httpError.error,
1196
- ok: false
1197
- });
1198
- },
1199
- complete: () => {
1200
- this.ReleaseSubscription(this._PUT$);
1201
- if (Tools.IsNotOnlyWhiteSpace(request.alertSuccess)) {
1202
- this.alert.Success(request.alertSuccess, 'Updated', 'fa-solid fa-arrows-rotate fa-spin');
1270
+ });
1271
+ }
1272
+ else {
1273
+ const subscription = this.http.request(new HttpRequest("PUT", request.url, request.body, { params: request.queryParams, headers: request.headers })).subscribe({
1274
+ next: (response) => {
1275
+ if (response.type > 0) {
1276
+ Resolve({
1277
+ body: {},
1278
+ status: response.status,
1279
+ message: response.statusText,
1280
+ ok: true
1281
+ });
1282
+ }
1283
+ },
1284
+ error: (httpError) => {
1285
+ this.ReleaseSubscription(subscription);
1286
+ this.AlertError(httpError, request.alertError);
1287
+ Resolve({
1288
+ body: {},
1289
+ status: httpError.status,
1290
+ message: httpError.error?.message || httpError.error,
1291
+ ok: false
1292
+ });
1293
+ },
1294
+ complete: () => {
1295
+ this.ReleaseSubscription(subscription);
1296
+ if (Tools.IsNotOnlyWhiteSpace(request.alertSuccess)) {
1297
+ this.alert.Success(request.alertSuccess, 'Updated', 'fa-solid fa-arrows-rotate fa-spin');
1298
+ }
1203
1299
  }
1204
- }
1205
- });
1300
+ });
1301
+ }
1206
1302
  });
1207
1303
  }
1208
1304
  /** HTTP PATCH */
1209
- HTTP_PATCH(request) {
1305
+ HTTP_PATCH(request, cancelPrevious = true) {
1210
1306
  return new Promise(Resolve => {
1211
- this.ReleaseSubscription(this._PATCH$);
1212
- this._PATCH$ = this.http.request(new HttpRequest("PATCH", request.url, request.body, { params: request.queryParams, headers: request.headers })).subscribe({
1213
- next: (response) => {
1214
- if (response.type > 0) {
1307
+ if (cancelPrevious) {
1308
+ this.ReleaseSubscription(this._PATCH$);
1309
+ this._PATCH$ = this.http.request(new HttpRequest("PATCH", request.url, request.body, { params: request.queryParams, headers: request.headers })).subscribe({
1310
+ next: (response) => {
1311
+ if (response.type > 0) {
1312
+ Resolve({
1313
+ body: {},
1314
+ status: response.status,
1315
+ message: response.statusText,
1316
+ ok: true
1317
+ });
1318
+ }
1319
+ },
1320
+ error: (httpError) => {
1321
+ this.ReleaseSubscription(this._PATCH$);
1322
+ this.AlertError(httpError, request.alertError);
1215
1323
  Resolve({
1216
1324
  body: {},
1217
- status: response.status,
1218
- message: response.statusText,
1219
- ok: true
1325
+ status: httpError.status,
1326
+ message: httpError.error?.message || httpError.error,
1327
+ ok: false
1220
1328
  });
1329
+ },
1330
+ complete: () => {
1331
+ this.ReleaseSubscription(this._PATCH$);
1332
+ if (Tools.IsNotOnlyWhiteSpace(request.alertSuccess)) {
1333
+ this.alert.Success(request.alertSuccess, 'Updated', 'fa-solid fa-arrows-rotate fa-spin');
1334
+ }
1221
1335
  }
1222
- },
1223
- error: (httpError) => {
1224
- this.ReleaseSubscription(this._PATCH$);
1225
- this.AlertError(httpError, request.alertError);
1226
- Resolve({
1227
- body: {},
1228
- status: httpError.status,
1229
- message: httpError.error?.message || httpError.error,
1230
- ok: false
1231
- });
1232
- },
1233
- complete: () => {
1234
- this.ReleaseSubscription(this._PATCH$);
1235
- if (Tools.IsNotOnlyWhiteSpace(request.alertSuccess)) {
1236
- this.alert.Success(request.alertSuccess, 'Updated', 'fa-solid fa-arrows-rotate fa-spin');
1336
+ });
1337
+ }
1338
+ else {
1339
+ const subscription = this.http.request(new HttpRequest("PATCH", request.url, request.body, { params: request.queryParams, headers: request.headers })).subscribe({
1340
+ next: (response) => {
1341
+ if (response.type > 0) {
1342
+ Resolve({
1343
+ body: {},
1344
+ status: response.status,
1345
+ message: response.statusText,
1346
+ ok: true
1347
+ });
1348
+ }
1349
+ },
1350
+ error: (httpError) => {
1351
+ this.ReleaseSubscription(subscription);
1352
+ this.AlertError(httpError, request.alertError);
1353
+ Resolve({
1354
+ body: {},
1355
+ status: httpError.status,
1356
+ message: httpError.error?.message || httpError.error,
1357
+ ok: false
1358
+ });
1359
+ },
1360
+ complete: () => {
1361
+ this.ReleaseSubscription(subscription);
1362
+ if (Tools.IsNotOnlyWhiteSpace(request.alertSuccess)) {
1363
+ this.alert.Success(request.alertSuccess, 'Updated', 'fa-solid fa-arrows-rotate fa-spin');
1364
+ }
1237
1365
  }
1238
- }
1239
- });
1366
+ });
1367
+ }
1240
1368
  });
1241
1369
  }
1242
1370
  /** HTTP DELETE */
1243
- HTTP_DELETE(request) {
1371
+ HTTP_DELETE(request, cancelPrevious = true) {
1244
1372
  return new Promise(Resolve => {
1245
- this.ReleaseSubscription(this._DELETE$);
1246
- this._DELETE$ = this.http.request(new HttpRequest("DELETE", request.url, { params: request.queryParams, headers: request.headers })).subscribe({
1247
- next: (response) => {
1248
- if (response.type > 0) {
1373
+ if (cancelPrevious) {
1374
+ this.ReleaseSubscription(this._DELETE$);
1375
+ this._DELETE$ = this.http.request(new HttpRequest("DELETE", request.url, { params: request.queryParams, headers: request.headers })).subscribe({
1376
+ next: (response) => {
1377
+ if (response.type > 0) {
1378
+ Resolve({
1379
+ body: {},
1380
+ status: response.status,
1381
+ message: response.statusText,
1382
+ ok: true
1383
+ });
1384
+ }
1385
+ },
1386
+ error: (httpError) => {
1387
+ this.ReleaseSubscription(this._DELETE$);
1388
+ this.AlertError(httpError, request.alertError);
1249
1389
  Resolve({
1250
1390
  body: {},
1251
- status: response.status,
1252
- message: response.statusText,
1253
- ok: true
1391
+ status: httpError.status,
1392
+ message: httpError.error?.message || httpError.error,
1393
+ ok: false
1254
1394
  });
1395
+ },
1396
+ complete: () => {
1397
+ this.ReleaseSubscription(this._DELETE$);
1398
+ if (Tools.IsNotOnlyWhiteSpace(request.alertSuccess)) {
1399
+ this.alert.Success(request.alertSuccess, 'Deleted', 'fa-regular fa-trash-can');
1400
+ }
1255
1401
  }
1256
- },
1257
- error: (httpError) => {
1258
- this.ReleaseSubscription(this._DELETE$);
1259
- this.AlertError(httpError, request.alertError);
1260
- Resolve({
1261
- body: {},
1262
- status: httpError.status,
1263
- message: httpError.error?.message || httpError.error,
1264
- ok: false
1265
- });
1266
- },
1267
- complete: () => {
1268
- this.ReleaseSubscription(this._DELETE$);
1269
- if (Tools.IsNotOnlyWhiteSpace(request.alertSuccess)) {
1270
- this.alert.Success(request.alertSuccess, 'Deleted', 'fa-regular fa-trash-can');
1402
+ });
1403
+ }
1404
+ else {
1405
+ const subscription = this.http.request(new HttpRequest("DELETE", request.url, { params: request.queryParams, headers: request.headers })).subscribe({
1406
+ next: (response) => {
1407
+ if (response.type > 0) {
1408
+ Resolve({
1409
+ body: {},
1410
+ status: response.status,
1411
+ message: response.statusText,
1412
+ ok: true
1413
+ });
1414
+ }
1415
+ },
1416
+ error: (httpError) => {
1417
+ this.ReleaseSubscription(subscription);
1418
+ this.AlertError(httpError, request.alertError);
1419
+ Resolve({
1420
+ body: {},
1421
+ status: httpError.status,
1422
+ message: httpError.error?.message || httpError.error,
1423
+ ok: false
1424
+ });
1425
+ },
1426
+ complete: () => {
1427
+ this.ReleaseSubscription(subscription);
1428
+ if (Tools.IsNotOnlyWhiteSpace(request.alertSuccess)) {
1429
+ this.alert.Success(request.alertSuccess, 'Deleted', 'fa-regular fa-trash-can');
1430
+ }
1271
1431
  }
1272
- }
1273
- });
1432
+ });
1433
+ }
1274
1434
  });
1275
1435
  }
1276
1436
  /** */