Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow admins to view and cancel other users jobs #8112

Merged
merged 3 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.released

### Changed
- 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)
- 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)

### Fixed
- 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)
Expand Down
4 changes: 3 additions & 1 deletion app/models/job/Job.scala
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,9 @@ class JobDAO @Inject()(sqlClient: SqlClient)(implicit ec: ExecutionContext)
"""

private def listAccessQ(requestingUserId: ObjectId) =
q"""_owner = $requestingUserId"""
q"""_owner = $requestingUserId OR
((SELECT u._organization FROM webknossos.users_ u WHERE u._id = _owner) IN (SELECT _organization FROM webknossos.users_ WHERE _id = $requestingUserId AND isAdmin))
frcroth marked this conversation as resolved.
Show resolved Hide resolved
"""

override def findAll(implicit ctx: DBAccessContext): Fox[List[Job]] =
for {
Expand Down
2 changes: 2 additions & 0 deletions app/models/job/JobService.scala
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,11 @@ class JobService @Inject()(wkConf: WkConf,
owner <- userDAO.findOne(job._owner) ?~> "user.notFound"
organization <- organizationDAO.findOne(owner._organization) ?~> "organization.notFound"
resultLink = job.resultLink(organization._id)
ownerJson <- userService.compactWrites(owner)
} yield {
Json.obj(
"id" -> job._id.id,
"owner" -> ownerJson,
"command" -> job.command,
"commandArgs" -> (job.commandArgs - "webknossos_token" - "user_auth_token"),
"state" -> job.state,
Expand Down
1 change: 1 addition & 0 deletions frontend/javascripts/admin/api/jobs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { assertResponseLimit } from "./api_utils";
function transformBackendJobToAPIJob(job: any): APIJob {
return {
id: job.id,
owner: job.owner,
type: job.command,
datasetName: job.commandArgs.dataset_name,
organizationId: job.commandArgs.organization_name,
Expand Down
16 changes: 14 additions & 2 deletions frontend/javascripts/admin/job/job_list_view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
InfoCircleOutlined,
} from "@ant-design/icons";
import type * as React from "react";
import { type APIJob, APIJobType } from "types/api_flow_types";
import { type APIJob, APIJobType, type APIUserBase } from "types/api_flow_types";
import { getJobs, cancelJob } from "admin/admin_rest_api";
import Persistence from "libs/persistence";
import * as Utils from "libs/utils";
Expand Down Expand Up @@ -375,7 +375,7 @@ function JobListView() {
</Tooltip>
</a>
<br />
WEBKNOSSOS will notfiy you via email when a job has finished or reload this page to track
WEBKNOSSOS will notify you via email when a job has finished or reload this page to track
progress.
</Typography.Paragraph>
<div
Expand Down Expand Up @@ -410,6 +410,18 @@ function JobListView() {
sorter={Utils.compareBy<APIJob>((job) => job.createdAt)}
defaultSortOrder="descend"
/>
<Column
title="Owner"
dataIndex="owner"
key="owner"
sorter={Utils.localeCompareBy<APIJob>((job) => job.owner.lastName)}
render={(owner: APIUserBase) => (
<>
<div>{owner.email ? `${owner.lastName}, ${owner.firstName}` : "-"}</div>
<div>{owner.email ? `(${owner.email})` : "-"}</div>
</>
)}
/>
<Column
title="State"
key="state"
Expand Down
1 change: 1 addition & 0 deletions frontend/javascripts/types/api_flow_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,7 @@ export type WkLibsNdBoundingBox = BoundingBoxObject & {

export type APIJob = {
readonly id: string;
readonly owner: APIUserBase;
readonly datasetName: string | null | undefined;
readonly exportFileName: string | null | undefined;
readonly layerName: string | null | undefined;
Expand Down