forked from Alex/Pterodactyl-Panel
admin(ui): add missing API requests
This commit is contained in:
parent
63daa7b14f
commit
b45592466e
12
resources/scripts/api/admin/databases/createDatabase.ts
Normal file
12
resources/scripts/api/admin/databases/createDatabase.ts
Normal file
@ -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);
|
||||
});
|
||||
};
|
9
resources/scripts/api/admin/databases/deleteDatabase.ts
Normal file
9
resources/scripts/api/admin/databases/deleteDatabase.ts
Normal file
@ -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);
|
||||
});
|
||||
};
|
10
resources/scripts/api/admin/databases/getDatabase.ts
Normal file
10
resources/scripts/api/admin/databases/getDatabase.ts
Normal file
@ -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 { Location } from '@/api/admin/locations/getLocations';
|
||||
import { Location, rawDataToLocation } from '@/api/admin/locations/getLocations';
|
||||
|
||||
export default (short: string, long?: string): Promise<Location> => {
|
||||
return new Promise((resolve, reject) => {
|
||||
http.post('/api/application/locations', {
|
||||
short, long,
|
||||
})
|
||||
.then(({ data }) => resolve(data.attributes))
|
||||
.then(({ data }) => resolve(rawDataToLocation(data)))
|
||||
.catch(reject);
|
||||
});
|
||||
};
|
||||
|
9
resources/scripts/api/admin/locations/deleteLocation.ts
Normal file
9
resources/scripts/api/admin/locations/deleteLocation.ts
Normal file
@ -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);
|
||||
});
|
||||
};
|
10
resources/scripts/api/admin/locations/getLocation.ts
Normal file
10
resources/scripts/api/admin/locations/getLocation.ts
Normal file
@ -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);
|
||||
});
|
||||
};
|
12
resources/scripts/api/admin/mounts/createMount.ts
Normal file
12
resources/scripts/api/admin/mounts/createMount.ts
Normal file
@ -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);
|
||||
});
|
||||
};
|
9
resources/scripts/api/admin/mounts/deleteMount.ts
Normal file
9
resources/scripts/api/admin/mounts/deleteMount.ts
Normal file
@ -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);
|
||||
});
|
||||
};
|
10
resources/scripts/api/admin/mounts/getMount.ts
Normal file
10
resources/scripts/api/admin/mounts/getMount.ts
Normal file
@ -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 { Nest } from '@/api/admin/nests/getNests';
|
||||
import { Nest, rawDataToNest } from '@/api/admin/nests/getNests';
|
||||
|
||||
export default (name: string, description?: string): Promise<Nest> => {
|
||||
return new Promise((resolve, reject) => {
|
||||
http.post('/api/application/nests', {
|
||||
name, description,
|
||||
})
|
||||
.then(({ data }) => resolve(data.attributes))
|
||||
.then(({ data }) => resolve(rawDataToNest(data)))
|
||||
.catch(reject);
|
||||
});
|
||||
};
|
||||
|
9
resources/scripts/api/admin/nests/deleteNest.ts
Normal file
9
resources/scripts/api/admin/nests/deleteNest.ts
Normal file
@ -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);
|
||||
});
|
||||
};
|
12
resources/scripts/api/admin/nests/eggs/createEgg.ts
Normal file
12
resources/scripts/api/admin/nests/eggs/createEgg.ts
Normal file
@ -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);
|
||||
});
|
||||
};
|
9
resources/scripts/api/admin/nests/eggs/deleteEgg.ts
Normal file
9
resources/scripts/api/admin/nests/eggs/deleteEgg.ts
Normal file
@ -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);
|
||||
});
|
||||
};
|
10
resources/scripts/api/admin/nests/eggs/getEgg.ts
Normal file
10
resources/scripts/api/admin/nests/eggs/getEgg.ts
Normal file
@ -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),
|
||||
});
|
||||
|
||||
export default (id: number): Promise<Egg[]> => {
|
||||
export default (nestId: number): Promise<Egg[]> => {
|
||||
return new Promise((resolve, reject) => {
|
||||
http.get(`/api/application/nests/${id}`)
|
||||
http.get(`/api/application/nests/${nestId}`)
|
||||
.then(({ data }) => resolve((data.data || []).map(rawDataToEgg)))
|
||||
.catch(reject);
|
||||
});
|
||||
|
10
resources/scripts/api/admin/nests/getNest.ts
Normal file
10
resources/scripts/api/admin/nests/getNest.ts
Normal file
@ -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);
|
||||
});
|
||||
};
|
12
resources/scripts/api/admin/nodes/createNode.ts
Normal file
12
resources/scripts/api/admin/nodes/createNode.ts
Normal file
@ -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);
|
||||
});
|
||||
};
|
9
resources/scripts/api/admin/nodes/deleteNode.ts
Normal file
9
resources/scripts/api/admin/nodes/deleteNode.ts
Normal file
@ -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);
|
||||
});
|
||||
};
|
10
resources/scripts/api/admin/nodes/getNode.ts
Normal file
10
resources/scripts/api/admin/nodes/getNode.ts
Normal file
@ -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 { Role } from '@/api/admin/roles/getRoles';
|
||||
import { Role, rawDataToRole } from '@/api/admin/roles/getRoles';
|
||||
|
||||
export default (name: string, description?: string): Promise<Role> => {
|
||||
return new Promise((resolve, reject) => {
|
||||
http.post('/api/application/roles', {
|
||||
name, description,
|
||||
})
|
||||
.then(({ data }) => resolve(data.attributes))
|
||||
.then(({ data }) => resolve(rawDataToRole(data)))
|
||||
.catch(reject);
|
||||
});
|
||||
};
|
||||
|
9
resources/scripts/api/admin/roles/deleteRole.ts
Normal file
9
resources/scripts/api/admin/roles/deleteRole.ts
Normal file
@ -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);
|
||||
});
|
||||
};
|
10
resources/scripts/api/admin/roles/getRole.ts
Normal file
10
resources/scripts/api/admin/roles/getRole.ts
Normal file
@ -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);
|
||||
});
|
||||
};
|
12
resources/scripts/api/admin/servers/createServer.ts
Normal file
12
resources/scripts/api/admin/servers/createServer.ts
Normal file
@ -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);
|
||||
});
|
||||
};
|
9
resources/scripts/api/admin/servers/deleteServer.ts
Normal file
9
resources/scripts/api/admin/servers/deleteServer.ts
Normal file
@ -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);
|
||||
});
|
||||
};
|
10
resources/scripts/api/admin/servers/getServer.ts
Normal file
10
resources/scripts/api/admin/servers/getServer.ts
Normal file
@ -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,
|
||||
externalId: attributes.external_id,
|
||||
uuid: attributes.uuid,
|
||||
@ -56,7 +56,7 @@ export default (include: string[] = []) => {
|
||||
const { data } = await http.get('/api/application/servers', { params: { include: include.join(','), page } });
|
||||
|
||||
return ({
|
||||
items: (data.data || []).map(rawDataToServerObject),
|
||||
items: (data.data || []).map(rawDataToServer),
|
||||
pagination: getPaginationSet(data.meta.pagination),
|
||||
});
|
||||
});
|
||||
|
12
resources/scripts/api/admin/users/createUser.ts
Normal file
12
resources/scripts/api/admin/users/createUser.ts
Normal file
@ -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);
|
||||
});
|
||||
};
|
9
resources/scripts/api/admin/users/deleteUser.ts
Normal file
9
resources/scripts/api/admin/users/deleteUser.ts
Normal file
@ -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);
|
||||
});
|
||||
};
|
10
resources/scripts/api/admin/users/getUser.ts
Normal file
10
resources/scripts/api/admin/users/getUser.ts
Normal file
@ -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
Block a user