Centralize rights management
	
		
			
	
		
	
	
		
	
		
			All checks were successful
		
		
	
	
		
			
				
	
				continuous-integration/drone/push Build is passing
				
			
		
		
	
	
				
					
				
			
		
			All checks were successful
		
		
	
	continuous-integration/drone/push Build is passing
				
			This commit is contained in:
		@@ -1,10 +1,16 @@
 | 
			
		||||
import { APIClient } from "./ApiClient";
 | 
			
		||||
import { VMInfo } from "./VMApi";
 | 
			
		||||
 | 
			
		||||
export interface ServerConfig {
 | 
			
		||||
  authenticated: boolean;
 | 
			
		||||
  disable_auth: boolean;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export interface Rights {
 | 
			
		||||
  vms: VMInfo[];
 | 
			
		||||
  sys_info: boolean;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
let config: ServerConfig | null = null;
 | 
			
		||||
 | 
			
		||||
export class ServerApi {
 | 
			
		||||
@@ -27,4 +33,16 @@ export class ServerApi {
 | 
			
		||||
    if (config === null) throw new Error("Missing configuration!");
 | 
			
		||||
    return config;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Get application rights
 | 
			
		||||
   */
 | 
			
		||||
  static async GetRights(): Promise<Rights> {
 | 
			
		||||
    return (
 | 
			
		||||
      await APIClient.exec({
 | 
			
		||||
        uri: "/server/rights",
 | 
			
		||||
        method: "GET",
 | 
			
		||||
      })
 | 
			
		||||
    ).data;
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,5 @@
 | 
			
		||||
import { APIClient } from "./ApiClient";
 | 
			
		||||
 | 
			
		||||
export interface SysInfoConfig {
 | 
			
		||||
  allowed: boolean;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export interface LoadAverage {
 | 
			
		||||
  one: number;
 | 
			
		||||
  five: number;
 | 
			
		||||
@@ -24,14 +20,6 @@ export interface SysInfoStatus {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export class SysInfoApi {
 | 
			
		||||
  /**
 | 
			
		||||
   * Get system info configuration (ie. check if it allowed)
 | 
			
		||||
   */
 | 
			
		||||
  static async GetConfig(): Promise<SysInfoConfig> {
 | 
			
		||||
    return (await APIClient.exec({ method: "GET", uri: "/sysinfo/config" }))
 | 
			
		||||
      .data;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Get system status
 | 
			
		||||
   */
 | 
			
		||||
 
 | 
			
		||||
@@ -29,13 +29,6 @@ export type VMState =
 | 
			
		||||
  | "Other";
 | 
			
		||||
 | 
			
		||||
export class VMApi {
 | 
			
		||||
  /**
 | 
			
		||||
   * Get the list of VM that can be managed by this console
 | 
			
		||||
   */
 | 
			
		||||
  static async GetList(): Promise<VMInfo[]> {
 | 
			
		||||
    return (await APIClient.exec({ method: "GET", uri: "/vm/list" })).data;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Get the state of a VM
 | 
			
		||||
   */
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user