added dominika #6
@ -8,7 +8,7 @@
|
|||||||
<input
|
<input
|
||||||
matInput
|
matInput
|
||||||
#nameDevice
|
#nameDevice
|
||||||
maxlength="256"
|
maxlength="20"
|
||||||
placeholder="Nazwa urządzenia"
|
placeholder="Nazwa urządzenia"
|
||||||
[formControl]="name"
|
[formControl]="name"
|
||||||
/>
|
/>
|
||||||
@ -17,7 +17,7 @@
|
|||||||
>Podaj nazwę czujnika (w przypadku ESPEasy name device)</strong
|
>Podaj nazwę czujnika (w przypadku ESPEasy name device)</strong
|
||||||
>
|
>
|
||||||
</mat-hint>
|
</mat-hint>
|
||||||
<mat-hint align="end">{{ nameDevice.value.length }} / 100</mat-hint>
|
<mat-hint align="end">{{ nameDevice.value.length }} / 20</mat-hint>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</div>
|
</div>
|
||||||
<div class="input-wrapper">
|
<div class="input-wrapper">
|
||||||
@ -25,7 +25,7 @@
|
|||||||
<input
|
<input
|
||||||
matInput
|
matInput
|
||||||
#ipDevice
|
#ipDevice
|
||||||
maxlength="256"
|
maxlength="15"
|
||||||
placeholder="Adres IP urządzenia"
|
placeholder="Adres IP urządzenia"
|
||||||
[formControl]="ip"
|
[formControl]="ip"
|
||||||
/>
|
/>
|
||||||
@ -48,7 +48,7 @@
|
|||||||
<input
|
<input
|
||||||
matInput
|
matInput
|
||||||
#ipDeviceDel
|
#ipDeviceDel
|
||||||
maxlength="256"
|
maxlength="15"
|
||||||
placeholder="Adres IP urządzenia"
|
placeholder="Adres IP urządzenia"
|
||||||
[formControl]="ipDelete"
|
[formControl]="ipDelete"
|
||||||
/>
|
/>
|
||||||
@ -64,5 +64,33 @@
|
|||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
|
<table class="table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
|
||||||
|
<th scope="col">Nazwa</th>
|
||||||
|
<th scope="col">IP</th>
|
||||||
|
|
||||||
|
<th scope="col">Edytuj</th>
|
||||||
|
<th scope="col">Usuń</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
|
||||||
|
<tr *ngFor="let device of devices; let i = index"
|
||||||
|
[attr.data-index]="i"
|
||||||
|
>
|
||||||
|
|
||||||
|
|
||||||
|
<td>{{device.name}}</td>
|
||||||
|
<td>{{device.ip}}</td>
|
||||||
|
|
||||||
|
<td>edytuj</td>
|
||||||
|
<td><button (click)="onDeviceDelete(i)">usuń</button> </td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ import { Component, OnInit } from "@angular/core";
|
|||||||
import { FormControl } from "@angular/forms";
|
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 {UserService} from '../user.service';
|
import {UserService} from '../user.service';
|
||||||
import "rxjs/Rx";
|
import "rxjs/Rx";
|
||||||
|
|
||||||
@ -14,8 +15,8 @@ export class AdminComponent implements OnInit {
|
|||||||
name = new FormControl("");
|
name = new FormControl("");
|
||||||
ip = new FormControl("");
|
ip = new FormControl("");
|
||||||
ipDelete = new FormControl("");
|
ipDelete = new FormControl("");
|
||||||
|
devices = [];
|
||||||
constructor(private http: HttpClient, private user: UserService) {}
|
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) {
|
||||||
@ -31,15 +32,35 @@ export class AdminComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onDeviceDelete() {
|
onDeviceDelete(i) {
|
||||||
if (this.ipDelete.value.length > 0) {
|
|
||||||
|
if (this.devices[i].ip.length > 0) {
|
||||||
this.http
|
this.http
|
||||||
.delete("http://localhost:3000/device/" + this.ipDelete.value)
|
.delete("http://localhost:3000/device/" + this.devices[i].ip)
|
||||||
.subscribe(data => {
|
.subscribe(data => {
|
||||||
this.ipDelete.reset();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {}
|
|
||||||
|
onDeviceEdit() {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
|
||||||
|
this.statusService.getDB().subscribe(data => {
|
||||||
|
this.devices = data;
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -94,7 +94,7 @@
|
|||||||
><span> min</span><br />
|
><span> min</span><br />
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<span>Przewidywane zakończenie: </span>
|
<span>Przewidywane zakończenie za: </span>
|
||||||
<span class="boldMe">10</span
|
<span class="boldMe">10</span
|
||||||
><span> min</span>
|
><span> min</span>
|
||||||
</ul>
|
</ul>
|
||||||
|
Loading…
Reference in New Issue
Block a user