-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
issue-116, IU for resources management was added
- Loading branch information
GrandShow
authored and
GrandShow
committed
Jun 20, 2020
1 parent
0e9b75c
commit 05195e2
Showing
38 changed files
with
895 additions
and
85 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
1 change: 1 addition & 0 deletions
1
ui/src/app/admin/groups-management/groups-management.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 @@ | ||
<p>groups-management works!</p> |
Empty file.
25 changes: 25 additions & 0 deletions
25
ui/src/app/admin/groups-management/groups-management.component.spec.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,25 @@ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { GroupsManagementComponent } from './groups-management.component'; | ||
|
||
describe('GroupsManagementComponent', () => { | ||
let component: GroupsManagementComponent; | ||
let fixture: ComponentFixture<GroupsManagementComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ GroupsManagementComponent ] | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(GroupsManagementComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
15 changes: 15 additions & 0 deletions
15
ui/src/app/admin/groups-management/groups-management.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,15 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'app-groups-management', | ||
templateUrl: './groups-management.component.html', | ||
styleUrls: ['./groups-management.component.sass'] | ||
}) | ||
export class GroupsManagementComponent implements OnInit { | ||
|
||
constructor() { } | ||
|
||
ngOnInit(): void { | ||
} | ||
|
||
} |
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,8 @@ | ||
<mat-card-content style="width: 100%; text-align: center; font-size: 1.2em; padding-top: 20px;" | ||
>{{data.message}}</mat-card-content | ||
> | ||
<mat-card-actions | ||
style="width: 100%; display: flex; align-items: center; align-content: center; justify-content: center; margin: 0px;" | ||
> | ||
<button mat-raised-button color="warn" (click)="onNoClick()">Ok</button> | ||
</mat-card-actions> |
18 changes: 18 additions & 0 deletions
18
ui/src/app/admin/resources-management/resources-management.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,18 @@ | ||
<mat-toolbar> | ||
<button mat-raised-button class="btn" color="primary" (click)="addNewResource()">Add new</button> | ||
<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"> | ||
<div class="shadow"> | ||
<div class="checkbox"> | ||
<mat-checkbox color="primary" (change)="selectUnselectResource(res)"></mat-checkbox> | ||
</div> | ||
<mat-card-title class="resName"> | ||
<input matInput class="nameInput" type="text" [(ngModel)]="res.resourceName" /> | ||
</mat-card-title> | ||
<mat-card-content class="resDescription"> | ||
<textarea matInput class="descriptionInput" [(ngModel)]="res.resourceDescription"></textarea> | ||
</mat-card-content> | ||
</div> | ||
</mat-card> |
54 changes: 54 additions & 0 deletions
54
ui/src/app/admin/resources-management/resources-management.component.sass
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 @@ | ||
.btn | ||
margin-right: 8px | ||
.resource | ||
width: 450px | ||
height: 300px | ||
float: left | ||
background-image: url('../../../assets/img/projector.jpg') | ||
background-size: cover | ||
margin: 8px | ||
padding: 0px | ||
.resName | ||
width: calc( 100% - 48px ) | ||
position: absolute | ||
bottom: 33% | ||
.nameInput | ||
width: 100% | ||
color: white | ||
font-weight: 500 | ||
font-size: 1.4em | ||
box-sizing: border-box | ||
border: none | ||
.resDescription | ||
width: calc( 100% - 48px ) | ||
height: 30% | ||
color: white | ||
position: absolute | ||
bottom: 0 | ||
.descriptionInput | ||
width: 100% | ||
height: 100% | ||
padding: 4px | ||
background-color: rgba(0,0,0,0) | ||
color: white | ||
font-weight: 300 | ||
font-size: 1.2em | ||
box-sizing: border-box | ||
border: none | ||
&:active | ||
border: none | ||
outline: none | ||
.shadow | ||
width: 100% | ||
height: 100% | ||
background-color: rgba(0,0,0,0.5) | ||
border-radius: 4px | ||
padding: 16px | ||
.checkbox | ||
float: left | ||
width: 40px | ||
height: 40px | ||
border-radius: 0px 0px 40px 0px | ||
padding-left: 5px | ||
padding-top: 5px | ||
background-color: #3f51b5 |
25 changes: 25 additions & 0 deletions
25
ui/src/app/admin/resources-management/resources-management.component.spec.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,25 @@ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { ResourcesManagementComponent } from './resources-management.component'; | ||
|
||
describe('ResourcesManagementComponent', () => { | ||
let component: ResourcesManagementComponent; | ||
let fixture: ComponentFixture<ResourcesManagementComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ ResourcesManagementComponent ] | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(ResourcesManagementComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
143 changes: 143 additions & 0 deletions
143
ui/src/app/admin/resources-management/resources-management.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,143 @@ | ||
import {Component, OnInit, Inject} from '@angular/core'; | ||
import {ResourcesService} from './resources.service'; | ||
import {MatDialog, MatDialogRef, MAT_DIALOG_DATA} from '@angular/material/dialog'; | ||
import {DeleteDialogComponent} from '../../timetable/slider-menu/slider-menu.component'; | ||
import {AddRoleDialogComponent} from '../roles/roles.component'; | ||
|
||
import {Resource} from '../../models/Resource'; | ||
|
||
@Component({ | ||
selector: 'app-resources-management', | ||
templateUrl: './resources-management.component.html', | ||
styleUrls: ['./resources-management.component.sass'], | ||
}) | ||
export class ResourcesManagementComponent implements OnInit { | ||
resources: Resource[]; | ||
selectedResources: Resource[] = []; | ||
|
||
isDelete = false; | ||
constructor(private resourcesService: ResourcesService, public dialog: MatDialog) {} | ||
|
||
ngOnInit(): void { | ||
this.getResources(); | ||
} | ||
|
||
getResources(): void { | ||
this.resourcesService.getResources().subscribe(res => (this.resources = res)); | ||
} | ||
|
||
deleteResources(): void { | ||
if (this.selectedResources.length === 0) { | ||
const dialogRef = this.dialog.open(MessageDialogComponent, { | ||
width: '250px', | ||
data: {message: 'You must select at least 1 element!'}, | ||
}); | ||
|
||
dialogRef.afterClosed().subscribe(); | ||
} else { | ||
const dialogRef = this.dialog.open(DeleteDialogComponent, { | ||
width: '250px', | ||
data: {isDelete: this.isDelete}, | ||
}); | ||
|
||
dialogRef.afterClosed().subscribe(result => { | ||
this.isDelete = result; | ||
if (this.isDelete) { | ||
this.executeDeleteResources(); | ||
this.isDelete = false; | ||
} | ||
}); | ||
} | ||
} | ||
|
||
private executeDeleteResources(): void { | ||
this.selectedResources.map(res => { | ||
this.resourcesService.deleteResources(res); | ||
}); | ||
this.resources = this.resources.filter(el => !this.selectedResources.find(f => f.resourceId === el.resourceId)); | ||
this.selectedResources = []; | ||
} | ||
|
||
updateResources() { | ||
if (this.selectedResources.length === 0) { | ||
const dialogRef = this.dialog.open(MessageDialogComponent, { | ||
width: '250px', | ||
data: {message: 'You must select at least 1 element!'}, | ||
}); | ||
|
||
dialogRef.afterClosed().subscribe(); | ||
} else { | ||
const dialogRef = this.dialog.open(DeleteDialogComponent, { | ||
width: '250px', | ||
data: {isDelete: this.isDelete}, | ||
}); | ||
|
||
dialogRef.afterClosed().subscribe(result => { | ||
this.isDelete = result; | ||
if (this.isDelete) { | ||
this.executeUpdateResources(); | ||
this.isDelete = false; | ||
} | ||
}); | ||
} | ||
} | ||
|
||
private executeUpdateResources() { | ||
this.selectedResources.map(res => { | ||
this.resourcesService.updateResources(res); | ||
}); | ||
this.selectedResources = []; | ||
} | ||
|
||
addNewResource() { | ||
const newResource = { | ||
resourceName: '', | ||
resourceDescription: '', | ||
} as Resource; | ||
const dialogRef = this.dialog.open(AddRoleDialogComponent, { | ||
width: '250px', | ||
data: {message: 'Name of resource:'}, | ||
}); | ||
|
||
dialogRef.afterClosed().subscribe(result => { | ||
if (result) { | ||
newResource.resourceName = result; | ||
const dialogRef = this.dialog.open(AddRoleDialogComponent, { | ||
width: '300px', | ||
data: {message: 'Description of resource:'}, | ||
}); | ||
|
||
dialogRef.afterClosed().subscribe(description => { | ||
if (description) { | ||
newResource.resourceDescription = description; | ||
} | ||
this.executeAddNewResource(newResource); | ||
}); | ||
} | ||
}); | ||
} | ||
|
||
private executeAddNewResource(res) { | ||
this.resourcesService.addResources(res).subscribe(r => this.resources.push(r)); | ||
} | ||
|
||
selectUnselectResource(resource) { | ||
if (this.selectedResources.find(f => f === resource)) { | ||
this.selectedResources = this.selectedResources.filter(f => f !== resource); | ||
} else { | ||
this.selectedResources.push(resource); | ||
} | ||
} | ||
} | ||
|
||
@Component({ | ||
selector: 'app-message-dialog', | ||
templateUrl: 'message.html', | ||
}) | ||
export class MessageDialogComponent { | ||
constructor(public dialogRef: MatDialogRef<DeleteDialogComponent>, @Inject(MAT_DIALOG_DATA) public data) {} | ||
|
||
onNoClick(): void { | ||
this.dialogRef.close(); | ||
} | ||
} |
Oops, something went wrong.