perbaikan logic save device
This commit is contained in:
parent
633effdb9b
commit
b5e0962079
@ -13,7 +13,7 @@
|
|||||||
href="https://allbestsistem.com/"
|
href="https://allbestsistem.com/"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
style="background-color: #ffffff !important;"
|
style="background-color: #ffffff !important;"
|
||||||
>Smart Building Management Systems (V@2024-08-21.2)
|
>Smart Building Management Systems (V@2024-08-22.2)
|
||||||
</a></span
|
</a></span
|
||||||
>
|
>
|
||||||
</p>
|
</p>
|
||||||
|
@ -72,6 +72,8 @@ export class AddEditDeviceComponent implements OnInit {
|
|||||||
loadDevice(deviceId: string) {
|
loadDevice(deviceId: string) {
|
||||||
this.monitoringApiService.getDeviceById(deviceId).subscribe((data) => {
|
this.monitoringApiService.getDeviceById(deviceId).subscribe((data) => {
|
||||||
this.dataDevice = data;
|
this.dataDevice = data;
|
||||||
|
console.log(this.dataDevice);
|
||||||
|
|
||||||
this.formGetDevice(data);
|
this.formGetDevice(data);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -254,7 +256,7 @@ export class AddEditDeviceComponent implements OnInit {
|
|||||||
|
|
||||||
saveEdit() {
|
saveEdit() {
|
||||||
if (this.projectInfo.valid) {
|
if (this.projectInfo.valid) {
|
||||||
if (this.projectInfo.get("roomBuildingId").value) {
|
if (this.dataDevice.data.roomBuildingId) {
|
||||||
this.monitoringApiService
|
this.monitoringApiService
|
||||||
.putDevice(this.projectInfo.value, this.deviceId)
|
.putDevice(this.projectInfo.value, this.deviceId)
|
||||||
.subscribe((data) => {
|
.subscribe((data) => {
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
import { Component, ElementRef, ViewChild } from "@angular/core";
|
import { Component, ElementRef, ViewChild } from "@angular/core";
|
||||||
import { ActivatedRoute, Router } from "@angular/router";
|
import { ActivatedRoute, Router } from "@angular/router";
|
||||||
import { ChartOptions, ChartType, ChartDataset } from "chart.js";
|
|
||||||
import { EnergyMonitoringService } from "../../service/energy-monitoring.service";
|
import { EnergyMonitoringService } from "../../service/energy-monitoring.service";
|
||||||
import { CurrencyPipe } from "@angular/common";
|
import { CurrencyPipe } from "@angular/common";
|
||||||
import { LoginService } from "../../service/login.service";
|
import { LoginService } from "../../service/login.service";
|
||||||
import { DeviceService } from "../../service/device.service";
|
|
||||||
import { color } from "echarts";
|
|
||||||
import { NgbModal } from "@ng-bootstrap/ng-bootstrap";
|
import { NgbModal } from "@ng-bootstrap/ng-bootstrap";
|
||||||
import { ModalExportComponent } from "../modal-export/modal-export.component";
|
import { ModalExportComponent } from "../modal-export/modal-export.component";
|
||||||
|
|
||||||
@ -68,7 +65,7 @@ export class DetailComponent {
|
|||||||
private currencyPipe: CurrencyPipe,
|
private currencyPipe: CurrencyPipe,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private authService: LoginService,
|
private authService: LoginService,
|
||||||
private modalService: NgbModal,
|
private modalService: NgbModal
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
get formattedSummaryCost(): string {
|
get formattedSummaryCost(): string {
|
||||||
@ -88,26 +85,53 @@ export class DetailComponent {
|
|||||||
});
|
});
|
||||||
this.breadcrumbLink();
|
this.breadcrumbLink();
|
||||||
this.route.params.subscribe((params) => {
|
this.route.params.subscribe((params) => {
|
||||||
|
|
||||||
this.buildingId = params["buildingId"] ? params["buildingId"] : 0;
|
this.buildingId = params["buildingId"] ? params["buildingId"] : 0;
|
||||||
this.floorId = params["floorId"] ? params["floorId"] : 0;
|
this.floorId = params["floorId"] ? params["floorId"] : 0;
|
||||||
this.roomId = params["roomId"] ? params["roomId"] : 0;
|
this.roomId = params["roomId"] ? params["roomId"] : 0;
|
||||||
|
|
||||||
if (this.buildingId !== undefined && this.floorId === undefined && this.roomId === undefined) {
|
if (
|
||||||
|
this.buildingId !== undefined &&
|
||||||
|
this.floorId === undefined &&
|
||||||
|
this.roomId === undefined
|
||||||
|
) {
|
||||||
this.dataEnergyMonitoringTopCard(this.buildingId, 0, 0);
|
this.dataEnergyMonitoringTopCard(this.buildingId, 0, 0);
|
||||||
this.dataEnergyMonitoringSummary(this.buildingId, 0, 0);
|
this.dataEnergyMonitoringSummary(this.buildingId, 0, 0);
|
||||||
this.dataEnergyDeviceCategory(this.buildingId, 0, 0);
|
this.dataEnergyDeviceCategory(this.buildingId, 0, 0);
|
||||||
this.dataEnergyChartKwhWater(this.buildingId, 0, 0);
|
this.dataEnergyChartKwhWater(this.buildingId, 0, 0);
|
||||||
} else if (this.buildingId !== undefined && this.floorId !== undefined && this.roomId === undefined) {
|
} else if (
|
||||||
|
this.buildingId !== undefined &&
|
||||||
|
this.floorId !== undefined &&
|
||||||
|
this.roomId === undefined
|
||||||
|
) {
|
||||||
this.dataEnergyMonitoringTopCard(this.buildingId, this.floorId, 0);
|
this.dataEnergyMonitoringTopCard(this.buildingId, this.floorId, 0);
|
||||||
this.dataEnergyMonitoringSummary(this.buildingId, this.floorId, 0);
|
this.dataEnergyMonitoringSummary(this.buildingId, this.floorId, 0);
|
||||||
this.dataEnergyDeviceCategory(this.buildingId, this.floorId, 0);
|
this.dataEnergyDeviceCategory(this.buildingId, this.floorId, 0);
|
||||||
this.dataEnergyChartKwhWater(this.buildingId, this.floorId, 0);
|
this.dataEnergyChartKwhWater(this.buildingId, this.floorId, 0);
|
||||||
} else if (this.buildingId !== undefined && this.floorId !== undefined && this.roomId !== undefined) {
|
} else if (
|
||||||
this.dataEnergyMonitoringTopCard(this.buildingId, this.floorId, this.roomId);
|
this.buildingId !== undefined &&
|
||||||
this.dataEnergyMonitoringSummary(this.buildingId, this.floorId, this.roomId);
|
this.floorId !== undefined &&
|
||||||
this.dataEnergyDeviceCategory(this.buildingId, this.floorId, this.roomId);
|
this.roomId !== undefined
|
||||||
this.dataEnergyChartKwhWater(this.buildingId, this.floorId, this.roomId);
|
) {
|
||||||
|
this.dataEnergyMonitoringTopCard(
|
||||||
|
this.buildingId,
|
||||||
|
this.floorId,
|
||||||
|
this.roomId
|
||||||
|
);
|
||||||
|
this.dataEnergyMonitoringSummary(
|
||||||
|
this.buildingId,
|
||||||
|
this.floorId,
|
||||||
|
this.roomId
|
||||||
|
);
|
||||||
|
this.dataEnergyDeviceCategory(
|
||||||
|
this.buildingId,
|
||||||
|
this.floorId,
|
||||||
|
this.roomId
|
||||||
|
);
|
||||||
|
this.dataEnergyChartKwhWater(
|
||||||
|
this.buildingId,
|
||||||
|
this.floorId,
|
||||||
|
this.roomId
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.dataDeviceIr();
|
this.dataDeviceIr();
|
||||||
@ -115,6 +139,64 @@ export class DetailComponent {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
breadcrumbLink() {
|
||||||
|
if (this.mode === "building") {
|
||||||
|
this.breadcrumb = {
|
||||||
|
mainlabel: "Energy Monitoring",
|
||||||
|
linkBack: "/monitoring",
|
||||||
|
isLinkBack: true,
|
||||||
|
links: [
|
||||||
|
{
|
||||||
|
name: "Building",
|
||||||
|
isLink: false,
|
||||||
|
link: "",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
} else if (this.mode === "floor") {
|
||||||
|
this.breadcrumb = {
|
||||||
|
mainlabel: "Energy Monitoring",
|
||||||
|
linkBack: "/monitoring",
|
||||||
|
isLinkBack: true,
|
||||||
|
links: [
|
||||||
|
{
|
||||||
|
name: "Building",
|
||||||
|
isLink: false,
|
||||||
|
link: "",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Floor",
|
||||||
|
isLink: false,
|
||||||
|
link: "",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
} else if (this.mode === "room") {
|
||||||
|
this.breadcrumb = {
|
||||||
|
mainlabel: "Energy Monitoring",
|
||||||
|
linkBack: "/monitoring",
|
||||||
|
isLinkBack: true,
|
||||||
|
links: [
|
||||||
|
{
|
||||||
|
name: "Building",
|
||||||
|
isLink: false,
|
||||||
|
link: "",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Floor",
|
||||||
|
isLink: false,
|
||||||
|
link: "",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Room",
|
||||||
|
isLink: false,
|
||||||
|
link: "",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
getAirQualityData() {
|
getAirQualityData() {
|
||||||
this.valueAirQuality = Math.floor(Math.random() * 501);
|
this.valueAirQuality = Math.floor(Math.random() * 501);
|
||||||
this.chartOption = {
|
this.chartOption = {
|
||||||
@ -214,26 +296,6 @@ export class DetailComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
breadcrumbLink() {
|
|
||||||
this.breadcrumb = {
|
|
||||||
mainlabel: "Energy Monitoring",
|
|
||||||
linkBack: "/monitoring",
|
|
||||||
isLinkBack: true,
|
|
||||||
links: [
|
|
||||||
{
|
|
||||||
name: "Dashboard",
|
|
||||||
isLink: false,
|
|
||||||
link: "",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Energy Monitoring",
|
|
||||||
isLink: false,
|
|
||||||
link: "",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
dataDeviceIr() {
|
dataDeviceIr() {
|
||||||
const today = new Date().getDay();
|
const today = new Date().getDay();
|
||||||
this.days[today].isToday = true;
|
this.days[today].isToday = true;
|
||||||
@ -291,13 +353,13 @@ export class DetailComponent {
|
|||||||
legend: {},
|
legend: {},
|
||||||
toolbox: {
|
toolbox: {
|
||||||
show: true,
|
show: true,
|
||||||
orient: 'vertical',
|
orient: "vertical",
|
||||||
feature: {
|
feature: {
|
||||||
dataView: { show: true, readOnly: false },
|
dataView: { show: true, readOnly: false },
|
||||||
magicType: { show: true, type: ['line', 'bar'] },
|
magicType: { show: true, type: ["line", "bar"] },
|
||||||
restore: { show: true },
|
restore: { show: true },
|
||||||
saveAsImage: { show: true }
|
saveAsImage: { show: true },
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
grid: {
|
grid: {
|
||||||
left: "3%",
|
left: "3%",
|
||||||
@ -309,7 +371,6 @@ export class DetailComponent {
|
|||||||
{
|
{
|
||||||
type: "category",
|
type: "category",
|
||||||
data: this.barChartLabels,
|
data: this.barChartLabels,
|
||||||
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
yAxis: [
|
yAxis: [
|
||||||
@ -342,7 +403,7 @@ export class DetailComponent {
|
|||||||
};
|
};
|
||||||
onClick: (params) => {
|
onClick: (params) => {
|
||||||
this.onChartClick(params);
|
this.onChartClick(params);
|
||||||
}
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -362,7 +423,6 @@ export class DetailComponent {
|
|||||||
(result) => {
|
(result) => {
|
||||||
if (result) {
|
if (result) {
|
||||||
console.log(result);
|
console.log(result);
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
(reason) => {
|
(reason) => {
|
||||||
@ -375,6 +435,12 @@ export class DetailComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
seeMore(buildingId, floorId, roomId) {
|
seeMore(buildingId, floorId, roomId) {
|
||||||
this.router.navigate(["/monitoring/control-device-see-more/", buildingId, floorId, roomId, this.mode]);
|
this.router.navigate([
|
||||||
|
"/monitoring/control-device-see-more/",
|
||||||
|
buildingId,
|
||||||
|
floorId,
|
||||||
|
roomId,
|
||||||
|
this.mode,
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -138,7 +138,7 @@
|
|||||||
<p
|
<p
|
||||||
class="card-subtitle line-on-side text-muted text-center font-small-3 mx-2 my-1"
|
class="card-subtitle line-on-side text-muted text-center font-small-3 mx-2 my-1"
|
||||||
>
|
>
|
||||||
<span>(v@2024.08.21.2)</span>
|
<span>(v@2024.08.22.2)</span>
|
||||||
</p>
|
</p>
|
||||||
<!-- <div class="card-body">
|
<!-- <div class="card-body">
|
||||||
<a
|
<a
|
||||||
|
Loading…
x
Reference in New Issue
Block a user