Skip to content

Commit

Permalink
feat: add selected task sheet url
Browse files Browse the repository at this point in the history
  • Loading branch information
jakerenzella committed Oct 6, 2022
1 parent e33fb83 commit 00a7fb5
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 5 deletions.
15 changes: 14 additions & 1 deletion src/app/common/footer/footer.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,22 @@
</span>

<div fxFlex fxFlexAlign="end start" fxLayout="row" fxLayoutAlign="end center">
<button mat-icon-button aria-label="" class="button small-button">
<button mat-icon-button aria-label="" class="button small-button" [matMenuTriggerFor]="aboveMenu">
<mat-icon class="small-icon">more_vert</mat-icon>
</button>
<mat-menu #aboveMenu="matMenu" yPosition="above">
<button mat-menu-item (click)="viewTaskSheet()">View task sheet</button>
<button mat-menu-item (click)="viewSubmission()">View student submission</button>
<mat-divider></mat-divider>
<button mat-menu-item (click)="selectedTask?.updateTaskStatus('time_exceeded')">
<mat-icon aria-hidden="false" aria-label="Example home icon" fontIcon="running_with_errors"></mat-icon>
Mark as time exceeded
</button>
<button mat-menu-item (click)="selectedTask?.updateTaskStatus('fail')">
<mat-icon aria-hidden="false" aria-label="Fail icon" fontIcon="cancel"></mat-icon>
Mark as fail
</button>
</mat-menu>
<button mat-icon-button aria-label="" class="button small-button" (click)="downloadFiles()">
<mat-icon class="small-icon">sim_card_download</mat-icon>
</button>
Expand Down
10 changes: 8 additions & 2 deletions src/app/common/footer/footer.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ export class FooterComponent implements OnInit {
this.selectedTask$.subscribe((task) => {
this.selectedTask = task;
});

// this.selectedTask$.subscribe(this.selectedTaskService.selectedTask$);
}

downloadFiles() {
Expand All @@ -40,4 +38,12 @@ export class FooterComponent implements OnInit {
`${this.selectedTask.project.student.lastName}-${this.selectedTask.definition.name}.pdf`
);
}

viewTaskSheet() {
this.selectedTaskService.showTaskSheet();
}

viewSubmission() {
this.selectedTaskService.showSubmission();
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<f-pdf-viewer *ngIf="task" [pdfUrl]="urls.taskSheetPdfUrl"></f-pdf-viewer>
<f-pdf-viewer *ngIf="task" [pdfUrl]="pdfUrl"></f-pdf-viewer>
<!-- <span [hidden]="tutor">{{ task.definition.name }}</span> -->
<!-- <span [hidden]="!tutor" style="display: inline-flex" -->
<!-- >{{ task.definition.name }} <f-user-badge style="margin-left: 10px" [project]="task.project"></f-user-badge -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ enum dashboardViews {
export class TaskDashboardComponent implements OnInit, OnChanges {
@Input() task: Task;
@Input() showSubmission: boolean;
@Input() pdfUrl: string;
currentView: dashboardViews = dashboardViews.submission;
taskStatusData: any;
constructor(
Expand Down
11 changes: 10 additions & 1 deletion src/app/projects/states/dashboard/selected-task.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,23 @@ export class SelectedTaskService {
constructor(private taskService: TaskService) {}

private task$ = new BehaviorSubject<Task>(null);
public currentPdfUrl$ = new BehaviorSubject<string>(null);

public setSelectedTask(task: number | Task) {
if (typeof task === 'number') {
this.taskService.get(task).subscribe(this.task$);
} else {
this.task$.next(task);
}
// this.task$.next(this.taskService.get(id));
this.showSubmission();
}

public showTaskSheet() {
this.currentPdfUrl$.next(this.task$.value?.definition?.getTaskPDFUrl(false));
}

public showSubmission() {
this.currentPdfUrl$.next(this.task$.value.submissionUrl(false));
}

public get selectedTask$(): Subject<Task> {
Expand Down

0 comments on commit 00a7fb5

Please sign in to comment.