-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #373 from fujaba/feat/course-members
Course Members
- Loading branch information
Showing
26 changed files
with
324 additions
and
111 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
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
18 changes: 15 additions & 3 deletions
18
frontend/src/app/assignment/modules/course/share/share.component.ts
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 |
---|---|---|
@@ -1,19 +1,31 @@ | ||
import {DOCUMENT} from '@angular/common'; | ||
import {Component, Inject} from '@angular/core'; | ||
import {Component, Inject, OnInit} from '@angular/core'; | ||
import {ActivatedRoute} from '@angular/router'; | ||
import {CourseService} from "../../../services/course.service"; | ||
import {switchMap} from "rxjs/operators"; | ||
import Course from "../../../model/course"; | ||
|
||
@Component({ | ||
selector: 'app-assignment-share', | ||
templateUrl: './share.component.html', | ||
styleUrls: ['./share.component.scss'], | ||
}) | ||
export class ShareComponent { | ||
export class ShareComponent implements OnInit { | ||
course?: Course; | ||
|
||
readonly origin: string; | ||
|
||
constructor( | ||
public readonly route: ActivatedRoute, | ||
private courseService: CourseService, | ||
private route: ActivatedRoute, | ||
@Inject(DOCUMENT) document: Document, | ||
) { | ||
this.origin = document.location.origin; | ||
} | ||
|
||
ngOnInit() { | ||
this.route.params.pipe( | ||
switchMap(({cid}) => this.courseService.get(cid)), | ||
).subscribe(course => this.course = course); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
frontend/src/app/assignment/modules/shared/edit-member-list/edit-member-list.component.html
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,13 @@ | ||
<h5 class="d-flex align-items-center"> | ||
Members | ||
<app-user-typeahead class="ms-auto" [(user)]="newMember"></app-user-typeahead> | ||
<button class="btn btn-success bi-person-add ms-2" [disabled]="!newMember" (click)="addMember()"> | ||
Add Member | ||
</button> | ||
</h5> | ||
<div class="mb-3"> | ||
<app-member-list [members]="members" [owner]="owner" (deleted)="deleteMember($event)"></app-member-list> | ||
<div class="form-text"> | ||
Add teaching assistants and other people who should have full access to this {{ namespace|slice:0:-1 }}. | ||
</div> | ||
</div> |
Empty file.
54 changes: 54 additions & 0 deletions
54
frontend/src/app/assignment/modules/shared/edit-member-list/edit-member-list.component.ts
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,54 @@ | ||
import {Component, Input, OnInit} from '@angular/core'; | ||
import {Member} from "../../../../user/member"; | ||
import {User} from "../../../../user/user"; | ||
import {switchMap, tap} from "rxjs/operators"; | ||
import {forkJoin} from "rxjs"; | ||
import {MemberService, Namespace} from "../../../services/member.service"; | ||
import {UserService} from "../../../../user/user.service"; | ||
|
||
@Component({ | ||
selector: 'app-edit-member-list', | ||
templateUrl: './edit-member-list.component.html', | ||
styleUrls: ['./edit-member-list.component.scss'] | ||
}) | ||
export class EditMemberListComponent implements OnInit { | ||
@Input({required: true}) namespace: Namespace; | ||
@Input({required: true}) parent: string; | ||
@Input() owner?: string; | ||
|
||
members: Member[]; | ||
|
||
newMember?: User; | ||
|
||
constructor( | ||
private memberService: MemberService, | ||
private userService: UserService, | ||
) { | ||
} | ||
|
||
ngOnInit() { | ||
this.memberService.findAll(this.namespace, this.parent).pipe( | ||
tap(members => this.members = members), | ||
switchMap(members => forkJoin(members.map(member => this.userService.findOne(member.user).pipe( | ||
tap(user => member._user = user), | ||
)))), | ||
).subscribe(); | ||
} | ||
|
||
addMember() { | ||
this.memberService.update(this.namespace, { | ||
parent: this.parent, | ||
user: this.newMember!.id!, | ||
_user: this.newMember!, | ||
}).subscribe(member => { | ||
this.members.push(member); | ||
this.newMember = undefined; | ||
}); | ||
} | ||
|
||
deleteMember(member: Member) { | ||
this.memberService.delete(this.namespace, member.parent, member.user).subscribe(() => { | ||
this.members.splice(this.members.indexOf(member), 1); | ||
}); | ||
} | ||
} |
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
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
10 changes: 5 additions & 5 deletions
10
...s/assignments/src/member/member.module.ts → ...gnment-member/assignment-member.module.ts
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 |
---|---|---|
@@ -1,25 +1,25 @@ | ||
import {forwardRef, Module} from '@nestjs/common'; | ||
import {MongooseModule} from '@nestjs/mongoose'; | ||
import {Member, MemberAuthGuard, MemberSchema, MemberService} from '@app/member'; | ||
import {MemberController} from './member.controller'; | ||
import {MemberHandler} from "./member.handler"; | ||
import {AssignmentMemberController} from './assignment-member.controller'; | ||
import {AssignmentMemberHandler} from "./assignment-member.handler"; | ||
import {AssignmentModule} from "../assignment/assignment.module"; | ||
|
||
@Module({ | ||
imports: [ | ||
MongooseModule.forFeature([{name: Member.name, schema: MemberSchema}]), | ||
forwardRef(() => AssignmentModule), | ||
], | ||
controllers: [MemberController], | ||
controllers: [AssignmentMemberController], | ||
providers: [ | ||
MemberService, | ||
MemberAuthGuard, | ||
MemberHandler, | ||
AssignmentMemberHandler, | ||
], | ||
exports: [ | ||
MemberService, | ||
MemberAuthGuard, | ||
], | ||
}) | ||
export class MemberModule { | ||
export class AssignmentMemberModule { | ||
} |
Oops, something went wrong.