Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -349,9 +349,31 @@ <h4 class="text-center" style="color: black !important">
<mat-accordion class="full-width">
<mat-expansion-panel [expanded]="serviceForm.getRawValue().type">
<mat-expansion-panel-header
>{{ 'services.options' | transloco }}
>{{ 'services.options' | transloco }}s
</mat-expansion-panel-header>
<div class="details-section">
<ng-container *ngIf="this.isNetworkService">
<mat-form-field class="full-width" appearance="outline">
<mat-label>Service Definition</mat-label>
<textarea
matInput
rows="10"
[(ngModel)]="serviceDefinition"
[ngModelOptions]="{ standalone: true }"></textarea>
</mat-form-field>
</ng-container>

<!-- <ng-container *ngIf="this.isNetworkService">
<df-script-editor
[type]="getControl('type')"
formControlName="content"
[storageServiceId]="getConfigControl('storageServiceId')"
[storagePath]="getConfigControl('storagePath')"
[content]="getConfigControl('content')"
[cache]="serviceData ? serviceData.name : ''"
class="full-width"></df-script-editor
></ng-container> -->

<ng-container *ngFor="let item of viewSchema">
<ng-container
*ngIf="
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ import { DfThemeService } from 'src/app/shared/services/df-theme.service';
export class DfServiceDetailsComponent implements OnInit {
edit = false;
isDatabase = false;
isNetworkService = false;
serviceTypes: Array<ServiceType>;
notIncludedServices: Array<ServiceType>;
serviceForm: FormGroup;
Expand All @@ -94,6 +95,7 @@ export class DfServiceDetailsComponent implements OnInit {
configSchema: Array<ConfigSchema>;
images: Array<ImageObject>;
search = '';
serviceDefinition: string;

systemEvents: Array<{ label: string; value: string }>;

Expand All @@ -114,6 +116,9 @@ export class DfServiceDetailsComponent implements OnInit {
label: [''],
description: [''],
isActive: [true],
service_doc_by_service_id: this.fb.group({
content: [''],
}),
});
const id = this.activatedRoute.snapshot.paramMap.get('id');
if (id) {
Expand All @@ -137,6 +142,9 @@ export class DfServiceDetailsComponent implements OnInit {
if (route['groups'] && route['groups'][0] === 'Database') {
this.isDatabase = true;
}
if (route['groups'] && route['groups'][0] === 'Remote Service') {
this.isNetworkService = true;
}
const { data, serviceTypes, groups } = route;
const licenseType = env.platform?.license;
this.serviceTypes = serviceTypes;
Expand Down Expand Up @@ -183,20 +191,24 @@ export class DfServiceDetailsComponent implements OnInit {
...data,
config: data.config,
});
this.serviceForm.controls['type'].disable();
(this.serviceDefinition = data?.serviceDocByServiceId.content),
this.serviceForm.controls['type'].disable();
} else {
this.serviceForm.controls['type'].valueChanges.subscribe(value => {
this.serviceForm.removeControl('config');
this.configSchema = this.getConfigSchema(value);
this.initializeConfig();
});
(this.serviceDefinition = data?.serviceDocByServiceId.content),
this.serviceForm.controls['type'].valueChanges.subscribe(value => {
this.serviceForm.removeControl('config');
this.configSchema = this.getConfigSchema(value);
this.initializeConfig();
});
}
});
this.serviceForm.controls['type'].valueChanges.subscribe(value => {
this.serviceForm.patchValue({
label: value,
if (this.isDatabase) {
this.serviceForm.controls['type'].valueChanges.subscribe(value => {
this.serviceForm.patchValue({
label: value,
});
});
});
}
}

initializeConfig() {
Expand All @@ -207,12 +219,12 @@ export class DfServiceDetailsComponent implements OnInit {
if (control.required) {
validator.push(Validators.required);
}
config.addControl(
config?.addControl(
control.name,
new FormControl(control.default, validator)
);
});
this.serviceForm.addControl('config', config);
this.serviceForm?.addControl('config', config);
}
}

Expand Down Expand Up @@ -266,6 +278,27 @@ export class DfServiceDetailsComponent implements OnInit {
return;
}
const data = this.serviceForm.getRawValue();
data.service_doc_by_service_id.content = this.serviceDefinition;
type Params = {
snackbarError: string;
snackbarSuccess: string;
fields?: string;
related?: string;
};

let params: Params = {
snackbarError: 'server',
snackbarSuccess: 'services.createSuccessMsg',
};

if (this.isNetworkService) {
params = {
...params,
fields: '*',
related: 'service_doc_by_service_id',
};
}

if (this.edit) {
this.servicesService
.update(this.serviceData.id, data, {
Expand All @@ -278,11 +311,10 @@ export class DfServiceDetailsComponent implements OnInit {
} else {
this.servicesService
.create(
{ resource: [data] },
{
snackbarError: 'server',
snackbarSuccess: 'services.createSuccessMsg',
}
resource: [data],
},
params
)
.subscribe(() => {
this.router.navigate([`/api-connections/api-docs/${data.name}`]);
Expand Down