Skip to content
Snippets Groups Projects
Commit 077f2d80 authored by Oleg Semenov's avatar Oleg Semenov
Browse files

implemented frontend group creations

parent c05a6b4b
No related branches found
No related tags found
No related merge requests found
...@@ -2,8 +2,9 @@ import {Component, Input, OnInit} from '@angular/core'; ...@@ -2,8 +2,9 @@ import {Component, Input, OnInit} from '@angular/core';
import {FacultyDO} from "../../types/facultyDO"; import {FacultyDO} from "../../types/facultyDO";
import {ModulesDO} from "../../types/modulesDO"; import {ModulesDO} from "../../types/modulesDO";
import {GroupDO} from "../../types/groupDO"; import {GroupDO} from "../../types/groupDO";
import {ActivatedRoute} from "@angular/router"; import {ActivatedRoute, Router} from "@angular/router";
import {DataProviderService} from "../../services/data-provider.service"; import {DataProviderService} from "../../services/data-provider.service";
import {ResponseType} from "../../types/response-type";
@Component({ @Component({
selector: 'app-create-group-page', selector: 'app-create-group-page',
...@@ -20,8 +21,9 @@ export class CreateGroupComponent implements OnInit { ...@@ -20,8 +21,9 @@ export class CreateGroupComponent implements OnInit {
selectedFaculty:FacultyDO; selectedFaculty:FacultyDO;
selectedGroup: GroupDO; selectedGroup: GroupDO;
newGroup: GroupDO; newGroup: GroupDO;
errorMessage: string;
constructor(private route: ActivatedRoute,private dataService: DataProviderService) {} constructor(private router: Router, private route: ActivatedRoute,private dataService: DataProviderService) {}
ngOnInit(): void { ngOnInit(): void {
this.getAllFaculties(); this.getAllFaculties();
...@@ -42,8 +44,7 @@ export class CreateGroupComponent implements OnInit { ...@@ -42,8 +44,7 @@ export class CreateGroupComponent implements OnInit {
} }
clickToCreate(): void { clickToCreate(): void {
this.newGroup = new GroupDO(); this.createGroup();
this.createGroup(this.newGroup);
} }
getAllFaculties() { getAllFaculties() {
...@@ -70,10 +71,19 @@ export class CreateGroupComponent implements OnInit { ...@@ -70,10 +71,19 @@ export class CreateGroupComponent implements OnInit {
}) })
} }
createGroup(group: GroupDO) { createGroup() {
this.route.params.subscribe((params) => { let newID = this.modules.length + 1;
this.dataService.createGroupData(group).then((response) => { let moduleId = this.selectedModule.getId;
}) this.newGroup = new GroupDO(newID, moduleId, '', '');
}) this.dataService.createGroupData(this.newGroup).then((group) => {
this.router.navigateByUrl('/new', {state: {group: this.newGroup}});
}, (error) => {
if(error.type === ResponseType.CONNECTION_PROBLEM) {
this.errorMessage = 'Connection Problem';
} else {
this.errorMessage = 'Unknown error happened!';
}
}
);
} }
} }
export class GroupDO { export class GroupDO {
id: number;
modulid: number; private id: number;
status: string; private modulid: number;
date: string; private status: string;
private date: string;
constructor(private iD: number, private moduleId:
number, private statuS: string, datE: string) {
this.id = iD;
this.modulid = moduleId;
this.status = statuS;
this.date = datE;
}
} }
export class ModulesDO { export class ModulesDO {
id: number;
private id: number;
titel: string; titel: string;
get getId(): number {
return this.id;
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment