mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-20 05:13:18 -07:00
feat: added feature update to the frontend
This commit is contained in:
parent
689a869507
commit
d6b5b85ba2
7 changed files with 72 additions and 2 deletions
|
@ -16,4 +16,8 @@ export class FeatureService extends ServiceHelpers {
|
|||
public getFeatures(): Observable<IFeatureEnablement[]> {
|
||||
return this.http.get<IFeatureEnablement[]>(this.url, {headers: this.headers});
|
||||
}
|
||||
|
||||
public update(feature: IFeatureEnablement): Observable<IFeatureEnablement[]> {
|
||||
return this.http.post<IFeatureEnablement[]>(this.url, JSON.stringify(feature), {headers: this.headers});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
<settings-menu></settings-menu>
|
||||
|
||||
<div class="small-middle-container">
|
||||
<legend>Features</legend>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-8">
|
||||
<div class="mat-table">
|
||||
<div class="mat-row" *ngFor="let feature of features">
|
||||
<div class="mat-cell">{{feature.name}}</div>
|
||||
<div class="mat-cell">
|
||||
<span *ngIf="feature.enabled">
|
||||
<i class="fas fa-check-circle" style="color:green;"></i>
|
||||
</span>
|
||||
<span *ngIf="!feature.enabled">
|
||||
<i class="fas fa-times-circle" style="color:red;"></i>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
|
@ -0,0 +1,23 @@
|
|||
import { Component, OnInit } from "@angular/core";
|
||||
|
||||
import { FeaturesFacade } from "../../state/features";
|
||||
import { IFeatureEnablement } from "../../interfaces";
|
||||
import { firstValueFrom } from "rxjs";
|
||||
|
||||
@Component({
|
||||
templateUrl: "./features.component.html"
|
||||
})
|
||||
export class FeaturesComponent implements OnInit {
|
||||
|
||||
public features: IFeatureEnablement[];
|
||||
|
||||
constructor(private readonly featuresFacade: FeaturesFacade) { }
|
||||
|
||||
public async ngOnInit() {
|
||||
this.featuresFacade.features$().subscribe(x => this.features = x);
|
||||
}
|
||||
|
||||
public enableFeature(feature: IFeatureEnablement) {
|
||||
firstValueFrom(this.featuresFacade.update(feature));
|
||||
}
|
||||
}
|
|
@ -38,6 +38,7 @@ import { DogNzbComponent } from "./dognzb/dognzb.component";
|
|||
import { EmailNotificationComponent } from "./notifications/emailnotification.component";
|
||||
import { EmbyComponent } from "./emby/emby.component";
|
||||
import { FailedRequestsComponent } from "./failedrequests/failedrequests.component";
|
||||
import { FeaturesComponent } from "./features/features.component";
|
||||
import { GotifyComponent } from "./notifications/gotify.component";
|
||||
import { HubService } from "../services/hub.service";
|
||||
import {InputSwitchModule} from "primeng/inputswitch";
|
||||
|
@ -120,6 +121,7 @@ const routes: Routes = [
|
|||
{ path: "FailedRequests", component: FailedRequestsComponent, canActivate: [AuthGuard] },
|
||||
{ path: "Logs", component: LogsComponent, canActivate: [AuthGuard] },
|
||||
{ path: "CloudMobile", component: CloudMobileComponent, canActivate: [AuthGuard] },
|
||||
{ path: "Features", component: FeaturesComponent, canActivate: [AuthGuard] },
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
|
@ -184,6 +186,7 @@ const routes: Routes = [
|
|||
LogsComponent,
|
||||
TwilioComponent,
|
||||
WhatsAppComponent,
|
||||
FeaturesComponent,
|
||||
CloudMobileComponent,
|
||||
UpdateDialogComponent,
|
||||
],
|
||||
|
|
|
@ -1,3 +1,10 @@
|
|||
import { IFeatureEnablement } from "../../interfaces";
|
||||
|
||||
export class LoadFeatures {
|
||||
public static readonly type = '[Features] LoadAll';
|
||||
}
|
||||
export class UpdateFeature {
|
||||
public static readonly type = '[Features] Update';
|
||||
|
||||
constructor(public feature: IFeatureEnablement) { }
|
||||
}
|
|
@ -1,7 +1,8 @@
|
|||
import { LoadFeatures, UpdateFeature } from "./features.actions";
|
||||
|
||||
import { FeaturesSelectors } from "./features.selectors";
|
||||
import { IFeatureEnablement } from "../../interfaces";
|
||||
import { Injectable } from "@angular/core";
|
||||
import { LoadFeatures } from "./features.actions";
|
||||
import { Observable } from "rxjs";
|
||||
import { Store } from "@ngxs/store";
|
||||
|
||||
|
@ -14,6 +15,8 @@ export class FeaturesFacade {
|
|||
|
||||
public features$ = (): Observable<IFeatureEnablement[]> => this.store.select(FeaturesSelectors.features);
|
||||
|
||||
public update = (feature: IFeatureEnablement): Observable<unknown> => this.store.dispatch(new UpdateFeature(feature));
|
||||
|
||||
public loadFeatures = (): Observable<unknown> => this.store.dispatch(new LoadFeatures());
|
||||
|
||||
public is4kEnabled = (): boolean => this.store.selectSnapshot(FeaturesSelectors.is4kEnabled);
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import { Action, State, StateContext } from "@ngxs/store";
|
||||
import { LoadFeatures, UpdateFeature } from "./features.actions";
|
||||
|
||||
import { FEATURES_STATE_TOKEN } from "./types";
|
||||
import { FeatureService } from "../../services/feature.service";
|
||||
import { IFeatureEnablement } from "../../interfaces";
|
||||
import { Injectable } from "@angular/core";
|
||||
import { LoadFeatures } from "./features.actions";
|
||||
import { Observable } from "rxjs";
|
||||
import { tap } from "rxjs/operators";
|
||||
|
||||
|
@ -23,4 +23,11 @@ export class FeatureState {
|
|||
)
|
||||
);
|
||||
}
|
||||
|
||||
@Action(UpdateFeature)
|
||||
public update({ setState }: StateContext<IFeatureEnablement[]>, { feature }: UpdateFeature): Observable<IFeatureEnablement[]> {
|
||||
return this.featuresService.update(feature).pipe(
|
||||
tap((result) => setState(result))
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue