place-card.component.ts 1.44 KB
Newer Older
1
2
import { Component, OnInit, Input } from '@angular/core';
import { Place } from '../../../place';
3
import { Time } from '../../../time';
mdsecurity's avatar
mdsecurity committed
4
import { DataProviderService } from '../../../data-provider.service';
mdsecurity's avatar
mdsecurity committed
5
6
import { MdDialog } from '@angular/material';
import { FeedbackDialogComponent } from './feedback-dialog/feedback-dialog.component';
7
8
import { DomSanitizer } from '@angular/platform-browser';
import { Observable } from 'rxjs/Rx';
mdsecurity's avatar
mdsecurity committed
9
@Component({
mdsecurity's avatar
mdsecurity committed
10
11
12
	selector: 'app-place-card',
	templateUrl: './place-card.component.html',
	styleUrls: ['./place-card.component.scss']
mdsecurity's avatar
mdsecurity committed
13
})
mdsecurity's avatar
mdsecurity committed
14

mdsecurity's avatar
mdsecurity committed
15
export class PlaceCardComponent implements OnInit {
mdsecurity's avatar
mdsecurity committed
16
	@Input() private place: Place;
17
18
19
20
	private openFor = new Time();
	private isOpen;
	private url;
	constructor(private dataProvider: DataProviderService, public dialog: MdDialog, private sanitizer: DomSanitizer) { }
mdsecurity's avatar
mdsecurity committed
21
	ngOnInit() {
22
23
24
25
26
27
		this.url = this.sanitizer.bypassSecurityTrustUrl('https://unsplash.it/200/300?image=' + Math.floor((Math.random() * 999 + 1)));
		let timer = Observable.timer(0,60000);
		timer.subscribe(t => {
			this.openFor = this.place.openFor();
			this.isOpen = this.place.isOpen()
		});
mdsecurity's avatar
mdsecurity committed
28
29
30
	}
	openInContext() {
		this.dataProvider.setContext(this.place);
31
		// console.log(this.place.openFor().hour+ " "+ this.place.openFor().minute+ " "+ this.place.openFor().second)
32
		// console.log(this.place);
mdsecurity's avatar
mdsecurity committed
33
	}
mdsecurity's avatar
mdsecurity committed
34
35
36
37
38
	openDialog() {
		let dialogRef = this.dialog.open(FeedbackDialogComponent);
		dialogRef.afterClosed().subscribe(result => {
		});
	}
mdsecurity's avatar
mdsecurity committed
39
}