Skip to content

Commit

Permalink
[WIP] Fix missing subsystem in settings
Browse files Browse the repository at this point in the history
  • Loading branch information
vlabo committed Jul 3, 2024
1 parent 594e53d commit 8a27480
Show file tree
Hide file tree
Showing 2 changed files with 453 additions and 19 deletions.
39 changes: 20 additions & 19 deletions desktop/angular/src/app/shared/config/config-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
} from '@safing/portmaster-api';
import { BehaviorSubject, Subscription, combineLatest } from 'rxjs';
import { debounceTime } from 'rxjs/operators';
import { StatusService, Subsystem } from 'src/app/services';
import { StatusService } from 'src/app/services';
import {
fadeInAnimation,
fadeInListAnimation,
Expand All @@ -43,6 +43,10 @@ import {
ImportConfig,
ImportDialogComponent,
} from './import-dialog/import-dialog.component';
import { HttpClient } from '@angular/common/http';
import { environment } from 'src/environments/environment';

import { subsystems, SubsystemWithExpertise } from './subsystems'

interface Category {
name: string;
Expand All @@ -52,12 +56,6 @@ interface Category {
hasUserDefinedValues: boolean;
}

interface SubsystemWithExpertise extends Subsystem {
minimumExpertise: ExpertiseLevelNumber;
isDisabled: boolean;
hasUserDefinedValues: boolean;
}

@Component({
selector: 'app-settings-view',
templateUrl: './config-settings.html',
Expand All @@ -66,7 +64,7 @@ interface SubsystemWithExpertise extends Subsystem {
})
export class ConfigSettingsViewComponent
implements OnInit, OnDestroy, AfterViewInit {
subsystems: SubsystemWithExpertise[] = [];
subsystems: SubsystemWithExpertise[] = subsystems;
others: Setting[] | null = null;
settings: Map<string, Category[]> = new Map();

Expand Down Expand Up @@ -207,7 +205,8 @@ export class ConfigSettingsViewComponent
private searchService: FuzzySearchService,
private actionIndicator: ActionIndicatorService,
private portapi: PortapiService,
private dialog: SfngDialogService
private dialog: SfngDialogService,
private http : HttpClient
) { }

openImportDialog() {
Expand Down Expand Up @@ -303,21 +302,12 @@ export class ConfigSettingsViewComponent
ngOnInit(): void {
this.subscription = combineLatest([
this.onSettingsChange,
this.statusService.querySubsystem(),
this.onSearch.pipe(debounceTime(250)),
this.configService.watch<StringSetting>('core/releaseLevel'),
])
.pipe(debounceTime(10))
.subscribe(
([settings, subsystems, searchTerm, currentReleaseLevelSetting]) => {
this.subsystems = subsystems.map((s) => ({
...s,
// we start with developer and decrease to the lowest number required
// while grouping the settings.
minimumExpertise: ExpertiseLevelNumber.developer,
isDisabled: false,
hasUserDefinedValues: false,
}));
([settings, searchTerm, currentReleaseLevelSetting]) => {
this.others = [];
this.settings = new Map();

Expand Down Expand Up @@ -498,6 +488,17 @@ export class ConfigSettingsViewComponent
}
}
);


this.http.get<Setting[]>(`${environment.httpAPI}/v1/config/options`)
.subscribe({
next: response => {
this.onSettingsChange.next(response);
},
error: err => {
console.log('Failed to fetch settings', err);
}
})
}

ngAfterViewInit() {
Expand Down
Loading

0 comments on commit 8a27480

Please sign in to comment.