admin(ui): add missing API requests
This commit is contained in:
parent
63daa7b14f
commit
b45592466e
|
@ -0,0 +1,12 @@
|
||||||
|
import http from '@/api/http';
|
||||||
|
import { Database, rawDataToDatabase } from '@/api/admin/databases/getDatabases';
|
||||||
|
|
||||||
|
export default (name: string): Promise<Database> => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
http.post('/api/application/databases', {
|
||||||
|
name,
|
||||||
|
})
|
||||||
|
.then(({ data }) => resolve(rawDataToDatabase(data)))
|
||||||
|
.catch(reject);
|
||||||
|
});
|
||||||
|
};
|
|
@ -0,0 +1,9 @@
|
||||||
|
import http from '@/api/http';
|
||||||
|
|
||||||
|
export default (id: number): Promise<void> => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
http.delete(`/api/application/databases/${id}`)
|
||||||
|
.then(() => resolve())
|
||||||
|
.catch(reject);
|
||||||
|
});
|
||||||
|
};
|
|
@ -0,0 +1,10 @@
|
||||||
|
import http from '@/api/http';
|
||||||
|
import { Database, rawDataToDatabase } from '@/api/admin/databases/getDatabases';
|
||||||
|
|
||||||
|
export default (id: number): Promise<Database> => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
http.get(`/api/application/databases/${id}`)
|
||||||
|
.then(({ data }) => resolve(rawDataToDatabase(data)))
|
||||||
|
.catch(reject);
|
||||||
|
});
|
||||||
|
};
|
|
@ -1,12 +1,12 @@
|
||||||
import http from '@/api/http';
|
import http from '@/api/http';
|
||||||
import { Location } from '@/api/admin/locations/getLocations';
|
import { Location, rawDataToLocation } from '@/api/admin/locations/getLocations';
|
||||||
|
|
||||||
export default (short: string, long?: string): Promise<Location> => {
|
export default (short: string, long?: string): Promise<Location> => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
http.post('/api/application/locations', {
|
http.post('/api/application/locations', {
|
||||||
short, long,
|
short, long,
|
||||||
})
|
})
|
||||||
.then(({ data }) => resolve(data.attributes))
|
.then(({ data }) => resolve(rawDataToLocation(data)))
|
||||||
.catch(reject);
|
.catch(reject);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
import http from '@/api/http';
|
||||||
|
|
||||||
|
export default (id: number): Promise<void> => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
http.delete(`/api/application/locations/${id}`)
|
||||||
|
.then(() => resolve())
|
||||||
|
.catch(reject);
|
||||||
|
});
|
||||||
|
};
|
|
@ -0,0 +1,10 @@
|
||||||
|
import http from '@/api/http';
|
||||||
|
import { Location, rawDataToLocation } from '@/api/admin/locations/getLocations';
|
||||||
|
|
||||||
|
export default (id: number): Promise<Location> => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
http.get(`/api/application/locations/${id}`)
|
||||||
|
.then(({ data }) => resolve(rawDataToLocation(data)))
|
||||||
|
.catch(reject);
|
||||||
|
});
|
||||||
|
};
|
|
@ -0,0 +1,12 @@
|
||||||
|
import http from '@/api/http';
|
||||||
|
import { Mount, rawDataToMount } from '@/api/admin/mounts/getMounts';
|
||||||
|
|
||||||
|
export default (name: string, description: string, source: string, target: string, readOnly: boolean, userMountable: boolean): Promise<Mount> => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
http.post('/api/application/mounts', {
|
||||||
|
name, description, source, target, read_only: readOnly, user_mountable: userMountable,
|
||||||
|
})
|
||||||
|
.then(({ data }) => resolve(rawDataToMount(data)))
|
||||||
|
.catch(reject);
|
||||||
|
});
|
||||||
|
};
|
|
@ -0,0 +1,9 @@
|
||||||
|
import http from '@/api/http';
|
||||||
|
|
||||||
|
export default (id: number): Promise<void> => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
http.delete(`/api/application/mounts/${id}`)
|
||||||
|
.then(() => resolve())
|
||||||
|
.catch(reject);
|
||||||
|
});
|
||||||
|
};
|
|
@ -0,0 +1,10 @@
|
||||||
|
import http from '@/api/http';
|
||||||
|
import { Mount, rawDataToMount } from '@/api/admin/mounts/getMounts';
|
||||||
|
|
||||||
|
export default (id: number): Promise<Mount> => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
http.get(`/api/application/mounts/${id}`)
|
||||||
|
.then(({ data }) => resolve(rawDataToMount(data)))
|
||||||
|
.catch(reject);
|
||||||
|
});
|
||||||
|
};
|
|
@ -1,12 +1,12 @@
|
||||||
import http from '@/api/http';
|
import http from '@/api/http';
|
||||||
import { Nest } from '@/api/admin/nests/getNests';
|
import { Nest, rawDataToNest } from '@/api/admin/nests/getNests';
|
||||||
|
|
||||||
export default (name: string, description?: string): Promise<Nest> => {
|
export default (name: string, description?: string): Promise<Nest> => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
http.post('/api/application/nests', {
|
http.post('/api/application/nests', {
|
||||||
name, description,
|
name, description,
|
||||||
})
|
})
|
||||||
.then(({ data }) => resolve(data.attributes))
|
.then(({ data }) => resolve(rawDataToNest(data)))
|
||||||
.catch(reject);
|
.catch(reject);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
import http from '@/api/http';
|
||||||
|
|
||||||
|
export default (id: number): Promise<void> => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
http.delete(`/api/application/nests/${id}`)
|
||||||
|
.then(() => resolve())
|
||||||
|
.catch(reject);
|
||||||
|
});
|
||||||
|
};
|
|
@ -0,0 +1,12 @@
|
||||||
|
import http from '@/api/http';
|
||||||
|
import { Egg, rawDataToEgg } from '@/api/admin/nests/eggs/getEggs';
|
||||||
|
|
||||||
|
export default (nestId: number, name: string): Promise<Egg> => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
http.post('/api/application/eggs', {
|
||||||
|
nestId, name,
|
||||||
|
})
|
||||||
|
.then(({ data }) => resolve(rawDataToEgg(data.attributes)))
|
||||||
|
.catch(reject);
|
||||||
|
});
|
||||||
|
};
|
|
@ -0,0 +1,9 @@
|
||||||
|
import http from '@/api/http';
|
||||||
|
|
||||||
|
export default (id: number): Promise<void> => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
http.delete(`/api/application/eggs/${id}`)
|
||||||
|
.then(() => resolve())
|
||||||
|
.catch(reject);
|
||||||
|
});
|
||||||
|
};
|
|
@ -0,0 +1,10 @@
|
||||||
|
import http from '@/api/http';
|
||||||
|
import { Egg, rawDataToEgg } from '@/api/admin/nests/eggs/getEggs';
|
||||||
|
|
||||||
|
export default (id: number): Promise<Egg> => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
http.get(`/api/application/eggs/${id}`)
|
||||||
|
.then(({ data }) => resolve(rawDataToEgg(data)))
|
||||||
|
.catch(reject);
|
||||||
|
});
|
||||||
|
};
|
|
@ -48,9 +48,9 @@ export const rawDataToEgg = ({ attributes }: FractalResponseData): Egg => ({
|
||||||
updatedAt: new Date(attributes.updated_at),
|
updatedAt: new Date(attributes.updated_at),
|
||||||
});
|
});
|
||||||
|
|
||||||
export default (id: number): Promise<Egg[]> => {
|
export default (nestId: number): Promise<Egg[]> => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
http.get(`/api/application/nests/${id}`)
|
http.get(`/api/application/nests/${nestId}`)
|
||||||
.then(({ data }) => resolve((data.data || []).map(rawDataToEgg)))
|
.then(({ data }) => resolve((data.data || []).map(rawDataToEgg)))
|
||||||
.catch(reject);
|
.catch(reject);
|
||||||
});
|
});
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
import http from '@/api/http';
|
||||||
|
import { Nest, rawDataToNest } from '@/api/admin/nests/getNests';
|
||||||
|
|
||||||
|
export default (id: number): Promise<Nest> => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
http.get(`/api/application/nests/${id}`)
|
||||||
|
.then(({ data }) => resolve(rawDataToNest(data)))
|
||||||
|
.catch(reject);
|
||||||
|
});
|
||||||
|
};
|
|
@ -0,0 +1,12 @@
|
||||||
|
import http from '@/api/http';
|
||||||
|
import { Node, rawDataToNode } from '@/api/admin/nodes/getNodes';
|
||||||
|
|
||||||
|
export default (name: string, description?: string): Promise<Node> => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
http.post('/api/application/nodes', {
|
||||||
|
name, description,
|
||||||
|
})
|
||||||
|
.then(({ data }) => resolve(rawDataToNode(data)))
|
||||||
|
.catch(reject);
|
||||||
|
});
|
||||||
|
};
|
|
@ -0,0 +1,9 @@
|
||||||
|
import http from '@/api/http';
|
||||||
|
|
||||||
|
export default (id: number): Promise<void> => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
http.delete(`/api/application/nodes/${id}`)
|
||||||
|
.then(() => resolve())
|
||||||
|
.catch(reject);
|
||||||
|
});
|
||||||
|
};
|
|
@ -0,0 +1,10 @@
|
||||||
|
import http from '@/api/http';
|
||||||
|
import { Node, rawDataToNode } from '@/api/admin/nodes/getNodes';
|
||||||
|
|
||||||
|
export default (id: number): Promise<Node> => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
http.get(`/api/application/nodes/${id}`)
|
||||||
|
.then(({ data }) => resolve(rawDataToNode(data)))
|
||||||
|
.catch(reject);
|
||||||
|
});
|
||||||
|
};
|
|
@ -1,12 +1,12 @@
|
||||||
import http from '@/api/http';
|
import http from '@/api/http';
|
||||||
import { Role } from '@/api/admin/roles/getRoles';
|
import { Role, rawDataToRole } from '@/api/admin/roles/getRoles';
|
||||||
|
|
||||||
export default (name: string, description?: string): Promise<Role> => {
|
export default (name: string, description?: string): Promise<Role> => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
http.post('/api/application/roles', {
|
http.post('/api/application/roles', {
|
||||||
name, description,
|
name, description,
|
||||||
})
|
})
|
||||||
.then(({ data }) => resolve(data.attributes))
|
.then(({ data }) => resolve(rawDataToRole(data)))
|
||||||
.catch(reject);
|
.catch(reject);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
import http from '@/api/http';
|
||||||
|
|
||||||
|
export default (id: number): Promise<void> => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
http.delete(`/api/application/roles/${id}`)
|
||||||
|
.then(() => resolve())
|
||||||
|
.catch(reject);
|
||||||
|
});
|
||||||
|
};
|
|
@ -0,0 +1,10 @@
|
||||||
|
import http from '@/api/http';
|
||||||
|
import { Role, rawDataToRole } from '@/api/admin/roles/getRoles';
|
||||||
|
|
||||||
|
export default (id: number): Promise<Role> => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
http.get(`/api/application/roles/${id}`)
|
||||||
|
.then(({ data }) => resolve(rawDataToRole(data)))
|
||||||
|
.catch(reject);
|
||||||
|
});
|
||||||
|
};
|
|
@ -0,0 +1,12 @@
|
||||||
|
import http from '@/api/http';
|
||||||
|
import { Server, rawDataToServer } from '@/api/admin/servers/getServers';
|
||||||
|
|
||||||
|
export default (name: string, description: string): Promise<Server> => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
http.post('/api/application/servers', {
|
||||||
|
name, description,
|
||||||
|
})
|
||||||
|
.then(({ data }) => resolve(rawDataToServer(data)))
|
||||||
|
.catch(reject);
|
||||||
|
});
|
||||||
|
};
|
|
@ -0,0 +1,9 @@
|
||||||
|
import http from '@/api/http';
|
||||||
|
|
||||||
|
export default (id: number): Promise<void> => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
http.delete(`/api/application/servers/${id}`)
|
||||||
|
.then(() => resolve())
|
||||||
|
.catch(reject);
|
||||||
|
});
|
||||||
|
};
|
|
@ -0,0 +1,10 @@
|
||||||
|
import http from '@/api/http';
|
||||||
|
import { Server, rawDataToServer } from '@/api/admin/servers/getServers';
|
||||||
|
|
||||||
|
export default (id: number): Promise<Server> => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
http.get(`/api/application/servers/${id}`)
|
||||||
|
.then(({ data }) => resolve(rawDataToServer(data)))
|
||||||
|
.catch(reject);
|
||||||
|
});
|
||||||
|
};
|
|
@ -23,7 +23,7 @@ export interface Server {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const rawDataToServerObject = ({ attributes }: FractalResponseData): Server => ({
|
export const rawDataToServer = ({ attributes }: FractalResponseData): Server => ({
|
||||||
id: attributes.id,
|
id: attributes.id,
|
||||||
externalId: attributes.external_id,
|
externalId: attributes.external_id,
|
||||||
uuid: attributes.uuid,
|
uuid: attributes.uuid,
|
||||||
|
@ -56,7 +56,7 @@ export default (include: string[] = []) => {
|
||||||
const { data } = await http.get('/api/application/servers', { params: { include: include.join(','), page } });
|
const { data } = await http.get('/api/application/servers', { params: { include: include.join(','), page } });
|
||||||
|
|
||||||
return ({
|
return ({
|
||||||
items: (data.data || []).map(rawDataToServerObject),
|
items: (data.data || []).map(rawDataToServer),
|
||||||
pagination: getPaginationSet(data.meta.pagination),
|
pagination: getPaginationSet(data.meta.pagination),
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
import http from '@/api/http';
|
||||||
|
import { User, rawDataToUser } from '@/api/admin/users/getUsers';
|
||||||
|
|
||||||
|
export default (name: string): Promise<User> => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
http.post('/api/application/users', {
|
||||||
|
name,
|
||||||
|
})
|
||||||
|
.then(({ data }) => resolve(rawDataToUser(data)))
|
||||||
|
.catch(reject);
|
||||||
|
});
|
||||||
|
};
|
|
@ -0,0 +1,9 @@
|
||||||
|
import http from '@/api/http';
|
||||||
|
|
||||||
|
export default (id: number): Promise<void> => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
http.delete(`/api/application/users/${id}`)
|
||||||
|
.then(() => resolve())
|
||||||
|
.catch(reject);
|
||||||
|
});
|
||||||
|
};
|
|
@ -0,0 +1,10 @@
|
||||||
|
import http from '@/api/http';
|
||||||
|
import { User, rawDataToUser } from '@/api/admin/users/getUsers';
|
||||||
|
|
||||||
|
export default (id: number): Promise<User> => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
http.get(`/api/application/users/${id}`)
|
||||||
|
.then(({ data }) => resolve(rawDataToUser(data)))
|
||||||
|
.catch(reject);
|
||||||
|
});
|
||||||
|
};
|
Loading…
Reference in New Issue