Skip to content

Commit 4e129f6

Browse files
authored
FOGL-7457: Fixed configuration issues (#255)
Fixed configuration issues
1 parent e1a178e commit 4e129f6

File tree

14 files changed

+308
-352
lines changed

14 files changed

+308
-352
lines changed

src/app/components/core/configuration-manager/configuration-group/configuration-group.component.html

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ <h6 class="is-6 has-text-weight-semibold">
77
</a>
88
</h6>
99
</li>
10+
<!-- Advanced and security group -->
11+
<li *ngFor="let g of advanceCategoriesGroup" [ngClass]="{'is-active': selectedGroup == g.group}">
12+
<h6 class="is-6 has-text-weight-semibold">
13+
<a (click)="selectTab(g.group)">
14+
{{g.group}}
15+
</a>
16+
</h6>
17+
</li>
1018
<ng-container *ngIf="from !== 'notification'">
1119
<li [ngClass]="{'is-active': selectedGroup == 'developer'}"
1220
*ngIf="developerFeaturesService.getDeveloperFeatureControl() && pages.includes(from) && rolesService.hasEditPermissions()">
@@ -19,6 +27,12 @@ <h6 class="is-6 has-text-weight-semibold">
1927
</div>
2028
<div [ngClass]="{'highlight': from !== 'config-manager'}">
2129
<ng-container *ngFor="let g of groups">
30+
<app-show-configuration [hidden]="selectedGroup !== g.group" [groupConfiguration]="g.config" [group]="g.group"
31+
[selectedGroup]="selectedGroup" [fullConfiguration]="category.config" (event)="getChangedConfiguration($event)"
32+
(formStatusEvent)="formStatus($event)"></app-show-configuration>
33+
</ng-container>
34+
<!-- Advanced and security group configuration -->
35+
<ng-container *ngFor="let g of advanceCategoriesGroup">
2236
<ng-container *ngIf="g.category == category?.name+'Advanced'; else SecurityGroup">
2337
<app-show-configuration [hidden]="selectedGroup !== g.group" [groupConfiguration]="g.config" [group]="g.group"
2438
[selectedGroup]="selectedGroup" [fullConfiguration]="g.config" (event)="getChangedAdvanceConfiguration($event)"
@@ -32,16 +46,11 @@ <h6 class="is-6 has-text-weight-semibold">
3246
(formStatusEvent)="formStatus($event)"></app-show-configuration>
3347
</ng-container>
3448
</ng-template>
35-
<ng-template #pluginGroup>
36-
<app-show-configuration [hidden]="selectedGroup !== g.group" [groupConfiguration]="g.config" [group]="g.group"
37-
[selectedGroup]="selectedGroup" [fullConfiguration]="category.config" (event)="getChangedConfiguration($event)"
38-
(formStatusEvent)="formStatus($event)"></app-show-configuration>
39-
</ng-template>
4049
</ng-container>
4150
<ng-container *ngIf="from !== 'notification'">
4251
<app-plugin-persist-data *ngIf="selectedGroup == 'developer' && pages.includes(from)" [serviceStaus]="serviceStatus"
4352
[serviceName]="category?.name" [pluginName]="plugin">
4453
</app-plugin-persist-data>
4554
</ng-container>
4655

47-
</div>
56+
</div>

src/app/components/core/configuration-manager/configuration-group/configuration-group.component.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export class ConfigurationGroupComponent implements OnInit {
2929
securityConfiguration: any;
3030
changedAdvanceConfiguration: any;
3131
changedSecurityConfiguration: any;
32+
advanceCategoriesGroup = [];
3233

3334
constructor(
3435
public developerFeaturesService: DeveloperFeaturesService,
@@ -70,6 +71,9 @@ export class ConfigurationGroupComponent implements OnInit {
7071
e.group === 'Default Configuration' ? acc.unshift(e) : acc.push(e);
7172
return acc;
7273
}, []);
74+
75+
// set initial group
76+
this.selectedGroup = this.groups[0]?.group;
7377
}
7478

7579
/**
@@ -83,6 +87,7 @@ export class ConfigurationGroupComponent implements OnInit {
8387
}
8488

8589
public getChildConfigData() {
90+
this.advanceCategoriesGroup = [];
8691
// No advance configuration on add form
8792
if (this.pages.includes(this.from) && this.category) {
8893
this.categoryKey = this.category.name;
@@ -94,6 +99,7 @@ export class ConfigurationGroupComponent implements OnInit {
9499
this.configService.getCategoryConfigChildren(categoryName).
95100
subscribe(
96101
(data: any) => {
102+
this.advanceCategoriesGroup = [];
97103
const categoryChildren = data.categories?.filter(cat => (cat.key == `${this.categoryKey}Advanced`) || (cat.key == `${this.categoryKey}Security`));
98104
categoryChildren.forEach(cat => {
99105
// Set group of advance/security configuration
@@ -128,7 +134,7 @@ export class ConfigurationGroupComponent implements OnInit {
128134
if (category.key == `${this.categoryKey}Security`) {
129135
this.securityConfiguration = { key: category.key, config: cloneDeep(data) };
130136
}
131-
this.upsertAdvanceConfiguration(this.groups, { category: category.key, group: category.group, config: data });
137+
this.upsertAdvanceConfiguration(this.advanceCategoriesGroup, { category: category.key, group: category.group, config: data });
132138
},
133139
error => {
134140
console.log('error ', error);
@@ -141,7 +147,6 @@ export class ConfigurationGroupComponent implements OnInit {
141147
);
142148
}
143149

144-
145150
/**
146151
* Get the change config item values form show-child
147152
* component and emit that value to parent component.
@@ -194,6 +199,13 @@ export class ConfigurationGroupComponent implements OnInit {
194199
else {
195200
groups.push(config);
196201
}
202+
203+
groups = groups
204+
.sort((a, b) => a.group.localeCompare(b.group))
205+
.reduce((acc, e) => {
206+
e.group === 'Default Configuration' ? acc.unshift(e) : acc.push(e);
207+
return acc;
208+
}, []);
197209
}
198210

199211
formStatus(status: boolean) {

src/app/components/core/configuration-manager/configuration-manager.component.html

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@
4141
<div class="media">
4242
<div class="media-content">
4343
<p class="subtitle is-6">{{ category.description }}
44-
<button class="button is-small" id="refresh-check"
45-
(click)="refreshCategory(category.name, category.description)">
44+
<button class="button is-small" id="refresh-check" (click)="refreshCategory(category.name)">
4645
<span class="icon is-small">
4746
<i class="fa fa-sm fa-sync"></i>
4847
</span>
@@ -70,4 +69,4 @@
7069
</div>
7170
</div>
7271
</div>
73-
</div>
72+
</div>

src/app/components/core/configuration-manager/configuration-manager.component.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Component, Input, OnInit, ViewChild } from '@angular/core';
22
import { TreeComponent } from '@circlon/angular-tree-component';
3-
import { isEmpty, findIndex, cloneDeep } from 'lodash';
3+
import { isEmpty, find, cloneDeep } from 'lodash';
44

55
import {
66
AlertService, ConfigurationControlService, ConfigurationService,
@@ -213,7 +213,7 @@ export class ConfigurationManagerComponent implements OnInit {
213213
});
214214
}
215215

216-
public refreshCategory(categoryKey: string, categoryDesc: string): void {
216+
public refreshCategory(categoryKey: string): void {
217217
this.changedConfig = null;
218218
this.validConfigForm = false;
219219
/** request started */
@@ -223,8 +223,8 @@ export class ConfigurationManagerComponent implements OnInit {
223223
(data) => {
224224
/** request completed */
225225
this.ngProgress.done();
226-
const index = findIndex(this.categoryData, ['name', categoryKey]);
227-
this.categoryData[index] = { name: categoryKey, config: data, description: categoryDesc };
226+
const category = find(this.categoryDataCopy, ['name', categoryKey]);
227+
category.config = data;
228228
},
229229
error => {
230230
/** request completed */
@@ -274,6 +274,7 @@ export class ConfigurationManagerComponent implements OnInit {
274274
this.validConfigForm = false;
275275
this.alertService.success('Configuration updated successfully.', true);
276276
this.ngProgress.done();
277+
this.refreshCategory(categoryName);
277278
},
278279
(error) => {
279280
this.ngProgress.done();

src/app/components/core/configuration-manager/show-configuration/show-configuration.component.ts

Lines changed: 38 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -38,24 +38,6 @@ export class ShowConfigurationComponent implements OnInit {
3838
if (changes?.selectedGroup?.currentValue == this.group) {
3939
this.configControlService.checkConfigItemOnGroupChange(this.form, this.fullConfiguration);
4040
}
41-
42-
if (this.jsonElements) {
43-
this.jsonElements.forEach((jsonComp: CodemirrorComponent) => {
44-
jsonComp.codeMirror.refresh();
45-
});
46-
}
47-
48-
if (this.codeElements) {
49-
this.codeElements.forEach((codeElmt: CodemirrorComponent) => {
50-
codeElmt.codeMirror.refresh();
51-
});
52-
}
53-
// refresh codemirror editor to reflect changed values
54-
if (this.codeMirrorCmpt) {
55-
this.codeMirrorCmpt.forEach((comp: CodemirrorComponent) => {
56-
comp.codeMirror?.refresh();
57-
})
58-
}
5941
}
6042
}
6143

@@ -78,23 +60,48 @@ export class ShowConfigurationComponent implements OnInit {
7860
filter(changes => Object.keys(changes).length !== 0)
7961
).subscribe(
8062
data => {
81-
const [key, value] = Object.entries(data)[0];
82-
const configuration = this.groupConfiguration.find(c => c.key === key);
83-
if (configuration && configuration.type !== 'script') {
84-
configuration.value = value.toString();
85-
this.configControlService.checkConfigItemValidityOnChange(this.form, configuration, this.fullConfiguration);
86-
this.formStatusEvent.emit(this.form.status === 'VALID' ? true : false);
87-
if (this.form.valid) {
88-
this.event.emit(data);
63+
Object.keys(data).forEach(k => {
64+
if (data[k] !== this.fullConfiguration[k].value) {
65+
const configuration = this.groupConfiguration.find(c => c.key === k);
66+
if (configuration && configuration.type !== 'script') {
67+
configuration.value = data[k].toString();
68+
this.configControlService.checkConfigItemValidityOnChange(this.form, configuration, this.fullConfiguration);
69+
this.formStatusEvent.emit(this.form.status === 'VALID' ? true : false);
70+
if (this.form.valid) {
71+
this.event.emit(data);
72+
}
73+
} else {
74+
configuration.value = data[k].toString();
75+
const file = this.createScriptFile(data[k].toString(), configuration);
76+
this.event.emit({ [configuration.key]: file });
77+
}
8978
}
90-
} else {
91-
configuration.value = value.toString();
92-
const file = this.createScriptFile(value.toString(), configuration);
93-
this.event.emit({ [configuration.key]: file });
94-
}
79+
})
9580
});
9681
}
9782

83+
ngAfterViewChecked() {
84+
// refresh code mirror content after page load
85+
if (this.jsonElements) {
86+
this.jsonElements.forEach((jsonComp: CodemirrorComponent) => {
87+
jsonComp.codeMirror?.refresh();
88+
});
89+
}
90+
91+
if (this.codeElements) {
92+
this.codeElements.forEach((codeElmt: CodemirrorComponent) => {
93+
codeElmt.codeMirror?.refresh();
94+
});
95+
}
96+
97+
// refresh codemirror editor to reflect changed values
98+
if (this.codeMirrorCmpt) {
99+
this.codeMirrorCmpt.forEach((comp: CodemirrorComponent) => {
100+
comp.codeMirror?.refresh();
101+
})
102+
}
103+
}
104+
98105
createScriptFile(value: string, config: any) {
99106
const blob = new Blob([value], { type: 'plain/text' });
100107
const file = new File([blob], config.fileName.substring(config.fileName.lastIndexOf(config + 1)));

src/app/components/core/filter/add-filter-wizard/add-filter-wizard.component.html

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@
3535
[loading]="!pluginData.length && !stopLoading" (change)="filterSelectionChanged($event)"
3636
bindLabel="pluginToInstall" formControlName="pluginToInstall">
3737
</ng-select>
38-
<small *ngIf="!isValidPlugin" class="help is-danger level-left">* Please select a valid plugin</small>
38+
<small
39+
*ngIf="serviceForm.controls['pluginToInstall'].hasError('required') && serviceForm.controls['pluginToInstall'].touched"
40+
class="help is-danger level-left">* Please select a valid plugin</small>
3941
</div>
4042
</div>
4143
</div>
@@ -53,9 +55,11 @@
5355
<div class="column">
5456
<div class="field">
5557
<div class="control">
56-
<input class="input" id="name" type="text" placeholder="name" title="No double quotes!" autocomplete="off" formControlName="name" required
57-
(input)="validateServiceName($event)">
58-
<small *ngIf="!isValidName" class="help is-danger level-left">Application name is required</small>
58+
<input class="input" id="name" type="text" placeholder="name" title="No double quotes!"
59+
autocomplete="off" formControlName="name">
60+
<small
61+
*ngIf="serviceForm.controls['name'].hasError('required') && serviceForm.controls['name'].touched"
62+
class="help is-danger level-left">Application name is required</small>
5963
</div>
6064
</div>
6165
</div>
@@ -73,14 +77,15 @@
7377
<div class="column is-vertical-center">
7478
<div class="select is-multiple">
7579
<select #selectedPlugin multiple name="type" formControlName="plugin"
76-
(change)="getDescription(selectedPlugin.value)" required>
80+
(change)="selectPlugin(selectedPlugin.value)">
7781
<option *ngFor="let p of plugins" [value]="p.name"> {{ p.name }}</option>
7882
</select>
7983
</div>
8084
&nbsp;
81-
<small *ngIf="selectedPluginDescription && isValidPlugin && isSinglePlugin"
85+
<small *ngIf="!serviceForm.controls['plugin'].hasError('required')
86+
&& !serviceForm.controls['plugin'].hasError('multiplePlugins') "
8287
class="help description level-left">{{ selectedPluginDescription }}</small>
83-
<small *ngIf="!isSinglePlugin" class="help is-danger level-left">* Please select a single plugin</small>
88+
8489
</div>
8590
</div>
8691
<div *ngIf="plugin" class="column is-1">
@@ -116,7 +121,11 @@
116121
notFoundText="No plugins available to install" (change)="filterSelectionChanged($event)"
117122
bindLabel="pluginToInstall" formControlName="pluginToInstall">
118123
</ng-select>
119-
<small *ngIf="!isValidPlugin" class="help is-danger level-left">* Please select a valid plugin</small>
124+
<small
125+
*ngIf="serviceForm.controls['plugin'].hasError('required') && serviceForm.controls['plugin'].touched"
126+
class="help is-danger level-left">* Please select a valid plugin</small>
127+
<small *ngIf="serviceForm.controls['plugin'].hasError('multiplePlugins')"
128+
class="help is-danger level-left">* Please select a single plugin</small>
120129
<p id="requestInProgress" class="help has-text-centered"></p>
121130
</div>
122131
</div>
@@ -129,9 +138,11 @@
129138
<div class="field-body">
130139
<div class="field">
131140
<div class="control">
132-
<input class="input" id="name" type="text" placeholder="name" title="No double quotes!" autocomplete="off" formControlName="name" required
133-
(input)="validateServiceName($event)">
134-
<small *ngIf="!isValidName" class="help is-danger level-left">Application name is required</small>
141+
<input class="input" id="name" type="text" placeholder="name" title="No double quotes!"
142+
autocomplete="off" formControlName="name">
143+
<small
144+
*ngIf="serviceForm.controls['name'].hasError('required') && serviceForm.controls['name'].touched"
145+
class="help is-danger level-left">Application name is required</small>
135146
</div>
136147
</div>
137148
</div>
@@ -153,8 +164,8 @@
153164
<button (click)="movePrevious()" data-nav="previous" class="button" id="previous">Back</button>
154165
</div>
155166
<div class="steps-action">
156-
<button (click)="gotoNext()" data-nav="next" [disabled]="serviceForm.invalid" class="button is-link"
157-
id="next">Next</button>
167+
<button (click)="gotoNext()" data-nav="next" [disabled]="serviceForm.invalid || !validChildConfigurationForm"
168+
class="button is-link" id="next">Next</button>
158169
</div>
159170
</div>
160-
</div>
171+
</div>

0 commit comments

Comments
 (0)