diff --git a/src/routes/applications/[id]/index.svelte b/src/routes/applications/[id]/index.svelte
index a00f08d2f..78fa72dff 100644
--- a/src/routes/applications/[id]/index.svelte
+++ b/src/routes/applications/[id]/index.svelte
@@ -102,7 +102,7 @@
onMount(async () => {
if (browser && window.location.hostname === 'demo.coolify.io' && !application.fqdn) {
application.fqdn = `http://${cuid()}.demo.coolify.io`;
- await handleSubmit();
+ await post(`/applications/${id}.json`, { ...application });
}
domainEl.focus();
await getUsage();
diff --git a/src/routes/databases/[id]/index.svelte b/src/routes/databases/[id]/index.svelte
index 3ead53529..c9eb7a4ff 100644
--- a/src/routes/databases/[id]/index.svelte
+++ b/src/routes/databases/[id]/index.svelte
@@ -33,10 +33,40 @@
@@ -49,4 +79,31 @@
+
+
Database Usage
+
+
+
+
- Used Memory / Memory Limit
+ -
+ {usage?.MemUsage}
+
+
+
+
+
- Used CPU
+ -
+ {usage?.CPUPerc}
+
+
+
+
+
- Network IO
+ -
+ {usage?.NetIO}
+
+
+
+
+
diff --git a/src/routes/applications/[id]/usage.json.ts b/src/routes/databases/[id]/usage.json.ts
similarity index 55%
rename from src/routes/applications/[id]/usage.json.ts
rename to src/routes/databases/[id]/usage.json.ts
index 2ff28e6ae..9ec987310 100644
--- a/src/routes/applications/[id]/usage.json.ts
+++ b/src/routes/databases/[id]/usage.json.ts
@@ -1,9 +1,8 @@
-import { asyncExecShell, getUserDetails } from '$lib/common';
+import { getUserDetails } from '$lib/common';
import * as db from '$lib/database';
import { ErrorHandler } from '$lib/database';
-import { checkContainer, getContainerUsage, isContainerExited } from '$lib/haproxy';
+import { getContainerUsage } from '$lib/haproxy';
import type { RequestHandler } from '@sveltejs/kit';
-import { setDefaultConfiguration } from '$lib/buildPacks/common';
export const get: RequestHandler = async (event) => {
const { teamId, status, body } = await getUserDetails(event);
@@ -13,9 +12,9 @@ export const get: RequestHandler = async (event) => {
let usage = {};
try {
- const application = await db.getApplication({ id, teamId });
- if (application.destinationDockerId) {
- [usage] = await Promise.all([getContainerUsage(application.destinationDocker.engine, id)]);
+ const database = await db.getDatabase({ id, teamId });
+ if (database.destinationDockerId) {
+ [usage] = await Promise.all([getContainerUsage(database.destinationDocker.engine, id)]);
}
return {
status: 200,
diff --git a/src/routes/services/[id]/_Services/_Services.svelte b/src/routes/services/[id]/_Services/_Services.svelte
index 826a3bdc8..d1d638bb4 100644
--- a/src/routes/services/[id]/_Services/_Services.svelte
+++ b/src/routes/services/[id]/_Services/_Services.svelte
@@ -74,7 +74,7 @@
onMount(async () => {
if (browser && window.location.hostname === 'demo.coolify.io' && !service.fqdn) {
service.fqdn = `http://${cuid()}.demo.coolify.io`;
- await handleSubmit();
+ await post(`/services/${id}/${service.type}.json`, { ...service });
}
});
diff --git a/src/routes/services/[id]/index.svelte b/src/routes/services/[id]/index.svelte
index 2a3bc0d26..4d231a8fb 100644
--- a/src/routes/services/[id]/index.svelte
+++ b/src/routes/services/[id]/index.svelte
@@ -32,11 +32,41 @@
@@ -46,6 +76,7 @@
{service.name}
+
{#if service.fqdn}
+
+
Service Usage
+
+
+
+
- Used Memory / Memory Limit
+ -
+ {usage?.MemUsage}
+
+
+
+
- Used CPU
+ -
+ {usage?.CPUPerc}
+
+
+
+
+
- Network IO
+ -
+ {usage?.NetIO}
+
+
+
+
+
diff --git a/src/routes/services/[id]/usage.json.ts b/src/routes/services/[id]/usage.json.ts
new file mode 100644
index 000000000..24e27b1c4
--- /dev/null
+++ b/src/routes/services/[id]/usage.json.ts
@@ -0,0 +1,30 @@
+import { getUserDetails } from '$lib/common';
+import * as db from '$lib/database';
+import { ErrorHandler } from '$lib/database';
+import { getContainerUsage } from '$lib/haproxy';
+import type { RequestHandler } from '@sveltejs/kit';
+
+export const get: RequestHandler = async (event) => {
+ const { teamId, status, body } = await getUserDetails(event);
+ if (status === 401) return { status, body };
+
+ const { id } = event.params;
+
+ let usage = {};
+ try {
+ const service = await db.getService({ id, teamId });
+ if (service.destinationDockerId) {
+ [usage] = await Promise.all([getContainerUsage(service.destinationDocker.engine, id)]);
+ }
+ return {
+ status: 200,
+ body: {
+ usage
+ },
+ headers: {}
+ };
+ } catch (error) {
+ console.log(error);
+ return ErrorHandler(error);
+ }
+};