import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
import { map, switchMap } from 'rxjs/operators';
import { Md5 } from 'ts-md5';
import { ResourceSelectContextService } from '../../context.service';
import { AuthorizationStateService } from './../../../../authorization/state.service';
export class ResourceDashboardComponent {
    constructor(auth, contextService) {
        this.auth = auth;
        this.contextService = contextService;
        this.email$ = this.auth
            .getTokenPayload()
            .pipe(map(info => info.email));
        this.user$ = this.email$.pipe(switchMap(email => this.contextService.getUser(Md5.hashStr(email).toString())));
    }
}
ResourceDashboardComponent.decorators = [
    { type: Component, args: [{
                selector: 'acl-resource-dashboard',
                template: "<div class=\"dashboard\">\n  <div class=\"user\">\n    <span class=\"user__avatar\">\n      <img src=\"images/avatar.svg\" alt=\"\" />\n    </span>\n    <div class=\"user__info\">\n      <span> {{ 'hello' | translate }}{{ email$ | async }} </span>\n      <span>\n        <span class=\"with-colon\">{{ 'last_login_time' | translate }}</span>\n        <span>{{\n          (user$ | async)?.spec?.last_login_time | aclRelativeTime\n        }}</span>\n      </span>\n    </div>\n  </div>\n  <div class=\"stats\">\n    <span class=\"stats__item\">\n      <acl-resource-icon\n        type=\"project\"\n        color=\"white\"\n        [size]=\"28\"\n      ></acl-resource-icon>\n      <span>{{ 'project_number' | translate }}</span>\n      <span class=\"number\">{{ numbers?.project || 0 }}</span>\n    </span>\n    <span class=\"stats__item\">\n      <acl-resource-icon\n        type=\"cluster\"\n        color=\"white\"\n        [size]=\"28\"\n      ></acl-resource-icon>\n      <span>{{ 'cluster_number' | translate }}</span>\n      <span class=\"number\">{{ numbers?.cluster || 0 }}</span>\n    </span>\n    <!-- hidden temporarily -->\n    <!-- <span class=\"stats__item\" *ngIf=\"numbers.namespace !== undefined\">\n      <acl-resource-icon type=\"namespace\" color=\"white\" [size]=\"28\"></acl-resource-icon>\n      <span>{{ 'namespace_number' | translate }}</span>\n      <span class=\"number\">{{ numbers.namespace || 0 }}</span>\n    </span> -->\n  </div>\n</div>\n",
                changeDetection: ChangeDetectionStrategy.OnPush,
                styles: [".dashboard{height:80px;padding:15px 0 15px 16px;background-image:linear-gradient(94deg,#4392ff,#45acff);color:#fff;display:flex}.user{display:flex;margin-right:60px}.user__avatar{width:48px;height:48px;background-color:#fff;border-radius:50%;margin-right:16px}.user__info{display:flex;flex-direction:column}.user__info>span{line-height:20px}.user__info>span:first-child{line-height:25px;font-size:18px}.stats{font-size:12px;padding-bottom:6px}.stats,.stats__item{display:flex;align-items:flex-end}.stats__item{margin-right:60px}.stats__item .number{font-size:36px;margin-left:8px;line-height:1}acl-resource-icon{margin-right:8px;display:inline-flex}.with-colon:after{content:\":\";margin-right:8px}"]
            },] }
];
ResourceDashboardComponent.ctorParameters = () => [
    { type: AuthorizationStateService },
    { type: ResourceSelectContextService }
];
ResourceDashboardComponent.propDecorators = {
    numbers: [{ type: Input }]
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29tcG9uZW50LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vLi4vcGFja2FnZXMvYWxhdWRhLWNvbW1vbi1saWIvc3JjL2J1c2luZXNzL3Jlc291cmNlLXNlbGVjdC9pbnRlcm5hbHMvcmVzb3VyY2UtZGFzaGJvYXJkL2NvbXBvbmVudC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsdUJBQXVCLEVBQUUsU0FBUyxFQUFFLEtBQUssRUFBRSxNQUFNLGVBQWUsQ0FBQztBQUMxRSxPQUFPLEVBQUUsR0FBRyxFQUFFLFNBQVMsRUFBRSxNQUFNLGdCQUFnQixDQUFDO0FBQ2hELE9BQU8sRUFBRSxHQUFHLEVBQUUsTUFBTSxRQUFRLENBQUM7QUFFN0IsT0FBTyxFQUFFLDRCQUE0QixFQUFFLE1BQU0sdUJBQXVCLENBQUM7QUFJckUsT0FBTyxFQUFFLHlCQUF5QixFQUFFLE1BQU0sMkNBQTJDLENBQU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