0ecfb40f5e
Allow API to retrun max_connections for frontend database page
33 lines
1.1 KiB
TypeScript
33 lines
1.1 KiB
TypeScript
import http from '@/api/http';
|
|
|
|
export interface ServerDatabase {
|
|
id: string;
|
|
name: string;
|
|
username: string;
|
|
connectionString: string;
|
|
allowConnectionsFrom: string;
|
|
maxConnections: string;
|
|
password?: string;
|
|
}
|
|
|
|
export const rawDataToServerDatabase = (data: any): ServerDatabase => ({
|
|
id: data.id,
|
|
name: data.name,
|
|
username: data.username,
|
|
connectionString: `${data.host.address}:${data.host.port}`,
|
|
allowConnectionsFrom: data.connections_from,
|
|
maxConnections: data.max_connections,
|
|
password: data.relationships && data.relationships.password ? data.relationships.password.attributes.password : undefined,
|
|
});
|
|
|
|
export default (uuid: string, includePassword: boolean = true): Promise<ServerDatabase[]> => {
|
|
return new Promise((resolve, reject) => {
|
|
http.get(`/api/client/servers/${uuid}/databases`, {
|
|
params: includePassword ? { include: 'password' } : undefined,
|
|
})
|
|
.then(response => resolve(
|
|
(response.data.data || []).map((item: any) => rawDataToServerDatabase(item.attributes))
|
|
))
|
|
.catch(reject);
|
|
});
|
|
};
|