Skip to content

Commit

Permalink
issue-157, bug fixed, seo optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
GrandShow authored and GrandShow committed Jun 22, 2020
1 parent cbde205 commit d691a99
Show file tree
Hide file tree
Showing 46 changed files with 247 additions and 207 deletions.
File renamed without changes.
10 changes: 5 additions & 5 deletions ui/src/app/admin/admin.component.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { Component, OnInit } from '@angular/core';
import {Component, OnInit} from '@angular/core';
import {Title} from '@angular/platform-browser';

@Component({
selector: 'app-admin',
templateUrl: './admin.component.html',
styleUrls: ['./admin.component.sass']
styleUrls: ['./admin.component.sass'],
})
export class AdminComponent implements OnInit {

constructor() { }
constructor(private titleService: Title) {}

ngOnInit(): void {
this.titleService.setTitle('Admin panel');
}

}
10 changes: 5 additions & 5 deletions ui/src/app/admin/groups-management/group-update.html
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
<mat-form-field appearance="fill">
<mat-label>Specialisation:</mat-label>
<mat-select #spec>
<mat-option [value]="spec" *ngFor="let spec of specialisations">{{ spec }} </mat-option>
<mat-select #spec cdkFocusInitial>
<mat-option [value]="spec" *ngFor="let spec of specialisations; trackBy: trackById">{{ spec }} </mat-option>
</mat-select>
</mat-form-field>

<mat-form-field appearance="fill">
<mat-label>Year of education:</mat-label>
<mat-select #year>
<mat-option [value]="year" *ngFor="let year of yearsOfEducation">{{ year }} </mat-option>
<mat-option [value]="year" *ngFor="let year of yearsOfEducation; trackBy: trackById">{{ year }} </mat-option>
</mat-select>
</mat-form-field>

<mat-form-field appearance="fill">
<mat-label>Group number:</mat-label>
<mat-select #groupNum>
<mat-option [value]="num" *ngFor="let num of groupNums">{{ num }} </mat-option>
<mat-option [value]="num" *ngFor="let num of groupNums; trackBy: trackById">{{ num }} </mat-option>
</mat-select>
</mat-form-field>

<mat-form-field appearance="fill">
<mat-label>Curator:</mat-label>
<mat-select #curator>
<mat-option [value]="lecturer" *ngFor="let lecturer of lecturers"
<mat-option [value]="lecturer" *ngFor="let lecturer of lecturers; trackBy: trackById"
>{{ lecturer.firstName }} {{ lecturer.lastName }} {{ lecturer.surname }}
</mat-option>
</mat-select>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
</mat-toolbar>

<mat-accordion>
<mat-expansion-panel *ngFor="let group of groups; let id = index">
<mat-expansion-panel *ngFor="let group of groups; let id = index; trackBy: trackById">
<mat-expansion-panel-header>
<mat-panel-title style="width: 5%;">
<b> {{ group.specialisation }}-{{ group.yearOfEducation }}{{ group.groupNumber }} </b>
</mat-panel-title>

<mat-panel-title style="width: 10%;">
<b>Students in group: {{ group.students.length }}</b>
<b>Students in group: {{ group.students.length ? group.students.length : 0 }}</b>
</mat-panel-title>

<mat-panel-title style="width: 70%;">
Expand Down
34 changes: 22 additions & 12 deletions ui/src/app/admin/groups-management/groups-management.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,11 @@ export class GroupsManagementComponent implements OnInit {
});

dialogRef.afterClosed().subscribe(result => {
if (result.length) {
group.students = group.students.concat(result);
this.updateGroup(group, id);
if (result) {
if (result.length) {
group.students = group.students.concat(result);
this.updateGroup(group, id);
}
}
});
}
Expand Down Expand Up @@ -137,21 +139,21 @@ export class GroupsManagementComponent implements OnInit {

dialogRef.afterClosed().subscribe(result => {
if (result) {
let newGroup = {
const newGroup = {
specialisation: result[0],
yearOfEducation: result[1],
groupNumber: result[2],
curator: result[3],
} as Group;

const dialogRef = this.dialog.open(SelectUserDialogComponent, {
const dialogRef2 = this.dialog.open(SelectUserDialogComponent, {
width: '80%',
data: {query: '?role=student'},
});

dialogRef.afterClosed().subscribe(result => {
if (result) {
newGroup.students = result;
dialogRef2.afterClosed().subscribe(result2 => {
if (result2) {
newGroup.students = result2;
}
this.createGroup(newGroup);
});
Expand All @@ -175,6 +177,10 @@ export class GroupsManagementComponent implements OnInit {
this.dataSource[id].filter = filterValue.trim().toLowerCase();
}
}

trackById(index, item) {
return item.id;
}
}

// ---------------------------------------select user-------------------------
Expand All @@ -183,7 +189,7 @@ export class GroupsManagementComponent implements OnInit {
selector: 'app-select-users-dialog',
templateUrl: 'user-list.html',
})
export class SelectUserDialogComponent {
export class SelectUserDialogComponent implements OnInit {
@ViewChild(MatPaginator, {static: true}) paginator: MatPaginator;

users: UserAsResource[];
Expand Down Expand Up @@ -261,7 +267,7 @@ export class SelectUserDialogComponent {
selector: 'app-update-group-dialog',
templateUrl: 'group-update.html',
})
export class GroupUpdateDialogComponent {
export class GroupUpdateDialogComponent implements OnInit {
@ViewChild(MatPaginator, {static: true}) paginator: MatPaginator;

lecturers: UserAsResource[];
Expand All @@ -278,8 +284,8 @@ export class GroupUpdateDialogComponent {
ngOnInit(): void {
this.getLecturers();
this.getSpecialisations();
this.yearsOfEducation = this.yearsOfEducation.filter(y => y != this.data.yearOfEducation);
this.groupNums = this.groupNums.filter(y => y != this.data.groupNum);
this.yearsOfEducation = this.yearsOfEducation.filter(y => y !== this.data.yearOfEducation);
this.groupNums = this.groupNums.filter(y => y !== this.data.groupNum);
}

getLecturers(): void {
Expand All @@ -301,4 +307,8 @@ export class GroupUpdateDialogComponent {
onNoClick(): void {
this.dialogRef.close();
}

trackById(index, item) {
return item.id;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@ export class GroupsManagementService {
return this.http.get<Group[]>(this.GroupsUrl);
}

addGroups(Group: Group): Observable<Group> {
addGroups(group: Group): Observable<Group> {
console.log('added');
return this.http.post<Group>(this.GroupsUrl, Group, this.httpOptions);
return this.http.post<Group>(this.GroupsUrl, group, this.httpOptions);
}

updateGroup(group: Group): Observable<Group> {
console.log('updated');
return this.http.put<Group>(this.GroupsUrl, group, this.httpOptions);
}

deleteGroups(Group: Group): Observable<Group> {
deleteGroups(group: Group): Observable<Group> {
console.log('deleted');
const url = `api/fullGroups/${Group.id}`;
const url = `api/fullGroups/${group.id}`;
return this.http.delete<Group>(url, this.httpOptions);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<button mat-raised-button class="btn" color="primary" (click)="updateResources()">Submit changes</button>
<button mat-raised-button class="btn" color="warn" (click)="deleteResources()">Delete</button>
</mat-toolbar>
<mat-card class="resource" *ngFor="let res of resources">
<mat-card class="resource" *ngFor="let res of resources; trackBy: trackById">
<div class="shadow">
<div class="checkbox">
<mat-checkbox color="primary" (change)="selectUnselectResource(res)"></mat-checkbox>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,12 @@ export class ResourcesManagementComponent implements OnInit {
dialogRef.afterClosed().subscribe(result => {
if (result) {
newResource.resourceName = result;
const dialogRef = this.dialog.open(AddRoleDialogComponent, {
const dialogRef2 = this.dialog.open(AddRoleDialogComponent, {
width: '300px',
data: {message: 'Description of resource:'},
});

dialogRef.afterClosed().subscribe(description => {
dialogRef2.afterClosed().subscribe(description => {
if (description) {
newResource.resourceDescription = description;
}
Expand All @@ -128,6 +128,10 @@ export class ResourcesManagementComponent implements OnInit {
this.selectedResources.push(resource);
}
}

trackById(index, item) {
return item.id;
}
}

@Component({
Expand Down
12 changes: 6 additions & 6 deletions ui/src/app/admin/resources-management/resources.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@ export class ResourcesService {
return this.http.get<Resource[]>(this.resourcesUrl);
}

addResources(Resource: Resource): Observable<Resource> {
addResources(resource: Resource): Observable<Resource> {
console.log('added');
return this.http.post<Resource>(this.resourcesUrl, Resource, this.httpOptions);
return this.http.post<Resource>(this.resourcesUrl, resource, this.httpOptions);
}

deleteResources(Resource: Resource): Observable<Resource> {
deleteResources(resource: Resource): Observable<Resource> {
console.log('deleted');
const url = `api/Resources/${Resource.resourceId}`;
const url = `api/Resources/${resource.resourceId}`;
return this.http.delete<Resource>(url, this.httpOptions);
}

updateResources(Resource): Observable<Resource> {
updateResources(resource): Observable<Resource> {
console.log('updated');
return this.http.put<Resource>(this.resourcesUrl, Resource, this.httpOptions);
return this.http.put<Resource>(this.resourcesUrl, resource, this.httpOptions);
}
}
2 changes: 1 addition & 1 deletion ui/src/app/admin/roles/add-role.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<h1 mat-dialog-title style="width: 100%; text-align: center;">{{data.message}}</h1>
<div mat-dialog-content style="display: flex; align-items: center; justify-content: center;">
<mat-form-field>
<input matInput [(ngModel)]="name" />
<input matInput [(ngModel)]="name" cdkFocusInitial />
</mat-form-field>
</div>
<div mat-dialog-actions style="float: right;">
Expand Down
4 changes: 2 additions & 2 deletions ui/src/app/admin/roles/roles.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</mat-toolbar>

<mat-accordion>
<mat-expansion-panel *ngFor="let role of roles">
<mat-expansion-panel *ngFor="let role of roles; trackBy: trackById">
<mat-expansion-panel-header>
<mat-panel-title style="width: 20%;">
{{ role.name }}
Expand All @@ -34,7 +34,7 @@
</mat-expansion-panel-header>

<div class="fullInfo">
<div *ngFor="let feature of role.entries" class="permission">
<div *ngFor="let feature of role.entries; trackBy: trackById" class="permission">
<div class="permissionName">{{ feature.name }}</div>
<div class="permissionDescription">{{ feature.description }}</div>
<a class="delPermission" (click)="deleteFeatureInRole(role, feature)">DELETE</a>
Expand Down
8 changes: 8 additions & 0 deletions ui/src/app/admin/roles/roles.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ export class RolesComponent implements OnInit {
}
});
}

trackById(index, item) {
return item.id;
}
}

@Component({
Expand All @@ -155,6 +159,10 @@ export class SelectFeatureDialogComponent {
onNoClick(): void {
this.dialogRef.close();
}

trackById(index, item) {
return item.id;
}
}

@Component({
Expand Down
4 changes: 2 additions & 2 deletions ui/src/app/admin/roles/select-feature.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<h1 mat-dialog-title>Select new features</h1>
<div mat-dialog-content>
<mat-accordion>
<mat-expansion-panel *ngFor="let feature of data.features;let i = index">
<mat-expansion-panel *ngFor="let feature of data.features;let i = index; trackBy: trackById;">
<mat-expansion-panel-header>
<mat-panel-title>
<mat-checkbox color="primary" (change)="selectUnselectFeature(feature)">Select</mat-checkbox>
Expand All @@ -22,7 +22,7 @@ <h1 mat-dialog-title>Select new features</h1>
<div style="width: 30%; float: left;">Method</div>
</div>

<div *ngFor="let endpoint of feature.endpoints" style="width: 100%; float: left;">
<div *ngFor="let endpoint of feature.endpoints; trackBy: trackById;" style="width: 100%; float: left;">
<div style="width: 30%; float: left;">{{endpoint.name}}</div>
<div style="width: 30%; float: left;">{{endpoint.path}}</div>
<div style="width: 30%; float: left;">{{endpoint.method}}</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,11 @@ export class UsersManagementComponent implements OnInit {
}
}

selectUnselectUser(User: User): void {
if (this.selectedUsers.find(u => u === User)) {
this.selectedUsers = this.selectedUsers.filter(u => u !== User);
selectUnselectUser(user: User): void {
if (this.selectedUsers.find(u => u === user)) {
this.selectedUsers = this.selectedUsers.filter(u => u !== user);
} else {
this.selectedUsers.push(User);
this.selectedUsers.push(user);
}
}

Expand Down
8 changes: 4 additions & 4 deletions ui/src/app/admin/users-management/users.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ export class UsersService {
return this.http.get<User[]>(`${this.UsersUrl}${query}`);
}

addUsers(User: User): Observable<User> {
addUsers(user: User): Observable<User> {
console.log('added');
return this.http.post<User>(this.UsersUrl, User, this.httpOptions);
return this.http.post<User>(this.UsersUrl, user, this.httpOptions);
}

deleteUsers(User: User): Observable<User> {
deleteUsers(user: User): Observable<User> {
console.log('deleted');
const url = `api/fullUsers/${User.userId}`;
const url = `api/fullUsers/${user.userId}`;
return this.http.delete<User>(url, this.httpOptions);
}
}
10 changes: 5 additions & 5 deletions ui/src/app/error-page/error-page.component.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { Component, OnInit } from '@angular/core';
import {Component, OnInit} from '@angular/core';
import {Title} from '@angular/platform-browser';

@Component({
selector: 'app-error-page',
templateUrl: './error-page.component.html',
styleUrls: ['./error-page.component.sass']
styleUrls: ['./error-page.component.sass'],
})
export class ErrorPageComponent implements OnInit {

constructor() { }
constructor(private titleService: Title) {}

ngOnInit(): void {
this.titleService.setTitle('Oops, something went wrong');
}

}
Loading

0 comments on commit d691a99

Please sign in to comment.