Created
September 18, 2019 06:18
-
-
Save andimariadi/741a359f8894771cb6d9faacbed9e9ba to your computer and use it in GitHub Desktop.
getToday
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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((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]; | |
this.http.get(this.helper.globalUrl + 'android/api/get_daily_fleet/'+material+'/' + area).subscribe((data) => { | |
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