ui(admin): add new node page
This commit is contained in:
parent
3c01dbbcc5
commit
d0a78ec067
15 changed files with 362 additions and 176 deletions
|
@ -1,11 +1,41 @@
|
|||
import http from '@/api/http';
|
||||
import { Node, rawDataToNode } from '@/api/admin/nodes/getNodes';
|
||||
|
||||
export default (name: string, description: string | null, include: string[] = []): Promise<Node> => {
|
||||
export interface Values {
|
||||
name: string;
|
||||
locationId: number;
|
||||
databaseHostId: number | null;
|
||||
fqdn: string;
|
||||
scheme: string;
|
||||
behindProxy: boolean;
|
||||
public: boolean;
|
||||
daemonBase: string;
|
||||
|
||||
memory: number;
|
||||
memoryOverallocate: number;
|
||||
disk: number;
|
||||
diskOverallocate: number;
|
||||
|
||||
listenPortHTTP: number;
|
||||
publicPortHTTP: number;
|
||||
listenPortSFTP: number;
|
||||
publicPortSFTP: number;
|
||||
}
|
||||
|
||||
export default (values: Values, include: string[] = []): Promise<Node> => {
|
||||
const data = {};
|
||||
|
||||
Object.keys(values).forEach((key) => {
|
||||
const key2 = key
|
||||
.replace('HTTP', 'Http')
|
||||
.replace('SFTP', 'Sftp')
|
||||
.replace(/[A-Z]/g, letter => `_${letter.toLowerCase()}`);
|
||||
// @ts-ignore
|
||||
data[key2] = values[key];
|
||||
});
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
http.post('/api/application/nodes', {
|
||||
name, description,
|
||||
}, { params: { include: include.join(',') } })
|
||||
http.post('/api/application/nodes', data, { params: { include: include.join(',') } })
|
||||
.then(({ data }) => resolve(rawDataToNode(data)))
|
||||
.catch(reject);
|
||||
});
|
||||
|
|
|
@ -14,9 +14,7 @@ export default (id: number, node: Partial<Node>, include: string[] = []): Promis
|
|||
});
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
http.patch(`/api/application/nodes/${id}`, {
|
||||
...data,
|
||||
}, { params: { include: include.join(',') } })
|
||||
http.patch(`/api/application/nodes/${id}`, data, { params: { include: include.join(',') } })
|
||||
.then(({ data }) => resolve(rawDataToNode(data)))
|
||||
.catch(reject);
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue