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

@Component({
    selector: 'app-view-source-code',
    template: `
    <button *ngIf="sourceUrl" class="btn btn-accent ml-2" (click)="onOpenSourceUrl()">
        <span class="{{iconStyleClass}}"></span> {{label}}
    </button>
    `
})
export class AppViewSourceCodeComponent {
    @Input() label = 'View source';
    @Input() iconStyleClass = 'ux-icon ux-icon-fw ux-icon-code';
    @Input() sourceUrl: string;

    sourceRootPath: string = 'https://webgate.ec.europa.eu/CITnet/stash/projects/UXATEC/repos/eui/browse/app-eui-showcase/src/app/';

    onOpenSourceUrl() {
        window.open(this.sourceRootPath + this.sourceUrl, '_blank');
    }
}
