mirror of
https://github.com/hubHarmony/servii-frontend.git
synced 2024-11-18 05:40:31 +00:00
[~] Added toast exclusion list for API calls.
Removed FetchLogsRequest calls interface (duplicate of base ServerRequest)
This commit is contained in:
parent
ef1e5fc2ac
commit
3e329d5bb3
@ -36,10 +36,6 @@ interface CommandRequest extends BaseRequest {
|
||||
name: string;
|
||||
}
|
||||
|
||||
interface FetchLogsRequest extends BaseRequest {
|
||||
name: string;
|
||||
}
|
||||
|
||||
enum serviiRequest {
|
||||
setSubdomain = 'SetSubdomain',
|
||||
fetchServers = 'FetchServers',
|
||||
@ -54,6 +50,12 @@ enum serviiRequest {
|
||||
fetchLogs = 'FetchLogs',
|
||||
}
|
||||
|
||||
|
||||
const nonToastableCalls: string[] = [
|
||||
serviiRequest.fetchServers,
|
||||
serviiRequest.fetchLogs,
|
||||
];
|
||||
|
||||
class serviiApi {
|
||||
constructor() {}
|
||||
|
||||
@ -75,8 +77,9 @@ class serviiApi {
|
||||
return { return_code: status, message: json };
|
||||
}
|
||||
|
||||
if (!nonToastableCalls.includes(endpoint)) {
|
||||
|
||||
let toastType: 'success' | 'error' | 'info';
|
||||
let toastColor: string;
|
||||
|
||||
if (status >= 200 && status < 300) {
|
||||
toastType = 'success';
|
||||
@ -97,6 +100,7 @@ class serviiApi {
|
||||
theme: "light",
|
||||
transition: Bounce,
|
||||
});
|
||||
}
|
||||
|
||||
return { return_code: status, message: json.message };
|
||||
}
|
||||
@ -119,6 +123,11 @@ class serviiApi {
|
||||
return this.call(serviiRequest.fetchServers, payload);
|
||||
}
|
||||
|
||||
public static async fetchLogs(name: string): Promise<ApiResponse> {
|
||||
const payload: ServerRequest = { token: this.token(), name: name };
|
||||
return this.call(serviiRequest.fetchLogs, payload);
|
||||
}
|
||||
|
||||
public static async accountCreate(): Promise<ApiResponse> {
|
||||
const payload: BaseRequest = { token: this.token() };
|
||||
return this.call(serviiRequest.accountCreate, payload);
|
||||
@ -162,11 +171,6 @@ class serviiApi {
|
||||
const payload: CommandRequest = { token: this.token(), command: command, name: name };
|
||||
return this.call(serviiRequest.command, payload);
|
||||
}
|
||||
|
||||
public static async fetchLogs(name: string): Promise<ApiResponse> {
|
||||
const payload: FetchLogsRequest = { token: this.token(), name: name };
|
||||
return this.call(serviiRequest.fetchLogs, payload);
|
||||
}
|
||||
}
|
||||
|
||||
export default serviiApi;
|
||||
|
Loading…
Reference in New Issue
Block a user