/** @file
 * @author Edouard DUPIN
 * @copyright 2018, Edouard DUPIN, all right reserved
 * @license PROPRIETARY (see license file)
 */

import { Component, OnInit } from '@angular/core';

import { TypeService } from 'app/service/type';
import { ArianeService } from 'app/service/ariane';

@Component({
	selector: 'app-home',
	templateUrl: './home.html',
	styleUrls: ['./home.less']
})
export class HomeScene implements OnInit {
	dataList = [];
	error = '';
	constructor(private typeService: TypeService,
		private arianeService: ArianeService) {

	}

	ngOnInit() {
		let self = this;
		this.typeService.gets()
			.then((response) => {
				self.error = '';
				self.dataList = response;
			}).catch((response) => {
				self.error = 'Wrong e-mail/login or password';
				self.dataList = [];
			});
		this.arianeService.reset();
	}
	onSelectType(_event: any, _idSelected: number): void {
		this.arianeService.navigateType(_idSelected, _event.which === 2);
	}
}
