Skip to content

Commit

Permalink
Add datasource config UI
Browse files Browse the repository at this point in the history
  • Loading branch information
Waguramu committed Sep 9, 2024
1 parent baf645d commit 8d17f81
Show file tree
Hide file tree
Showing 16 changed files with 16,088 additions and 15,356 deletions.
89 changes: 87 additions & 2 deletions erdblick_app/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,17 @@ import {TreeTableFilterPatchDirective} from "./treetablefilter-patch.directive";
import {InputTextareaModule} from "primeng/inputtextarea";
import {FloatLabelModule} from "primeng/floatlabel";
import {TabViewModule} from "primeng/tabview";
import {
ArrayTypeComponent,
DatasourcesComponent,
MultiSchemaTypeComponent,
ObjectTypeComponent
} from "./datasources.component";
import {EditorService} from "./editor.service";
import {FormlyFieldConfig, FormlyModule} from "@ngx-formly/core";
import {ReactiveFormsModule} from '@angular/forms';
import {FormlyPrimeNGModule} from "@ngx-formly/primeng";
import {DataSourcesService} from "./datasources.service";

export function initializeServices(styleService: StyleService, mapService: MapService, coordService: CoordinatesService) {
return async () => {
Expand All @@ -69,6 +80,50 @@ export function initializeServices(styleService: StyleService, mapService: MapSe
}
}

export function minItemsValidationMessage(error: any, field: FormlyFieldConfig) {
return `should NOT have fewer than ${field.props?.['minItems']} items`;
}

export function maxItemsValidationMessage(error: any, field: FormlyFieldConfig) {
return `should NOT have more than ${field.props?.['maxItems']} items`;
}

export function minLengthValidationMessage(error: any, field: FormlyFieldConfig) {
return `should NOT be shorter than ${field.props?.minLength} characters`;
}

export function maxLengthValidationMessage(error: any, field: FormlyFieldConfig) {
return `should NOT be longer than ${field.props?.maxLength} characters`;
}

export function minValidationMessage(error: any, field: FormlyFieldConfig) {
return `should be >= ${field.props?.min}`;
}

export function maxValidationMessage(error: any, field: FormlyFieldConfig) {
return `should be <= ${field.props?.max}`;
}

export function multipleOfValidationMessage(error: any, field: FormlyFieldConfig) {
return `should be multiple of ${field.props?.step}`;
}

export function exclusiveMinimumValidationMessage(error: any, field: FormlyFieldConfig) {
return `should be > ${field.props?.step}`;
}

export function exclusiveMaximumValidationMessage(error: any, field: FormlyFieldConfig) {
return `should be < ${field.props?.step}`;
}

export function constValidationMessage(error: any, field: FormlyFieldConfig) {
return `should be equal to constant "${field.props?.['const']}"`;
}

export function typeValidationMessage({ schemaType }: any) {
return `should be "${schemaType[0]}".`;
}

@NgModule({
declarations: [
AppComponent,
Expand All @@ -83,7 +138,11 @@ export function initializeServices(styleService: StyleService, mapService: MapSe
CoordinatesPanelComponent,
FeatureSearchComponent,
AlertDialogComponent,
DatasourcesComponent,
OnEnterClickDirective,
ArrayTypeComponent,
ObjectTypeComponent,
MultiSchemaTypeComponent,
HighlightSearch,
TreeTableFilterPatchDirective,
],
Expand Down Expand Up @@ -124,9 +183,33 @@ export function initializeServices(styleService: StyleService, mapService: MapSe
TabViewModule,
InputTextareaModule,
ButtonGroupModule,
TabViewModule,
BreadcrumbModule,
TableModule
TableModule,
ReactiveFormsModule,
FormlyPrimeNGModule,
FormlyModule.forRoot({
validationMessages: [
{ name: 'required', message: 'This field is required' },
{ name: 'type', message: typeValidationMessage },
{ name: 'minLength', message: minLengthValidationMessage },
{ name: 'maxLength', message: maxLengthValidationMessage },
{ name: 'min', message: minValidationMessage },
{ name: 'max', message: maxValidationMessage },
{ name: 'multipleOf', message: multipleOfValidationMessage },
{ name: 'exclusiveMinimum', message: exclusiveMinimumValidationMessage },
{ name: 'exclusiveMaximum', message: exclusiveMaximumValidationMessage },
{ name: 'minItems', message: minItemsValidationMessage },
{ name: 'maxItems', message: maxItemsValidationMessage },
{ name: 'uniqueItems', message: 'should NOT have duplicate items' },
{ name: 'const', message: constValidationMessage },
{ name: 'enum', message: `must be equal to one of the allowed values` },
],
types: [
{ name: 'array', component: ArrayTypeComponent },
{ name: 'object', component: ObjectTypeComponent },
{ name: 'multischema', component: MultiSchemaTypeComponent }
],
})
],
providers: [
{
Expand All @@ -144,6 +227,8 @@ export function initializeServices(styleService: StyleService, mapService: MapSe
SidePanelService,
FeatureSearchService,
ClipboardService,
EditorService,
DataSourcesService,
provideHttpClient(withInterceptorsFromDi()),
]
})
Expand Down
Loading

0 comments on commit 8d17f81

Please sign in to comment.