Improved way to load server for server dashboard #131

This commit is contained in:
2023-02-10 19:33:44 +01:00
parent a6df06f13a
commit 4822348e01
13 changed files with 26088 additions and 19815 deletions

View File

@@ -27,13 +27,14 @@ export class DataService {
// );
// }
public query<T>(query: string, variables?: Variables): Observable<T> {
public query<T>(query: string, variables?: Variables, f?: Function): Observable<T> {
return this.http
.post<{ data: T }>(`${this.appsettings.getApiURL()}/api/graphql`, {
query: query,
variables: variables
})
.pipe(map((d) => d.data));
.pipe(map((d) => d.data))
.pipe(map((d) => f ? f(d) : d));
}
}

View File

@@ -1,16 +0,0 @@
import { TestBed } from '@angular/core/testing';
import { ServerService } from './server.service';
describe('ServerService', () => {
let service: ServerService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(ServerService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});

View File

@@ -1,23 +0,0 @@
import { Injectable } from "@angular/core";
import { BehaviorSubject } from "rxjs";
import { Server } from "src/app/models/data/server.model";
@Injectable({
providedIn: 'root'
})
export class ServerService {
private server!: Server;
server$ = new BehaviorSubject<Server | null>(null);
constructor() {
this.server$.subscribe(server => {
if (!server) {
return;
}
this.server = server;
});
}
}