Skip to content

Instantly share code, notes, and snippets.

@dmastag
Forked from andimariadi/home.ts
Last active September 18, 2019 06:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dmastag/11ea7df9d490e05340cb788e78bdd0a8 to your computer and use it in GitHub Desktop.
Save dmastag/11ea7df9d490e05340cb788e78bdd0a8 to your computer and use it in GitHub Desktop.
getToday
import {Component, ViewChild} from "@angular/core";
import {NavController, PopoverController} from "ionic-angular";
import { HttpClient } from "@angular/common/http";
import { HelperProvider } from '../../providers/helper/helper';
import { Storage } from "@ionic/storage";
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
@ViewChild('barOb') barOb;
@ViewChild('barCoal') barCoal;
@ViewChild('barMTD') barMTD;
@ViewChild('barYTD') barYTD;
barChart: any;
barChart2: any;
barChart3: any;
barChart4: any;
currentDate: String;
ob: any[] = [{
"plan_1": 0,
"actual_1": 0,
"actual_2": 0,
"ach_1": '0%',
"ach_2": '0%'
}];
ach_ob: String;
coal: any[] = [{
"plan_1": 0,
"actual_1": 0,
"actual_2": 0,
"ach_1": '0%',
"ach_2": '0%'
}];
db_area: String = '..';
database: any = [];
plan: any = [];
ach_coal: String;
currentToday: String = 'Up to date';
//for today scripting
loading_today: Boolean = true;
loading_today_text: String = 'Loading...';
constructor(
public nav: NavController,
public popoverCtrl: PopoverController,
private http: HttpClient,
private helper: HelperProvider,
private storage:Storage
) {
this.currentDate = this.helper.today;
this.getDb();
this.getToday('OB');
}
ionViewWillEnter() {
// console.log(this.helper.date);
}
async getDb() {
this.storage.get('area').then((val) => {
this.db_area = val;
})
}
async _callback_data(data) {
var dan = 0;
console.log(data);
for (let index = 0; index < data.length; index++) {
dan = data[index];
}
}
getToday(material) {
let plan: any = [];
this.storage.get('area').then(async (pit) => {
this.db_area = pit;
// pit = "";
if(pit == "ALL") {
pit = "";
}
pit = pit.split(',');
for (let index = 0; index < pit.length; index++) {
const area = pit[index];
const data = await this.http.get(this.helper.globalUrl + 'android/api/get_daily_fleet/'+material+'/' + area).toPromise();
this.database.push(data['plan_prod']);
}
console.log(this.database);
if(this.database){
console.log(this.database[0]);
console.log(this.database["0"]);
console.log(this.database[""]);
console.log(this.database['""']);
}
});
}
}
//
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment