Browse Source

feat: finished basic implementation of showing jobs on statistics admin page

Kristian Vos 1 year ago
parent
commit
17cca1d8df
2 changed files with 52 additions and 17 deletions
  1. 19 4
      backend/logic/actions/utils.js
  2. 33 13
      frontend/src/pages/Admin/Statistics.vue

+ 19 - 4
backend/logic/actions/utils.js

@@ -56,9 +56,26 @@ export default {
 			[
 				next => {
 					next(null, UtilsModule.moduleManager.modules[moduleName]);
+				},
+
+				({ jobStatistics, jobQueue }, next) => {
+					const taskMapFn = runningTask => ({
+						name: runningTask.job.name,
+						uniqueId: runningTask.job.uniqueId,
+						status: runningTask.job.status,
+						priority: runningTask.priority,
+						parentUniqueId: runningTask.job.parentJob?.uniqueId ?? "N/A",
+						parentName: runningTask.job.parentJob?.name ?? "N/A"
+					});
+					next(null, {
+						jobStatistics,
+						runningTasks: jobQueue.runningTasks.map(taskMapFn),
+						pausedTasks: jobQueue.pausedTasks.map(taskMapFn),
+						queuedTasks: jobQueue.queue.map(taskMapFn)
+					});
 				}
 			],
-			async (err, module) => {
+			async (err, data) => {
 				if (err && err !== true) {
 					err = await UtilsModule.runJob("GET_ERROR", { error: err }, this);
 					this.log("ERROR", "GET_MODULE", `User ${session.userId} failed to get module. '${err}'`);
@@ -68,9 +85,7 @@ export default {
 					cb({
 						status: "success",
 						message: "Successfully got module info.",
-						data: {
-							jobStatistics: module.jobStatistics
-						}
+						data
 					});
 				}
 			}

+ 33 - 13
frontend/src/pages/Admin/Statistics.vue

@@ -20,7 +20,9 @@ onMounted(() => {
 			socket.dispatch("utils.getModule", route.query.moduleName, res => {
 				if (res.status === "success")
 					activeModule.value = {
-						runningJobs: res.data.runningJobs,
+						runningTasks: res.data.runningTasks,
+						queuedTasks: res.data.queuedTasks,
+						pausedTasks: res.data.pausedTasks,
 						jobStatistics: res.data.jobStatistics
 					};
 			});
@@ -84,7 +86,11 @@ onMounted(() => {
 					<thead>
 						<tr>
 							<th>Name</th>
-							<th>Payload</th>
+							<th>UUID</th>
+							<th>Status</th>
+							<th>Priority</th>
+							<th>Parent UUID</th>
+							<th>Parent name</th>
 						</tr>
 					</thead>
 					<tbody>
@@ -93,9 +99,11 @@ onMounted(() => {
 							:key="JSON.stringify(job)"
 						>
 							<td>{{ job.name }}</td>
-							<td>
-								{{ JSON.stringify(job.payload) }}
-							</td>
+							<td>{{ job.uniqueId }}</td>
+							<td>{{ job.status }}</td>
+							<td>{{ job.priority }}</td>
+							<td>{{ job.parentUniqueId }}</td>
+							<td>{{ job.parentName }}</td>
 						</tr>
 					</tbody>
 				</table>
@@ -109,7 +117,11 @@ onMounted(() => {
 					<thead>
 						<tr>
 							<th>Name</th>
-							<th>Payload</th>
+							<th>UUID</th>
+							<th>Status</th>
+							<th>Priority</th>
+							<th>Parent UUID</th>
+							<th>Parent name</th>
 						</tr>
 					</thead>
 					<tbody>
@@ -118,9 +130,11 @@ onMounted(() => {
 							:key="JSON.stringify(job)"
 						>
 							<td>{{ job.name }}</td>
-							<td>
-								{{ JSON.stringify(job.payload) }}
-							</td>
+							<td>{{ job.uniqueId }}</td>
+							<td>{{ job.status }}</td>
+							<td>{{ job.priority }}</td>
+							<td>{{ job.parentUniqueId }}</td>
+							<td>{{ job.parentName }}</td>
 						</tr>
 					</tbody>
 				</table>
@@ -134,7 +148,11 @@ onMounted(() => {
 					<thead>
 						<tr>
 							<th>Name</th>
-							<th>Payload</th>
+							<th>UUID</th>
+							<th>Status</th>
+							<th>Priority</th>
+							<th>Parent UUID</th>
+							<th>Parent name</th>
 						</tr>
 					</thead>
 					<tbody>
@@ -143,9 +161,11 @@ onMounted(() => {
 							:key="JSON.stringify(job)"
 						>
 							<td>{{ job.name }}</td>
-							<td>
-								{{ JSON.stringify(job.payload) }}
-							</td>
+							<td>{{ job.uniqueId }}</td>
+							<td>{{ job.status }}</td>
+							<td>{{ job.priority }}</td>
+							<td>{{ job.parentUniqueId }}</td>
+							<td>{{ job.parentName }}</td>
 						</tr>
 					</tbody>
 				</table>