Improved way to load server for server dashboard #131
This commit is contained in:
@@ -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));
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -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();
|
||||
});
|
||||
});
|
@@ -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;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
Reference in New Issue
Block a user