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;
|
name: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface FetchLogsRequest extends BaseRequest {
|
|
||||||
name: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
enum serviiRequest {
|
enum serviiRequest {
|
||||||
setSubdomain = 'SetSubdomain',
|
setSubdomain = 'SetSubdomain',
|
||||||
fetchServers = 'FetchServers',
|
fetchServers = 'FetchServers',
|
||||||
@ -54,6 +50,12 @@ enum serviiRequest {
|
|||||||
fetchLogs = 'FetchLogs',
|
fetchLogs = 'FetchLogs',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const nonToastableCalls: string[] = [
|
||||||
|
serviiRequest.fetchServers,
|
||||||
|
serviiRequest.fetchLogs,
|
||||||
|
];
|
||||||
|
|
||||||
class serviiApi {
|
class serviiApi {
|
||||||
constructor() {}
|
constructor() {}
|
||||||
|
|
||||||
@ -75,8 +77,9 @@ class serviiApi {
|
|||||||
return { return_code: status, message: json };
|
return { return_code: status, message: json };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!nonToastableCalls.includes(endpoint)) {
|
||||||
|
|
||||||
let toastType: 'success' | 'error' | 'info';
|
let toastType: 'success' | 'error' | 'info';
|
||||||
let toastColor: string;
|
|
||||||
|
|
||||||
if (status >= 200 && status < 300) {
|
if (status >= 200 && status < 300) {
|
||||||
toastType = 'success';
|
toastType = 'success';
|
||||||
@ -97,6 +100,7 @@ class serviiApi {
|
|||||||
theme: "light",
|
theme: "light",
|
||||||
transition: Bounce,
|
transition: Bounce,
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return { return_code: status, message: json.message };
|
return { return_code: status, message: json.message };
|
||||||
}
|
}
|
||||||
@ -119,6 +123,11 @@ class serviiApi {
|
|||||||
return this.call(serviiRequest.fetchServers, payload);
|
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> {
|
public static async accountCreate(): Promise<ApiResponse> {
|
||||||
const payload: BaseRequest = { token: this.token() };
|
const payload: BaseRequest = { token: this.token() };
|
||||||
return this.call(serviiRequest.accountCreate, payload);
|
return this.call(serviiRequest.accountCreate, payload);
|
||||||
@ -162,11 +171,6 @@ class serviiApi {
|
|||||||
const payload: CommandRequest = { token: this.token(), command: command, name: name };
|
const payload: CommandRequest = { token: this.token(), command: command, name: name };
|
||||||
return this.call(serviiRequest.command, payload);
|
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;
|
export default serviiApi;
|
||||||
|
Loading…
Reference in New Issue
Block a user