ng-configcat-publicapi-ui 2.12.0 → 2.13.0
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/esm2020/lib/_services/index.mjs +2 -1
- package/fesm2015/ng-configcat-publicapi-ui.mjs +62 -62
- package/fesm2015/ng-configcat-publicapi-ui.mjs.map +1 -1
- package/fesm2020/ng-configcat-publicapi-ui.mjs +61 -61
- package/fesm2020/ng-configcat-publicapi-ui.mjs.map +1 -1
- package/lib/_services/index.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
export * from './public-api.service';
|
|
2
|
-
|
|
2
|
+
export * from './form-helper';
|
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi9wcm9qZWN0cy9uZy1jb25maWdjYXQtcHVibGljYXBpLXVpL3NyYy9saWIvX3NlcnZpY2VzL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLGNBQWMsc0JBQXNCLENBQUM7QUFDckMsY0FBYyxlQUFlLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyJleHBvcnQgKiBmcm9tICcuL3B1YmxpYy1hcGkuc2VydmljZSc7XG5leHBvcnQgKiBmcm9tICcuL2Zvcm0taGVscGVyJztcbiJdfQ==
|
|
@@ -170,6 +170,67 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.1", ngImpor
|
|
|
170
170
|
type: Input
|
|
171
171
|
}] } });
|
|
172
172
|
|
|
173
|
+
class FormHelper {
|
|
174
|
+
static getErrorMessage(control, hint = '') {
|
|
175
|
+
if (!control || control.valid) {
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
if (control.hasError('required')) {
|
|
179
|
+
return `${hint} The field is required.`;
|
|
180
|
+
}
|
|
181
|
+
if (control.hasError('pattern')) {
|
|
182
|
+
return 'Not a valid e-mail address.';
|
|
183
|
+
}
|
|
184
|
+
if (control.hasError('minlength')) {
|
|
185
|
+
return 'The field must be at least ' + control.getError('minlength').requiredLength + ' characters long';
|
|
186
|
+
}
|
|
187
|
+
if (control.hasError('maxlength')) {
|
|
188
|
+
return 'The field must be at max ' + control.getError('maxlength').requiredLength + ' characters long';
|
|
189
|
+
}
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
static handleErrors(formGroup, error) {
|
|
193
|
+
var _a, _b, _c, _d, _e, _f;
|
|
194
|
+
if (error instanceof HttpErrorResponse) {
|
|
195
|
+
const response = error;
|
|
196
|
+
switch (response.status) {
|
|
197
|
+
case 400:
|
|
198
|
+
let unknownFieldName = false;
|
|
199
|
+
for (const fieldName in error.error) {
|
|
200
|
+
if (error.error.hasOwnProperty(fieldName) && error.error[fieldName] &&
|
|
201
|
+
(((_a = error.error[fieldName]) === null || _a === void 0 ? void 0 : _a.length) > 0 || ((_c = (_b = error.error[fieldName]) === null || _b === void 0 ? void 0 : _b.Errors) === null || _c === void 0 ? void 0 : _c.length) > 0)) {
|
|
202
|
+
let jsonFieldName = fieldName;
|
|
203
|
+
if (jsonFieldName.length > 0) {
|
|
204
|
+
jsonFieldName = jsonFieldName[0].toLowerCase() + jsonFieldName.slice(1);
|
|
205
|
+
}
|
|
206
|
+
const errorMessage = ((_e = (_d = error.error[fieldName]) === null || _d === void 0 ? void 0 : _d.Errors) === null || _e === void 0 ? void 0 : _e.length) > 0 ?
|
|
207
|
+
((_f = error.error[fieldName]) === null || _f === void 0 ? void 0 : _f.Errors.map((e) => e.ErrorMessage)).join(', ')
|
|
208
|
+
: error.error[fieldName];
|
|
209
|
+
if (formGroup.controls.hasOwnProperty(jsonFieldName)) {
|
|
210
|
+
formGroup.controls[jsonFieldName].setErrors({ serverSide: errorMessage });
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
213
|
+
unknownFieldName = true;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
if (unknownFieldName) {
|
|
218
|
+
formGroup.setErrors({ serverSide: 'Something went wrong.' });
|
|
219
|
+
}
|
|
220
|
+
break;
|
|
221
|
+
// in these cases we do not show errors on the form, they're handled by the http
|
|
222
|
+
// interceptor in src\app\_interceptors\httpstatuscode.interceptor.ts
|
|
223
|
+
case 402:
|
|
224
|
+
case 429:
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
else {
|
|
229
|
+
formGroup.setErrors({ serverSide: 'Something went wrong on our side. This is not your fault. Please try again.' });
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
173
234
|
class ReasonDialogComponent {
|
|
174
235
|
constructor(dialogRef, formBuilder) {
|
|
175
236
|
this.dialogRef = dialogRef;
|
|
@@ -1405,67 +1466,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.1", ngImpor
|
|
|
1405
1466
|
type: Input
|
|
1406
1467
|
}] } });
|
|
1407
1468
|
|
|
1408
|
-
class FormHelper {
|
|
1409
|
-
static getErrorMessage(control, hint = '') {
|
|
1410
|
-
if (!control || control.valid) {
|
|
1411
|
-
return;
|
|
1412
|
-
}
|
|
1413
|
-
if (control.hasError('required')) {
|
|
1414
|
-
return `${hint} The field is required.`;
|
|
1415
|
-
}
|
|
1416
|
-
if (control.hasError('pattern')) {
|
|
1417
|
-
return 'Not a valid e-mail address.';
|
|
1418
|
-
}
|
|
1419
|
-
if (control.hasError('minlength')) {
|
|
1420
|
-
return 'The field must be at least ' + control.getError('minlength').requiredLength + ' characters long';
|
|
1421
|
-
}
|
|
1422
|
-
if (control.hasError('maxlength')) {
|
|
1423
|
-
return 'The field must be at max ' + control.getError('maxlength').requiredLength + ' characters long';
|
|
1424
|
-
}
|
|
1425
|
-
return;
|
|
1426
|
-
}
|
|
1427
|
-
static handleErrors(formGroup, error) {
|
|
1428
|
-
var _a, _b, _c, _d, _e, _f;
|
|
1429
|
-
if (error instanceof HttpErrorResponse) {
|
|
1430
|
-
const response = error;
|
|
1431
|
-
switch (response.status) {
|
|
1432
|
-
case 400:
|
|
1433
|
-
let unknownFieldName = false;
|
|
1434
|
-
for (const fieldName in error.error) {
|
|
1435
|
-
if (error.error.hasOwnProperty(fieldName) && error.error[fieldName] &&
|
|
1436
|
-
(((_a = error.error[fieldName]) === null || _a === void 0 ? void 0 : _a.length) > 0 || ((_c = (_b = error.error[fieldName]) === null || _b === void 0 ? void 0 : _b.Errors) === null || _c === void 0 ? void 0 : _c.length) > 0)) {
|
|
1437
|
-
let jsonFieldName = fieldName;
|
|
1438
|
-
if (jsonFieldName.length > 0) {
|
|
1439
|
-
jsonFieldName = jsonFieldName[0].toLowerCase() + jsonFieldName.slice(1);
|
|
1440
|
-
}
|
|
1441
|
-
const errorMessage = ((_e = (_d = error.error[fieldName]) === null || _d === void 0 ? void 0 : _d.Errors) === null || _e === void 0 ? void 0 : _e.length) > 0 ?
|
|
1442
|
-
((_f = error.error[fieldName]) === null || _f === void 0 ? void 0 : _f.Errors.map((e) => e.ErrorMessage)).join(', ')
|
|
1443
|
-
: error.error[fieldName];
|
|
1444
|
-
if (formGroup.controls.hasOwnProperty(jsonFieldName)) {
|
|
1445
|
-
formGroup.controls[jsonFieldName].setErrors({ serverSide: errorMessage });
|
|
1446
|
-
}
|
|
1447
|
-
else {
|
|
1448
|
-
unknownFieldName = true;
|
|
1449
|
-
}
|
|
1450
|
-
}
|
|
1451
|
-
}
|
|
1452
|
-
if (unknownFieldName) {
|
|
1453
|
-
formGroup.setErrors({ serverSide: 'Something went wrong.' });
|
|
1454
|
-
}
|
|
1455
|
-
break;
|
|
1456
|
-
// in these cases we do not show errors on the form, they're handled by the http
|
|
1457
|
-
// interceptor in src\app\_interceptors\httpstatuscode.interceptor.ts
|
|
1458
|
-
case 402:
|
|
1459
|
-
case 429:
|
|
1460
|
-
return;
|
|
1461
|
-
}
|
|
1462
|
-
}
|
|
1463
|
-
else {
|
|
1464
|
-
formGroup.setErrors({ serverSide: 'Something went wrong on our side. This is not your fault. Please try again.' });
|
|
1465
|
-
}
|
|
1466
|
-
}
|
|
1467
|
-
}
|
|
1468
|
-
|
|
1469
1469
|
class AuthorizationComponent {
|
|
1470
1470
|
constructor(formBuilder, publicApiService) {
|
|
1471
1471
|
this.formBuilder = formBuilder;
|
|
@@ -1643,5 +1643,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.1", ngImpor
|
|
|
1643
1643
|
* Generated bundle index. Do not edit.
|
|
1644
1644
|
*/
|
|
1645
1645
|
|
|
1646
|
-
export { AuthorizationComponent, ConfigSelectComponent, EnvironmentSelectComponent, NgConfigCatPublicApiUIModule, ProductSelectComponent, PublicApiService, SettingItemComponent, SettingSelectComponent };
|
|
1646
|
+
export { AuthorizationComponent, ConfigSelectComponent, EnvironmentSelectComponent, FormHelper, NgConfigCatPublicApiUIModule, ProductSelectComponent, PublicApiService, SettingItemComponent, SettingSelectComponent };
|
|
1647
1647
|
//# sourceMappingURL=ng-configcat-publicapi-ui.mjs.map
|