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

import { DashboardService, DashboardHome } from '../../openapi'


@Component({
    selector: 'gisaf-dashboard-home',
    templateUrl: './dashboard-home.component.html',
    styleUrls: ['./dashboard-home.component.css'],
    changeDetection: ChangeDetectionStrategy.OnPush,
})
export class DashboardHomeComponent implements OnInit {
    constructor(
        public dashboardService: DashboardService,
        private cdr: ChangeDetectorRef,
    ) {}

    dashboardHome: DashboardHome = {
        title: 'Welcome to Gisaf!',
        content: 'Gisaf is free, open source software for geomatics and GIS: <a href="http://redmine.auroville.org.in/projects/gisaf">Gisaf</a>.',
        footer: '<a rel="license" href="https://www.gnu.org/licenses/gpl.html"><img alt="GNU GPL v3 license"style="border-width:0" src="/static/icons/gplv3-88x31.png" title="GPL Open Source license"/></a>'
    }

    ngOnInit() {
        this.dashboardService.getHomeApiDashboardHomeGet().subscribe(
            data => {
                this.dashboardHome = data
                this.cdr.markForCheck()
            }
        )
    }
}
