fixes in groups
This commit is contained in:
parent
0c2f63c57a
commit
50a73f50ef
@ -23,9 +23,9 @@
|
||||
<h3>Users:</h3>
|
||||
<app-group-users [groupUsers]="group.users"></app-group-users>
|
||||
</div>
|
||||
<div *ngIf="group.admin.id === userId && group.userCandidates" class="mb-5 border p-3">
|
||||
<div *ngIf="group.admin.id === userId && group.groupCandidates" class="mb-5 border p-3">
|
||||
<h3>Group candidates:</h3>
|
||||
<app-group-candidates [candidates]="group.userCandidates"></app-group-candidates>
|
||||
<app-group-candidates [candidates]="groupCandidates$ | async"></app-group-candidates>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -1,8 +1,10 @@
|
||||
import { GroupCandidateService } from './../../services/group-candidate.service';
|
||||
import { Router, ActivatedRoute } from '@angular/router';
|
||||
import { GroupService } from './../../services/group.service';
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Group } from '../../interfaces/group.interface';
|
||||
import { Observable } from 'rxjs';
|
||||
import { User } from 'src/app/user/interfaces/user.interface';
|
||||
|
||||
@Component({
|
||||
selector: 'app-group-edit',
|
||||
@ -12,10 +14,12 @@ import { Observable } from 'rxjs';
|
||||
export class GroupEditComponent implements OnInit {
|
||||
|
||||
group$: Observable<Group>;
|
||||
groupCandidates$: Observable<User[]>;
|
||||
userId: string;
|
||||
groupId: number;
|
||||
|
||||
constructor(private groupService: GroupService,
|
||||
private groupCandidateService: GroupCandidateService,
|
||||
private activatedRoute: ActivatedRoute,
|
||||
private router: Router) { }
|
||||
|
||||
@ -23,6 +27,7 @@ export class GroupEditComponent implements OnInit {
|
||||
this.userId = localStorage.getItem('userId');
|
||||
this.groupId = this.activatedRoute.snapshot.params['groupId'];
|
||||
this.group$ = this.groupService.getGroup(this.groupId);
|
||||
this.groupCandidates$ = this.groupCandidateService.getList(this.groupId);
|
||||
}
|
||||
|
||||
onDelete(): void {
|
||||
|
@ -1,3 +1,4 @@
|
||||
import { BaseComponent } from './../user/components/base/base.component';
|
||||
import { NgModule } from '@angular/core';
|
||||
import { Routes, RouterModule } from '@angular/router';
|
||||
import { GroupMainComponent } from './components/group-main/group-main.component';
|
||||
@ -6,9 +7,15 @@ import { NewGroupComponent } from './components/new-group/new-group.component';
|
||||
|
||||
|
||||
const routes: Routes = [
|
||||
{ path: '', component: GroupMainComponent },
|
||||
{ path: 'add-new', component: NewGroupComponent },
|
||||
{ path: 'edit/:groupId', component: GroupEditComponent }
|
||||
{
|
||||
path: '',
|
||||
component: BaseComponent,
|
||||
children: [
|
||||
{ path: '', component: GroupMainComponent },
|
||||
{ path: 'add-new', component: NewGroupComponent },
|
||||
{ path: 'edit/:groupId', component: GroupEditComponent }
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
|
@ -20,7 +20,7 @@ export class GroupCandidateService {
|
||||
const joinRequest: JoinRequest = {
|
||||
groupId,
|
||||
userId: localStorage.getItem('userId')
|
||||
}
|
||||
};
|
||||
return this.http.post<void>(environment.host + environment.apiEndpoints.groupCandidates.joinRequest, joinRequest);
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,3 @@
|
||||
h3 {
|
||||
font-weight: 500;
|
||||
}
|
@ -1,3 +1,4 @@
|
||||
import { BaseComponent } from './../user/components/base/base.component';
|
||||
import { SubjectMainComponent } from './components/subject-main/subject-main.component';
|
||||
import { NgModule } from '@angular/core';
|
||||
import { Routes, RouterModule } from '@angular/router';
|
||||
@ -5,9 +6,15 @@ import { SubjectEditComponent } from './components/subject-edit/subject-edit.com
|
||||
|
||||
|
||||
const routes: Routes = [
|
||||
{ path: '', component: SubjectMainComponent },
|
||||
{ path: 'new-subject/:groupId', component: SubjectEditComponent },
|
||||
{ path: 'edit/:id/:groupId', component: SubjectEditComponent }
|
||||
{
|
||||
path: '',
|
||||
component: BaseComponent,
|
||||
children: [
|
||||
{ path: '', component: SubjectMainComponent },
|
||||
{ path: 'new-subject/:groupId', component: SubjectEditComponent },
|
||||
{ path: 'edit/:id/:groupId', component: SubjectEditComponent }
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
|
5
src/app/user/components/base/base.component.html
Normal file
5
src/app/user/components/base/base.component.html
Normal file
@ -0,0 +1,5 @@
|
||||
<div class="d-flex justify-content-end p-3 navbar bg-dark text-white mb-2">
|
||||
<div class="d-flex justify-content-center flex-column mr-3">{{ userName }} ({{ fullName }})</div>
|
||||
<button (click)="onLogout()" class="btn btn-primary">Log out</button>
|
||||
</div>
|
||||
<router-outlet></router-outlet>
|
0
src/app/user/components/base/base.component.scss
Normal file
0
src/app/user/components/base/base.component.scss
Normal file
25
src/app/user/components/base/base.component.spec.ts
Normal file
25
src/app/user/components/base/base.component.spec.ts
Normal file
@ -0,0 +1,25 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { BaseComponent } from './base.component';
|
||||
|
||||
describe('BaseComponent', () => {
|
||||
let component: BaseComponent;
|
||||
let fixture: ComponentFixture<BaseComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ BaseComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(BaseComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
29
src/app/user/components/base/base.component.ts
Normal file
29
src/app/user/components/base/base.component.ts
Normal file
@ -0,0 +1,29 @@
|
||||
import { Router } from '@angular/router';
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'app-base',
|
||||
templateUrl: './base.component.html',
|
||||
styleUrls: ['./base.component.scss']
|
||||
})
|
||||
export class BaseComponent implements OnInit {
|
||||
|
||||
userName: string;
|
||||
fullName: string;
|
||||
|
||||
constructor(private router: Router) { }
|
||||
|
||||
ngOnInit(): void {
|
||||
this.userName = localStorage.getItem('userName');
|
||||
this.fullName = localStorage.getItem('fullName');
|
||||
}
|
||||
|
||||
onLogout(): void {
|
||||
localStorage.setItem('token', '');
|
||||
localStorage.setItem('userId', '');
|
||||
localStorage.setItem('userName', '');
|
||||
localStorage.setItem('fullName', '');
|
||||
this.router.navigateByUrl('/');
|
||||
}
|
||||
|
||||
}
|
@ -6,17 +6,21 @@ import { LoginComponent } from './components/login/login.component';
|
||||
import { ReactiveFormsModule } from '@angular/forms';
|
||||
import { MatFormFieldModule } from '@angular/material/form-field';
|
||||
import { UserRoutingModule } from './user-routing.module';
|
||||
import { BaseComponent } from './components/base/base.component';
|
||||
|
||||
|
||||
|
||||
@NgModule({
|
||||
declarations: [RegisterComponent, LoginComponent],
|
||||
declarations: [RegisterComponent, LoginComponent, BaseComponent],
|
||||
imports: [
|
||||
CommonModule,
|
||||
ReactiveFormsModule,
|
||||
MatFormFieldModule,
|
||||
MatInputModule,
|
||||
UserRoutingModule
|
||||
],
|
||||
exports: [
|
||||
BaseComponent
|
||||
]
|
||||
})
|
||||
export class UserModule { }
|
||||
|
@ -28,9 +28,9 @@ export const environment = {
|
||||
leave: 'api/groups/leave'
|
||||
},
|
||||
groupCandidates: {
|
||||
getList: 'api/group-candidates/list',
|
||||
joinRequest: 'api/group-candidates/join-request',
|
||||
delete: 'api/group-candidates/delete'
|
||||
getList: 'api/groupCandidates/list',
|
||||
joinRequest: 'api/groupCandidates/join-request',
|
||||
delete: 'api/groupCandidates/delete'
|
||||
}
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user