Finished auto role list #134
This commit is contained in:
@@ -9,6 +9,7 @@ import { Queries } from "../../models/graphql/queries.model";
|
||||
import { Query } from "../../models/graphql/query.model";
|
||||
import { SidebarService } from "../sidebar/sidebar.service";
|
||||
import { SpinnerService } from "../spinner/spinner.service";
|
||||
import { GraphQLResult } from "../../models/graphql/result.model";
|
||||
|
||||
@Injectable({
|
||||
providedIn: "root"
|
||||
@@ -20,7 +21,7 @@ export class DataService {
|
||||
private http: HttpClient,
|
||||
private sidebar: SidebarService,
|
||||
private spinner: SpinnerService,
|
||||
private router: Router,
|
||||
private router: Router
|
||||
) {
|
||||
}
|
||||
|
||||
@@ -28,7 +29,7 @@ export class DataService {
|
||||
this.spinner.showSpinner();
|
||||
if (!route.snapshot.params["serverId"]) {
|
||||
this.spinner.hideSpinner();
|
||||
this.router.navigate(['/dashboard']);
|
||||
this.router.navigate(["/dashboard"]);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -46,21 +47,31 @@ export class DataService {
|
||||
|
||||
public query<T>(query: string, variables?: Variables, f?: Function): Observable<T> {
|
||||
return this.http
|
||||
.post<{ data: T }>(`${this.appsettings.getApiURL()}/api/graphql`, {
|
||||
.post<GraphQLResult>(`${this.appsettings.getApiURL()}/api/graphql`, {
|
||||
query: query,
|
||||
variables: variables
|
||||
})
|
||||
.pipe(map((d) => d.data))
|
||||
.pipe(map(d => {
|
||||
if (d.errors && d.errors.length > 0) {
|
||||
throw new Error(d.errors.toString());
|
||||
}
|
||||
return d.data;
|
||||
}))
|
||||
.pipe(map((d) => f ? f(d) : d));
|
||||
}
|
||||
|
||||
public mutation<T>(query: string, variables?: object, f?: Function): Observable<T> {
|
||||
return this.http
|
||||
.post<{ data: T }>(`${this.appsettings.getApiURL()}/api/graphql`, {
|
||||
.post<GraphQLResult>(`${this.appsettings.getApiURL()}/api/graphql`, {
|
||||
query: query,
|
||||
variables: variables
|
||||
})
|
||||
.pipe(map((d) => d.data))
|
||||
.pipe(map(d => {
|
||||
if (d.errors && d.errors.length > 0) {
|
||||
throw new Error(d.errors.toString());
|
||||
}
|
||||
return d.data;
|
||||
}))
|
||||
.pipe(map((d) => f ? f(d) : d));
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user