import { Injector, Component, ViewChild, AfterViewInit, HostBinding, ElementRef, OnInit, Directive, HostListener, Input, Output, EventEmitter, ViewContainerRef } from "@angular/core"; import { AppComponentBase } from "@shared/common/app-component-base"; import { appModuleAnimation } from "@shared/animations/routerTransition"; import { LocalStorageService } from "@shared/utils/local-storage.service"; import { Router } from "@angular/router"; import { ModalDirective } from "ngx-bootstrap"; import { LazyLoadEvent } from "primeng/api"; import * as moment from 'moment'; import { ProfileServiceProxy, CurrentUserProfileEditDto } from '@shared/service-proxies/service-proxies'; @Component({ selector: 'controllerHeaderFlyoutComponent', templateUrl: 'controller-header-flyout.component.html', animations: [appModuleAnimation()] }) export class ControllerHeaderFlyoutComponent extends AppComponentBase implements OnInit, AfterViewInit { @HostBinding('id') id = 'kt_quick_sidebar'; @HostBinding('class') classes = 'kt-quick-panel'; @HostBinding('attr.mQuickSidebarOffcanvas') @HostBinding('style.overflow') styleOverflow: any = 'hidden'; mQuickSidebarOffcanvas: any; showLocationIcon: boolean = false; showPackageTypeIcon: boolean = false; showFleetIcon: boolean = false showDriverIcon: boolean = false showContactsIcon: boolean = false showCorporateIdentity: boolean = false showAccountsIcon = false hideEmpty: boolean = false; hideCompleted: boolean = true; hidePickedUp: boolean = true; rowsToShow: number = 50; todaysDate: Date; locationId: number; locations: any; filters: { locationFilter: number, statusFilter: number, typeFilter: number, startDate: Date, endDate: Date, orderStatusCode: string } = {}; timezone: string; currentRoutes: any; public userProfile: CurrentUserProfileEditDto; constructor( injector: Injector, private _localStorageService: LocalStorageService, private el: ElementRef, private router: Router, private viewContainerRef: ViewContainerRef, private _profileService: ProfileServiceProxy ) { super(injector); this.todaysDate = new Date(Date.now()); this.currentRoutes = this.router.url; this.currentRoutes = this.currentRoutes.toString().split('/'); this.currentRoutes = this.currentRoutes[this.currentRoutes.length - 1]; } _isOpen: boolean; _pinned = false; getParentComponent() { return this.viewContainerRef['_data'].componentView.component.viewContainerRef['_view'].component } ngOnInit(): void { if (localStorage.getItem('loadDate') == null) { $(".controllerDatePicker1").val(moment(this.todaysDate).format('MM/DD/YYYY')); } else { //$(".controllerDatePicker1").val(moment(localStorage.getItem('loadDate')).format('MM/DD/YYYY')); $(".controllerDatePicker1").val(localStorage.getItem('loadDate')); // console.log($(".controllerDatePicker1").val()); } if (localStorage.getItem('operatingLocationId') != null) { this.locationId = parseInt(localStorage.getItem('operatingLocationId')); } } ngAfterViewInit(): void { this.mQuickSidebarOffcanvas = new KTOffcanvas(this.el.nativeElement, { overlay: true, baseClass: 'kt-quick-panel', closeBy: 'controller-header-close', toggleBy: 'controller_header_settings_toggle' }); this.mQuickSidebarOffcanvas.events.push({ name: 'afterHide', handler: () => { if (this._pinned) { this.mQuickSidebarOffcanvas.show(); } else { this.isOpen = false; } } }, { name: 'afterShow', handler: () => { this.isOpen = true; } }); } set pinned(newValue: boolean) { if (newValue === this._pinned) { return; } this._pinned = newValue; } get pinned(): boolean { return this._pinned; } reversePinned(): void { this.pinned = !this.pinned; } set isOpen(newValue: boolean) { if (newValue === this._isOpen) { return; } this._isOpen = newValue; } get isOpen(): boolean { return this._isOpen; } switchHideEmpty(event) { console.log(event.target.checked); this.hideEmpty = event.target.checked; } switchHideCompleted(event) { console.log(event.target.checked); this.hideCompleted = event.target.checked; } switchHidePickedUp(event) { console.log(event.target.checked); this.hidePickedUp = event.target.checked; } getDataFilter(event?: LazyLoadEvent) { console.log(this.hideEmpty); console.log(this.hideCompleted); console.log(this.hidePickedUp); console.log(this.rowsToShow); } showFlyout(x: any, data: any): void { // var locationss = this.getParentComponent().locations; console.log(x); let that = this; this.locations = x; $("#locationSelectInput").val(x["0"].id); $('#locationSelectInput').on('change', function () { $("#locationSelectInput").val($(this).val()); that.getParentComponent().filters.locationFilter = $("#locationSelectInput").val(); }); this.filters.locationFilter = x["0"].id; this.userProfile = data; } filterRoutes() { let that = this; that.getParentComponent().filters.locationFilter = $("#locationSelectInput").val(); that.getParentComponent().filters.startDate = $(".controllerDatePicker1").val(); that.getParentComponent().filters.endDate = $(".controllerDatePicker1").val(); localStorage.setItem('operatingLocationId', $("#locationSelectInput").val().toString()); this.getParentComponent().filterRoutes(); this.locations.forEach(element => { if (element.id == $("#locationSelectInput").val()) { this.timezone = element.timeZone.value; } }); this.userProfile.timezone = this.timezone; // this._profileService.updateCurrentUserProfile(this.userProfile).subscribe(() => { // localStorage.setItem('timeZone', this.timezone); // }); } generateRoutes() { this.getParentComponent().generateRoute(); } }