Skip to content

Commit

Permalink
fix(ui,api): allow maintainers to read job info, update deps (#5881)
Browse files Browse the repository at this point in the history
  • Loading branch information
richardlt authored Jul 8, 2021
1 parent c7e1148 commit 6c07e41
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 22 deletions.
12 changes: 9 additions & 3 deletions engine/api/router_middleware_auth_permission.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,15 @@ func (api *API) checkJobIDPermissions(ctx context.Context, w http.ResponseWriter
if runNodeJob.ExecGroups.HasOneOf(getAPIConsumer(ctx).GetGroupIDs()...) {
return nil
}
if isAdmin(ctx) {
trackSudo(ctx, w)
return nil
if perm == sdk.PermissionRead {
if isMaintainer(ctx) {
return nil
}
} else {
if isAdmin(ctx) {
trackSudo(ctx, w)
return nil
}
}

return sdk.WrapError(sdk.ErrForbidden, "not authorized for job %s", jobID)
Expand Down
6 changes: 3 additions & 3 deletions ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"@ngxs/store": "3.7.0",
"@richardlt/ng2-semantic-ui": "0.10.0-alpha.6-fork-5",
"@swimlane/ngx-charts": "16.0.0",
"@types/dagre-d3": "0.4.38",
"@types/dagre-d3": "0.6.2",
"@types/js-yaml": "3.12.2",
"@types/zxcvbn": "4.4.0",
"angular2-prettyjson": "3.0.1",
Expand All @@ -60,7 +60,7 @@
"core-js": "2.6.3",
"d3": "5.7.0",
"d3-zoom": "1.7.3",
"dagre-d3": "0.6.3",
"dagre-d3": "0.6.4",
"diff": "4.0.2",
"dragula": "3.7.2",
"enhanced-resolve": "4.1.1",
Expand All @@ -86,7 +86,7 @@
"ngx-markdown": "10.1.1",
"ngx-moment": "5.0.0",
"postcss": "8.3.0",
"prismjs": "1.23.0",
"prismjs": "1.24.1",
"raven-js": "3.27.2",
"rxjs": "6.5.4",
"rxjs-compat": "6.3.3",
Expand Down
33 changes: 18 additions & 15 deletions ui/src/app/views/admin/service/list/service.list.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ export class ServiceListComponent {
name: 'common_status',
type: ColumnType.LABEL,
selector: (c: MonitoringStatusLine) => ({
class: MonitoringStatusLineUtil.color(c),
value: c.status
})
class: MonitoringStatusLineUtil.color(c),
value: c.status
})
},
<Column<MonitoringStatusLine>>{
name: 'common_value',
Expand All @@ -84,22 +84,24 @@ export class ServiceListComponent {
return line.status.toLowerCase().indexOf(lowerFilter) !== -1;
}
return line.status.toLowerCase().indexOf(lowerFilter) !== -1 ||
line.component.toLowerCase().indexOf(lowerFilter) !== -1 ||
line.value.toLowerCase().indexOf(lowerFilter) !== -1 ||
line.type.toLowerCase().indexOf(lowerFilter) !== -1 ||
(line.service && line.service.toLowerCase().indexOf(lowerFilter) !== -1) ||
(line.hostname && line.hostname.toLowerCase().indexOf(lowerFilter) !== -1) ||
(line.session && line.session.toLowerCase().indexOf(lowerFilter) !== -1) ||
(line.consumer && line.consumer.toLowerCase().indexOf(lowerFilter) !== -1);
line.component.toLowerCase().indexOf(lowerFilter) !== -1 ||
line.value.toLowerCase().indexOf(lowerFilter) !== -1 ||
line.type.toLowerCase().indexOf(lowerFilter) !== -1 ||
(line.service && line.service.toLowerCase().indexOf(lowerFilter) !== -1) ||
(line.hostname && line.hostname.toLowerCase().indexOf(lowerFilter) !== -1) ||
(line.session && line.session.toLowerCase().indexOf(lowerFilter) !== -1) ||
(line.consumer && line.consumer.toLowerCase().indexOf(lowerFilter) !== -1);
}
};

forkJoin(
forkJoin([
this.refreshProfiles(),
this.refreshStatus(),
this.refreshServices(),
this.refreshGoroutines(),
).pipe(finalize(() => this._cd.markForCheck())).subscribe( _ => {
]).pipe(
finalize(() => this._cd.markForCheck())
).subscribe(_ => {
this.status.lines.forEach(g => {
if (g.component.startsWith('Global/')) {
let type = g.component.slice(7);
Expand All @@ -123,7 +125,7 @@ export class ServiceListComponent {
name: type,
value: g.value,
status: g.status,
services: this.services.filter(srv => srv.type === type)
services: this.services.filter(srv => srv.type === type).sort((a, b) => a.name < b.name ? -1 : 1)
});
break;
}
Expand All @@ -148,7 +150,7 @@ export class ServiceListComponent {
refreshServices(): Observable<any> {
return this._serviceService.getServices().pipe(tap(services => {
if (services) {
this.services = services;
this.services = [];
services.forEach(s => {
s.status = 'OK';
if (s.monitoring_status.lines) {
Expand All @@ -162,7 +164,8 @@ export class ServiceListComponent {
}
}
}
})
this.services.push(s);
});
}
}));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export class WorkflowGraphComponent implements AfterViewInit, OnDestroy {
this.svg = d3.select(element).append('svg');

let g = this.svg.append('g');
this.render(g, this.g);
this.render(g, <any>this.g);

this.zoom = d3.zoom().scaleExtent([
WorkflowGraphComponent.minScale,
Expand Down

0 comments on commit 6c07e41

Please sign in to comment.