diff --git a/src/app/group/components/group-edit/group-edit.component.html b/src/app/group/components/group-edit/group-edit.component.html new file mode 100644 index 0000000..8e86740 --- /dev/null +++ b/src/app/group/components/group-edit/group-edit.component.html @@ -0,0 +1 @@ +

group-edit works!

diff --git a/src/app/group/components/group-edit/group-edit.component.scss b/src/app/group/components/group-edit/group-edit.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/app/group/components/group-edit/group-edit.component.spec.ts b/src/app/group/components/group-edit/group-edit.component.spec.ts new file mode 100644 index 0000000..01fbd35 --- /dev/null +++ b/src/app/group/components/group-edit/group-edit.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { GroupEditComponent } from './group-edit.component'; + +describe('GroupEditComponent', () => { + let component: GroupEditComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ GroupEditComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(GroupEditComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/group/components/group-edit/group-edit.component.ts b/src/app/group/components/group-edit/group-edit.component.ts new file mode 100644 index 0000000..1eddabb --- /dev/null +++ b/src/app/group/components/group-edit/group-edit.component.ts @@ -0,0 +1,15 @@ +import { Component, OnInit } from '@angular/core'; + +@Component({ + selector: 'app-group-edit', + templateUrl: './group-edit.component.html', + styleUrls: ['./group-edit.component.scss'] +}) +export class GroupEditComponent implements OnInit { + + constructor() { } + + ngOnInit(): void { + } + +} diff --git a/src/app/group/components/group-list/group-list.component.html b/src/app/group/components/group-list/group-list.component.html new file mode 100644 index 0000000..18dc4d3 --- /dev/null +++ b/src/app/group/components/group-list/group-list.component.html @@ -0,0 +1,21 @@ +
+
+
+
+
+ Name: {{ group.name }} +
+
+ Year: {{ group.year }} +
+
+ Admin: {{ group.admin.fullName }} ({{group.admin.userName}}) +
+
+
+ + +
+
+
+
diff --git a/src/app/group/components/group-list/group-list.component.scss b/src/app/group/components/group-list/group-list.component.scss new file mode 100644 index 0000000..3d80f4d --- /dev/null +++ b/src/app/group/components/group-list/group-list.component.scss @@ -0,0 +1,5 @@ +.list-container { + .group-list-item { + border: 1px solid black; + } +} diff --git a/src/app/group/components/group-list/group-list.component.spec.ts b/src/app/group/components/group-list/group-list.component.spec.ts new file mode 100644 index 0000000..d6495c5 --- /dev/null +++ b/src/app/group/components/group-list/group-list.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { GroupListComponent } from './group-list.component'; + +describe('GroupListComponent', () => { + let component: GroupListComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ GroupListComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(GroupListComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/group/components/group-list/group-list.component.ts b/src/app/group/components/group-list/group-list.component.ts new file mode 100644 index 0000000..5ce8060 --- /dev/null +++ b/src/app/group/components/group-list/group-list.component.ts @@ -0,0 +1,28 @@ +import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; +import { Group } from '../../interfaces/group.interface'; + +@Component({ + selector: 'app-group-list', + templateUrl: './group-list.component.html', + styleUrls: ['./group-list.component.scss'] +}) +export class GroupListComponent implements OnInit { + + @Input() groups: Group[]; + @Output() joinRequest = new EventEmitter(); + @Output() show = new EventEmitter(); + + constructor() { } + + ngOnInit(): void { + } + + onShow(groupId: number): void { + this.show.emit(groupId); + } + + onJoinRequest(groupId: number): void { + this.joinRequest.emit(groupId); + } + +} diff --git a/src/app/group/components/group-main/group-main.component.html b/src/app/group/components/group-main/group-main.component.html new file mode 100644 index 0000000..55c6b2d --- /dev/null +++ b/src/app/group/components/group-main/group-main.component.html @@ -0,0 +1,18 @@ +
+ +
+ + + + + + + + + + diff --git a/src/app/group/components/group-main/group-main.component.scss b/src/app/group/components/group-main/group-main.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/app/group/components/group-main/group-main.component.spec.ts b/src/app/group/components/group-main/group-main.component.spec.ts new file mode 100644 index 0000000..10ff6a1 --- /dev/null +++ b/src/app/group/components/group-main/group-main.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { GroupMainComponent } from './group-main.component'; + +describe('GroupMainComponent', () => { + let component: GroupMainComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ GroupMainComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(GroupMainComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/group/components/group-main/group-main.component.ts b/src/app/group/components/group-main/group-main.component.ts new file mode 100644 index 0000000..db9da39 --- /dev/null +++ b/src/app/group/components/group-main/group-main.component.ts @@ -0,0 +1,32 @@ +import { GroupService } from './../../services/group.service'; +import { Component, OnInit } from '@angular/core'; +import { Group } from '../../interfaces/group.interface'; + +@Component({ + selector: 'app-group-main', + templateUrl: './group-main.component.html', + styleUrls: ['./group-main.component.scss'] +}) +export class GroupMainComponent implements OnInit { + + userGroups: Group[]; + allGroups: Group[]; + + constructor(private groupService: GroupService) { } + + ngOnInit(): void { + } + + onAddNew(): void { + + } + + onShow(groupId: number) { + + } + + onJoinRequest(groupId: number) { + + } + +} diff --git a/src/app/group/group-routing.module.ts b/src/app/group/group-routing.module.ts new file mode 100644 index 0000000..e99f6ac --- /dev/null +++ b/src/app/group/group-routing.module.ts @@ -0,0 +1,15 @@ +import { NgModule } from '@angular/core'; +import { Routes, RouterModule } from '@angular/router'; + + +const routes: Routes = [ + { path: '', component: GroupMainComponent }, + { path: 'new-group', component: GroupEditComponent }, + { path: 'edit/:id', component: GrouptEditComponent } +]; + +@NgModule({ + imports: [RouterModule.forChild(routes)], + exports: [RouterModule], +}) +export class GroupRoutingModule { } diff --git a/src/app/group/group.module.ts b/src/app/group/group.module.ts new file mode 100644 index 0000000..383fb27 --- /dev/null +++ b/src/app/group/group.module.ts @@ -0,0 +1,17 @@ +import { NgModule } from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { GroupMainComponent } from './components/group-main/group-main.component'; +import { GroupListComponent } from './components/group-list/group-list.component'; +import { GroupEditComponent } from './components/group-edit/group-edit.component'; +import {MatTabsModule} from '@angular/material/tabs'; + + + +@NgModule({ + declarations: [GroupMainComponent, GroupListComponent, GroupEditComponent], + imports: [ + CommonModule, + MatTabsModule, + ] +}) +export class GroupModule { } diff --git a/src/app/group/interfaces/group.interface.ts b/src/app/group/interfaces/group.interface.ts new file mode 100644 index 0000000..18778fe --- /dev/null +++ b/src/app/group/interfaces/group.interface.ts @@ -0,0 +1,11 @@ +import { User } from "src/app/user/interfaces/user.interface"; + +export interface Group { + id: number; + name: string; + year: number; + admin: User; + users: User[]; + userCandidates: User[]; + isUserInGroup?: boolean; +} diff --git a/src/app/group/services/group.service.spec.ts b/src/app/group/services/group.service.spec.ts new file mode 100644 index 0000000..e3216be --- /dev/null +++ b/src/app/group/services/group.service.spec.ts @@ -0,0 +1,16 @@ +import { TestBed } from '@angular/core/testing'; + +import { GroupService } from './group.service'; + +describe('GroupService', () => { + let service: GroupService; + + beforeEach(() => { + TestBed.configureTestingModule({}); + service = TestBed.inject(GroupService); + }); + + it('should be created', () => { + expect(service).toBeTruthy(); + }); +}); diff --git a/src/app/group/services/group.service.ts b/src/app/group/services/group.service.ts new file mode 100644 index 0000000..1ddc947 --- /dev/null +++ b/src/app/group/services/group.service.ts @@ -0,0 +1,22 @@ +import { Observable } from 'rxjs'; +import { Injectable } from '@angular/core'; +import { environment } from 'src/environments/environment'; +import { Group } from '../interfaces/group.interface'; +import { HttpClient } from '@angular/common/http'; + +@Injectable({ + providedIn: 'root' +}) +export class GroupService { + + constructor(private http: HttpClient) { } + + add(group: Group): Observable { + return this.http.post(environment.host + environment.apiEndpoints.groups, group); + } + + getAllGroups(): Observable { + return this.http.get(environment.host + environment.apiEndpoints.groups.getAll); + } + +} diff --git a/src/environments/environment.ts b/src/environments/environment.ts index 89351a9..b1bfd43 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -12,6 +12,12 @@ export const environment = { users: { register: 'api/users/register', login: 'api/users/login' + }, + groups: { + getAll: 'api/groups/all', + getUserGroups: 'api/groups/user-groups', + create: 'api/groups/create', + delete: 'api/groups/delete' } } };