import { Component, Injector, OnInit, ViewChild, ViewEncapsulation, ElementRef, AfterViewInit, Renderer, Input } from '@angular/core'; import { ActivatedRoute, Route, Router } from '@angular/router'; import { AppConsts } from '@shared/AppConsts'; import { CommonModule, Location } from '@angular/common'; import { AppAuthService } from '@app/shared/common/auth/app-auth.service'; import { appModuleAnimation } from '@shared/animations/routerTransition'; import { AppComponentBase } from '@shared/common/app-component-base'; import { RouteListDto, RouteServiceProxy, LocationListDto, LocationServiceProxy, ControllerRouteServiceProxy, GenerateRouteInputDto, AddressAddressTypeLookupTableDto, ProfileServiceProxy, CurrentUserProfileEditDto, LocationNameDto, ControllerKpiCountServiceProxy, ControllerRouteDetailServiceProxy, PreferencesServiceProxy, UserPreferencesServiceProxy, CreateOrEditPreferenceDto, CreateOrEditUserPreferenceDto, UserPreferenceInput, GetLocationLockDto } from '@shared/service-proxies/service-proxies'; import * as moment from 'moment'; import { LazyLoadEvent } from 'primeng/components/common/lazyloadevent'; import { Paginator } from 'primeng/components/paginator/paginator'; import { Table } from 'primeng/components/table/table'; import { HttpClient } from '@angular/common/http'; import { finalize } from 'rxjs/operators'; import * as _ from 'lodash'; import { TabsetComponent } from 'ngx-bootstrap'; /**** STANDARD ****/ import { DispatchDetailsComponents } from '@app/sprintship/controller/dispatch/dispatch-details.component'; import { DispatchDetailsGroupComponents } from '@app/sprintship/controller/dispatch/dispatch-details.group.component'; /**** SHARED COMPONENTS ****/ import { TimerComponent } from '@app/sprintship/core-components/timer/timer.component'; import { ControllerRoutesService } from '@app/sprintship/controller/routes/croutes.service'; import { ControllerShowHideComponent } from '@app/sprintship/controller/core-components/controller-show-hide-modal.component.ts'; import { CreateRouteControllerModalComponent } from '@app/sprintship/controller/modals/create-routes-controller-modal.component'; import { DriverListTabComponent } from '@app/sprintship/controller/drivers/driver-list.component'; import { KPIBoxComponent } from '@app/sprintship/controller/kpi-box/kpi-box.component'; import { KpiLaboratoryComponent } from '@app/sprintship/controller/kpi-box/kpi-laboratory/kpi-laboratory.component'; import { VehicleListTabComponent } from '@app/sprintship/controller/vehicles/vehicle-list.component'; import { AppSessionService } from '@shared/common/session/app-session.service'; import { GenerateRoutesTrackingComponent } from './generate-routes-tracking.component'; import { interval, Subscription } from 'rxjs'; import { map } from 'rxjs/operators' import * as signalR from '@aspnet/signalr'; import { OrderListTabComponent } from '../orders/order-list.component'; import * as controller_table_settings from '@app/sprintship/controller/core-components/controller-table-settings.json'; import { OrderPackagesComponent } from '@app/sprintship/order-management/order-package-rad/orderPackages.component'; import { ControllerOrderPackagesComponent } from '../order-packages/order-packages-list.component'; import { TimerService } from '@app/sprintship/core-components/timer/timer.service'; import { CallBackModalComponent } from '@app/sprintship/controller/modals/call_back_modal.component'; import { CallInModalComponent } from '@app/sprintship/controller/modals/call_in_modal.component'; import { ControllerOrderIncidentsComponent } from '../order-incident/order-incident-list.component'; import { ControllerHeaderFlyoutComponent } from '@app/shared/layout/flyout/controller-header/controller-header-flyout.component'; import { RouteDetailModal } from '@app/sprintship/controller/route-detail/route-detail-modal.component'; import { XmlHttpRequestHelper } from '@shared/helpers/XmlHttpRequestHelper'; // import { CallBackModalComponent } from '@app/sprintship/controller/modals/call_back_modal.component'; // import { CallInModalComponent } from '@app/sprintship/controller/modals/call_in_modal.component'; import { FileDownloadService } from '@shared/utils/file-download.service'; import { ImportRouteScheduleTracking } from '@app/main/laboratory/clinics/route-schedule-import-tracking'; import { FileUpload } from 'primeng/fileupload'; import { result } from 'lodash'; import { UnlockModalComponent } from '@app/sprintship/controller/modals/unlock-modal.component'; import { LockModalComponent } from '@app/sprintship/controller/modals/lock-modal.component'; declare var $: any; declare var jquery: any; @Component({ selector: 'controller-main', templateUrl: 'croutes.component.html', encapsulation: ViewEncapsulation.None, styleUrls: ['./croutes.component.less', './dropdown.component.less'], animations: [appModuleAnimation()], providers: [ControllerRoutesService, TimerService] }) export class CRoutesComponent extends AppComponentBase implements OnInit { private hubConnection: signalR.HubConnection private importConnection: signalR.HubConnection /***** PAGES *****/ @ViewChild('routeDetailModal', { static: true }) routeDetailModal: RouteDetailModal; @ViewChild('controllerTab', { static: false }) staticTabs: TabsetComponent; @ViewChild('controllerTab', { read: ElementRef, static: true }) cRef: ElementRef; @ViewChild('controllerHeader', { read: ElementRef, static: true }) cHeader: ElementRef; @ViewChild('timerComponent', { static: false }) timerComponent: TimerComponent; // @ViewChild('callBackModal', { // static: false // }) callBackModal: CallBackModalComponent; // @ViewChild('callInModal', { // static: false // }) callInModal: CallInModalComponent; /***** COMPONENTS *****/ @ViewChild(DriverListTabComponent, { static: false }) driverTab: DriverListTabComponent; @ViewChild(VehicleListTabComponent, { static: false }) vehicleTab: VehicleListTabComponent; @ViewChild(OrderListTabComponent, { static: false }) tOrderComponents: OrderListTabComponent; @ViewChild(KPIBoxComponent, { static: false }) tKpiComponents: KPIBoxComponent; @ViewChild(ControllerOrderPackagesComponent, { static: false }) tOrderPackages: ControllerOrderPackagesComponent; @ViewChild(ControllerOrderIncidentsComponent, { static: false }) tOrderIncidents: ControllerOrderIncidentsComponent; /***** MODAL *****/ /***** STANDARD *****/ @ViewChild(DispatchDetailsComponents, { static: false }) dispatchDetailsComponent: DispatchDetailsComponents; @ViewChild(DispatchDetailsGroupComponents, { static: false }) dispatchDetailsGroupComponent: DispatchDetailsGroupComponents; /***** LABORATORY *****/ @ViewChild(KpiLaboratoryComponent, { static: false }) kpiLabComponent: KpiLaboratoryComponent; /***** EXTRAS *****/ @ViewChild('controllerHeaderFlyoutComponent', { static: false }) controllerHeaderFlyoutComponent: ControllerHeaderFlyoutComponent; @ViewChild('dr', { static: false }) dr: ElementRef; // @ViewChild('columnChooser', { // static: false // }) columnChooser: ControllerShowHideComponent; @ViewChild('generateRoutesTracking', { static: false }) generateRoutesTracking: GenerateRoutesTrackingComponent; // @ViewChild('createRouteControllerModal', { // static: false // }) createRouteControllerModal: CreateRouteControllerModalComponent; // @ViewChild(KPIBoxComponent, {static: false}) tKpiBoxComponents: KPIBoxComponent; // @ViewChild('callBackModal', {static: false}) callBackModal: CallBackModalComponent; // @ViewChild('callInModal', {static: false}) callInModal: CallInModalComponent; // importing @ViewChild('importRouteScheduleTracking', { static: false }) importRouteScheduleTracking: ImportRouteScheduleTracking; @ViewChild('ExcelFileUpload', { static: true }) excelFileUpload: FileUpload; @ViewChild('unlockModal', { static: true }) unlockModal: UnlockModalComponent; @ViewChild('lockModal', { static: true }) lockModal: LockModalComponent; isEnabledLaboratory: boolean = false; controller_edition_type: string = 'STANDARD'; updateProfile: CurrentUserProfileEditDto = new CurrentUserProfileEditDto; userPreferenceInput: UserPreferenceInput = new UserPreferenceInput; locations: LocationNameDto[] = []; hide: boolean = true; hide_menu: boolean = true; key: number; tblMain: any; todaysDate: string; event: LazyLoadEvent; generateEnable: boolean; timerVar: any; // time_interval: number; // orderStatusCode: string = undefined; completed: boolean; fRouteName: string; statistics: any; lastRefresh: string; timerInterval: string; KPIfilters: { unassignedWillCalls: any, completeWillCalls: any, completeStops: any, } = {}; filters: { locationFilter: number, statusFilter: number, typeFilter: number, startDate: moment.Moment, endDate: moment.Moment, orderStatusCode: string, filterTxt: string, routeId: string, routeName: string, vehicleName: string, driverName: string, completed: boolean, orderType: Array, osName: string, routeIds: Array, orderIds: Array, managerIds: Array, routeTypeIds: Array, unassignedStopsFilter: boolean, orderKPIFilter: string } = {}; search_string: string; txtFilter: string; allowed_dispatch: string = 'ALLOWED'; statusLocatorComponent: boolean = false; locationName: string; orderPackageListComponent: boolean = false; orderIncidentListComponent: boolean = false; orderListComponent: boolean = false; heightTemp: string; advancedFiltersAreShown: boolean = false; inputs: { locationId: number; loadDate: moment.Moment; } = {}; subscription: Subscription; searchFilters: { route: string, vehicleName: string, driverName: string, showCompletion: boolean, routeIds: Array, orderType: Array, deviceType: string, } = {}; userProfile: { name: string, surname: string, userName: string, emailAddress: string, phoneNumber: string, isPhoneNumberConfirmed: boolean, timezone: string, qrCodeSetupImageUrl: string, isGoogleAuthenticatorEnabled: boolean } = {}; testDate: string; currentRoutes: any; noLocation: boolean; @Input('edition_name') edition: string; localRouteIds = []; orderIds = []; kpiClick: boolean; filterType: string; groupGridBy: string; tabdisable: boolean; firstload: boolean; afterLoad: boolean = false; uploadUrl: string; importRouteScheduleImpoting: boolean = false; inputUserPreferences: CreateOrEditUserPreferenceDto = new CreateOrEditUserPreferenceDto(); inputPreferences: CreateOrEditPreferenceDto = new CreateOrEditPreferenceDto(); haveLoadDate: boolean = false; haveLocation: boolean = false; lockOrUnlockLocation: boolean; lockOrUnlockLocationDetails: GetLocationLockDto = new GetLocationLockDto(); constructor( injector: Injector, private _controllerRouteService: ControllerRouteServiceProxy, private _locationServiceProxy: LocationServiceProxy, private _routeService: RouteServiceProxy, private _cRoutesService: ControllerRoutesService, private _timerService: TimerService, private renderer: Renderer, private elem: ElementRef, private _profileService: ProfileServiceProxy, private router: Router, private _location: Location, private _authService: AppAuthService, private _cKpiCountService: ControllerKpiCountServiceProxy, private _controllerRouteDetailService: ControllerRouteDetailServiceProxy, private _fileDownloadService: FileDownloadService, private _preferencesService: PreferencesServiceProxy, private _userPreferencesService: UserPreferencesServiceProxy, private _httpClient: HttpClient, ) { super(injector); // interval(parseInt(sessionStorage.getItem('timer-interval'))).pipe( // map((x)=>{ // console.log('INTERVAL: '); // console.log(x); // that.dispatchDetailsComponent.populateTable(); // }) // ); } _construct() { this.kpiClick = false; this.noLocation = false; this.lastRefresh = 'N/A'; if (sessionStorage.getItem('last-refresh') != null) { this.lastRefresh = sessionStorage.getItem('last-refresh'); } this.timerInterval = '900000'; if (sessionStorage.getItem('timer-interval') == null) { sessionStorage.setItem('timer-interval', this.timerInterval); } $('#kpiToggleLink').html('Show KPI'); if (abp.auth.isGranted('Pages.Shipping.Controller') === false) { this.allowed_dispatch = 'NOT_ALLOWED'; this.router.navigate(['/app/sprintship/not-allowed']) } else { this.allowed_dispatch = 'ALLOWED'; this.generateEnable = false; this.isEnabledLaboratory = abp.features.isEnabled('App.ControllerRouteManagementFeature.RouteDetailsManagementFeature'); if (this.isEnabledLaboratory) { this.controller_edition_type = 'LABORATORY'; } this.edition = this.controller_edition_type; this.currentRoutes = this.router.url; this.currentRoutes = this.currentRoutes.toString().split('/'); this.currentRoutes = this.currentRoutes[this.currentRoutes.length - 1]; this.todaysDate = moment(Date.now()).format('MM/DD/YYYY'); if (localStorage.getItem('loadDate') == null) { this.todaysDate = moment(Date.now()).format('MM/DD/YYYY'); // var loadDate = moment.tz(this.todaysDate, localStorage.getItem('timeZoneId')).format('YYYY-MM-DD'); localStorage.setItem('loadDate', this.todaysDate); } // this.getUserServerSettings('loadDate',this.todaysDate); } this._cRoutesService.StatisticsObj.subscribe(result => { this.statistics = result; if (this.edition === 'LABORATORY') { this.statistics = result; this.kpiLabComponent.getStatistics(result); } else if (this.edition === 'STANDARD') { this.statistics = result; this.tKpiComponents.getStatisticsStandard(result); } }); var that = this; if (localStorage.getItem('groupGridBy') == null) { localStorage.setItem('groupGridBy', 'None'); } if (this.edition == 'STANDARD') { localStorage.setItem('groupGridBy', 'None'); } this.groupGridBy = localStorage.getItem('groupGridBy'); this.importRouteScheduleImpoting = abp.features.isEnabled('App.OrderImporting'); this.uploadUrl = AppConsts.remoteServiceBaseUrl + '/Import/ImportFromExcel'; } refreshIntervalTimer() { // this.dispatchDetailsComponent.populateTable(); return null; } enableAll() { $('.controllerSearchFilter').css('visibility', 'visible'); this.tabdisable = false; } disableAll() { $('.controllerSearchFilter').css('visibility', 'hidden'); this.tabdisable = true; } hideKpi(): void { if (this.hide == true) { this.hide = false; $('#kpiToggleIcon').removeClass('fa-eye-slash'); $('#kpiToggleIcon').addClass('fa-eye'); $('#kpiIndicator').html('Show KPI'); } else { this.hide = true; $('#kpiToggleIcon').addClass('fa-eye-slash'); $('#kpiToggleIcon').removeClass('fa-eye'); $('#kpiIndicator').html('Hide KPI'); } } hideKpiDropdown(): void { if (this.hide == true) { this.hide = false; $('#kpiToggleLink').html('Show KPI'); } else { this.hide = true; $('#kpiToggleLink').html('Hide KPI'); } } hideMenu(): void { if (this.hide_menu == true) { $('.dropdown-controller-menu').css('display', 'block'); this.hide_menu = false; } else { $('.dropdown-controller-menu').css('display', 'none'); this.hide_menu = true; } } showColumnChooser() { // this.columnChooser.show(); } ngOnInit(): void { this._construct(); let timeId = localStorage.getItem('timeZoneId'); moment.tz.setDefault(timeId); let that = this; this.firstload = true; // this.time_interval = $('#refreshInterval').val(); this.tabdisable = false; // this.timerVar = setInterval(function refreshIntervalTimer() { // // that.dispatchDetailsComponent.populateTable(); // if(that.groupGridBy === 'None') // { // that.dispatchDetailsComponent.populateTable(); // } else if (that.groupGridBy === 'Route-Type') // { // that.dispatchDetailsGroupComponent.populateTable(); // } // }, parseInt(sessionStorage.getItem('timer-interval'))); this.getFilter(); // if (localStorage.getItem('timeZone') == null) { // that.locationName = 'Please Select Location '; // } this.getLocationsOnLoad().then(function (result) { if (result !== null) { that.getUserServerSettingsPromise1().then(function (rs) { }); // that.getUserServerSettingsPromise('operatingLocationId').then(function(rs){ // var optLoc = rs; // if(rs == 'NONE') // { // $('#inputLocation').val(result); // var locationId = result; // if (localStorage.getItem('operatingLocationId') == null) { // localStorage.setItem('operatingLocationId', result.toString()); // console.log('1'); // console.log(result.toString()); // that.getUserServerSettings('operatingLocationId', result.toString()); // } else { // $('#inputLocation').val(localStorage.getItem('operatingLocationId')); // that.filters.locationFilter = parseInt($('#inputLocation').val()); // } // that.insertServerSettings('operatingLocationId', localStorage.getItem('operatingLocationId').toString()); // } else { // $('#inputLocation').val(localStorage.getItem('operatingLocationId')); // that.filters.locationFilter = parseInt($('#inputLocation').val()); // } // that.insertServerSettings('operatingLocationId', localStorage.getItem('operatingLocationId').toString()); // //that.tKpiComponents.getKpiCount(); // // that.tRouteComponents.populateTable(); // that.inputs.loadDate = that.filters.startDate; // that.inputs.locationId = that.filters.locationFilter; // // localStorage.setItem('loadDate', moment(that.cHeader.nativeElement.querySelector('.controllerDatePicker1').value).format('YYYY-MM-DD')); // if (localStorage.getItem('loadDate') == null) { // localStorage.setItem('loadDate', moment(that.todaysDate).format('MM/DD/YYYY')); // } // that.insertServerSettings('loadDate', localStorage.getItem('loadDate').toString()) // that.filters.startDate = moment(localStorage.getItem('loadDate')); // that.filters.endDate = moment(localStorage.getItem('loadDate')); // that.controllerHeaderFlyoutComponent.flyoutDate = moment(localStorage.getItem('loadDate')).toDate(); // // that.filterRoutes(); // $('.selLocation').select2(); // that.backgroundProcessListener(); // that.filters.orderStatusCode = ""; // //that.refresh(null); // that.filters.routeIds = []; // console.log('THAT FILTER ROUTES 1') // that.filterRoutes(); // if(that.edition === 'LABORATORY') // { // that.kpiLabComponent.clearFilter(); // } // } // else // { // $('#inputLocation').val(rs); // locationId = rs; // localStorage.setItem('operatingLocationId', rs.toString()); // that.getUserServerSettings('operatingLocationId', rs.toString()); // //that.tKpiComponents.getKpiCount(); // // that.tRouteComponents.populateTable(); // that.inputs.loadDate = that.filters.startDate; // that.inputs.locationId = parseInt(locationId.toString()); // // localStorage.setItem('loadDate', moment(that.cHeader.nativeElement.querySelector('.controllerDatePicker1').value).format('YYYY-MM-DD')); // that.getUserServerSettingsPromise('loadDate').then(function(resultDate){ // if(resultDate == 'NONE') // { // if (localStorage.getItem('loadDate') == null) { // localStorage.setItem('loadDate', moment(that.todaysDate).format('MM/DD/YYYY')); // } // // that.filterRoutes(); // $('.selLocation').select2(); // that.backgroundProcessListener(); // that.filters.orderStatusCode = ""; // //that.refresh(null); // that.filters.routeIds = []; // if (localStorage.getItem('loadDate') == null) { // localStorage.setItem('loadDate', moment(that.todaysDate).format('MM/DD/YYYY')); // } // that.insertServerSettings('loadDate', localStorage.getItem('loadDate').toString()) // that.filters.startDate = moment(localStorage.getItem('loadDate')); // that.filters.endDate = moment(localStorage.getItem('loadDate')); // that.controllerHeaderFlyoutComponent.flyoutDate = moment(localStorage.getItem('loadDate')).toDate(); // // that.filterRoutes(); // $('.selLocation').select2(); // that.backgroundProcessListener(); // that.filters.orderStatusCode = ""; // //that.refresh(null); // that.filters.routeIds = []; // console.log('THAT FILTER ROUTES 1') // that.filterRoutes(); // if(that.edition === 'LABORATORY') // { // that.kpiLabComponent.clearFilter(); // } // } // else // { // $('#inputLocation').val(rs); // locationId = rs; // localStorage.setItem('operatingLocationId', rs.toString()); // that.getUserServerSettings('operatingLocationId', rs.toString()); // //that.tKpiComponents.getKpiCount(); // // that.tRouteComponents.populateTable(); // that.inputs.loadDate = that.filters.startDate; // that.inputs.locationId = parseInt(locationId.toString()); // // localStorage.setItem('loadDate', moment(that.cHeader.nativeElement.querySelector('.controllerDatePicker1').value).format('YYYY-MM-DD')); // that.getUserServerSettingsPromise('loadDate').then(function(resultDate){ // if(resultDate == 'NONE') // { // if (localStorage.getItem('loadDate') == null) { // localStorage.setItem('loadDate', moment(that.todaysDate).format('MM/DD/YYYY')); // } // // that.filterRoutes(); // $('.selLocation').select2(); // that.backgroundProcessListener(); // that.filters.orderStatusCode = ""; // //that.refresh(null); // that.filters.routeIds = []; // if(that.edition === 'LABORATORY') // { // that.kpiLabComponent.clearFilter(); // } // } // else // { // localStorage.setItem('loadDate', resultDate.toString()); // that.filters.startDate = moment(localStorage.getItem('loadDate')); // that.filters.endDate = moment(localStorage.getItem('loadDate')); // that.controllerHeaderFlyoutComponent.flyoutDate = moment(localStorage.getItem('loadDate')).toDate(); // // that.filterRoutes(); // $('.selLocation').select2(); // that.backgroundProcessListener(); // that.filters.orderStatusCode = ""; // //that.refresh(null); // that.filters.routeIds = []; // if(that.edition === 'LABORATORY') // { // that.kpiLabComponent.clearFilter(); // } // } // else // { // localStorage.setItem('loadDate', resultDate.toString()); // that.filters.startDate = moment(localStorage.getItem('loadDate')); // that.filters.endDate = moment(localStorage.getItem('loadDate')); // that.controllerHeaderFlyoutComponent.flyoutDate = moment(localStorage.getItem('loadDate')).toDate(); // // that.filterRoutes(); // $('.selLocation').select2(); // that.backgroundProcessListener(); // that.filters.orderStatusCode = ""; // //that.refresh(null); // that.filters.routeIds = []; // if(that.edition === 'LABORATORY') // { // that.kpiLabComponent.clearFilter(); // } // } // console.log('THAT FILTER ROUTES 2') // that.controllerHeaderFlyoutComponent.flyoutDate = moment(localStorage.getItem('loadDate')).toDate(); // that.filters.startDate = moment(localStorage.getItem('loadDate')); // that.filters.endDate = moment(localStorage.getItem('loadDate')); // that.filters.locationFilter = parseInt(optLoc.toString()); // that.inputs.locationId = parseInt(optLoc.toString()); // that.filterRoutes() // }); // } // }); // } // console.log('THAT FILTER ROUTES 2') // that.controllerHeaderFlyoutComponent.flyoutDate = moment(localStorage.getItem('loadDate')).toDate(); // that.filters.startDate = moment(localStorage.getItem('loadDate')); // that.filters.endDate = moment(localStorage.getItem('loadDate')); // that.filters.locationFilter = parseInt(optLoc.toString()); // that.inputs.locationId = parseInt(optLoc.toString()); // that.filterRoutes() // }); // } // that.afterLoad=true; // }); } else { that.noLocation = true; } that.groupGridBy = localStorage.getItem('groupGridBy'); }); // this._profileService.getCurrentUserProfileForEdit().subscribe((result) => { // this.userProfile.name = result.name; // this.userProfile.surname = result.surname; // this.userProfile.userName = result.userName; // this.userProfile.emailAddress = result.emailAddress; // this.userProfile.phoneNumber = result.phoneNumber; // this.userProfile.isPhoneNumberConfirmed = result.isPhoneNumberConfirmed; // this.userProfile.timezone = result.timezone; // this.userProfile.qrCodeSetupImageUrl = result.qrCodeSetupImageUrl; // this.userProfile.isGoogleAuthenticatorEnabled = result.isGoogleAuthenticatorEnabled; // this.updateProfile.hasBackgroundImage = result.hasBackgroundImage; // this.updateProfile.name = this.userProfile.name; // this.updateProfile.surname = this.userProfile.surname; // this.updateProfile.userName = this.userProfile.userName; // this.updateProfile.emailAddress = this.userProfile.emailAddress; // this.updateProfile.phoneNumber = this.userProfile.phoneNumber; // this.updateProfile.isPhoneNumberConfirmed = this.userProfile.isPhoneNumberConfirmed; // this.updateProfile.qrCodeSetupImageUrl = this.userProfile.qrCodeSetupImageUrl; // this.updateProfile.isGoogleAuthenticatorEnabled = this.userProfile.isGoogleAuthenticatorEnabled; // this.updateProfile.timezone = localStorage.getItem('timeZone'); // this._profileService.updateCurrentUserProfile(this.updateProfile).subscribe((result) => {}); // }); } ngOnDestroy() { if (this.timerVar) { clearInterval(this.timerVar); } } resetInterval() { var that = this; clearInterval(that.timerVar); that.timerVar = setInterval(function refreshIntervalTimer() { that.dispatchDetailsComponent.populateTable(); }, parseInt(sessionStorage.getItem('timer-interval'))); } setFilter() { localStorage.setItem('searchFilter', JSON.stringify(this.searchFilters)); } getFilter() { if (localStorage.getItem('searchFilter') == null) { this.searchFilters.route = ''; this.searchFilters.driverName = ''; this.searchFilters.showCompletion = false; this.searchFilters.vehicleName = ''; } else { this.searchFilters = JSON.parse(localStorage.getItem('searchFilter')); } localStorage.setItem('searchFilter', JSON.stringify(this.searchFilters)); this.completed = this.searchFilters.showCompletion; this.filters.routeName = this.searchFilters.route; this.filters.driverName = this.searchFilters.driverName; this.filters.vehicleName = this.searchFilters.vehicleName; this.fRouteName = this.searchFilters.route; this.filters.completed = this.searchFilters.showCompletion; } getLocationsOnLoad() { let that = this; return new Promise(function (resolve, reject) { that.spinnerService.show(); that._locationServiceProxy.getLocationNames(undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined) .subscribe(result => { if (result == null) { $("#locationSelectInput").val(''); resolve(null); } else { that.locations = result; if (localStorage.getItem('operatingLocationId') == null || localStorage.getItem('operatingLocationId') == undefined || localStorage.getItem('operatingLocationId') == '') { localStorage.setItem('operatingLocationId', that.locations['0'].id); } if (localStorage.getItem('timeZone') == null) { localStorage.setItem('timeZone', that.locations['0'].timezone); } else { if (that.locations.length === 0) { that.locationName = 'NONE'; } else { // that.locationName = that.locations['0']['name']; } } $("#locationSelectInput").val(result["0"].id); that.txtFilter = null; resolve(result["0"].id); } }); }); } insertServerSettings(preferences: string, value: string) { let that = this; this._preferencesService.getAll(undefined, preferences, undefined, undefined, undefined, undefined).subscribe(resultPref => { if (resultPref.totalCount > 0) { that.inputUserPreferences.userId = abp.session.userId; that.inputUserPreferences.value = value; that.inputUserPreferences.preferenceId = resultPref.items[0].preference.id; that._userPreferencesService.createOrEdit(that.inputUserPreferences).subscribe(resultInsertPref => { }) } else { that.inputPreferences.code = preferences; that.inputPreferences.description = preferences; that._preferencesService.createOrEdit(that.inputPreferences).subscribe(resultInsertPref => { that.insertServerSettings(preferences, value); }); } }); } getUserServerSettings(preferences: string, value: string) { let that = this; this._preferencesService.getAll(undefined, preferences, undefined, undefined, undefined, undefined).subscribe(resultPref => { if (resultPref.totalCount > 0) { that._userPreferencesService.getAll(undefined, abp.session.userId, undefined, resultPref.items[0].preference.id, undefined, undefined, undefined).subscribe(result2 => { that._userPreferencesService.getUserPreferenceForEdit(result2.items[0].userPreference.id).subscribe(result => { var fresult = JSON.parse(JSON.stringify(result)); if (Object.keys(fresult).length == 0) { that.todaysDate = moment(Date.now()).format('MM/DD/YYYY'); // var loadDate = moment.tz(this.todaysDate, localStorage.getItem('timeZoneId')).format('YYYY-MM-DD'); localStorage.setItem(preferences, value); that.inputUserPreferences.userId = abp.session.userId; that.inputUserPreferences.value = value; that.inputUserPreferences.preferenceId = resultPref.items[0].preference.id that._userPreferencesService.createOrEdit(that.inputUserPreferences).subscribe(resultInsertPref => { }) } else { localStorage.setItem(preferences, value); that.inputUserPreferences.userId = abp.session.userId; that.inputUserPreferences.value = value; that.inputUserPreferences.preferenceId = resultPref.items[0].preference.id that.inputUserPreferences.id = fresult.userPreference.id; that._userPreferencesService.createOrEdit(that.inputUserPreferences).subscribe(resultInsertPref => { }) } }); }); } else { that.inputPreferences.code = preferences; that.inputPreferences.description = preferences; that._preferencesService.createOrEdit(that.inputPreferences).subscribe(resultInsertPref => { that.getUserServerSettings(preferences, value); }); } }); } getUserServerSettingsPromise(preferences: string) { let that = this; return new Promise(function (resolve, reject) { that.spinnerService.show(); that._preferencesService.getAll(undefined, preferences, undefined, undefined, undefined, undefined).subscribe(resultPref => { if (resultPref.totalCount > 0) { that._userPreferencesService.getAll(undefined, abp.session.userId, undefined, resultPref.items[0].preference.id, undefined, undefined, undefined).subscribe(result2 => { if (result2.totalCount == 0) { resolve('NONE'); } else { that._userPreferencesService.getUserPreferenceForEdit(result2.items[0].userPreference.id).subscribe(result => { if (Object.keys(result).length == 0) { that.inputUserPreferences.userId = abp.session.userId; that.inputUserPreferences.preferenceId = resultPref.items[0].preference.id that.inputUserPreferences.id = result.userPreference.id; resolve('NONE'); } else { resolve(result.userPreference.value); } }); } }); } else { that.inputPreferences.code = preferences; that.inputPreferences.description = preferences; that._preferencesService.createOrEdit(that.inputPreferences).subscribe(resultInsertPref => { that._preferencesService.getAll(undefined, preferences, undefined, undefined, undefined, undefined).subscribe(resultPref => { that._userPreferencesService.getAll(undefined, abp.session.userId, undefined, resultPref.items[0].preference.id, undefined, undefined, undefined).subscribe(result2 => { if (result2.totalCount == 0) { resolve('NONE'); } else { that._userPreferencesService.getUserPreferenceForEdit(result2.items[0].userPreference.id).subscribe(result => { if (Object.keys(result).length == 0) { that.inputUserPreferences.userId = abp.session.userId; that.inputUserPreferences.preferenceId = resultPref.items[0].preference.id that.inputUserPreferences.id = result.userPreference.id; resolve('NONE'); } else { resolve(result.userPreference.value); } }); } }); }); }); } }); }); } getUserServerSettingsPromise1() { let that = this; return new Promise(function (resolve, reject) { var locationId = localStorage.getItem('operatingLocationId') == null ? that.locations[0].id.toString() : localStorage.getItem('operatingLocationId'); var loadDate = localStorage.getItem('loadDate') == null ? that.todaysDate : localStorage.getItem('loadDate') that._userPreferencesService.getCurrentuserPreference().subscribe(result => { if (result == null) { that.userPreferenceInput.locationValue = locationId; that.userPreferenceInput.loadDateValue = loadDate; that._userPreferencesService.createOrEditUserPreference(that.userPreferenceInput); } else { for (var data in result) { if (result[data].userPreference.preferences.code == "operatingLocationId") { localStorage.setItem("operatingLocationId", result[data].userPreference.value); that.filters.locationFilter = parseInt(result[data].userPreference.value); that.inputs.locationId = parseInt(result[data].userPreference.value.toString()); $("#locationSelectInput").val(result[data].userPreference.value); that.haveLocation = true; } if (result[data].userPreference.preferences.code == "loadDate") { localStorage.setItem("loadDate", result[data].userPreference.value); that.controllerHeaderFlyoutComponent.flyoutDate = moment(localStorage.getItem('loadDate')).toDate(); that.filters.startDate = moment(localStorage.getItem('loadDate')); that.filters.endDate = moment(localStorage.getItem('loadDate')); that.haveLoadDate = true; } } if (!that.haveLocation) { that.insertServerSettings('operatingLocationId', locationId); that.filters.locationFilter = parseInt(locationId); } if (!that.haveLoadDate) { that.insertServerSettings('loadDate', loadDate); that.controllerHeaderFlyoutComponent.flyoutDate = moment(localStorage.getItem('loadDate')).toDate(); that.filters.startDate = moment(localStorage.getItem('loadDate')); that.filters.endDate = moment(localStorage.getItem('loadDate')); } } $('.selLocation').select2(); that.backgroundProcessListener(); that.filters.orderStatusCode = ""; that.filters.routeIds = []; that.filterRoutes(); if (that.edition === 'LABORATORY') { that.kpiLabComponent.clearFilter(); } }); resolve(null); }); } loadRouteComponent() { var that = this; if (this.groupGridBy === 'None') { that.dispatchDetailsComponent.populateTable(); } else if (this.groupGridBy === 'Route-Type') { that.dispatchDetailsGroupComponent.populateTable(); } } refreshPage(value: any) { // if (value.action === 'CONTROLLER_REFRESH') { // this.filterRoutes(); // } } changeInterval(value: any) { // this.time_interval = value; } formatDate(date) { var d = new Date(date), month = '' + (d.getMonth() + 1), day = '' + d.getDate(), year = d.getFullYear(); if (month.length < 2) month = '0' + month; if (day.length < 2) day = '0' + day; return [year, month, day].join('-'); } filterStops(data: any) { this.orderIds = data; let that = this; this.orderPackageListComponent = true; this.tOrderPackages.filterData = this.filters.orderIds; this.tOrderPackages.filters.unassignedStopsFilter = true; // this.tOrderPackages.getOrderPackages(null, 'KPI_BOX'); this.loadOrderPackagesListComponent('KPI_BOX'); } filterRoutes() { let key; this.getLocationLock(); if (this.groupGridBy === 'None') { this.dispatchDetailsComponent.kpiClick = this.kpiClick; } else if (this.groupGridBy === 'Route-Type') { this.dispatchDetailsGroupComponent.kpiClick = this.kpiClick; } if (this.filters.routeName != undefined) { this.searchFilters.route = this.filters.routeName; this.setFilter(); } else { this.searchFilters.route = ''; this.setFilter(); } if (this.filters.vehicleName != undefined) { this.searchFilters.vehicleName = this.filters.vehicleName; this.setFilter(); } else { this.searchFilters.vehicleName = ''; this.setFilter(); } if (this.filters.driverName != undefined) { this.searchFilters.driverName = this.filters.driverName; this.setFilter() } else { this.searchFilters.driverName = ''; this.setFilter(); } if (this.currentRoutes == 'dispatch') { for (key in this.locations) { if (this.locations[key].id == this.filters.locationFilter) { /*$(".location").text(this.locations[key].name + " - ");*/ $(".location").text(this.locations[key].name + ""); } } // this.cHeader.nativeElement.querySelector('.datePicker').innerHTML = moment(localStorage.getItem('loadDate')).format('dddd, MMMM DD, YYYY'); // $(".datePicker").text(moment(localStorage.getItem('loadDate')).format('dddd, MMMM DD, YYYY')); let that = this; // localStorage.setItem('loadDate', $(".controllerDatePicker1").val()); // if ($(".controllerDatePicker1").val()) { // // let str = $(".controllerDatePicker1").val().toString().format('YYYY-MM-DD'); // // $(".controllerDatePicker1").val(moment(localStorage.getItem('loadDate')).format('MM/DD/YYYY')); // localStorage.setItem('loadDate',$(".controllerDatePicker1").val()); // } let nowDate = moment(this.todaysDate).toDate(); let nowDateMoment = moment(nowDate); let duration = {}; duration['_data'] = { 'days': 0 }; duration = moment.duration(nowDateMoment.diff(this.filters.endDate)); if (typeof duration !== "undefined") { if (duration['_data'].days > 0) { this.generateEnable = true; } else { this.generateEnable = false; } } //localStorage.setItem('loadDate', moment(this.filters.endDate).format('YYYY-MM-DD')); this.inputs.loadDate = this.filters.endDate; this.inputs.locationId = that.filters.locationFilter; if (this.edition === 'STANDARD') { this.tKpiComponents.getKpiCount(); } this.searchFilters = JSON.parse(localStorage.getItem('searchFilter')); this.completed = this.searchFilters.showCompletion; if (!this.isEnabledLaboratory) { this.filters.completed = this.searchFilters.showCompletion; } // this.filters.orderType = this.searchFilters.orderType; // this.filters.osName = this.searchFilters.deviceType, // this.filters.routeIds = this.searchFilters.routeIds // console.log("SWITCH FILTER: "); // console.log(this.cRef.nativeElement.querySelector('.nav-tabs .active a span').innerText); switch (this.cRef.nativeElement.querySelector('.nav-tabs .active a span').innerText) { case 'Routes': switch (this.edition) { case 'STANDARD': // that.tRouteComponents.populateTable(); if (this.groupGridBy === 'None') { that.dispatchDetailsComponent.populateTable(); } else if (this.groupGridBy === 'Route-Type') { that.dispatchDetailsGroupComponent.populateTable(); } break; case 'LABORATORY': // this._cRoutesService.setStatistics({ // "result": "OK", // "total_vehicles": "0", // "total_packages": "0" // }); if (this.kpiClick == false) { that._cRoutesService.setStatistics({ 'total_stops': 0, 'total_callins': 0, 'total_routes': 0, 'completed_stops': 0, 'completed_callins': 0, 'total_completed_routes': 0, 'total_unassigned_routes': 0, 'total_unassigned_stops': 0, 'total_not_checkin': 0, 'total_twenty_minutes': 0, 'total_thirty_minutes': 0, 'total_unassigned_willcalls': 0, 'unassigned_routes_ids': [], 'not_check_in_routes_ids': [], 'completed_route_ids': [], 'unassigned_stop_ids': [], 'completed_stops_id': [], 'completed_call_in_stops_ids': [] }); } // console.log('CALLING LABORATORY: '); if (this.groupGridBy === 'None') { that.dispatchDetailsComponent.populateTable(); } else if (this.groupGridBy === 'Route-Type') { that.dispatchDetailsGroupComponent.populateTable(); } break; default: if (this.groupGridBy === 'None') { that.dispatchDetailsComponent.populateTable(); } else if (this.groupGridBy === 'Route-Type') { that.dispatchDetailsGroupComponent.populateTable(); } break; } break; case 'Orders': that.tOrderComponents.getOrder(); break; case 'Packages': that.filterType = 'NONE'; that.tOrderPackages.getOrderPackages(); // null, null, 'NONE' break; case 'Vehicles': that.vehicleTab.getVehicleList(); break; case 'Drivers': that.driverTab.getDriverList(); break; case 'Incidents': that.tOrderIncidents.getOrderIncident(); break; default: // switch (this.edition) { // case 'STANDARD': // // that.tRouteComponents.populateTable(); // that.dispatchDetailsComponent.populateTable(); // break; // case 'LABORATORY': // that.dispatchDetailsComponent.populateTable(); // break; // default: // // that.tRouteComponents.populateTable(); // that.dispatchDetailsComponent.populateTable(); // break; // } if (this.groupGridBy === 'None') { that.dispatchDetailsComponent.populateTable(); } else if (this.groupGridBy === 'Route-Type') { that.dispatchDetailsGroupComponent.populateTable(); } break; } //this.cHeader.nativeElement.querySelector('.datePicker').innerHTML = moment(localStorage.getItem('loadDate')).format('dddd, MMMM DD, YYYY'); // this.cHeader.nativeElement.querySelector('.datePicker').innerHTML = localStorage.getItem('loadDate'); } } TodayFilter() { // this._cKpiCountService.getRefreshTime(parseInt(localStorage.getItem('operatingLocationId'))) // .subscribe(result=>{ // console.log('TOdays date'); // console.log(result); // }); if (this.noLocation === false) { this.firstload = false; // this.todaysDate = moment(Date.now()).format('MM/DD/YYYY'); this._controllerRouteService.getBranchTime(undefined, this.filters.locationFilter, undefined, undefined, undefined) .subscribe(result => { let dateLocation; dateLocation = result.split(' '); // console.log('DATE LOCATION: '); // console.log(dateLocation); localStorage.setItem('loadDate', dateLocation[0]); var loadDate = dateLocation[0]; this.filters.startDate = moment(localStorage.getItem('loadDate')); this.filters.endDate = moment(localStorage.getItem('loadDate')); this.controllerHeaderFlyoutComponent.flyoutDate = moment(localStorage.getItem('loadDate')).toDate(); $(".controllerDatePicker1").val(dateLocation[0]); // this.getUserServerSettings('loadDate', dateLocation[0]); this.userPreferenceInput.loadDateValue = localStorage.getItem('loadDate'); this.userPreferenceInput.locationValue = localStorage.getItem('operatingLocationId'); this._userPreferencesService.createOrEditUserPreference(this.userPreferenceInput).subscribe(res => { this.filterRoutes(); }); localStorage.setItem('loadDate', dateLocation[0]); this.controllerHeaderFlyoutComponent.getRoutes(); this.dispatchDetailsComponent.noResultFound = false; }); } } loadDriverListComponent() { //this.driverListComponent = true; this.driverTab.getDriverList(); } loadVehicleListComponent() { // this.tVehicleComponents.getVehicleList(); this.vehicleTab.getVehicleList(); } loadOrderPackagesListComponent(filterType: string) { filterType = filterType != null ? filterType : 'NONE' let that = this; this.orderPackageListComponent = true; this.tOrderPackages.filterData = this.filters.orderIds = undefined; this.staticTabs.tabs[2].active = true; if (filterType == 'NONE') { this.tOrderPackages.filters.unassignedStopsFilter = false this.tOrderPackages.filters.willCallFilter = false this.tOrderPackages.filters.orderStatusCode = undefined this.tOrderPackages.getOrderPackages(); } else if (filterType == 'UNASSIGNED_ORDERS') { this.tOrderPackages.filters.willCallFilter = false this.tOrderPackages.filters.orderStatusCode = undefined this.tOrderPackages.getOrderPackages(); } else if (filterType == 'COMPLETED_STOPS') { this.tOrderPackages.filters.unassignedStopsFilter = false this.tOrderPackages.filters.willCallFilter = false this.tOrderPackages.getOrderPackages(); } else if (filterType == 'COMPLETED_CALLIN') { this.tOrderPackages.filters.unassignedStopsFilter = false this.tOrderPackages.filters.orderStatusCode = undefined this.tOrderPackages.getOrderPackages(); } else { this.tOrderPackages.getOrderPackages(); } } loadOrderIncidentListComponent() { let that = this; this.orderIncidentListComponent = true; // that.filters.locationFilter = $("#locationSelectInput").val(); // this.filters.startDate = $('#kt_datetimepicker_6').val(); // this.filters.endDate = $('#kt_datetimepicker_6').val(); this.tOrderIncidents.getOrderIncident(undefined); } loadOrderListComponent(filterType: string) { let that = this; this.orderListComponent = true; // that.filters.locationFilter = $("#locationSelectInput").val(); // this.filters.startDate = $('#kt_datetimepicker_6').val(); // this.filters.endDate = $('#kt_datetimepicker_6').val(); // this.getLocationsOnLoad(); if (filterType == 'NONE') { this.tOrderComponents.filters.unassignedStopsFilter = false this.tOrderComponents.filters.willCallFilter = false this.tOrderComponents.filters.orderStatusCode = undefined; this.tOrderComponents.orderIds = this.filters.orderIds; this.tOrderComponents.getOrder(); } else if (filterType == 'KPI_REMAINING_STOPS') { this.tOrderComponents.filters.orderKPIFilter = "KPI_REMAINING_STOPS"; this.tOrderComponents.getOrder(); } else if (filterType == 'KPI_REMAINING_DELIVERIES') { this.tOrderComponents.filters.orderKPIFilter = "KPI_REMAINING_DELIVERIES"; this.tOrderComponents.getOrder(); } else if (filterType == 'KPI_PICKED_UP') { this.tOrderComponents.filters.orderKPIFilter = "KPI_PICKED_UP"; this.tOrderComponents.getOrder(); } else if (filterType == 'KPI_DELIVERED') { this.tOrderComponents.filters.orderKPIFilter = "KPI_DELIVERED"; this.tOrderComponents.getOrder(); } else if (filterType == 'KPI_UNASSIGNED') { this.tOrderComponents.filters.orderKPIFilter = "KPI_UNASSIGNED"; this.tOrderComponents.getOrder(); } else if (filterType == 'KPI_DELIVERY_ISSUE') { this.tOrderComponents.filters.orderKPIFilter = "KPI_DELIVERY_ISSUE"; this.tOrderComponents.getOrder(); } else if (filterType == 'UNASSIGNED_ORDERS') { this.tOrderComponents.filters.willCallFilter = false this.tOrderComponents.filters.orderStatusCode = undefined this.tOrderComponents.getOrder(); } else if (filterType == 'COMPLETED_STOPS') { this.tOrderComponents.filters.unassignedStopsFilter = false this.tOrderComponents.filters.willCallFilter = false this.tOrderComponents.getOrder(); } else if (filterType == 'COMPLETED_CALLIN') { this.tOrderComponents.filters.unassignedStopsFilter = false this.tOrderComponents.filters.orderStatusCode = undefined this.tOrderComponents.getOrder(); } else { this.tOrderComponents.orderIds = this.filters.orderIds; this.tOrderComponents.unassignedWillCalls = this.KPIfilters.unassignedWillCalls; this.tOrderComponents.getOrder(); } // this.tOrderComponents.getOrder(undefined); } getSelected() { let elements = this.elem.nativeElement.querySelectorAll('.checkboxItem'); } filterRoutesByParameters() { var that = this; this.search_string = this.txtFilter; switch (this.edition) { case 'STANDARD': if (this.groupGridBy === 'None') { this.dispatchDetailsComponent.setFilter(this.txtFilter); } else if (this.groupGridBy === 'Route-Type') { this.dispatchDetailsGroupComponent.setFilter(this.txtFilter); } this._cRoutesService.setStatistics({ "result": "OK", "total_vehicles": "0", "total_packages": "0" }); // this.tRouteComponents.populateTable(); if (this.groupGridBy === 'None') { that.dispatchDetailsComponent.populateTable(); } else if (this.groupGridBy === 'Route-Type') { that.dispatchDetailsGroupComponent.populateTable(); } break; case 'LABORATORY': this.dispatchDetailsComponent.setFilter(this.txtFilter); this._cRoutesService.setStatistics({ "result": "OK", "total_vehicles": "0", "total_packages": "0" }); if (this.groupGridBy === 'None') { that.dispatchDetailsComponent.populateTable(); } else if (this.groupGridBy === 'Route-Type') { that.dispatchDetailsGroupComponent.populateTable(); } break; default: this.dispatchDetailsComponent.setFilter(this.txtFilter); this._cRoutesService.setStatistics({ "result": "OK", "total_vehicles": "0", "total_packages": "0" }); if (this.groupGridBy === 'None') { that.dispatchDetailsComponent.populateTable(); } else if (this.groupGridBy === 'Route-Type') { that.dispatchDetailsGroupComponent.populateTable(); } break; } } backgroundProcessListener() { this.hubConnection = new signalR.HubConnectionBuilder() .withUrl(AppConsts.remoteServiceBaseUrl + '/signalr-background') .build(); this.hubConnection .start() .then() .catch(err => console.log('Error while starting connection: ' + err)); this.hubConnection.on('BackgroundMessage:' + abp.session.tenantId + ':generateRoutes', (message) => { if (message.match(/Route created/) || message.match(/Order created/)) { this.generateRoutesTracking.logMessage(message, true); } else { this.generateRoutesTracking.logMessage(message); } }); } importListener() { this.importConnection = new signalR.HubConnectionBuilder() .withUrl(AppConsts.remoteServiceBaseUrl + '/import') .build(); this.importConnection .start() .then(() => console.log('Connection started')) .catch(err => console.log('Error while starting connection: ' + err)); this.importConnection.on('BackgroundMessage', (message) => { if (message.match(/End Importing/)) { this.importRouteScheduleTracking.importing = false; this.importConnection.off; } else { this.importRouteScheduleTracking.logMessage(message); } }); } showCreateRoutes() { // this.createRouteControllerModal.show(); } showCallBack() { // this.callBackModal.show(); } showCallIn() { // this.callInModal.show(); } refresh(event: any) { // if(this.noLocation === false) // { this.firstload = true; this.filters.routeIds = []; this.filterRoutes(); if (this.edition === 'LABORATORY') { this.kpiLabComponent.clearFilter(); } // } } setCompleted() { this.searchFilters.showCompletion = this.completed; this.setFilter(); this.refresh(undefined); } async generateRoute() { this.generateRoutesTracking.clearMessages(); let timeId = localStorage.getItem('timeZoneId'); let params = new GenerateRouteInputDto({ // loadDateEnd: moment.tz(this.filters.endDate, "UTC"), loadDateEnd: moment.tz(localStorage.getItem('loadDate'), timeId), loadDateStart: moment.tz(localStorage.getItem('loadDate'), timeId), locationId: this.filters.locationFilter, action: "RUN", jobId: "" }); let runResult = await this._controllerRouteService.generateRouteManual(params).toPromise(); if (runResult.success) { if (runResult.jobId) { this.generateRoutesTracking.modal.show(); params.jobId = runResult.jobId; params.action = "TRACK"; let observable = interval(1500).subscribe((val) => { this._controllerRouteService.generateRouteManual(params).subscribe(watcher => { if (watcher.result == "DONE") { this.generateRoutesTracking.complete(); observable.unsubscribe(); this.filterRoutes(); } }); }); } } } showFlyOut(): void { if (this.noLocation === false) { this.controllerHeaderFlyoutComponent.showFlyout(this.locations, this.userProfile, this.edition); } } getRouteAndDriver(filterFlyoutHolder): void { // this.controllerHeaderFlyoutComponent.filterRouteData = filterFlyoutHolder; } // private static getUserConfig(): any { // const cookieLangValue = abp.utils.getCookieValue('Abp.Localization.CultureName'); // const token = abp.auth.getToken(); // let requestHeaders = { // '.AspNetCore.Culture': ('c=' + cookieLangValue + '|uic=' + cookieLangValue), // 'Abp.TenantId': abp.multiTenancy.getTenantIdCookie() // }; // if (token) { // requestHeaders['Authorization'] = 'Bearer ' + token; // } // return XmlHttpRequestHelper.ajax('GET', AppConsts.remoteServiceBaseUrl + '/AbpUserConfiguration/GetAll', requestHeaders, null, (response) => { // let result = response.result; // localStorage.setItem('timeZoneId', result.timing.timeZoneInfo.iana.timeZoneId); // }); // } PrintRouteSheet() { this.localRouteIds = JSON.parse(localStorage.getItem('routeIds')); if (this.localRouteIds.length == 0) { this.notify.error(this.l('Please select atleast one route')); } else { window.open('/app/sprintship/route-sheet-print', '_blank'); } } PrintRoute() { this.localRouteIds = JSON.parse(localStorage.getItem('routeIds')); if (this.localRouteIds.length == 0) { this.notify.error(this.l('Please select atleast one route')); } else { window.open('/app/sprintship/route-print', '_blank'); } } myProfile() { abp.event.trigger('app.show.mySettingsModal'); } logOut() { this._authService.logout(); } exportRouteSchedules(): void { this.spinnerService.show(); this._controllerRouteDetailService .getRouteScheduleToExcel(parseInt(localStorage.getItem('operatingLocationId'))) .subscribe(result => { // this._fileDownloadService.downloadTempFile(result); if (result) { this.spinnerService.hide(); window.open(AppConsts.remoteServiceBaseUrl + '/File/DownloadTempFile?fileType=' + result.fileType + '&fileToken=' + result.fileToken + '&fileName=' + result.fileName, '_blank'); } }) } // data: { files: File } // test(event): void { // this.importListener(); // this.importRouteScheduleTracking.clearMessages(); // this.importRouteScheduleTracking.modal.show(); // const formData: FormData = new FormData(); // const file = data.files[0]; // formData.append('file', file, file.name); // formData.append('key','workbook'); // formData.append('loadDate', moment().tz(localStorage.getItem('timeZoneId')).format()); // // formData.append('entity','addresses','addresses'); // this._httpClient // .post(this.uploadUrl, formData) // .subscribe(response => { // if (response.success) { // this.notify.success(this.l('ImportStart')); // } else if (response.error != null) { // this.notify.error(this.l('ImportFailed')); // } // }); // } // onUploadExcelError(): void { // this.notify.error(this.l('ImportFailed')); // } getLocationLock(): void { let locId = parseInt(localStorage.getItem('operatingLocationId')); if (locId != null) { this._locationServiceProxy.getLocationForLock( locId ) .subscribe(result => { this.lockOrUnlockLocation = result.lock; this.lockOrUnlockLocationDetails = result; }) } } unlockLocation(): void { let locId = localStorage.getItem('operatingLocationId'); this.unlockModal.show(locId); } lockLocation(): void { this.lockModal.show(this.lockOrUnlockLocationDetails); } }