-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Run): Allow teachers to archive runs (#1173)
- Loading branch information
1 parent
2c2a7ae
commit 16d6b90
Showing
32 changed files
with
1,671 additions
and
403 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { MatMenuHarness } from '@angular/material/menu/testing'; | ||
|
||
export async function clickMenuButton(thisContext: any, menuButtonText: string): Promise<void> { | ||
const getMenu = thisContext.locatorFor(MatMenuHarness); | ||
const menu = await getMenu(); | ||
await menu.open(); | ||
return menu.clickItem({ text: menuButtonText }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export class ArchiveProjectResponse { | ||
archived: boolean; | ||
id: number; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { HttpClient, HttpParams } from '@angular/common/http'; | ||
import { Injectable } from '@angular/core'; | ||
import { Observable, Subject } from 'rxjs'; | ||
import { Project } from '../domain/project'; | ||
import { ArchiveProjectResponse } from '../domain/archiveProjectResponse'; | ||
|
||
@Injectable() | ||
export class ArchiveProjectService { | ||
private refreshProjectsEventSource: Subject<void> = new Subject<void>(); | ||
public refreshProjectsEvent$ = this.refreshProjectsEventSource.asObservable(); | ||
|
||
constructor(private http: HttpClient) {} | ||
|
||
archiveProject(project: Project): Observable<ArchiveProjectResponse> { | ||
return this.http.put<ArchiveProjectResponse>(`/api/project/${project.id}/archived`, null); | ||
} | ||
|
||
archiveProjects(projects: Project[]): Observable<ArchiveProjectResponse[]> { | ||
const projectIds = projects.map((project) => project.id); | ||
return this.http.put<ArchiveProjectResponse[]>(`/api/projects/archived`, projectIds); | ||
} | ||
|
||
unarchiveProject(project: Project): Observable<ArchiveProjectResponse> { | ||
return this.http.delete<ArchiveProjectResponse>(`/api/project/${project.id}/archived`); | ||
} | ||
|
||
unarchiveProjects(projects: Project[]): Observable<ArchiveProjectResponse[]> { | ||
let params = new HttpParams(); | ||
for (const project of projects) { | ||
params = params.append('projectIds', project.id); | ||
} | ||
return this.http.delete<ArchiveProjectResponse[]>(`/api/projects/archived`, { | ||
params: params | ||
}); | ||
} | ||
|
||
refreshProjects(): void { | ||
this.refreshProjectsEventSource.next(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { Observable, Subject, of } from 'rxjs'; | ||
import { Project } from '../domain/project'; | ||
import { ArchiveProjectResponse } from '../domain/archiveProjectResponse'; | ||
|
||
export class MockArchiveProjectService { | ||
private refreshProjectsEventSource: Subject<void> = new Subject<void>(); | ||
public refreshProjectsEvent$ = this.refreshProjectsEventSource.asObservable(); | ||
|
||
archiveProject(project: Project): Observable<ArchiveProjectResponse> { | ||
return this.archiveProjectHelper(project, true); | ||
} | ||
|
||
unarchiveProject(project: Project): Observable<ArchiveProjectResponse> { | ||
return this.archiveProjectHelper(project, false); | ||
} | ||
|
||
private archiveProjectHelper( | ||
project: Project, | ||
archived: boolean | ||
): Observable<ArchiveProjectResponse> { | ||
project.archived = archived; | ||
return of(project); | ||
} | ||
|
||
archiveProjects(projects: Project[]): Observable<ArchiveProjectResponse[]> { | ||
return this.archiveProjectsHelper(projects, true); | ||
} | ||
|
||
unarchiveProjects(projects: Project[]): Observable<ArchiveProjectResponse[]> { | ||
return this.archiveProjectsHelper(projects, false); | ||
} | ||
|
||
private archiveProjectsHelper( | ||
projects: Project[], | ||
archived: boolean | ||
): Observable<ArchiveProjectResponse[]> { | ||
projects.forEach((project) => (project.archived = archived)); | ||
return of(projects); | ||
} | ||
|
||
refreshProjects(): void { | ||
this.refreshProjectsEventSource.next(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.