diff --git a/backend/proxmox_api/controllers/default_controller.py b/backend/proxmox_api/controllers/default_controller.py index 72b0ca7..d6d45bf 100644 --- a/backend/proxmox_api/controllers/default_controller.py +++ b/backend/proxmox_api/controllers/default_controller.py @@ -484,6 +484,7 @@ def get_vm_id(vmid): # noqa: E501 status = proxmox.get_proxmox_vm_status(vmid, node) type = dbfct.get_vm_type(vmid) created_on = get_vm_created_on(vmid) + last_backup_date = proxmox.get_vm_last_backup_date(vmid) (vmConfig, response) = proxmox.get_vm_config(vmid, node) #print("get_vm_config for " , vmid , " took ") @@ -492,13 +493,12 @@ def get_vm_id(vmid): # noqa: E501 if response == 500: print("500 error, vmConfig = ", vmConfig) return vmConfig, 500 - print("500 ended") elif response == 404: return {"error": "VM not found"},404 elif response == 200 or( response == 201 and 'status' in vmConfig.keys()): # If the returned code is 201 and the vm is just created return vmConfig, response elif response != 201 : - return {"error": "API unkonwn response"},500 + return {"error": "API unknown response"},500 try: name = vmConfig["name"] ram = vmConfig["ram"] @@ -522,7 +522,7 @@ def get_vm_id(vmid): # noqa: E501 if status[0]["status"] != 'running': return {"name": name, "autoreboot": autoreboot, "user": owner if admin else "", "ip": "", "status": status[0]["status"], "ram": ram, "cpu": cpu, "disk": disk, "type": type[0]["type"], - "ram_usage": 0, "cpu_usage": 0, "uptime": 0, "created_on": created_on[0]["created_on"], "unsecure" : isUnsecure}, 201 + "ram_usage": 0, "cpu_usage": 0, "uptime": 0, "created_on": created_on[0]["created_on"], "unsecure" : isUnsecure, "last_backup_date" : last_backup_date}, 201 else: ip = proxmox.get_vm_ip(vmid, node) current_status,response = proxmox.get_vm_current_status(vmid, node) @@ -552,7 +552,7 @@ def get_vm_id(vmid): # noqa: E501 , "status": status[0]["status"], "ram": ram , "cpu": cpu, "disk": disk, "type": type[0]["type"] , "ram_usage": ram_usage, "cpu_usage": cpu_usage - , "uptime": uptime, "created_on": created_on[0]["created_on"], "unsecure":isUnsecure}, 201 + , "uptime": uptime, "created_on": created_on[0]["created_on"], "unsecure":isUnsecure, "last_backup_date" : last_backup_date}, 201 elif status[1] == 404 or type[1] == 404 : return {"error": "vm not found"}, 404 diff --git a/frontend/src/app/models/vm.ts b/frontend/src/app/models/vm.ts index e564f76..f827d63 100644 --- a/frontend/src/app/models/vm.ts +++ b/frontend/src/app/models/vm.ts @@ -15,6 +15,7 @@ export class Vm { public ramUsage?: string, public cpuUsage?: string, public uptime?: string, + public lastBackupDate?: string, public createdOn?: string, public isUnsecure?: boolean, diff --git a/frontend/src/app/vm/vm.component.html b/frontend/src/app/vm/vm.component.html index 426c858..2b9d8e1 100644 --- a/frontend/src/app/vm/vm.component.html +++ b/frontend/src/app/vm/vm.component.html @@ -161,7 +161,7 @@

{{'vm.information' | translate}}

{{'vm.owner' | translate}} : {{ user.vms[0].user }}

{{'vm.createdOn' | translate}} : {{user.vms[0].createdOn}}

- +

{{'vm.lastBackup' | translate}} : {{formatTimestamp(user.vms[0].lastBackup)}}

{{'vm.upTime' | translate}} : {{secondsToDhms( user.vms[0].uptime )}}



diff --git a/frontend/src/app/vm/vm.component.ts b/frontend/src/app/vm/vm.component.ts index 00f28fb..2ce7117 100644 --- a/frontend/src/app/vm/vm.component.ts +++ b/frontend/src/app/vm/vm.component.ts @@ -109,6 +109,17 @@ export class VmComponent implements OnInit, OnDestroy { return dDisplay + hDisplay + mDisplay + sDisplay; } + formatTimestamp(timestamp): string { + const date = new Date(timestamp*1000); + const year = date.getFullYear(); + const month = (date.getMonth() + 1).toString().padStart(2, '0'); + const day = date.getDate().toString().padStart(2, '0'); + const hours = date.getHours().toString().padStart(2, '0'); + const minutes = date.getMinutes().toString().padStart(2, '0'); + + return `${year}-${month}-${day} ${hours}:${minutes}`; + } + commit_edit(status: string): void { const data = { @@ -215,6 +226,7 @@ export class VmComponent implements OnInit, OnDestroy { vm.ramUsage = rep.body['ram_usage']; vm.cpuUsage = rep.body['cpu_usage']; vm.uptime = rep.body['uptime']; + vm.lastBackupDate = rep.body['last_backup_date']; vm.isUnsecure = Boolean(rep.body["unsecure"]); if (rep.body['ip'] == ""){ vm.ip = "" diff --git a/frontend/src/app/vms/vms.component.ts b/frontend/src/app/vms/vms.component.ts index fbc1793..450f17b 100644 --- a/frontend/src/app/vms/vms.component.ts +++ b/frontend/src/app/vms/vms.component.ts @@ -146,6 +146,8 @@ export class VmsComponent implements OnInit, OnDestroy { vm.user = rep.body['user']; vm.ip = rep.body['ip'][0]; vm.uptime = rep.body['uptime']; + vm.lastBackupDate = rep.body['last_backup_date'] + vm.createdOn = rep.body['created_on']; if (rep.body['type'] === 'nginx_vm') { vm.type = "web_server"; diff --git a/frontend/src/assets/i18n/en.json b/frontend/src/assets/i18n/en.json index 3e14967..9bcc52f 100644 --- a/frontend/src/assets/i18n/en.json +++ b/frontend/src/assets/i18n/en.json @@ -225,6 +225,7 @@ "vm.owner": "Owner", "vm.createdOn": "Created on", "vm.uptime": "Uptime", + "vm.lastBackup": "Last backup", "vm.systemInformation": "System Information", "vm.cpu": "CPU", "vm.ram": "RAM (GB)", diff --git a/frontend/src/assets/i18n/fr.json b/frontend/src/assets/i18n/fr.json index 137f373..4c84f1c 100644 --- a/frontend/src/assets/i18n/fr.json +++ b/frontend/src/assets/i18n/fr.json @@ -235,6 +235,7 @@ "vm.owner": "Propriétaire", "vm.createdOn": "Créée le", "vm.uptime": "Uptime", + "vm.lastBackup": "Dernière backup", "vm.systemInformation": "Informations sur le Système", "vm.cpu": "CPU", "vm.ram": "RAM (GB)",