Skip to content

Commit

Permalink
Update service and add repository name on catalog archive detail
Browse files Browse the repository at this point in the history
  • Loading branch information
GaetanF committed Nov 4, 2024
1 parent 91720d9 commit 1fbdcc5
Show file tree
Hide file tree
Showing 13 changed files with 245 additions and 117 deletions.
3 changes: 3 additions & 0 deletions src/app/@cyborg/components/catalog/catalog.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
<div class="row">
Type : {{ archiveDetail.policy_type }}
</div>
<div class="row">
Repository : {{ archiveDetail.repository_name }}
</div>
<div class="row">
Original size : {{ archiveDetail.original_size | humanSize }}
</div>
Expand Down
3 changes: 3 additions & 0 deletions src/app/@cyborg/components/catalog/catalog.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export class CatalogComponent implements OnInit, OnDestroy {
archive_name: undefined,
hostname: undefined,
policy_type: undefined,
repository_name: undefined,
original_size: undefined,
compressed_size: undefined,
deduplicated_size: undefined,
Expand Down Expand Up @@ -183,6 +184,8 @@ export class CatalogComponent implements OnInit, OnDestroy {
this.archiveDetail[k] = res.summary_fields.policy.policy_type;
} else if (k === 'hostname') {
this.archiveDetail[k] = res.summary_fields.client.hostname;
} else if (k === 'repository_name') {
this.archiveDetail[k] = res.summary_fields.repository.name;
} else {
this.archiveDetail[k] = res[k];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,10 @@ export class PolicyFormComponent implements OnInit {
} else if (model === 'piped') {
// eslint-disable-next-line @typescript-eslint/naming-convention
this.formPolicy.patchValue({extra_vars: '{\n"command":""\n}'});
} else {
} else if (model === 'rootfs') {
// eslint-disable-next-line @typescript-eslint/naming-convention
this.formPolicy.patchValue({extra_vars: '{\n"with_partition_table": false\n}'});
}else {
// eslint-disable-next-line @typescript-eslint/naming-convention
this.formPolicy.patchValue({extra_vars: '{}'});
}
Expand Down
2 changes: 2 additions & 0 deletions src/app/@cyborg/components/job-output/job-output.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ export class JobOutputComponent {
).subscribe((messages) => {
if (messages.type === 'job_event') {
this.events.splice(messages.counter - 1, 0, messages);
}else{
console.log(messages);
}
});
this.websocketService.send({
Expand Down
54 changes: 34 additions & 20 deletions src/app/@cyborg/components/job-result/job-result.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,38 @@
<nb-card>
<nb-card-body>
<div class="panelHeader row">
<div class="panelHeader-text col-sm-9">Details</div>
<div class="panelHeader-button col-sm-3">
<button nbTooltip="Relaunch Job" nbTooltipStatus="primary" nbButton size="tiny"
class="StandardOut-actionButton"
data-tip-watch="toggleStdoutFullscreenTooltip"
data-placement="top"
[ngClass]="{'StandardOut-actionButton--active': stdoutFullScreen}"
(click)="relaunch()">
<fa-icon icon="rocket"></fa-icon>
</button>
<button nbTooltip="Cancel Job" nbTooltipStatus="primary" nbButton size="tiny"
class="StandardOut-actionButton"
data-tip-watch="toggleStdoutFullscreenTooltip"
data-placement="top"
[ngClass]="{'StandardOut-actionButton--active': stdoutFullScreen}"
(click)="cancel()">
<fa-icon icon="stop-circle"></fa-icon>
</button>
<div class="panelHeader-text col-sm-7">Details</div>
<div class="panelHeader-button col-sm-5 row m-0">
<div class="col text-center" *ngIf="job.job_type === 'job'">
<button nbTooltip="Check Integrity Job" nbTooltipStatus="primary" nbButton size="tiny"
class="StandardOut-actionButton mx-1"
data-tip-watch="toggleStdoutFullscreenTooltip"
data-placement="top"
[ngClass]="{'StandardOut-actionButton--active': stdoutFullScreen}"
(click)="checkIntegrity()">
<fa-icon icon="list-check"></fa-icon>
</button>
</div>
<div class="col text-center" *ngIf="job.status === 'successful' || job.status === 'failed'">
<button nbTooltip="Relaunch Job" nbTooltipStatus="primary" nbButton size="tiny"
class="StandardOut-actionButton mx-1"
data-tip-watch="toggleStdoutFullscreenTooltip"
data-placement="top"
[ngClass]="{'StandardOut-actionButton--active': stdoutFullScreen}"
(click)="relaunch()">
<fa-icon icon="rocket"></fa-icon>
</button>
</div>
<div class="col text-center" *ngIf="job.status === 'waiting' || job.status === 'running' || job.status === 'pending'">
<button nbTooltip="Cancel Job" nbTooltipStatus="primary" nbButton size="tiny"
class="StandardOut-actionButton mx-1"
data-tip-watch="toggleStdoutFullscreenTooltip"
data-placement="top"
[ngClass]="{'StandardOut-actionButton--active': stdoutFullScreen}"
(click)="cancel()">
<fa-icon icon="stop-circle"></fa-icon>
</button>
</div>
</div>
</div>
<div class="row">
Expand Down Expand Up @@ -140,7 +154,7 @@

<!-- FULL-SCREEN TOGGLE ACTION -->
<button nbButton nbTooltip="Expand display" nbTooltipStatus="primary" size="tiny"
class="StandardOut-actionButton"
class="StandardOut-actionButton m-1"
data-tip-watch="toggleStdoutFullscreenTooltip"
data-placement="top"
[ngClass]="{'StandardOut-actionButton--active': stdoutFullScreen}"
Expand All @@ -166,7 +180,7 @@
</div>
</div>
<div class="row">
<cbg-job-output></cbg-job-output>
<cbg-job-output class="p-0"></cbg-job-output>
</div>
</nb-card-body>
</nb-card>
Expand Down
66 changes: 55 additions & 11 deletions src/app/@cyborg/components/job-result/job-result.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import {Component, OnInit} from '@angular/core';
import {ActivatedRoute} from '@angular/router';
import {JobsService} from '../../services';
import {NbGlobalPhysicalPosition, NbToastrService} from '@nebular/theme';
import {takeUntil} from "rxjs/operators";
import {WebsocketService} from "../../../websocket.service";
import {Subject} from "rxjs";

@Component({
selector: 'cbg-job-result',
Expand All @@ -12,12 +15,14 @@ export class JobResultComponent {
public job: any;
public jobId: number;
public stdoutFullScreen = false;
destroyed$ = new Subject();
public localServer = localStorage.getItem('localServer') ? localStorage.getItem('localServer') : '';
private counter: any;

constructor(private route: ActivatedRoute,
private jobsService: JobsService,
private toastrService: NbToastrService) {
private toastrService: NbToastrService,
private websocketService: WebsocketService) {
this.job = {
// eslint-disable-next-line @typescript-eslint/naming-convention
summary_fields: {
Expand All @@ -32,6 +37,7 @@ export class JobResultComponent {
if (this.jobId !== 0) {
this.jobsService.get(this.jobId).subscribe((res) => {
this.job = res;
this.startWebsocket();
if (this.job.status === 'running') {
this.startCounter();
}
Expand Down Expand Up @@ -68,24 +74,62 @@ export class JobResultComponent {
}

cancel(): void {
this.jobsService.cancelJob(this.jobId).subscribe(() => {
this.toastrService.show('', 'Job canceled', {
position: NbGlobalPhysicalPosition.BOTTOM_RIGHT,
status: 'success'
});
}, (err) => {
this.toastrService.show(err, 'Cannot cancel this Job', {
position: NbGlobalPhysicalPosition.BOTTOM_RIGHT,
status: 'danger'
});
this.jobsService.cancelJob(this.jobId).subscribe({
next: () => {
this.toastrService.show('', 'Job canceled', {
position: NbGlobalPhysicalPosition.BOTTOM_RIGHT,
status: 'success'
});
}
,
error: (err) => {
this.toastrService.show(err, 'Cannot cancel this Job', {
position: NbGlobalPhysicalPosition.BOTTOM_RIGHT,
status: 'danger'
});
}
});
}

relaunch(): void {
}

checkIntegrity(): void {
this.jobsService.checkIntegrity(this.jobId).subscribe({
next: () => {
this.toastrService.show('', 'Job check launched', {
position: NbGlobalPhysicalPosition.BOTTOM_RIGHT,
status: 'success'
});
},
error: (err) => {
this.toastrService.show(err, 'Cannot launch check on this Job', {
position: NbGlobalPhysicalPosition.BOTTOM_RIGHT,
status: 'danger'
});
}
});
}

toggleStdoutFullscreen(): void {
this.stdoutFullScreen = !this.stdoutFullScreen;
}

startWebsocket(): void {
if (['successful', 'failed', 'finished'].indexOf(this.job.status) === -1) {
this.websocketService.connect().pipe(
takeUntil(this.destroyed$)
).subscribe((messages) => {
if (messages.group_name === 'jobs' && this.jobId === messages.job_id) {
this.jobsService.get(this.jobId).subscribe((res) => {
this.job = res;
if (this.job.status === 'running') {
this.startCounter();
}
});
}
});
}
}

}
40 changes: 23 additions & 17 deletions src/app/@cyborg/services/catalogs/catalogs.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ export class CatalogsService extends CrudService {
return new Observable((subscriber) => {
const params = {};
const url = '/api/v1/jobs/?fields=archive_name&not__archive_name=&archive_name__isnull=False&order=-archive_name&page_size=10000';
this.http.get(url, params).subscribe((result: any) => {
subscriber.next(result.results);
}, (error) => {
subscriber.error(error);
this.http.get(url, params).subscribe({
next: (result: any) => {
subscriber.next(result.results);
}, error: (error) => {
subscriber.error(error);
}
});
});
}
Expand All @@ -29,10 +31,12 @@ export class CatalogsService extends CrudService {
return new Observable((subscriber) => {
const params = {};
const url = '/api/v1/jobs/?archive_name=' + archiveName;
this.http.get(url, params).subscribe((result: any) => {
subscriber.next(result.results[0]);
}, (error) => {
subscriber.error(error);
this.http.get(url, params).subscribe({
next: (result: any) => {
subscriber.next(result.results[0]);
}, error: (error) => {
subscriber.error(error);
}
});
});
}
Expand Down Expand Up @@ -64,16 +68,18 @@ export class CatalogsService extends CrudService {
}
return new Observable((subscriber) => {
const url = '/api/v1/escatalogs/?archive_name=' + this.archiveName;
this.http.get(url, {}).subscribe((result: any) => {
if (result.count > 0) {
this.requestPages(path, recursive).subscribe((data) => {
subscriber.next(data.results);
});
} else {
subscriber.next(false);
this.http.get(url, {}).subscribe({
next: (result: any) => {
if (result.count > 0) {
this.requestPages(path, recursive).subscribe((data) => {
subscriber.next(data.results);
});
} else {
subscriber.next(false);
}
}, error: (error) => {
subscriber.error(error);
}
}, (error) => {
subscriber.error(error);
});
});
}
Expand Down
10 changes: 6 additions & 4 deletions src/app/@cyborg/services/clients/clients.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ export class ClientsService extends CrudService {
public count(): Observable<any> {
return new Observable((subscriber) => {
const params = {};
this.http.get('/api/v1/' + this.endpoint + '/', params).subscribe((result: any) => {
subscriber.next(result.count);
}, (error) => {
subscriber.error(error);
this.http.get('/api/v1/' + this.endpoint + '/', params).subscribe({
next: (result: any) => {
subscriber.next(result.count);
}, error: (error) => {
subscriber.error(error);
}
});
});
}
Expand Down
Loading

0 comments on commit 1fbdcc5

Please sign in to comment.