commit 7c56b223877663f3ac03abb7c29cf3e40d648a19
Author: Hung Hoang <hoanghun5@gmail.com>
Date:   Fri May 10 02:33:07 2019 +0200

    Re#7470 Implemented basic table

diff --git a/webapp/src/app/app-routing.module.ts b/webapp/src/app/app-routing.module.ts
index bfa21c7..04ab14b 100644
--- a/webapp/src/app/app-routing.module.ts
+++ b/webapp/src/app/app-routing.module.ts
@@ -1,6 +1,6 @@
 import { NgModule } from '@angular/core';
 import { Routes, RouterModule } from '@angular/router';
-import {EmployeesListComponent} from './employees-list/employees-list.component';
+import {EmployeesListComponent} from './employees/employees-list.component';
 import {DashboardComponent} from './dashboard/dashboard.component';
 
 const routes: Routes = [
diff --git a/webapp/src/app/app.module.ts b/webapp/src/app/app.module.ts
index 14eb9d0..6462ff4 100644
--- a/webapp/src/app/app.module.ts
+++ b/webapp/src/app/app.module.ts
@@ -4,18 +4,17 @@ import { NgModule } from '@angular/core';
 import { AppRoutingModule } from './app-routing.module';
 import { AppComponent } from './app.component';
 import { MenuComponent } from './menu/menu.component';
-import { EmployeesListComponent } from './employees-list/employees-list.component';
 import { DashboardModule } from './dashboard/dashboard.module';
 import { HeaderComponent } from './header/header.component';
 import { MatDialogModule } from '@angular/material';
 import {ProfileSettingsModule} from './profile-settings/profile-settings.module';
 import {HttpClientModule} from '@angular/common/http';
+import {EmployeesModule} from './employees/employees.module';
 
 @NgModule({
   declarations: [
     AppComponent,
     MenuComponent,
-    EmployeesListComponent,
     HeaderComponent
   ],
   imports: [
@@ -24,7 +23,8 @@ import {HttpClientModule} from '@angular/common/http';
     AppRoutingModule,
     DashboardModule,
     MatDialogModule,
-    ProfileSettingsModule
+    ProfileSettingsModule,
+    EmployeesModule
   ],
   providers: [],
   bootstrap: [AppComponent]
diff --git a/webapp/src/app/employee-list-item/employee-list-item.component.html b/webapp/src/app/employee-list-item/employee-list-item.component.html
deleted file mode 100644
index 0103758..0000000
--- a/webapp/src/app/employee-list-item/employee-list-item.component.html
+++ /dev/null
@@ -1,3 +0,0 @@
-<p>
-  employee-list-item works!
-</p>
diff --git a/webapp/src/app/employee-list-item/employee-list-item.component.sass b/webapp/src/app/employee-list-item/employee-list-item.component.sass
deleted file mode 100644
index e69de29..0000000
diff --git a/webapp/src/app/employee-list-item/employee-list-item.component.spec.ts b/webapp/src/app/employee-list-item/employee-list-item.component.spec.ts
deleted file mode 100644
index 75b5e3e..0000000
--- a/webapp/src/app/employee-list-item/employee-list-item.component.spec.ts
+++ /dev/null
@@ -1,25 +0,0 @@
-import { async, ComponentFixture, TestBed } from '@angular/core/testing';
-
-import { EmployeeListItemComponent } from './employee-list-item.component';
-
-describe('EmployeeListItemComponent', () => {
-  let component: EmployeeListItemComponent;
-  let fixture: ComponentFixture<EmployeeListItemComponent>;
-
-  beforeEach(async(() => {
-    TestBed.configureTestingModule({
-      declarations: [ EmployeeListItemComponent ]
-    })
-    .compileComponents();
-  }));
-
-  beforeEach(() => {
-    fixture = TestBed.createComponent(EmployeeListItemComponent);
-    component = fixture.componentInstance;
-    fixture.detectChanges();
-  });
-
-  it('should create', () => {
-    expect(component).toBeTruthy();
-  });
-});
diff --git a/webapp/src/app/employee-list-item/employee-list-item.component.ts b/webapp/src/app/employee-list-item/employee-list-item.component.ts
deleted file mode 100644
index b57b885..0000000
--- a/webapp/src/app/employee-list-item/employee-list-item.component.ts
+++ /dev/null
@@ -1,15 +0,0 @@
-import { Component, OnInit } from '@angular/core';
-
-@Component({
-  selector: 'app-employee-list-item',
-  templateUrl: './employee-list-item.component.html',
-  styleUrls: ['./employee-list-item.component.sass']
-})
-export class EmployeeListItemComponent implements OnInit {
-
-  constructor() { }
-
-  ngOnInit() {
-  }
-
-}
diff --git a/webapp/src/app/employees-list/employees-list.component.html b/webapp/src/app/employees-list/employees-list.component.html
deleted file mode 100644
index 13bb425..0000000
--- a/webapp/src/app/employees-list/employees-list.component.html
+++ /dev/null
@@ -1,35 +0,0 @@
-<div>
-  <div>
-    <h3>Zaměstnanci
-      <span class="material-icons">add</span>
-      <span class="material-icons">edit</span>
-    </h3>
-    <div *ngIf="employeesBasicInformation">
-      {{employeesBasicInformation[0].name.first}}
-      {{employeesBasicInformation[0].calendar[0].date}}
-      {{employeesBasicInformation[0].calendar[0].from}}
-      {{employeesBasicInformation[0].calendar[0].to}}
-<!--      {{employeesBasicInformation[0].calendar[1].date}}-->
-    </div>
-    <div *ngIf="employeeProfile">
-      {{employeeProfile.photo}}
-      {{employeeProfile.name.last}}
-    </div>
-    <div *ngIf="requests">
-<!--      {{requests.vacation[0].user.name.first}}-->
-<!--      {{requests.vacation[0].date}}-->
-      {{requests.vacation[0].from}}
-<!--      {{requests.authorization[0].date}}-->
-    </div>
-    <div *ngIf="calendars">
-      {{calendars[0].status}}
-      {{calendars[0].to}}
-    </div>
-
-    <div *ngIf="settings">
-      {{settings.sickDay.unit}}
-    </div>
-    <button (click)="doSomethingFancy()">SUPER BUTTON ZKUS ME</button>
-  </div>
-  <hr>
-</div>
diff --git a/webapp/src/app/employees-list/employees-list.component.sass b/webapp/src/app/employees-list/employees-list.component.sass
deleted file mode 100644
index 5eee04e..0000000
--- a/webapp/src/app/employees-list/employees-list.component.sass
+++ /dev/null
@@ -1,6 +0,0 @@
-.material-icons
-    display: inline-flex
-    align-items: center
-    justify-content: center
-    vertical-align: middle
-
diff --git a/webapp/src/app/employees-list/employees-list.component.ts b/webapp/src/app/employees-list/employees-list.component.ts
deleted file mode 100644
index 1e8dd75..0000000
--- a/webapp/src/app/employees-list/employees-list.component.ts
+++ /dev/null
@@ -1,79 +0,0 @@
-import {Component, OnInit} from '@angular/core';
-import {UserBasicInformation} from '../models/user-basic-information.model';
-import {UserProfile} from '../models/user-profile.model';
-import {UsersService} from '../services/users.service';
-import {UserService} from '../services/user.service';
-import {Requests} from '../models/requests.model';
-import {Calendar} from '../models/calendar.model';
-import {SettingsService} from '../services/settings.service';
-import {Settings} from '../models/settings.model';
-import {PostRequest, PostSettings} from '../models/post-requests.model';
-import {RequestStatus, TimeUnit, UserType} from '../enums/common.enum';
-
-@Component({
-  selector: 'app-employees-list',
-  templateUrl: './employees-list.component.html',
-  styleUrls: ['./employees-list.component.sass']
-})
-export class EmployeesListComponent implements OnInit {
-
-  employeesBasicInformation: UserBasicInformation[];
-  employeeProfile: UserProfile;
-  requests: Requests;
-  calendars: Calendar[];
-  settings: Settings;
-
-  doSomethingFancy(): void {
-    console.log('klikam');
-    this.settingsService.postDefaultSettingsWithResponse(this.settings)
-      .subscribe(resp => console.log(resp));
-
-    this.userService.postCalendarWithResponse(this.calendars)
-      .subscribe(resp => console.log(resp));
-
-    const request: PostRequest = {
-      id: 10,
-      status: RequestStatus.ACCEPTED,
-    };
-    this.userService.postAuthorizationRequestWithResponse(request)
-      .subscribe(resp => console.log(resp));
-
-    const settings: PostSettings = {
-      role: UserType.EMPLOYEE,
-      sickday: {
-        unit: TimeUnit.DAY,
-        value: 10,
-      },
-      vacation: {
-        unit: TimeUnit.DAY,
-        value: 10,
-      },
-    };
-
-    this.userService.postUserSettingsWithResponse(1, settings)
-      .subscribe(resp => console.log(resp));
-  }
-
-  constructor(private usersService: UsersService,
-              private userService: UserService,
-              private settingsService: SettingsService) {
-  }
-
-  ngOnInit() {
-    this.usersService.getAuthorizedUsers()
-      .subscribe((data: UserBasicInformation[]) => this.employeesBasicInformation = { ...data});
-
-    this.userService.getEmployeeProfile(1)
-      .subscribe((data: UserProfile) => this.employeeProfile = { ...data});
-
-    this.usersService.getAuthorizationRequests()
-      .subscribe((data: Requests) => this.requests = { ...data});
-
-    this.userService.getMonthlyCalendar(1)
-      .subscribe((data: Calendar[]) => this.calendars = { ...data});
-
-    this.settingsService.getDefaultSettings()
-      .subscribe((data: Settings) => this.settings = { ...data});
-  }
-
-}
diff --git a/webapp/src/app/employees/employees-list.component.html b/webapp/src/app/employees/employees-list.component.html
new file mode 100644
index 0000000..1ed724e
--- /dev/null
+++ b/webapp/src/app/employees/employees-list.component.html
@@ -0,0 +1,33 @@
+<div class="employee-component">
+  <h3>Zaměstnanci
+    <span class="material-icons" style="font-size: medium; margin-right: 5px">add</span>
+    <span class="material-icons" style="font-size: medium">edit</span>
+  </h3>
+
+  <table class="table text-center table-hover">
+    <thead class="thead-light">
+    <tr>
+      <th scope="col" style="width: 15%">Celé jméno</th>
+      <th scope="col" style="width: 5.0%" *ngFor="let day of days">{{day}}</th>
+      <th></th>
+    </tr>
+    </thead>
+    <tbody>
+    <tr *ngFor="let user of users">
+      <th scope="row">{{user.name}}</th>
+      <td *ngFor="let date of user.dates">
+
+        <div
+          [class.sickday]="date.type === 'SICKDAY'"
+          [class.vacation]="date.type === 'VACATION'"
+        >
+          {{date.date.getDate()}}
+        </div>
+      </td>
+      <td>
+        <span class="material-icons" style="font-size: small">edit</span>
+      </td>
+    </tr>
+    </tbody>
+  </table>
+</div>
diff --git a/webapp/src/app/employees/employees-list.component.sass b/webapp/src/app/employees/employees-list.component.sass
new file mode 100644
index 0000000..b4a7e8b
--- /dev/null
+++ b/webapp/src/app/employees/employees-list.component.sass
@@ -0,0 +1,21 @@
+@import '../../common-styles/basic-component'
+
+.material-icons
+    display: inline-flex
+    align-items: center
+    justify-content: center
+    vertical-align: middle
+
+.employee-component
+  @extend .basic-component
+  margin-top: 15px
+
+
+.sickday
+  background: #ffc0c0
+  border-radius: 40%
+
+.vacation
+  background-color: #68b040
+  border-radius: 40%
+  width: 40px
diff --git a/webapp/src/app/employees/employees-list.component.ts b/webapp/src/app/employees/employees-list.component.ts
new file mode 100644
index 0000000..9af85b7
--- /dev/null
+++ b/webapp/src/app/employees/employees-list.component.ts
@@ -0,0 +1,116 @@
+import {Component, OnInit} from '@angular/core';
+import {UserBasicInformation} from '../models/user-basic-information.model';
+import {UsersService} from '../services/users.service';
+import {VacationType} from '../enums/common.enum';
+
+class DayInfo {
+  date: Date;
+  type: VacationType;
+}
+
+class User {
+  id: number;
+  name: string;
+  dates: DayInfo[];
+}
+
+const daysOfWeek: string[] = [
+  'po',
+  'ut',
+  'st',
+  'ct',
+  'pa',
+  'so',
+  'ne',
+];
+
+@Component({
+  selector: 'app-employees-list',
+  templateUrl: './employees-list.component.html',
+  styleUrls: ['./employees-list.component.sass']
+})
+export class EmployeesListComponent implements OnInit {
+  private users: User[];
+  private days: string[];
+  private dates: Date[];
+  private employeesBasicInformation: UserBasicInformation[] = [];
+  readonly todayDate: Date = new Date();
+
+  constructor(private usersService: UsersService) {
+    this.generateDays();
+    this.generateDates();
+    this.editDates();
+  }
+
+  private generateDays(): void {
+    this.days = [];
+
+    for (let i = this.todayDate.getDay() - 8; i < this.todayDate.getDay() + 7; i++) {
+      this.days.push(daysOfWeek[((i % 7) + 7) % 7]);
+    }
+  }
+
+  private generateDates() {
+    this.dates = [];
+    for (let i = 0; i < 15; i++) {
+      this.dates.push(new Date());
+    }
+  }
+
+  private editDates(): void {
+    let j = 0;
+    let date: Date;
+
+    for (let i = -7; i < 8; i++) {
+      date = this.dates[j++];
+      date.setDate(date.getDate() + i);
+    }
+  }
+
+  private mapUsers(): void {
+    let user: User;
+    this.users = [];
+
+    for (const info of this.employeesBasicInformation) {
+      user = new User();
+      user.name = info.name.first + ' ' + info.name.last;
+      user.id = info.id;
+      user.dates = this.mapDays(info);
+      this.users.push(user);
+    }
+  }
+
+  private mapDays(user: UserBasicInformation): DayInfo[] {
+    const dayInfo: DayInfo[] = [];
+
+    for (const date of this.dates) {
+      const day: DayInfo = new DayInfo();
+      day.type = VacationType.NONE;
+
+      for (const vacationDay of user.calendar) {
+        const vacationDate: Date = new Date(vacationDay.date);
+
+        if (vacationDate.getDate() === date.getDate()) {
+          day.type = vacationDay.type;
+        }
+      }
+
+      day.date = date;
+      dayInfo.push(day);
+    }
+
+    return dayInfo;
+  }
+
+  ngOnInit() {
+    this.usersService.getAuthorizedUsers()
+      .subscribe((data: UserBasicInformation[]) => {
+        for (const entry of data) {
+          this.employeesBasicInformation.push(entry);
+        }
+        this.mapUsers();
+        console.log(this.users);
+      });
+  }
+
+}
diff --git a/webapp/src/app/employees/employees.module.ts b/webapp/src/app/employees/employees.module.ts
new file mode 100644
index 0000000..e24e25d
--- /dev/null
+++ b/webapp/src/app/employees/employees.module.ts
@@ -0,0 +1,15 @@
+import { NgModule } from '@angular/core';
+import { CommonModule } from '@angular/common';
+import {EmployeesListComponent} from './employees-list.component';
+import {MatTableModule} from '@angular/material';
+
+@NgModule({
+  declarations: [
+    EmployeesListComponent,
+  ],
+  imports: [
+    CommonModule,
+    MatTableModule
+  ]
+})
+export class EmployeesModule { }
