import { Component, EventEmitter, Injector, Output, ViewChild } from '@angular/core'; import { AppComponentBase } from '@shared/common/app-component-base'; import { TimeSheetServiceProxy, UserServiceProxy, CreateTimeSheetInput, UpdateTimeSheetInput, UserListDto, TimeSheetInput, TimeSheetListDto, } from '@shared/service-proxies/service-proxies'; import * as _ from 'lodash'; import { finalize } from 'rxjs/operators'; import * as moment from 'moment'; import { ModalDirective } from 'ngx-bootstrap'; @Component({ selector: 'viewTimeSheetModal', templateUrl: './view-timesheet.component.html', styles: [`.user-edit-dialog-profile-image { margin-bottom: 20px; }`] }) export class ViewTimeSheetModalComponent extends AppComponentBase { @ViewChild('createOrEditModal', { static: true }) modal: ModalDirective; @Output() modalSave: EventEmitter = new EventEmitter(); isCreate: boolean = false; active = false; saving = false; loginDate: any; logoutDate: any; timesheet: { id: number, loginTime: any, logoutTime: any, creatorUserId: number, employeeName, } = {}; users: UserListDto[] = []; userInput:any; item: TimeSheetListDto; constructor( injector: Injector, private _timeSheetServiceProxy: TimeSheetServiceProxy, private _userServiceProxy: UserServiceProxy, ) { super(injector); } onShown(): void { $('.kt-select2').select2(); } show(item: TimeSheetListDto): void { // this._timeSheetServiceProxy // .getTimeSheet(id,undefined, undefined, undefined, undefined, undefined, undefined, undefined) // .subscribe(result => { // this.timesheet = result.items[0]; // this.loginDate = moment.utc(this.timesheet.loginTime).toDate(); // this.logoutDate = moment.utc(this.timesheet.logoutTime).toDate(); // this.timesheet.loginTime = moment.utc(this.timesheet.loginTime).toDate(); // this.timesheet.logoutTime = moment.utc(this.timesheet.logoutTime).toDate(); // this.userInput = this.timesheet.creatorUserId; // console.log(this.timesheet.loginTime); // this.modal.show(); // }); this.item = item; this.item.user ? this.timesheet.employeeName = this.item.user.name +" " +this.item.user.surname : this.timesheet.employeeName='n/a'; this.timesheet.loginTime = moment.utc(this.item.loginTime).toDate(); this.timesheet.logoutTime = moment.utc(this.item.logoutTime).toDate(); this.loginDate = moment.utc(this.item.loginTime).toDate(); this.logoutDate = moment.utc(this.item.logoutTime).toDate(); // console.log(this.item.loginTime); this.active = true; this.modal.show(); } alertSaveSuccess(): void { this.notify.info(this.l('SavedSuccessfully')); this.modalSave.emit(null); this.close(); } close(): void { this.active = false; this.modal.hide(); } }