Skip to content

Commit 2cd6647

Browse files
authored
Allow admins to view and cancel other users jobs (#8112)
1 parent 18fb4e0 commit 2cd6647

File tree

6 files changed

+22
-3
lines changed

6 files changed

+22
-3
lines changed

CHANGELOG.unreleased.md

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.released
1717

1818
### Changed
1919
- Some mesh-related actions were disabled in proofreading-mode when using meshfiles that were created for a mapping rather than an oversegmentation. [#8091](https://github.com/scalableminds/webknossos/pull/8091)
20+
- Admins can now see and cancel all jobs. The owner of the job is shown in the job list. [#8112](https://github.com/scalableminds/webknossos/pull/8112)
2021

2122
### Fixed
2223
- Fixed a bug during dataset upload in case the configured `datastore.baseFolder` is an absolute path. [#8098](https://github.com/scalableminds/webknossos/pull/8098) [#8103](https://github.com/scalableminds/webknossos/pull/8103)

app/models/job/Job.scala

+3-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,9 @@ class JobDAO @Inject()(sqlClient: SqlClient)(implicit ec: ExecutionContext)
141141
"""
142142

143143
private def listAccessQ(requestingUserId: ObjectId) =
144-
q"""_owner = $requestingUserId"""
144+
q"""_owner = $requestingUserId OR
145+
((SELECT u._organization FROM webknossos.users_ u WHERE u._id = _owner) IN (SELECT _organization FROM webknossos.users_ WHERE _id = $requestingUserId AND isAdmin))
146+
"""
145147

146148
override def findAll(implicit ctx: DBAccessContext): Fox[List[Job]] =
147149
for {

app/models/job/JobService.scala

+2
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,11 @@ class JobService @Inject()(wkConf: WkConf,
163163
owner <- userDAO.findOne(job._owner) ?~> "user.notFound"
164164
organization <- organizationDAO.findOne(owner._organization) ?~> "organization.notFound"
165165
resultLink = job.resultLink(organization._id)
166+
ownerJson <- userService.compactWrites(owner)
166167
} yield {
167168
Json.obj(
168169
"id" -> job._id.id,
170+
"owner" -> ownerJson,
169171
"command" -> job.command,
170172
"commandArgs" -> (job.commandArgs - "webknossos_token" - "user_auth_token"),
171173
"state" -> job.state,

frontend/javascripts/admin/api/jobs.ts

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { assertResponseLimit } from "./api_utils";
1616
function transformBackendJobToAPIJob(job: any): APIJob {
1717
return {
1818
id: job.id,
19+
owner: job.owner,
1920
type: job.command,
2021
datasetName: job.commandArgs.dataset_name,
2122
organizationId: job.commandArgs.organization_name,

frontend/javascripts/admin/job/job_list_view.tsx

+14-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
InfoCircleOutlined,
1616
} from "@ant-design/icons";
1717
import type * as React from "react";
18-
import { type APIJob, APIJobType } from "types/api_flow_types";
18+
import { type APIJob, APIJobType, type APIUserBase } from "types/api_flow_types";
1919
import { getJobs, cancelJob } from "admin/admin_rest_api";
2020
import Persistence from "libs/persistence";
2121
import * as Utils from "libs/utils";
@@ -375,7 +375,7 @@ function JobListView() {
375375
</Tooltip>
376376
</a>
377377
<br />
378-
WEBKNOSSOS will notfiy you via email when a job has finished or reload this page to track
378+
WEBKNOSSOS will notify you via email when a job has finished or reload this page to track
379379
progress.
380380
</Typography.Paragraph>
381381
<div
@@ -410,6 +410,18 @@ function JobListView() {
410410
sorter={Utils.compareBy<APIJob>((job) => job.createdAt)}
411411
defaultSortOrder="descend"
412412
/>
413+
<Column
414+
title="Owner"
415+
dataIndex="owner"
416+
key="owner"
417+
sorter={Utils.localeCompareBy<APIJob>((job) => job.owner.lastName)}
418+
render={(owner: APIUserBase) => (
419+
<>
420+
<div>{owner.email ? `${owner.lastName}, ${owner.firstName}` : "-"}</div>
421+
<div>{owner.email ? `(${owner.email})` : "-"}</div>
422+
</>
423+
)}
424+
/>
413425
<Column
414426
title="State"
415427
key="state"

frontend/javascripts/types/api_flow_types.ts

+1
Original file line numberDiff line numberDiff line change
@@ -711,6 +711,7 @@ export type WkLibsNdBoundingBox = BoundingBoxObject & {
711711

712712
export type APIJob = {
713713
readonly id: string;
714+
readonly owner: APIUserBase;
714715
readonly datasetName: string | null | undefined;
715716
readonly exportFileName: string | null | undefined;
716717
readonly layerName: string | null | undefined;

0 commit comments

Comments
 (0)