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
@@ -1,25 +1,26 @@
<form [formGroup]="scriptForm" class="details-section" (ngSubmit)="submit()">
<mat-form-field class="full-width" subscriptSizing="dynamic">
<mat-label>{{ 'service' | transloco }}</mat-label>
<mat-select
[(value)]="selectedServiceItem"
(selectionChange)="selectedServiceItemEvent()">
<mat-option *ngFor="let service of storeServiceArray" [value]="service">
{{ service }}
</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field class="half-width" subscriptSizing="dynamic">
<mat-label>{{ 'scripts.scriptName' | transloco }}</mat-label>
<mat-select
[(value)]="selectedEventItem"
(selectionChange)="selectedEventItemEvent()">
<mat-option *ngFor="let item of ungroupedEventItems" [value]="item">
{{ item }}
</mat-option>
</mat-select>
<!-- <input matInput formControlName="name" [matAutocomplete]="autoGroup" /> -->
<!-- <mat-autocomplete #autoGroup="matAutocomplete">
<ng-container *ngIf="type !== 'edit'; else editing">
<mat-form-field class="full-width" subscriptSizing="dynamic">
<mat-label>{{ 'service' | transloco }}</mat-label>
<mat-select
[(value)]="selectedServiceItem"
(selectionChange)="selectedServiceItemEvent()">
<mat-option *ngFor="let service of storeServiceArray" [value]="service">
{{ service }}
</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field class="half-width" subscriptSizing="dynamic">
<mat-label>{{ 'scripts.scriptType' | transloco }}</mat-label>
<mat-select
[(value)]="selectedEventItem"
(selectionChange)="selectedEventItemEvent()">
<mat-option *ngFor="let item of ungroupedEventItems" [value]="item">
{{ item }}
</mat-option>
</mat-select>
<!-- <input matInput formControlName="name" [matAutocomplete]="autoGroup" /> -->
<!-- <mat-autocomplete #autoGroup="matAutocomplete">
<mat-optgroup
*ngFor="let group of ungroupedEventItems"
[label]="group.name">
Expand All @@ -28,15 +29,15 @@
</mat-option>
</mat-optgroup>
</mat-autocomplete> -->
</mat-form-field>
<mat-form-field class="half-width" subscriptSizing="dynamic">
<mat-label>{{ 'scripts.scriptName' | transloco }}</mat-label>
<mat-select [(value)]="selectedRouteItem">
<mat-option *ngFor="let item of ungroupedRouteOptions" [value]="item">
{{ item }}
</mat-option>
</mat-select>
<!-- <mat-label>{{ 'scripts.scriptName' | transloco }}</mat-label>
</mat-form-field>
<mat-form-field class="half-width" subscriptSizing="dynamic">
<mat-label>{{ 'scripts.scriptMethod' | transloco }}</mat-label>
<mat-select [(value)]="selectedRouteItem">
<mat-option *ngFor="let item of ungroupedRouteOptions" [value]="item">
{{ item }}
</mat-option>
</mat-select>
<!-- <mat-label>{{ 'scripts.scriptName' | transloco }}</mat-label>
<input matInput formControlName="name" [matAutocomplete]="autoGroup" />
<mat-autocomplete #autoGroup="matAutocomplete">
<mat-option
Expand All @@ -46,7 +47,30 @@
{{ event }}
</mat-option>
</mat-autocomplete> -->
</mat-form-field>
</mat-form-field>
<ng-container *ngIf="this.tableOptions">
<mat-form-field class="full-width" subscriptSizing="dynamic">
<mat-label>{{ 'scripts.tableName' | transloco }}</mat-label>
<mat-select [(value)]="selectTable" (selectionChange)="selectedTable()">
<mat-option *ngFor="let item of tableOptions" [value]="item">
{{ item }}
</mat-option>
</mat-select>
</mat-form-field>
</ng-container>
<ng-container *ngIf="this.completeScriptName">
<mat-form-field class="full-width">
<mat-label>{{ 'scripts.scriptName' | transloco }}</mat-label>
<input matInput [value]="this.completeScriptName" />
</mat-form-field>
</ng-container>
</ng-container>
<ng-template #editing>
<mat-form-field class="full-width">
<mat-label>{{ 'scripts.tableName' | transloco }}</mat-label>
<input matInput disabled [value]="this.completeScriptName" />
</mat-form-field>
</ng-template>
<mat-form-field class="full-width" subscriptSizing="dynamic">
<mat-label>{{ 'scriptType' | transloco }}</mat-label>
<mat-select formControlName="type">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,14 @@ export class DfScriptDetailsComponent implements OnInit {
ungroupedEventItems: string[];
ungroupedEventOptions: ScriptEvent;
ungroupedRouteOptions: string[];
tableOptions: string[];
storeServiceArray: string[];
selectedStorageItem: string;
selectedServiceItem: string;
selectedEventItem: string;
selectedRouteItem: string;
selectTable: string;
completeScriptName: string;
loaded = false;
constructor(
private activatedRoute: ActivatedRoute,
Expand All @@ -88,20 +91,6 @@ export class DfScriptDetailsComponent implements OnInit {
storagePath: [''],
isActive: [false],
});
// this.baseService
// .getAll<{
// serviceTypes: Array<ServiceType>;
// services: Array<Service>;
// }>({
// additionalParams: [
// {
// key: 'group',
// value:
// 'Database, Big Data, Script, Remote Service, File, Excel, Cache, Email, Notification, Log, Source Control, IoT, LDAP, SSO, OAuth, user, system',
// },
// ],
// })
// .subscribe();
}

storageServices: Service;
Expand All @@ -112,6 +101,7 @@ export class DfScriptDetailsComponent implements OnInit {
this.scriptDetails = data;
this.scriptForm.patchValue(data);
this.scriptForm.controls['name'].disable();
this.completeScriptName = data.name;
} else {
this.scriptEvents = groupEvents(data);
this.unGroupedEvents = data;
Expand All @@ -125,18 +115,6 @@ export class DfScriptDetailsComponent implements OnInit {
startWith(''),
map(value => this.filterGroup(value))
);
// this.scriptForm.controls['storageServiceId'].valueChanges.subscribe(res => {
// let serviceType = res.name;
// if (res.name === 'api_docs') {
// serviceType = 'apiDocs';
// this.ungroupedEventOptions = this.unGroupedEvents[serviceType];
// }

// this.ungroupedEventOptions = this.unGroupedEvents[serviceType];
// Object.keys(this.ungroupedEventOptions).forEach(key => {
// this.ungroupedEventItems.push(key);
// });
// });
this.loaded = true;
}

Expand All @@ -163,7 +141,7 @@ export class DfScriptDetailsComponent implements OnInit {
script.storageServiceId?.type === 'local_file'
? script.storagePath
: null,
name: this.selectedRouteItem,
name: this.completeScriptName,
};
if (this.type === 'edit') {
this.scriptDetails = { ...this.scriptDetails, ...scriptItem };
Expand Down Expand Up @@ -193,6 +171,9 @@ export class DfScriptDetailsComponent implements OnInit {
}

selectedServiceItemEvent() {
this.ungroupedEventItems = [];
this.ungroupedRouteOptions = [];
this.selectedRouteItem = '';
let serviceType: string = this.selectedServiceItem;
if (serviceType === 'api_docs') {
serviceType = 'apiDocs';
Expand All @@ -205,8 +186,23 @@ export class DfScriptDetailsComponent implements OnInit {
}

selectedEventItemEvent() {
this.tableOptions = [];
this.ungroupedRouteOptions = [
...this.ungroupedEventOptions[this.selectedEventItem].endpoints,
];

if (this.ungroupedEventOptions[this.selectedEventItem].parameter) {
this.tableOptions = [
...this.ungroupedEventOptions[this.selectedEventItem].parameter
.tableName,
];
}
}

selectedTable() {
this.completeScriptName = this.selectedRouteItem.replace(
'{table_name}',
this.selectTable
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class DfScriptEditorComponent implements OnInit {
additionalParams: [
{
key: 'group',
value: 'source control,file,database, email,notification,log,iot',
value: 'source control,file',
},
],
})
Expand Down
4 changes: 4 additions & 0 deletions src/assets/i18n/scripts/en.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{
"scriptName": "Script Name",
"scriptMethod": "Script Method",
"scriptType": "Script Type",
"scriptLocation": "Script Location",
"tableName": "Table Name",
"active": "Active",
"importScriptFile": "Import a script file",
"fromDesktop": "From Desktop",
Expand Down