Compare commits
No commits in common. "master" and "developer" have entirely different histories.
@ -2,14 +2,13 @@ import { NgModule } from "@angular/core";
|
|||||||
import { Routes, RouterModule } from "@angular/router";
|
import { Routes, RouterModule } from "@angular/router";
|
||||||
import { AppComponent } from "./app.component";
|
import { AppComponent } from "./app.component";
|
||||||
import { AdminComponent } from "./admin/admin.component";
|
import { AdminComponent } from "./admin/admin.component";
|
||||||
import { LoginComponent } from "./login/login.component";
|
|
||||||
import { StatusListComponent } from "./status-list/status-list.component";
|
import { StatusListComponent } from "./status-list/status-list.component";
|
||||||
|
|
||||||
const routes: Routes = [
|
const routes: Routes = [
|
||||||
{ path: "", component: StatusListComponent },
|
{ path: "", component: StatusListComponent },
|
||||||
{
|
{
|
||||||
path: "login",
|
path: "admin",
|
||||||
component: LoginComponent
|
component: AdminComponent
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -46,9 +46,7 @@ import {
|
|||||||
} from "@angular/material";
|
} from "@angular/material";
|
||||||
import { AdminComponent } from "./admin/admin.component";
|
import { AdminComponent } from "./admin/admin.component";
|
||||||
import { FormsModule, ReactiveFormsModule } from "@angular/forms";
|
import { FormsModule, ReactiveFormsModule } from "@angular/forms";
|
||||||
import { FormComponent } from "./admin/form/form.component";
|
import { FormComponent } from './admin/form/form.component';
|
||||||
import { LoginComponent } from "./login/login.component";
|
|
||||||
import { UserService } from "./user.service";
|
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [
|
declarations: [
|
||||||
@ -56,8 +54,7 @@ import { UserService } from "./user.service";
|
|||||||
StatusListComponent,
|
StatusListComponent,
|
||||||
HeaderComponent,
|
HeaderComponent,
|
||||||
AdminComponent,
|
AdminComponent,
|
||||||
FormComponent,
|
FormComponent
|
||||||
LoginComponent
|
|
||||||
],
|
],
|
||||||
imports: [
|
imports: [
|
||||||
BrowserModule,
|
BrowserModule,
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
import { TestBed, async, inject } from '@angular/core/testing';
|
|
||||||
|
|
||||||
import { AuthguardGuard } from './authguard.guard';
|
|
||||||
|
|
||||||
describe('AuthguardGuard', () => {
|
|
||||||
beforeEach(() => {
|
|
||||||
TestBed.configureTestingModule({
|
|
||||||
providers: [AuthguardGuard]
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should ...', inject([AuthguardGuard], (guard: AuthguardGuard) => {
|
|
||||||
expect(guard).toBeTruthy();
|
|
||||||
}));
|
|
||||||
});
|
|
@ -1,21 +0,0 @@
|
|||||||
import { Injectable } from "@angular/core";
|
|
||||||
import {
|
|
||||||
CanActivate,
|
|
||||||
ActivatedRouteSnapshot,
|
|
||||||
RouterStateSnapshot
|
|
||||||
} from "@angular/router";
|
|
||||||
import { Observable } from "rxjs";
|
|
||||||
import { UserService } from "./user.service";
|
|
||||||
|
|
||||||
@Injectable({
|
|
||||||
providedIn: "root"
|
|
||||||
})
|
|
||||||
export class AuthgardGuard implements CanActivate {
|
|
||||||
constructor(private user: UserService) {}
|
|
||||||
canActivate(
|
|
||||||
next: ActivatedRouteSnapshot,
|
|
||||||
state: RouterStateSnapshot
|
|
||||||
): Observable<boolean> | Promise<boolean> | boolean {
|
|
||||||
return this.user.getUserLoggedIn();
|
|
||||||
}
|
|
||||||
}
|
|
@ -5,7 +5,13 @@
|
|||||||
<img src="/assets/img/logo.png" routerLink="/" class="logo-img" alt="logo">
|
<img src="/assets/img/logo.png" routerLink="/" class="logo-img" alt="logo">
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="battery col-md-3 col-xs-3">
|
||||||
|
<img src="/assets/img/battery.png" class="battery-img" alt="battery">
|
||||||
|
<div class="battery-percent">
|
||||||
|
<span>98</span>
|
||||||
|
<span>%</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -1,16 +0,0 @@
|
|||||||
<div style="margin-top:30px">
|
|
||||||
<form (submit)="loginUser($event)">
|
|
||||||
<div class="input">
|
|
||||||
<label> Nazwa użytkownika</label> <input type="text" />
|
|
||||||
</div>
|
|
||||||
<div class="input"><label>Hasło</label> <input type="password" /></div>
|
|
||||||
<span style="color: red">{{
|
|
||||||
statusLog == 1
|
|
||||||
? " "
|
|
||||||
: statusLog == 2
|
|
||||||
? "Niepoprawny login lub hasło"
|
|
||||||
: " "
|
|
||||||
}}</span>
|
|
||||||
<div class="input"><input type="submit" value="Login" /></div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
@ -1,36 +0,0 @@
|
|||||||
:host {
|
|
||||||
flex-grow: 1;
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.input {
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.input label {
|
|
||||||
position: absolute;
|
|
||||||
top: 0;
|
|
||||||
transform: translateY(-50%);
|
|
||||||
left: 10px;
|
|
||||||
background: white;
|
|
||||||
padding: 5px 2px;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.input input {
|
|
||||||
padding: 10px 10px;
|
|
||||||
font-size: 20px;
|
|
||||||
outline: 0px;
|
|
||||||
}
|
|
||||||
|
|
||||||
div {
|
|
||||||
margin-bottom: 15px;
|
|
||||||
}
|
|
||||||
|
|
||||||
input[type="submit"] {
|
|
||||||
background-color: #0099ff;
|
|
||||||
border: none;
|
|
||||||
color: white;
|
|
||||||
border-radius: 5px;
|
|
||||||
}
|
|
@ -1,25 +0,0 @@
|
|||||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
|
||||||
|
|
||||||
import { LoginComponent } from './login.component';
|
|
||||||
|
|
||||||
describe('LoginComponent', () => {
|
|
||||||
let component: LoginComponent;
|
|
||||||
let fixture: ComponentFixture<LoginComponent>;
|
|
||||||
|
|
||||||
beforeEach(async(() => {
|
|
||||||
TestBed.configureTestingModule({
|
|
||||||
declarations: [ LoginComponent ]
|
|
||||||
})
|
|
||||||
.compileComponents();
|
|
||||||
}));
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
fixture = TestBed.createComponent(LoginComponent);
|
|
||||||
component = fixture.componentInstance;
|
|
||||||
fixture.detectChanges();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should create', () => {
|
|
||||||
expect(component).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
@ -1,27 +0,0 @@
|
|||||||
import { Component, OnInit } from "@angular/core";
|
|
||||||
import { Router } from "@angular/router";
|
|
||||||
import { UserService } from "../user.service";
|
|
||||||
@Component({
|
|
||||||
selector: "app-login",
|
|
||||||
templateUrl: "./login.component.html",
|
|
||||||
styleUrls: ["./login.component.less"]
|
|
||||||
})
|
|
||||||
export class LoginComponent implements OnInit {
|
|
||||||
constructor(private router: Router, private user: UserService) {}
|
|
||||||
statusLog = 0;
|
|
||||||
ngOnInit() {}
|
|
||||||
|
|
||||||
loginUser(e) {
|
|
||||||
e.preventDefault();
|
|
||||||
var username = e.target.elements[0].value;
|
|
||||||
var password = e.target.elements[1].value;
|
|
||||||
|
|
||||||
if (username == "admin" && password == "admin") {
|
|
||||||
this.user.setUserLoggedIn();
|
|
||||||
this.router.navigate(["admin"]);
|
|
||||||
this.statusLog = 1;
|
|
||||||
} else {
|
|
||||||
this.statusLog = 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -32,7 +32,7 @@
|
|||||||
? "Zajęte"
|
? "Zajęte"
|
||||||
: device.lastStatus == 0
|
: device.lastStatus == 0
|
||||||
? "Wolne"
|
? "Wolne"
|
||||||
: "Rozładowana bateria"
|
: "Brak połączenia z czujnikiem"
|
||||||
}}</b>
|
}}</b>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -59,18 +59,18 @@
|
|||||||
? "Zajęte"
|
? "Zajęte"
|
||||||
: activeDevice.lastStatus == 0
|
: activeDevice.lastStatus == 0
|
||||||
? "Wolne"
|
? "Wolne"
|
||||||
: "Rozładowana bateria"
|
: "Brak połączenia z czujnikiem"
|
||||||
}}</span>
|
}}</span>
|
||||||
</p>
|
</p>
|
||||||
<p class="machine-status2">
|
<p class="machine-status2">
|
||||||
{{
|
{{
|
||||||
activeDevice.lastStatus == 1
|
activeDevice.lastStatus == 1
|
||||||
? "Zajęte od:"
|
? "Zajęte"
|
||||||
: activeDevice.lastStatus == 0
|
: activeDevice.lastStatus == 0
|
||||||
? "Wolne od:"
|
? "Wolne"
|
||||||
: "Rozładowana bateria"
|
: "Brak połączenia z czujnikiem"
|
||||||
}}
|
}}
|
||||||
|
od:
|
||||||
<span
|
<span
|
||||||
>{{ time > 60 ? this.Math.floor(time / 60) : this.Math.floor(time) }}
|
>{{ time > 60 ? this.Math.floor(time / 60) : this.Math.floor(time) }}
|
||||||
{{ time > 60 ? "min" : "sek" }}
|
{{ time > 60 ? "min" : "sek" }}
|
||||||
|
@ -1,12 +0,0 @@
|
|||||||
import { TestBed } from '@angular/core/testing';
|
|
||||||
|
|
||||||
import { UserService } from './user.service';
|
|
||||||
|
|
||||||
describe('UserService', () => {
|
|
||||||
beforeEach(() => TestBed.configureTestingModule({}));
|
|
||||||
|
|
||||||
it('should be created', () => {
|
|
||||||
const service: UserService = TestBed.get(UserService);
|
|
||||||
expect(service).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
@ -1,20 +0,0 @@
|
|||||||
import { Injectable } from "@angular/core";
|
|
||||||
|
|
||||||
@Injectable({
|
|
||||||
providedIn: "root"
|
|
||||||
})
|
|
||||||
export class UserService {
|
|
||||||
private isUserLoggedIn;
|
|
||||||
private username;
|
|
||||||
|
|
||||||
constructor() {
|
|
||||||
this.isUserLoggedIn = false;
|
|
||||||
}
|
|
||||||
setUserLoggedIn() {
|
|
||||||
this.isUserLoggedIn = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
getUserLoggedIn() {
|
|
||||||
return this.isUserLoggedIn;
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user