minor changes

This commit is contained in:
Dawid Kubicki 2019-01-21 09:27:09 +01:00
parent d943d7e5d2
commit bc1e030169
8 changed files with 189 additions and 24 deletions

View File

@ -3,6 +3,7 @@ import { FormControl } from "@angular/forms";
import { HttpClient } from "@angular/common/http"; import { HttpClient } from "@angular/common/http";
import { Observable } from "rxjs/Observable"; import { Observable } from "rxjs/Observable";
import { StatusService } from "../shared/status/status.service"; import { StatusService } from "../shared/status/status.service";
import { UserService } from "../user.service";
import "rxjs/Rx"; import "rxjs/Rx";
@Component({ @Component({
@ -18,7 +19,11 @@ export class AdminComponent implements OnInit {
updateName = new FormControl(""); updateName = new FormControl("");
updateID = new FormControl(""); updateID = new FormControl("");
constructor(private http: HttpClient, private statusService: StatusService) {} constructor(
private http: HttpClient,
private user: UserService,
private statusService: StatusService
) {}
onAddDevice() { onAddDevice() {
if (this.name.value.length > 0 && this.ip.value.length > 0) { if (this.name.value.length > 0 && this.ip.value.length > 0) {

View File

@ -8,8 +8,8 @@ import { StatusListComponent } from "./status-list/status-list.component";
const routes: Routes = [ const routes: Routes = [
{ path: "", component: StatusListComponent }, { path: "", component: StatusListComponent },
{ {
path: "admin", path: "login",
component: AdminComponent component: LoginComponent
} }
]; ];

View File

@ -49,8 +49,56 @@ 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 { LoginComponent } from "./login/login.component";
import { UserService } from "./user.service"; import { UserService } from "./user.service";
import { RouterModule, Routes } from "@angular/router";
import { AuthguardGuard } from "./authguard.guard";
const appRoutes: Routes = [
{
path: "",
component: LoginComponent
},
{
path: "admin",
component: AdminComponent,
canActivate: [AuthguardGuard]
}
];
@NgModule({ @NgModule({
exports: [
MatAutocompleteModule,
MatButtonModule,
MatButtonToggleModule,
MatCardModule,
MatCheckboxModule,
MatChipsModule,
MatStepperModule,
MatDatepickerModule,
MatDialogModule,
MatDividerModule,
MatExpansionModule,
MatGridListModule,
MatIconModule,
MatInputModule,
MatListModule,
MatMenuModule,
MatNativeDateModule,
MatPaginatorModule,
MatProgressBarModule,
MatProgressSpinnerModule,
MatRadioModule,
MatRippleModule,
MatSelectModule,
MatSidenavModule,
MatSliderModule,
MatSlideToggleModule,
MatSnackBarModule,
MatSortModule,
MatTableModule,
MatTabsModule,
MatToolbarModule,
MatTooltipModule
],
declarations: [ declarations: [
AppComponent, AppComponent,
StatusListComponent, StatusListComponent,
@ -60,6 +108,7 @@ import { UserService } from "./user.service";
LoginComponent LoginComponent
], ],
imports: [ imports: [
RouterModule.forRoot(appRoutes),
BrowserModule, BrowserModule,
AppRoutingModule, AppRoutingModule,
HttpClientModule, HttpClientModule,
@ -78,7 +127,7 @@ import { UserService } from "./user.service";
MatFormFieldModule, MatFormFieldModule,
MatInputModule MatInputModule
], ],
providers: [StatusService], providers: [StatusService, UserService, AuthguardGuard],
bootstrap: [AppComponent] bootstrap: [AppComponent]
}) })
export class AppModule {} export class AppModule {}

View File

@ -10,7 +10,7 @@ import { UserService } from "./user.service";
@Injectable({ @Injectable({
providedIn: "root" providedIn: "root"
}) })
export class AuthgardGuard implements CanActivate { export class AuthguardGuard implements CanActivate {
constructor(private user: UserService) {} constructor(private user: UserService) {}
canActivate( canActivate(
next: ActivatedRouteSnapshot, next: ActivatedRouteSnapshot,

View File

@ -1,16 +1,16 @@
<nav class="navbar"> <nav class="navbar">
<div class="row"> <div class="row">
<div class="logo col-md-9 col-xs-9"> <div class="logo col-md-9 col-xs-9">
<a routerLinkActive="/"> <a routerLinkActive="/">
<img src="/assets/img/logo.png" routerLink="/" class="logo-img" alt="logo"> <img
</a> src="/assets/img/logo.png"
</div> routerLink="/"
class="logo-img"
alt="logo"
</div> />
</a>
</div>
</div>
</nav> </nav>
<!-- <p><span matBadge="4" matBadgeOverlap="false">Status serwerals</span></p> --> <!-- <p><span matBadge="4" matBadgeOverlap="false">Status serwerals</span></p> -->

View File

@ -16,9 +16,9 @@ export class LoginComponent implements OnInit {
var username = e.target.elements[0].value; var username = e.target.elements[0].value;
var password = e.target.elements[1].value; var password = e.target.elements[1].value;
if (username == "admin" && password == "admin") { if (username == "admin" && password == "cap_login") {
this.user.setUserLoggedIn(); this.user.setUserLoggedIn();
this.router.navigate(["admin"]); this.router.navigate(["cap_password_123"]);
this.statusLog = 1; this.statusLog = 1;
} else { } else {
this.statusLog = 2; this.statusLog = 2;

View File

@ -40,15 +40,14 @@
<div class="row machine-row"> <div class="row machine-row">
<div class="col-md-5 col-xs-11"> <div class="col-md-5 col-xs-11">
<p class="text-center machine-text"> <p class="machine-status-title">{{ activeDevice.name }}</p>
- <span>{{ activeDevice.name }}</span> -
</p>
<p class="machine-status"> <p class="machine-status">
Status: Status:
<img <img
[src]=" [src]="
activeDevice.lastStatus == 1 activeDevice.lastStatus == 1
? '../assets/img/busy.png'
: activeDevice.lastStatus == 2
? '../assets/img/busy.png' ? '../assets/img/busy.png'
: '../assets/img/free.png' : '../assets/img/free.png'
" "
@ -118,3 +117,22 @@
<div id="tabel" class="col-md-6"><canvas id="lineChart"></canvas></div> <div id="tabel" class="col-md-6"><canvas id="lineChart"></canvas></div>
<div id="tabel" class="col-md-6"><canvas id="barChart"></canvas></div> <div id="tabel" class="col-md-6"><canvas id="barChart"></canvas></div>
</div> </div>
<footer>
<div class="row">
<div class="logo col-md-6">
<a routerLinkActive="/">
<img
src="/assets/img/logo.png"
routerLink="/"
class="logo-img"
alt="logo"
/>
</a>
</div>
<div class="col-md-6" style="text-align: right">
<div class="example-button-row">
<button mat-flat-button color="primary">Instrukcja obsługi</button>
</div>
</div>
</div>
</footer>

View File

@ -53,6 +53,26 @@ table {
} }
} }
.machine-status-title {
color: #000000;
font-size: 33px;
font-weight: 400;
margin-left: 30px;
letter-spacing: 0.5px;
img {
width: 15px;
margin-top: -3px;
margin-left: 10px;
}
span {
font-size: 24px;
margin-left: 15px;
top: -10px;
}
}
.machine-image { .machine-image {
width: 230px; width: 230px;
margin-top: 0px; margin-top: 0px;
@ -200,3 +220,76 @@ table {
.example-button-row a { .example-button-row a {
margin-right: 8px; margin-right: 8px;
} }
footer {
margin-bottom: 50px;
.row {
margin-top: 100px;
margin-bottom: 50px;
span {
font-size: 20px;
font-weight: 200;
color: #000000;
}
.logo-img {
width: 200px;
margin-top: -1px;
cursor: pointer;
}
.battery-img {
width: 13px;
margin-top: -6px;
position: relative;
}
.battery {
.battery-percent {
position: relative;
display: inline-block;
margin-left: 10px;
}
}
.flag {
outline: none !important;
cursor: pointer;
text-align: center;
.flag-img {
width: 28px;
}
.lang-change {
position: relative;
display: inline-block;
outline: none !important;
.active {
border-bottom: 1px solid black;
outline: none !important;
}
span {
font-weight: 300;
color: #000000;
margin-left: 5px;
margin-right: 5px;
outline: none !important;
}
span:hover {
opacity: 0.5;
cursor: pointer;
outline: none !important;
}
}
}
.menu-img {
cursor: pointer;
float: right;
margin-top: 5px;
}
}
.example-button-row button,
.example-button-row a {
margin-right: 8px;
}
}