|
@@ -17,6 +17,7 @@ import { formatDate, DatePipe } from '@angular/common';
|
|
|
import {AngularMyDatePickerDirective,IAngularMyDpOptions, IMyDateModel} from 'angular-mydatepicker';
|
|
import {AngularMyDatePickerDirective,IAngularMyDpOptions, IMyDateModel} from 'angular-mydatepicker';
|
|
|
import printJS from 'print-js'
|
|
import printJS from 'print-js'
|
|
|
import { ExportType,ExcelOptions, Options } from 'mat-table-exporter';
|
|
import { ExportType,ExcelOptions, Options } from 'mat-table-exporter';
|
|
|
|
|
+import * as $ from "jquery";
|
|
|
|
|
|
|
|
@Component({
|
|
@Component({
|
|
|
selector: 'app-assets',
|
|
selector: 'app-assets',
|
|
@@ -193,7 +194,7 @@ export class AssetsComponent implements OnInit {
|
|
|
//this.chartjs = true;
|
|
//this.chartjs = true;
|
|
|
setTimeout(()=>{
|
|
setTimeout(()=>{
|
|
|
Swal.close();
|
|
Swal.close();
|
|
|
- }, 2700);
|
|
|
|
|
|
|
+ }, 2500);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Default check asset dropdown if a value is equal to an assetID
|
|
// Default check asset dropdown if a value is equal to an assetID
|
|
@@ -372,9 +373,11 @@ export class AssetsComponent implements OnInit {
|
|
|
this.savings_logs_data.push(this.savings_logs[savingDate]["ahorro"]);
|
|
this.savings_logs_data.push(this.savings_logs[savingDate]["ahorro"]);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
// Get the measures according to the meters, given the params required
|
|
// Get the measures according to the meters, given the params required
|
|
|
this.logsService.getEnergyProducedByParams(assetId,interval,dateRange).toPromise()
|
|
this.logsService.getEnergyProducedByParams(assetId,interval,dateRange).toPromise()
|
|
|
.then((data: any) => {
|
|
.then((data: any) => {
|
|
|
|
|
+
|
|
|
this.metersData = [];
|
|
this.metersData = [];
|
|
|
this.metersKeys = Object.keys(data["data"]["dataset"]);
|
|
this.metersKeys = Object.keys(data["data"]["dataset"]);
|
|
|
|
|
|
|
@@ -395,7 +398,7 @@ export class AssetsComponent implements OnInit {
|
|
|
this.metersData.push({"label": label, backgroundColor: this.barChartColors[prop], data: measure_values, borderColor: this.borderChartColors[prop] });
|
|
this.metersData.push({"label": label, backgroundColor: this.barChartColors[prop], data: measure_values, borderColor: this.borderChartColors[prop] });
|
|
|
this.tableData.push({headers: label+" [kWh]", dataValues: measure_values});
|
|
this.tableData.push({headers: label+" [kWh]", dataValues: measure_values});
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// this.metersData.push({ "label": "Ahorro", data: [10,30,30,40,30,20,15,25,30,35], type: "line", backgroundColor: "#e57272", borderColor: "#ce2525", borderWidth: 2, yAxisID: 'y-axis-ahorro',})
|
|
// this.metersData.push({ "label": "Ahorro", data: [10,30,30,40,30,20,15,25,30,35], type: "line", backgroundColor: "#e57272", borderColor: "#ce2525", borderWidth: 2, yAxisID: 'y-axis-ahorro',})
|
|
|
// Initialization of arrays for the table view of the measure values
|
|
// Initialization of arrays for the table view of the measure values
|
|
|
this.array1 = this.array2 = this.array3 = [];
|
|
this.array1 = this.array2 = this.array3 = [];
|
|
@@ -443,7 +446,7 @@ export class AssetsComponent implements OnInit {
|
|
|
// According to the selected interval in the option buttons of the chart, the date is given an specific format
|
|
// According to the selected interval in the option buttons of the chart, the date is given an specific format
|
|
|
switch (view){
|
|
switch (view){
|
|
|
case "day":
|
|
case "day":
|
|
|
- this.barChartLabels = this.metersValues[0]["data"].map(obj => formatDate(obj.dateMax, 'HH:mm ','es-Es','-0600')).reverse();
|
|
|
|
|
|
|
+ this.barChartLabels = this.metersValues[0]["data"].map(obj => formatDate(obj.dateMin, 'HH:mm ','es-Es','-0600')).reverse();
|
|
|
break;
|
|
break;
|
|
|
case 'week':
|
|
case 'week':
|
|
|
this.barChartLabels = this.metersValues[0]["data"].map(obj => formatDate(obj.dateMax, 'EEEE dd','es-Es','-0600')).reverse();
|
|
this.barChartLabels = this.metersValues[0]["data"].map(obj => formatDate(obj.dateMax, 'EEEE dd','es-Es','-0600')).reverse();
|
|
@@ -463,6 +466,14 @@ export class AssetsComponent implements OnInit {
|
|
|
this.displayedColumns.push(this.tableData[v]["headers"]);
|
|
this.displayedColumns.push(this.tableData[v]["headers"]);
|
|
|
}
|
|
}
|
|
|
this.tableData2 = this.array1;
|
|
this.tableData2 = this.array1;
|
|
|
|
|
+ if (this.array1.length == 0){
|
|
|
|
|
+ $(".no-data").css('visibility', 'visible');
|
|
|
|
|
+ $(".chart-container").css('visibility', 'hidden');
|
|
|
|
|
+ }
|
|
|
|
|
+ else {
|
|
|
|
|
+ $(".no-data").css('visibility', 'hidden');
|
|
|
|
|
+ $(".chart-container").css('visibility', 'visible');
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
this.dataSource.data = this.tableData2;
|
|
this.dataSource.data = this.tableData2;
|
|
|
this.dataSource.paginator = this.paginator;
|
|
this.dataSource.paginator = this.paginator;
|
|
@@ -508,13 +519,21 @@ export class AssetsComponent implements OnInit {
|
|
|
yAxes: [
|
|
yAxes: [
|
|
|
{
|
|
{
|
|
|
stacked: true,
|
|
stacked: true,
|
|
|
- position: "left"
|
|
|
|
|
|
|
+ position: "left",
|
|
|
|
|
+ scaleLabel: {
|
|
|
|
|
+ display: true,
|
|
|
|
|
+ labelString: 'Kilowatts hora [kWh]'
|
|
|
|
|
+ },
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
display: true,
|
|
display: true,
|
|
|
stacked: true,
|
|
stacked: true,
|
|
|
position: 'right',
|
|
position: 'right',
|
|
|
id: 'y-axis-ahorro',
|
|
id: 'y-axis-ahorro',
|
|
|
|
|
+ scaleLabel: {
|
|
|
|
|
+ display: true,
|
|
|
|
|
+ labelString: 'Ahorro [US$]'
|
|
|
|
|
+ },
|
|
|
gridLines: {
|
|
gridLines: {
|
|
|
drawOnChartArea: false
|
|
drawOnChartArea: false
|
|
|
}
|
|
}
|
|
@@ -533,7 +552,7 @@ export class AssetsComponent implements OnInit {
|
|
|
});
|
|
});
|
|
|
setTimeout(()=>{
|
|
setTimeout(()=>{
|
|
|
Swal.close();
|
|
Swal.close();
|
|
|
- }, 1500)
|
|
|
|
|
|
|
+ }, 1600)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
getDateWithFormat(view:string, date:string){
|
|
getDateWithFormat(view:string, date:string){
|
|
@@ -606,7 +625,7 @@ export class AssetsComponent implements OnInit {
|
|
|
|
|
|
|
|
this.chart1Type = chartType;
|
|
this.chart1Type = chartType;
|
|
|
|
|
|
|
|
- if (this.chart1 != undefined){
|
|
|
|
|
|
|
+ if (this.chart1 != undefined || this.chart1 == undefined){
|
|
|
this.chart1.destroy();
|
|
this.chart1.destroy();
|
|
|
}
|
|
}
|
|
|
this.chart1 = undefined;
|
|
this.chart1 = undefined;
|
|
@@ -648,13 +667,21 @@ export class AssetsComponent implements OnInit {
|
|
|
yAxes: [
|
|
yAxes: [
|
|
|
{
|
|
{
|
|
|
stacked: true,
|
|
stacked: true,
|
|
|
- position: "left"
|
|
|
|
|
|
|
+ position: "left",
|
|
|
|
|
+ scaleLabel: {
|
|
|
|
|
+ display: true,
|
|
|
|
|
+ labelString: 'Kilowatts hora [kWh]'
|
|
|
|
|
+ }
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
display: true,
|
|
display: true,
|
|
|
stacked: false,
|
|
stacked: false,
|
|
|
position: 'right',
|
|
position: 'right',
|
|
|
id: 'y-axis-ahorro',
|
|
id: 'y-axis-ahorro',
|
|
|
|
|
+ scaleLabel: {
|
|
|
|
|
+ display: true,
|
|
|
|
|
+ labelString: 'Ahorro [US$]'
|
|
|
|
|
+ },
|
|
|
gridLines: {
|
|
gridLines: {
|
|
|
drawOnChartArea: false
|
|
drawOnChartArea: false
|
|
|
}
|
|
}
|