From 8512a7558ed8f150c3287311e61cc86fea7dca02 Mon Sep 17 00:00:00 2001 From: Vishesh Date: Mon, 5 Feb 2024 16:40:49 +0530 Subject: [PATCH 01/13] Add UI to view and download usage records --- .../admin/usage/GenerateUsageRecordsCmd.java | 4 +- ui/public/locales/en.json | 26 + ui/src/components/view/ListView.vue | 46 +- ui/src/config/router.js | 10 +- ui/src/config/section/infra/usage.js | 328 ++++++++ ui/src/core/lazy_lib/icons_use.js | 2 + ui/src/utils/util.js | 24 + ui/src/views/iam/RolePermissionTab.vue | 27 +- ui/src/views/infra/UsageRecords.vue | 712 ++++++++++++++++++ 9 files changed, 1147 insertions(+), 32 deletions(-) create mode 100644 ui/src/config/section/infra/usage.js create mode 100644 ui/src/views/infra/UsageRecords.vue diff --git a/api/src/main/java/org/apache/cloudstack/api/command/admin/usage/GenerateUsageRecordsCmd.java b/api/src/main/java/org/apache/cloudstack/api/command/admin/usage/GenerateUsageRecordsCmd.java index 491b0fe85bae..a0314586d92d 100644 --- a/api/src/main/java/org/apache/cloudstack/api/command/admin/usage/GenerateUsageRecordsCmd.java +++ b/api/src/main/java/org/apache/cloudstack/api/command/admin/usage/GenerateUsageRecordsCmd.java @@ -47,13 +47,13 @@ public class GenerateUsageRecordsCmd extends BaseCmd { @Parameter(name = ApiConstants.END_DATE, type = CommandType.DATE, - required = true, + required = false, description = "End date range for usage record query. Use yyyy-MM-dd as the date format, e.g. startDate=2009-06-03.") private Date endDate; @Parameter(name = ApiConstants.START_DATE, type = CommandType.DATE, - required = true, + required = false, description = "Start date range for usage record query. Use yyyy-MM-dd as the date format, e.g. startDate=2009-06-01.") private Date startDate; diff --git a/ui/public/locales/en.json b/ui/public/locales/en.json index 67b36d717a28..615b1580d459 100644 --- a/ui/public/locales/en.json +++ b/ui/public/locales/en.json @@ -615,6 +615,7 @@ "label.datetime.filter.starting": "Starting {startDate}.", "label.datetime.filter.up.to": "Up to {endDate}.", "label.day": "Day", +"label.days": "Days", "label.day.of.month": "Day of month", "label.day.of.week": "Day of week", "label.db.usage.metrics": "DB/Usage server", @@ -803,6 +804,7 @@ "label.done": "Done", "label.down": "Down", "label.download": "Download", +"label.download.csv": "Download CSV", "label.download.kubeconfig.cluster": "Download kubeconfig for the cluster

The kubectl command-line tool uses kubeconfig files to find the information it needs to choose a cluster and communicate with the API server of a cluster.", "label.download.kubectl": "Download kubectl tool for cluster's Kubernetes version", "label.download.kubernetes.cluster.config": "Download Kubernetes cluster config", @@ -921,6 +923,7 @@ "label.fetch.instances": "Fetch Instances", "label.fetch.latest": "Fetch latest", "label.filename": "File Name", +"label.fetched": "Fetched", "label.files": "Alternate files to retrieve", "label.filter": "Filter", "label.filter.annotations.all": "All comments", @@ -1226,6 +1229,8 @@ "label.label": "Label", "label.last.updated": "Last update", "label.lastannotated": "Last annotation date", +"label.lastheartbeat": "Last heartbeat", +"label.lastsuccessfuljob": "Last successful job", "label.lastboottime": "Boot time of the management server machine", "label.lastname": "Last name", "label.lastname.lower": "lastname", @@ -1520,6 +1525,7 @@ "label.of": "of", "label.of.month": "of month", "label.offerha": "Offer HA", +"label.offeringid": "Offering ID", "label.offeringtype": "Compute offering type", "label.ok": "OK", "label.only.end.date.and.time": "Only end date and time", @@ -1728,7 +1734,14 @@ "label.rados.secret": "RADOS secret", "label.rados.user": "RADOS user", "label.ram": "RAM", +"label.range.today": "Today", +"label.range.yesterday": "Yesterday", +"label.range.last.1week": "Last 1 week", +"label.range.last.2week": "Last 2 weeks", +"label.range.last.1month": "Last 1 month", +"label.range.last.3month": "Last 3 months", "label.raw.data": "Raw data", +"label.rawusage": "Raw usage (in hours)", "label.rbd": "RBD", "label.rbdid": "Cephx user", "label.rbdmonitor": "Ceph monitor", @@ -1970,6 +1983,7 @@ "label.sharedrouteripv6": "IPv6 address for the VR in this shared Network.", "label.sharewith": "Share with", "label.showing": "Showing", +"label.show.usage.records": "Show usage records", "label.shrinkok": "Shrink OK", "label.shutdown": "Shutdown", "label.shutdown.provider": "Shutdown provider", @@ -2278,8 +2292,20 @@ "label.upload.volume.from.url": "Upload volume from URL", "label.url": "URL", "label.usage.explanation": "Note: Only the usage server that owns the active usage job is shown here.", +"label.usage.records": "Usage records", +"label.usage.records.downloading": "Downloading usage records", +"label.usage.records.fetch.child.domains": "Fetch usage records for child domains", +"label.usage.records.usagetype.required": "Usage type is required with resource ID", +"label.usage.records.generate": "Generate usage records", +"label.usage.records.generate.description": "This will generate records only if there any records to be generated. i.e if the scheduled usage job was not run or failed", +"label.usage.records.purge": "Purge usage records", +"label.usage.records.purge.days": "Purge records older than", +"label.usage.records.purge.days.description": "Purge records older than the specified number of days.", +"label.usage.records.purge.alert": "Purging usage records will permanently delete the records from the database. Depending on the data being deleted, this can increase load on the database and may take a while. Are you sure you want to continue?", +"label.usageid": "Resource ID", "label.usageinterface": "Usage interface", "label.usagename": "Usage type", +"label.usagetype": "Usage type", "label.usageunit": "Unit", "label.usageislocal": "A Usage Server is installed locally", "label.usagetypedescription": "Usage description", diff --git a/ui/src/components/view/ListView.vue b/ui/src/components/view/ListView.vue index 2b1036a293dc..28c7bf789e6e 100644 --- a/ui/src/components/view/ListView.vue +++ b/ui/src/components/view/ListView.vue @@ -98,6 +98,9 @@ + @@ -275,6 +278,9 @@ +