import { Component, Input } from '@angular/core';
import * as i0 from "@angular/core";
import * as i1 from "../techlify-update.service";
import * as i2 from "../../core";
import * as i3 from "@angular/router";
import * as i4 from "@angular/common";
import * as i5 from "../../read-more/read-more.component";
import * as i6 from "@angular/flex-layout/flex";
import * as i7 from "@angular/material/button";
import * as i8 from "@angular/material/icon";
import * as i9 from "@angular/material/card";
export class TechlifyUpdatesTeaserComponent {
    constructor(techlifyUpdateService, errorHandler, router) {
        this.techlifyUpdateService = techlifyUpdateService;
        this.errorHandler = errorHandler;
        this.router = router;
        this.updates = [];
        this.rootNavUrl = '/techlify-updates';
        this.perPage = 4;
    }
    ngOnInit() {
        this.fetchUpdates();
    }
    async fetchUpdates() {
        try {
            let result = await this.techlifyUpdateService.getTechlifyUpdates({
                'for_current_user': true,
                'sort_by': 'released_on|desc',
                'perPage': this.perPage
            });
            this.updates = result?.data || [];
        }
        catch (error) {
            this.errorHandler.handleError(error);
        }
    }
    openUpdateHistory() {
        this.router.navigate([this.rootNavUrl + "/update-history"]);
    }
    async createUpdateViewRecord(update) {
        try {
            await this.techlifyUpdateService.createUpdateViewRecord({ update_id: update?.id });
            this.updates = this.updates.filter((x) => x.id != update.id);
        }
        catch (error) {
            this.errorHandler.handleError(error);
        }
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: TechlifyUpdatesTeaserComponent, deps: [{ token: i1.TechlifyUpdateService }, { token: i2.ErrorHandlerService }, { token: i3.Router }], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.13", type: TechlifyUpdatesTeaserComponent, selector: "app-techlify-updates-teaser", inputs: { rootNavUrl: "rootNavUrl", perPage: "perPage" }, ngImport: i0, template: "<div fxLayout=\"column\" fxLayoutGap=\"0.5rem\" *ngIf=\"updates?.length > 0\">\n    <mat-card fxLayout=\"column\" *ngFor=\"let update of updates\">\n        <div fxLayout=\"row\" fxLayoutGap=\"1rem\">\n            <mat-icon class=\"primary-color update-icon-wrapper\">\n                <span class=\"material-icons-outlined update-icon\">\n                    grading\n                </span>\n            </mat-icon>\n            <div fxLayout=\"column\" fxFlex>\n                <h5 class=\"primary-color m-0\">{{update?.title}}</h5>\n                <small><b>Released on : </b><span\n                        class=\"text-muted\">{{update?.released_on|date:'mediumDate'}}</span></small>\n            </div>\n        </div>\n        <div class=\"mb-2\">\n            <small><b>Version : </b><span class=\"text-muted\">{{update?.version}}</span></small>\n        </div>\n        <app-read-more class=\"text-muted mb-2\" [text]=\"update?.description\" [maxLength]=\"70\"></app-read-more>\n\n        <div class=\"mb-2\">\n            <button type=\"button\" mat-button class=\"primary-color text-small p-0 px-1\" (click)=\"openUpdateHistory()\">\n                <mat-icon class=\"mr-1\"> history</mat-icon>Update History\n            </button>\n        </div>\n        <div fxLayout>\n            <a *ngIf=\"update?.learn_more_link\" class=\"text-muted\" target=\"_blank\" [href]=\"update?.learn_more_link\">Learn\n                More</a>\n            <span fxFlex></span>\n            <button *ngIf=\"!update?.is_pinned\" type=\"button\" mat-stroked-button class=\"primary-color\"\n                (click)=\"createUpdateViewRecord(update)\">\n                Ok\n            </button>\n        </div>\n    </mat-card>\n</div>", styles: [".update-icon-wrapper{height:100%;width:40px}.update-icon{height:40px;font-size:40px}:host ::ng-deep app-read-more p{margin:0!important}\n"], dependencies: [{ kind: "directive", type: i4.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i5.ReadMoreComponent, selector: "app-read-more", inputs: ["text", "maxLength"] }, { kind: "directive", type: i6.DefaultLayoutDirective, selector: "  [fxLayout], [fxLayout.xs], [fxLayout.sm], [fxLayout.md],  [fxLayout.lg], [fxLayout.xl], [fxLayout.lt-sm], [fxLayout.lt-md],  [fxLayout.lt-lg], [fxLayout.lt-xl], [fxLayout.gt-xs], [fxLayout.gt-sm],  [fxLayout.gt-md], [fxLayout.gt-lg]", inputs: ["fxLayout", "fxLayout.xs", "fxLayout.sm", "fxLayout.md", "fxLayout.lg", "fxLayout.xl", "fxLayout.lt-sm", "fxLayout.lt-md", "fxLayout.lt-lg", "fxLayout.lt-xl", "fxLayout.gt-xs", "fxLayout.gt-sm", "fxLayout.gt-md", "fxLayout.gt-lg"] }, { kind: "directive", type: i6.DefaultLayoutGapDirective, selector: "  [fxLayoutGap], [fxLayoutGap.xs], [fxLayoutGap.sm], [fxLayoutGap.md],  [fxLayoutGap.lg], [fxLayoutGap.xl], [fxLayoutGap.lt-sm], [fxLayoutGap.lt-md],  [fxLayoutGap.lt-lg], [fxLayoutGap.lt-xl], [fxLayoutGap.gt-xs], [fxLayoutGap.gt-sm],  [fxLayoutGap.gt-md], [fxLayoutGap.gt-lg]", inputs: ["fxLayoutGap", "fxLayoutGap.xs", "fxLayoutGap.sm", "fxLayoutGap.md", "fxLayoutGap.lg", "fxLayoutGap.xl", "fxLayoutGap.lt-sm", "fxLayoutGap.lt-md", "fxLayoutGap.lt-lg", "fxLayoutGap.lt-xl", "fxLayoutGap.gt-xs", "fxLayoutGap.gt-sm", "fxLayoutGap.gt-md", "fxLayoutGap.gt-lg"] }, { kind: "directive", type: i6.DefaultFlexDirective, selector: "  [fxFlex], [fxFlex.xs], [fxFlex.sm], [fxFlex.md],  [fxFlex.lg], [fxFlex.xl], [fxFlex.lt-sm], [fxFlex.lt-md],  [fxFlex.lt-lg], [fxFlex.lt-xl], [fxFlex.gt-xs], [fxFlex.gt-sm],  [fxFlex.gt-md], [fxFlex.gt-lg]", inputs: ["fxFlex", "fxFlex.xs", "fxFlex.sm", "fxFlex.md", "fxFlex.lg", "fxFlex.xl", "fxFlex.lt-sm", "fxFlex.lt-md", "fxFlex.lt-lg", "fxFlex.lt-xl", "fxFlex.gt-xs", "fxFlex.gt-sm", "fxFlex.gt-md", "fxFlex.gt-lg"] }, { kind: "component", type: i7.MatButton, selector: "    button[mat-button], button[mat-raised-button], button[mat-flat-button],    button[mat-stroked-button]  ", exportAs: ["matButton"] }, { kind: "component", type: i8.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "component", type: i9.MatCard, selector: "mat-card", inputs: ["appearance"], exportAs: ["matCard"] }, { kind: "pipe", type: i4.DatePipe, name: "date" }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: TechlifyUpdatesTeaserComponent, decorators: [{
            type: Component,
            args: [{ selector: 'app-techlify-updates-teaser', template: "<div fxLayout=\"column\" fxLayoutGap=\"0.5rem\" *ngIf=\"updates?.length > 0\">\n    <mat-card fxLayout=\"column\" *ngFor=\"let update of updates\">\n        <div fxLayout=\"row\" fxLayoutGap=\"1rem\">\n            <mat-icon class=\"primary-color update-icon-wrapper\">\n                <span class=\"material-icons-outlined update-icon\">\n                    grading\n                </span>\n            </mat-icon>\n            <div fxLayout=\"column\" fxFlex>\n                <h5 class=\"primary-color m-0\">{{update?.title}}</h5>\n                <small><b>Released on : </b><span\n                        class=\"text-muted\">{{update?.released_on|date:'mediumDate'}}</span></small>\n            </div>\n        </div>\n        <div class=\"mb-2\">\n            <small><b>Version : </b><span class=\"text-muted\">{{update?.version}}</span></small>\n        </div>\n        <app-read-more class=\"text-muted mb-2\" [text]=\"update?.description\" [maxLength]=\"70\"></app-read-more>\n\n        <div class=\"mb-2\">\n            <button type=\"button\" mat-button class=\"primary-color text-small p-0 px-1\" (click)=\"openUpdateHistory()\">\n                <mat-icon class=\"mr-1\"> history</mat-icon>Update History\n            </button>\n        </div>\n        <div fxLayout>\n            <a *ngIf=\"update?.learn_more_link\" class=\"text-muted\" target=\"_blank\" [href]=\"update?.learn_more_link\">Learn\n                More</a>\n            <span fxFlex></span>\n            <button *ngIf=\"!update?.is_pinned\" type=\"button\" mat-stroked-button class=\"primary-color\"\n                (click)=\"createUpdateViewRecord(update)\">\n                Ok\n            </button>\n        </div>\n    </mat-card>\n</div>", styles: [".update-icon-wrapper{height:100%;width:40px}.update-icon{height:40px;font-size:40px}:host ::ng-deep app-read-more p{margin:0!important}\n"] }]
        }], ctorParameters: () => [{ type: i1.TechlifyUpdateService }, { type: i2.ErrorHandlerService }, { type: i3.Router }], propDecorators: { rootNavUrl: [{
                type: Input
            }], perPage: [{
                type: Input
            }] } });
//# sourceMappingURL=data:application/json;base64, 