\r\n
\r\n {{label}}\r\n * \r\n
\r\n
\r\n","import { Component, ViewChild, Optional, Inject, Input, Output, EventEmitter, ChangeDetectionStrategy } from '@angular/core';\r\nimport { BaseControlComponent } from \"../base/base-control.component\";\r\nimport { NG_VALUE_ACCESSOR, NgModel, NG_VALIDATORS, NG_ASYNC_VALIDATORS } from '@angular/forms';\r\nimport { retry } from 'rxjs/operators';\r\nimport { CorrectYeKeService } from 'src/services/correctyeke.service';\r\n@Component({\r\n //moduleId: module.id,\r\n selector: 'sep-input',\r\n styleUrls: ['input.component.scss'],\r\n templateUrl: 'input.component.html',\r\n providers: [\r\n { provide: NG_VALUE_ACCESSOR, useExisting: InputComponent, multi: true }\r\n ],\r\n changeDetection: ChangeDetectionStrategy.Default,\r\n})\r\nexport class InputComponent extends BaseControlComponent
{\r\n isshow: boolean;\r\n show() {\r\n this.isshow = !this.isshow;\r\n }\r\n focusFunction() {\r\n this.isshow = true;\r\n document.getElementById(this.name).focus();\r\n }\r\n focusOutFunction() {\r\n if (!this.value || this.value == '') {\r\n this.isshow = false;\r\n }\r\n }\r\n // @HostBinding('class') @Input('class') classList: string = '';\r\n\r\n @Input() class: string\r\n @Input() name: string;\r\n @Input() hint: string;\r\n @Input() icon: string;\r\n @Input() autocomplete: string = \"on\";\r\n @Input() withComma: boolean = true;\r\n @Output() numberValueChange: EventEmitter = new EventEmitter();\r\n @ViewChild(NgModel) model: NgModel;\r\n @Input() inputMask: string;\r\n _value: number;\r\n @Input()\r\n set numberValue(value: any) {\r\n if (value && this.textType == 'number' && this.withComma.toString().toLowerCase() === 'true') {\r\n var parts = value.toString().split(\".\");\r\n parts[0] = parts[0].replace(/,/g, \"\").replace(/\\B(?=(\\d{3})+(?!\\d))/g, \",\");\r\n this.value = parts.join(\".\");\r\n }\r\n else\r\n this.value = value as any;\r\n }\r\n get numberValue(): any {\r\n if (this.textType == 'number' && this.withComma.toString().toLowerCase() === 'true') {\r\n return Number(this.value.replace(/,/g, \"\"));\r\n }\r\n return this.value as any;\r\n }\r\n constructor(\r\n @Optional() @Inject(NG_VALIDATORS) validators: Array,\r\n @Optional() @Inject(NG_ASYNC_VALIDATORS) asyncValidators: Array,\r\n private cyk: CorrectYeKeService\r\n ) {\r\n super(validators, asyncValidators);\r\n if (!this.autocomplete) {\r\n this.autocomplete = \"on\";\r\n }\r\n }\r\n onChange(value: any) {\r\n if (value && this.textType == 'number' && this.withComma.toString().toLowerCase() === 'true') {\r\n this.valueChange.emit(this.value.replace(/,/g, \"\"));\r\n this.numberValueChange.emit(this.numberValue)\r\n }\r\n else {\r\n this.value = CorrectYeKeService.getCorrectYeKe(this.value);\r\n this.valueChange.emit(this.value);\r\n this.numberValueChange.emit(this.numberValue)\r\n }\r\n }\r\n}\r\n","import {\r\n DateAdapter,\r\n MAT_DATE_FORMATS,\r\n MAT_DATE_LOCALE\r\n} from '@angular/material/core';\r\n\r\n// import {A11yModule} from '@angular/cdk/a11y';\r\n// import {DragDropModule} from '@angular/cdk/drag-drop';\r\n// import {PortalModule} from '@angular/cdk/portal';\r\n// import {ScrollingModule} from '@angular/cdk/scrolling';\r\n// import {CdkStepperModule} from '@angular/cdk/stepper';\r\nimport { CdkTableModule } from '@angular/cdk/table';\r\nimport { MatFormFieldModule } from '@angular/material/form-field';\r\nimport { MatAutocompleteModule } from '@angular/material/autocomplete';\r\nimport { MatBadgeModule } from '@angular/material/badge';\r\nimport { MatBottomSheetModule } from '@angular/material/bottom-sheet';\r\nimport { MatButtonModule } from '@angular/material/button';\r\nimport { MatButtonToggleModule } from '@angular/material/button-toggle';\r\nimport { MatCardModule } from '@angular/material/card';\r\nimport { MatCheckboxModule } from '@angular/material/checkbox';\r\nimport { MatChipsModule } from '@angular/material/chips';\r\nimport { MatStepperModule } from '@angular/material/stepper';\r\nimport { MatDatepickerModule } from '@angular/material/datepicker';\r\nimport { MatDialogModule } from '@angular/material/dialog';\r\nimport { MatExpansionModule } from '@angular/material/expansion';\r\nimport { MatGridListModule } from '@angular/material/grid-list';\r\nimport { MatIconModule } from '@angular/material/icon';\r\nimport { MatInputModule } from '@angular/material/input';\r\nimport { MatListModule } from '@angular/material/list';\r\nimport { MatMenuModule } from '@angular/material/menu';\r\nimport { MatNativeDateModule, MatRippleModule } from '@angular/material/core';\r\nimport { MatPaginatorModule } from '@angular/material/paginator';\r\nimport { MatProgressBarModule } from '@angular/material/progress-bar';\r\nimport { MatProgressSpinnerModule } from '@angular/material/progress-spinner';\r\nimport { MatRadioModule } from '@angular/material/radio';\r\nimport { MatSelectModule } from '@angular/material/select';\r\nimport { MatSidenavModule } from '@angular/material/sidenav';\r\nimport { MatSliderModule } from '@angular/material/slider';\r\nimport { MatSlideToggleModule } from '@angular/material/slide-toggle';\r\nimport { MatSnackBarModule } from '@angular/material/snack-bar';\r\nimport { MatSortModule } from '@angular/material/sort';\r\nimport { MatTableModule } from '@angular/material/table';\r\nimport { MatTabsModule } from '@angular/material/tabs';\r\nimport { MatToolbarModule } from '@angular/material/toolbar';\r\nimport { MatTooltipModule } from '@angular/material/tooltip';\r\nimport { MatTreeModule } from '@angular/material/tree';\r\n\r\nimport { NgModule } from '@angular/core';\r\n\r\n@NgModule({\r\n imports: [\r\n MatAutocompleteModule,\r\n MatButtonModule,\r\n MatBottomSheetModule,\r\n MatButtonToggleModule,\r\n MatCardModule,\r\n MatCheckboxModule,\r\n MatChipsModule,\r\n MatDatepickerModule,\r\n MatDialogModule,\r\n MatExpansionModule,\r\n MatFormFieldModule,\r\n MatGridListModule,\r\n MatIconModule,\r\n MatInputModule,\r\n MatListModule,\r\n MatMenuModule,\r\n MatNativeDateModule,\r\n MatPaginatorModule,\r\n MatProgressBarModule,\r\n MatProgressSpinnerModule,\r\n MatRadioModule,\r\n MatRippleModule,\r\n MatSelectModule,\r\n MatSidenavModule,\r\n MatSliderModule,\r\n MatSlideToggleModule,\r\n MatSnackBarModule,\r\n MatStepperModule,\r\n MatSortModule,\r\n MatTableModule,\r\n MatTabsModule,\r\n MatToolbarModule,\r\n MatTooltipModule,\r\n CdkTableModule,\r\n MatTreeModule,\r\n MatBadgeModule\r\n ],\r\n exports: [\r\n MatAutocompleteModule,\r\n MatButtonModule,\r\n MatBottomSheetModule,\r\n MatButtonToggleModule,\r\n MatCardModule,\r\n MatCheckboxModule,\r\n MatChipsModule,\r\n MatDatepickerModule,\r\n MatDialogModule,\r\n MatExpansionModule,\r\n MatGridListModule,\r\n MatIconModule,\r\n MatInputModule,\r\n MatListModule,\r\n MatMenuModule,\r\n MatNativeDateModule,\r\n MatPaginatorModule,\r\n MatProgressBarModule,\r\n MatProgressSpinnerModule,\r\n MatRadioModule,\r\n MatRippleModule,\r\n MatSelectModule,\r\n MatSidenavModule,\r\n MatSliderModule,\r\n MatSlideToggleModule,\r\n MatSnackBarModule,\r\n MatStepperModule,\r\n MatSortModule,\r\n MatTableModule,\r\n MatTabsModule,\r\n MatToolbarModule,\r\n MatTooltipModule,\r\n CdkTableModule,\r\n MatTreeModule,\r\n MatBadgeModule\r\n ],\r\n providers: [\r\n ]\r\n})\r\nexport class MaterialModule { }\r\n","import { NgModule, ModuleWithProviders, Injector, ErrorHandler } from '@angular/core';\r\nimport { CommonModule } from '@angular/common';\r\nimport { TranslateModule, TranslateLoader } from '@ngx-translate/core';\r\nimport {\r\n HexadecimalValueValidator,\r\n ValidationComponent,\r\n ButtonComponent,\r\n InputComponent,\r\n} from './controls';\r\nimport { FormsModule } from '@angular/forms';\r\nimport { HTTP_INTERCEPTORS, HttpClientModule } from '@angular/common/http';\r\nimport { MinDirective, MaxDirective } from './controls/base/min.max.directive';\r\nimport { MaterialModule } from './material.module';\r\nimport { PersianNumberPipe } from 'src/services/persian-number.pipe';\r\nimport { CorrectYeKeService } from 'src/services/correctyeke.service';\r\n\r\nexport let AppInjector: Injector;\r\nconst components = [\r\n HexadecimalValueValidator,\r\n ValidationComponent,\r\n MinDirective,\r\n MaxDirective,\r\n ButtonComponent,\r\n InputComponent,\r\n]\r\nconst providers = [\r\n CorrectYeKeService\r\n\r\n]\r\n@NgModule({\r\n declarations: [...components],\r\n imports: [\r\n CommonModule,\r\n FormsModule,\r\n HttpClientModule,\r\n MaterialModule,\r\n TranslateModule\r\n ],\r\n exports: [\r\n CommonModule,\r\n FormsModule,\r\n ...components,\r\n MaterialModule,\r\n TranslateModule,\r\n ],\r\n providers: [\r\n ...providers,\r\n ]\r\n})\r\nexport class ControlsModule {\r\n constructor(private injector: Injector) {\r\n AppInjector = this.injector;\r\n }\r\n static forRoot(): ModuleWithProviders {\r\n return {\r\n ngModule: ControlsModule,\r\n providers: [...providers]\r\n };\r\n }\r\n}\r\n","// This file can be replaced during build by using the `fileReplacements` array.\r\n// `ng build --prod` replaces `environment.ts` with `environment.prod.ts`.\r\n// The list of file replacements can be found in `angular.json`.\r\n\r\nexport const environment = {\r\n production: false,\r\n baseUrl: null, // Change this to the address of your backend API if different from frontend address\r\n loginUrl: '/Login'\r\n};\r\n\r\n/*\r\n * For easier debugging in development mode, you can import the following file\r\n * to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`.\r\n *\r\n * This import should be commented out in production mode because it will have a negative impact\r\n * on performance if an error is thrown.\r\n */\r\n// import 'zone.js/plugins/zone-error'; // Included with Angular CLI.\r\n","import 'hammerjs';\r\nimport { enableProdMode } from '@angular/core';\r\nimport { platformBrowserDynamic } from '@angular/platform-browser-dynamic';\r\n\r\nimport { AppModule } from './app/app.module';\r\nimport { environment } from './environments/environment';\r\n\r\nif (environment.production) {\r\n enableProdMode();\r\n}\r\n\r\nplatformBrowserDynamic().bootstrapModule(AppModule)\r\n .catch(err => console.error(err));\r\n","export enum SourceProgramEnum {\r\n Tablet = 2,\r\n Kiosk = 4,\r\n DigitalMeuOffline = 5,\r\n DigitalMeuOnline = 6\r\n}\r\n","export enum StateEnum {\r\n Add = 0,\r\n Merge = 1,\r\n DeletedMerge = 2,\r\n Edited = 3,\r\n Deleted = 4,\r\n Save = 5,\r\n SaveMerge = 6,\r\n EditWithoutChange = 7, // 2ستونی\r\n EditWithChangeIncrease = 8, // 3ستونی\r\n DeletedForDuplicateFactor = 9,\r\n DeletedForTabletMerge = 10\r\n}\r\n\r\nexport enum ActionStateEnum {\r\n Save = 0,\r\n Merge = 1,\r\n Deleted = 2,\r\n Edited = 3,\r\n}\r\n","import { FactorDetailsModel } from './factordetails.model';\r\n\r\nexport class FactorModel {\r\n num: number;\r\n id: number;\r\n price?: number;\r\n status: number;\r\n mergeHeaderId?: number;\r\n discountPercent?: number;\r\n discountAmount?: number;\r\n serviceAmount?: number;\r\n servicePercent?: number;\r\n taxAmount?: number;\r\n taxPercent?: number;\r\n roundedAmount?: number;\r\n phoneNumber: string;\r\n fireLevel?: number;\r\n printAsh?: number;\r\n branchCode: number;\r\n description: string;\r\n transactionNo: string;\r\n errorCodePay: string;\r\n errorMessagePay: string;\r\n merchantIDPay: string;\r\n terminalIDPay: string;\r\n paymentTypeCode: number;\r\n flagPda?: number;\r\n tableId: string;\r\n tableName: string;\r\n customerName: string;\r\n flag: string;\r\n pard: number;\r\n waiterName: string;\r\n guestQty?: number;\r\n waiterId?: number;\r\n time: string;\r\n sourceFlag: string;\r\n pdaPrintFlag?: number;\r\n hasCashPrint?: number;\r\n tas?: number;\r\n creationTime: string;\r\n checked: boolean;\r\n redirectUrl: string;\r\n clubCardNo: number;\r\n usedCredit: number;\r\n creditUsedPersent: number;\r\n creditUsedRial: number;\r\n creditPersent: number;\r\n credit: number;\r\n creditPrice?: number;\r\n factorDetail?: FactorDetailsModel[];\r\n digitalMenuHeaderId?: number;\r\n FarsiDate: string;\r\n isOrderPrint?: number;\r\n constructor() {\r\n this.num = 0;\r\n this.FarsiDate = '';\r\n this.id = 0;\r\n this.price = 0;\r\n this.status = 0;\r\n this.clubCardNo = null;\r\n this.creationTime = \"\";\r\n this.mergeHeaderId = 0;\r\n this.discountPercent = 0;\r\n this.discountAmount = 0;\r\n this.serviceAmount = 0;\r\n this.servicePercent = 0;\r\n this.taxAmount = 0;\r\n this.taxPercent = 0;\r\n this.roundedAmount = 0;\r\n this.phoneNumber = '';\r\n this.branchCode = 0;\r\n this.description = '';\r\n this.transactionNo = '';\r\n this.errorCodePay = '';\r\n this.errorMessagePay = '';\r\n this.merchantIDPay = '';\r\n this.terminalIDPay = '';\r\n this.paymentTypeCode = 0;\r\n this.flagPda = 0;\r\n this.tableId = '';\r\n this.tableName = '';\r\n this.customerName = '';\r\n this.flag = '';\r\n this.waiterName = '';\r\n this.guestQty = null;\r\n this.waiterId = 0;\r\n this.time = '';\r\n this.sourceFlag = '';\r\n this.pdaPrintFlag = 0;\r\n this.hasCashPrint = 0;\r\n this.tas = 0;\r\n this.factorDetail = [];\r\n this.checked = false;\r\n this.creditPrice = null;\r\n this.digitalMenuHeaderId = null;\r\n }\r\n}\r\n\r\nexport class InvoiceModel {\r\n // شماره فاکتور \r\n num: number;\r\n // مبلغ قابل پرداخت\r\n price?: number;\r\n //تخفیف\r\n discountAmount?: number;\r\n serviceAmount?: number;\r\n taxAmount?: number;\r\n roundedAmount?: number;\r\n phoneNumber: string;\r\n description: string;\r\n //transactionNo: string;\r\n tableName: string;\r\n customerName: string;\r\n waiterName: string;\r\n // تعداد نفرات\r\n guestQty?: number;\r\n time: string;\r\n creationTime: string;\r\n // اعتبار باشگاه\r\n usedCredit: number;\r\n creditPrice?: number;\r\n sumQty: number;\r\n sumPrice: number;\r\n restaurantName: string;\r\n farsiDate: string;\r\n invoiceDetail?: InvoiceDetailsModel[];\r\n constructor() {\r\n this.num = 0;\r\n this.sumQty = 0;\r\n this.sumPrice = 0;\r\n this.price = 0;\r\n this.discountAmount = 0;\r\n this.serviceAmount = 0;\r\n this.taxAmount = 0;\r\n this.roundedAmount = 0;\r\n this.phoneNumber = '';\r\n this.description = '';\r\n //this.transactionNo = '';\r\n this.tableName = '';\r\n this.customerName = '';\r\n this.waiterName = '';\r\n this.guestQty = 0;\r\n this.creationTime = '';\r\n //this.time = '';\r\n this.invoiceDetail = [];\r\n this.creditPrice = 0;\r\n this.farsiDate = '';\r\n this.usedCredit = 0;\r\n\r\n }\r\n}\r\nexport class InvoiceDetailsModel {\r\n //radif: number;\r\n // نام کالا\r\n name: string;\r\n //unit: string;\r\n // تعداد\r\n qty?: number;\r\n unitPrice: number;\r\n // توضیحات\r\n toz: string;\r\n sumUnitPrice: number;\r\n constructor() {\r\n //this.radif = 0;\r\n this.sumUnitPrice = 0;\r\n this.name = '';\r\n //this.unit = '';\r\n this.qty = 0;\r\n this.unitPrice = 0;\r\n this.toz = '';\r\n }\r\n}\r\nexport class PrintInvoiceModel {\r\n num: number;\r\n pr: number;\r\n branchCode: number;\r\n printTime: string;\r\n}\r\n","export class ShareModel {\r\n language: string;\r\n isrtl: boolean;\r\n}\r\n","export class SocialMedia {\r\n id?: number;\r\n branchCode?: number;\r\n instagram?: string;\r\n telegram?: string;\r\n twitter?: string;\r\n facebook?: string;\r\n whatsApp?: string;\r\n website?: string;\r\n\r\n constructor() {\r\n this.instagram=\"\";\r\n this.telegram=\"\";\r\n this.twitter=\"\";\r\n this.facebook=\"\";\r\n this.whatsApp=\"\";\r\n this.website=\"\";\r\n\r\n }\r\n}\r\n","export class TableModel {\r\n tableId: number;\r\n tableName: string;\r\n nameGroup: string;\r\n tableCategoryId: number;\r\n num: number;\r\n time: string;\r\n waiterId?: number;\r\n waiterName: string;\r\n customerName: string;\r\n phoneNumber: string;\r\n guestQty: number;\r\n branchCode: number;\r\n isTas: number;\r\n fireLevel: number;\r\n printAsh: number;\r\n hasCashPrint: number;\r\n isOrderPrint?: number;\r\n}\r\n","export enum ThemeEnum {\r\n Dark = 0,\r\n Light = 1,\r\n Blue = 2,\r\n Orange = 3,\r\n}\r\n//export enum ThemeColor {\r\n// Dark = \"dark\",\r\n// Light = \"light\",\r\n// Blue = \"blue\",\r\n// Orange = \"orange\"\r\n//}\r\n","import { Injectable } from '@angular/core';\r\nimport { GoodsModel } from 'src/models/goods.model';\r\nimport { GoodsGroupModel } from 'src/models/goodsgroup.model';\r\nimport { SettingModel } from 'src/models/setting.model';\r\nimport { ShareModel } from 'src/models/share.model';\r\nimport { TableModel } from 'src/models/table.model';\r\nimport { UserModel } from 'src/models/user.model';\r\nimport { FactorModel } from 'src/models/factor.model';\r\nimport { LocalStoreManager } from '../services/local-store-manager.service';\r\nimport { RestApiService } from 'src/services/rest-api.service';\r\nimport { Observable, of } from 'rxjs';\r\nimport { catchError, map } from 'rxjs/operators';\r\nimport { StateEnum } from '../models/enum/state.enum';\r\nimport { SourceProgramEnum } from '../models/enum/sourceprogram.enum';\r\nimport { FormBuilder} from '@angular/forms';\r\nimport { ThemeEnum } from 'src/models/enum/theme.enum';\r\nimport { ActivatedRoute, Router, RouterLinkActive, Routes } from '@angular/router';\r\n\r\n@Injectable({\r\n providedIn: 'root'\r\n})\r\nexport class ShareDataService {\r\n public goodsGroup: GoodsGroupModel[];\r\n public order: GoodsModel[];\r\n public setting: SettingModel;\r\n public sharemodel: ShareModel;\r\n public filterTableList: TableModel[];\r\n public tableList: TableModel[];\r\n public orderTable: TableModel;\r\n public loginuser: UserModel;\r\n public openFactor: FactorModel;\r\n public waiterFactor: FactorModel[];\r\n public waiterOrder: GoodsModel[];\r\n public imageUrls: any[];\r\n public lastUrl: string;\r\n public validations_form: any;\r\n public formBuilder: FormBuilder;\r\n public digitalmenuFactorCount: Number;\r\n public selectedTableGroupIndex: number;\r\n public digitalmenuTableId: number;\r\n public hasSwitchTabIndex: boolean;\r\n public isClub: boolean;\r\n public tableId: string;\r\n public BranchCode: number;\r\n public currentTheme: string;\r\n public selectedGroupIndex?: number;\r\n public selectedtab: number = 0;\r\n \r\n navLinks = [];\r\n \r\n constructor(\r\n public api: RestApiService,\r\n private cache: LocalStoreManager,\r\n private route: ActivatedRoute,\r\n public router: Router,\r\n ) {\r\n }\r\n ngOnInit() {\r\n this.navLinks = (\r\n this.route.routeConfig && this.route.routeConfig.children ?\r\n this.buildNavItems(this.route.routeConfig.children) :\r\n []\r\n );\r\n }\r\n\r\n buildNavItems(routes: Routes) {\r\n return (routes)\r\n .filter(route => route.data)\r\n .map(({ path = '', data }) => ({\r\n path: path,\r\n label: data.label,\r\n icon: data.icon\r\n }));\r\n }\r\n\r\n isLinkActive(rla: RouterLinkActive): boolean {\r\n const routerLink = rla.linksWithHrefs.first;\r\n \r\n return this.router.isActive(routerLink.urlTree, false);\r\n }\r\n \r\n public goodsGroupList(): Observable {\r\n return this.api.getEntity('GoodsGroupList').pipe(\r\n map((res: GoodsGroupModel[]) => {\r\n this.goodsGroup = res;\r\n return this.goodsGroup;\r\n }),\r\n catchError((err) => {\r\n return of(null);\r\n }));\r\n } \r\n public waiterorderGoodsGroupList(): Observable {\r\n return this.api.getEntity('WaiterorderGoodsGroupList').pipe(\r\n map((res: GoodsGroupModel[]) => {\r\n this.goodsGroup = res;\r\n return this.goodsGroup;\r\n }),\r\n catchError((err) => {\r\n return of(null);\r\n }));\r\n }\r\n public clearData() {\r\n this.goodsGroup = [];\r\n this.order = [];\r\n this.openFactor = null;\r\n this.waiterFactor = [];\r\n this.waiterOrder = [];\r\n }\r\n // public getSetting(): Observable {\r\n // if ((this.setting)) {\r\n // return;\r\n // }\r\n // return this.api.getFilterEntity(\"Setting\", 0).pipe(\r\n // map((res: SettingModel) => {\r\n // this.setting = res;\r\n // return this.setting;\r\n // }),\r\n // catchError((err) => {\r\n // return of(null);\r\n // }));\r\n // }\r\n New_waiterFactor() {\r\n this.waiterFactor = null;\r\n this.waiterFactor = [];\r\n const factor = new FactorModel();\r\n this.waiterFactor.push(factor);\r\n this.waiterFactor[0].status = StateEnum.Save;\r\n this.waiterFactor[0].sourceFlag = SourceProgramEnum.Tablet.toString();\r\n this.waiterFactor[0].waiterId = this.loginuser.code;\r\n this.waiterFactor[0].waiterName = this.loginuser.name;\r\n this.formBuilder = new FormBuilder();\r\n }\r\n public getSetting(): Observable {\r\n this.cache.deleteData('setting');\r\n if ((this.setting)) {\r\n return null;\r\n }\r\n this.api.getFilterEntity('Setting', 0).subscribe(res => {\r\n this.setting = res;\r\n switch (this.setting.digitalMenuThem) {\r\n case ThemeEnum.Dark:\r\n this.setTheme('dark');\r\n break;\r\n case ThemeEnum.Light:\r\n this.setTheme('light');\r\n break;\r\n case ThemeEnum.Blue:\r\n this.setTheme('blue');\r\n break;\r\n case ThemeEnum.Orange:\r\n this.setTheme('orange');\r\n break;\r\n }\r\n this.cache.savePermanentData(this.setting, 'setting');\r\n });\r\n }\r\n getDigitalMenuCount() {\r\n this.api.getEntity('GetDigitalMenuFactorCount').subscribe((res: Number) => {\r\n this.digitalmenuFactorCount = res;\r\n });\r\n }\r\n setTheme(theme: string) {\r\n if (!theme) {\r\n theme = 'custom';\r\n this.cache.savePermanentData(theme, 'Theme');\r\n document.documentElement.classList.add(theme);\r\n } else {\r\n let currentTheme: string = this.cache.getData('Theme');\r\n if (currentTheme) {\r\n document.documentElement.classList.remove(currentTheme);\r\n }\r\n this.cache.savePermanentData(theme, 'Theme');\r\n document.documentElement.classList.add(theme);\r\n }\r\n this.currentTheme = theme;\r\n }\r\n\r\n ActivateTab(key: any) {\r\n switch (key) {\r\n case 0: // index of the tab\r\n this.router.navigate(['/portal/logo']);\r\n break;\r\n case 1:\r\n this.router.navigate(['/portal/goods']);\r\n break;\r\n case 2:\r\n this.router.navigate(['/portal/slider']);\r\n break;\r\n case 3:\r\n this.router.navigate(['/portal/social']);\r\n break;\r\n default:\r\n this.router.navigate(['/portal']);\r\n break;\r\n }\r\n }\r\n\r\n public reloadCurrentRoute() {\r\n let currentUrl = this.router.url;\r\n this.router.navigateByUrl('/', {skipLocationChange: true}).then(() => {\r\n this.router.navigate([currentUrl]);\r\n });\r\n }\r\n}\r\n","import { Injectable } from '@angular/core';\r\nimport { timer } from 'rxjs';\r\nimport { Subject, Subscription } from 'rxjs-compat';\r\nimport { takeUntil } from 'rxjs/operators';\r\nimport { UserModel } from 'src/models/user.model';\r\nimport { ShareDataService } from '../providers/sharedata.service';\r\nimport { CorrectYeKeService } from './correctyeke.service';\r\nimport { RestApiService } from './rest-api.service';\r\n\r\n@Injectable({\r\n providedIn: 'root'\r\n})\r\nexport class AuthService {\r\n private redirectUrl = '/';\r\n private loginUrl = '/login';\r\n private ordermanagementUrl = '/ordermanagement';\r\n public isloggedIn = false;\r\n public loggedInUser: UserModel;\r\n public users: UserModel[];\r\n public destroy$ = new Subject();\r\n public timerSubscription: Subscription;\r\n constructor(private api: RestApiService, private share: ShareDataService) {\r\n\r\n }\r\n isUserAuthenticated(username: string, password: string): boolean {\r\n let user: any;\r\n user = this.users.filter(\r\n u => CorrectYeKeService.getCorrectYeKe(u.name) === CorrectYeKeService.getCorrectYeKe(username) &&\r\n CorrectYeKeService.getCorrectYeKe(u.password) === CorrectYeKeService.getCorrectYeKe(password)\r\n );\r\n if (user.length !== 0) {\r\n this.isloggedIn = true;\r\n this.loggedInUser = user[0];\r\n } else {\r\n this.isloggedIn = false;\r\n }\r\n return this.isloggedIn;\r\n }\r\n isUserLoggedIn(): boolean {\r\n return this.isloggedIn;\r\n }\r\n getRedirectUrl(): string {\r\n return this.redirectUrl;\r\n }\r\n setRedirectUrl(url: string): void {\r\n this.redirectUrl = url;\r\n }\r\n getLoginUrl(): string {\r\n return this.loginUrl;\r\n }\r\n getLoggedInUser(): UserModel {\r\n return this.loggedInUser;\r\n }\r\n getOrdermanagementUrl(): string {\r\n return this.ordermanagementUrl;\r\n }\r\n logoutUser(): void {\r\n this.isloggedIn = false;\r\n }\r\n getDiffDays(sDate, eDate) {\r\n var startDate = new Date(sDate);\r\n var endDate = new Date(eDate);\r\n var Time = endDate.getTime() - startDate.getTime();\r\n return Time / (1000 * 3600 * 24);\r\n }\r\n onUserActivity() {\r\n this.destroy$.next();\r\n this.destroy$.complete();\r\n if (this.timerSubscription) {\r\n this.timerSubscription.unsubscribe();\r\n }\r\n this.startTimer();\r\n }\r\n startTimer() {\r\n this.timerSubscription = timer(20 * 60 * 1000)\r\n .pipe(\r\n takeUntil(this.destroy$)\r\n )\r\n .subscribe(() => {\r\n window.location.reload();\r\n });\r\n }\r\n}\r\n","import { Injectable } from '@angular/core';\r\n@Injectable()\r\nexport class CorrectYeKeService {\r\n public static getCorrectYeKe(text: string): string {\r\n if (!(text))\r\n return text;\r\n var s = \"\";\r\n for (var i = 0; i <= text.length; i++) {\r\n if (text[i]) {\r\n switch (text[i]) {\r\n case String.fromCharCode(1705):\r\n s = s + String.fromCharCode(1603);\r\n break;\r\n case String.fromCharCode(1609):\r\n case String.fromCharCode(1740):\r\n s = s + String.fromCharCode(1610);\r\n break;\r\n default:\r\n s += text[i];\r\n break;\r\n }\r\n }\r\n }\r\n if (!(s))\r\n return text;\r\n return s;\r\n }\r\n}\r\n","// ===========================================\r\n// Email: info@ebenmonney.com\r\n// www.ebenmonney.com/templates\r\n// ===========================================\r\n\r\nimport { Injectable } from '@angular/core';\r\nimport { HttpResponseBase, HttpResponse, HttpErrorResponse } from '@angular/common/http';\r\n\r\n@Injectable()\r\nexport class Utilities {\r\n public static readonly captionAndMessageSeparator = ':';\r\n public static readonly noNetworkMessageCaption = 'No Network';\r\n public static readonly noNetworkMessageDetail = 'The server cannot be reached';\r\n public static readonly accessDeniedMessageCaption = 'Access Denied!';\r\n public static readonly accessDeniedMessageDetail = '';\r\n public static readonly notFoundMessageCaption = 'Not Found';\r\n public static readonly notFoundMessageDetail = 'The target resource cannot be found';\r\n\r\n public static cookies =\r\n {\r\n getItem: (sKey) => {\r\n return decodeURIComponent(document.cookie.replace(new RegExp('(?:(?:^|.*;)\\\\s*' + encodeURIComponent(sKey).replace(/[\\-\\.\\+\\*]/g, '\\\\$&') + '\\\\s*\\\\=\\\\s*([^;]*).*$)|^.*$'), '$1')) || null;\r\n },\r\n setItem: (sKey, sValue, vEnd, sPath, sDomain, bSecure) => {\r\n if (!sKey || /^(?:expires|max\\-age|path|domain|secure)$/i.test(sKey)) {\r\n return false;\r\n }\r\n\r\n let sExpires = '';\r\n\r\n if (vEnd) {\r\n switch (vEnd.constructor) {\r\n case Number:\r\n sExpires = vEnd === Infinity ? '; expires=Fri, 31 Dec 9999 23:59:59 GMT' : '; max-age=' + vEnd;\r\n break;\r\n case String:\r\n sExpires = '; expires=' + vEnd;\r\n break;\r\n case Date:\r\n sExpires = '; expires=' + vEnd.toUTCString();\r\n break;\r\n }\r\n }\r\n\r\n document.cookie = encodeURIComponent(sKey) + '=' + encodeURIComponent(sValue) + sExpires + (sDomain ? '; domain=' + sDomain : '') + (sPath ? '; path=' + sPath : '') + (bSecure ? '; secure' : '');\r\n return true;\r\n },\r\n removeItem: (sKey, sPath, sDomain) => {\r\n if (!sKey) {\r\n return false;\r\n }\r\n document.cookie = encodeURIComponent(sKey) + '=; expires=Thu, 01 Jan 1970 00:00:00 GMT' + (sDomain ? '; domain=' + sDomain : '') + (sPath ? '; path=' + sPath : '');\r\n return true;\r\n },\r\n hasItem: (sKey) => {\r\n return (new RegExp('(?:^|;\\\\s*)' + encodeURIComponent(sKey).replace(/[\\-\\.\\+\\*]/g, '\\\\$&') + '\\\\s*\\\\=')).test(document.cookie);\r\n },\r\n keys: () => {\r\n const aKeys = document.cookie.replace(/((?:^|\\s*;)[^\\=]+)(?=;|$)|^\\s*|\\s*(?:\\=[^;]*)?(?:\\1|$)/g, '').split(/\\s*(?:\\=[^;]*)?;\\s*/);\r\n for (let nIdx = 0; nIdx < aKeys.length; nIdx++) { aKeys[nIdx] = decodeURIComponent(aKeys[nIdx]); }\r\n return aKeys;\r\n }\r\n };\r\n\r\n public static getHttpResponseMessages(data: HttpResponseBase | any): string[] {\r\n const responses: string[] = [];\r\n\r\n if (data instanceof HttpResponseBase) {\r\n if (this.checkNoNetwork(data)) {\r\n responses.push(`${this.noNetworkMessageCaption}${this.captionAndMessageSeparator} ${this.noNetworkMessageDetail}`);\r\n } else {\r\n const responseObject = this.getResponseBody(data);\r\n\r\n if (responseObject && (typeof responseObject === 'object' || responseObject instanceof Object)) {\r\n for (const key in responseObject) {\r\n if (key) {\r\n responses.push(`${key}${this.captionAndMessageSeparator} ${responseObject[key]}`);\r\n } else if (responseObject[key]) {\r\n responses.push(responseObject[key].toString());\r\n }\r\n }\r\n }\r\n }\r\n\r\n if (!responses.length) {\r\n if ((data as any).body) {\r\n responses.push(`body: ${(data as any).body}`);\r\n }\r\n\r\n if ((data as any).error) {\r\n responses.push(`error: ${(data as any).error}`);\r\n }\r\n }\r\n }\r\n\r\n if (!responses.length) {\r\n if (this.getResponseBody(data)) {\r\n responses.push(this.getResponseBody(data).toString());\r\n } else {\r\n responses.push(data.toString());\r\n }\r\n }\r\n\r\n if (this.checkAccessDenied(data)) {\r\n responses.splice(0, 0, `${this.accessDeniedMessageCaption}${this.captionAndMessageSeparator} ${this.accessDeniedMessageDetail}`);\r\n }\r\n\r\n if (this.checkNotFound(data)) {\r\n let message = `${this.notFoundMessageCaption}${this.captionAndMessageSeparator} ${this.notFoundMessageDetail}`;\r\n if (data.url) {\r\n message += `. ${data.url}`;\r\n }\r\n\r\n responses.splice(0, 0, message);\r\n }\r\n\r\n return responses;\r\n }\r\n\r\n public static getHttpResponseMessage(data: HttpResponseBase | any): string {\r\n const httpMessage =\r\n Utilities.findHttpResponseMessage(Utilities.noNetworkMessageCaption, data) ||\r\n Utilities.findHttpResponseMessage(Utilities.notFoundMessageCaption, data) ||\r\n Utilities.findHttpResponseMessage('error_description', data) ||\r\n Utilities.findHttpResponseMessage('error', data) ||\r\n Utilities.getHttpResponseMessages(data).join();\r\n\r\n return httpMessage;\r\n }\r\n\r\n public static findHttpResponseMessage(messageToFind: string, data: HttpResponse | any, seachInCaptionOnly = true, includeCaptionInResult = false): string {\r\n const searchString = messageToFind.toLowerCase();\r\n const httpMessages = this.getHttpResponseMessages(data);\r\n\r\n for (const message of httpMessages) {\r\n const fullMessage = Utilities.splitInTwo(message, this.captionAndMessageSeparator);\r\n\r\n if (fullMessage.firstPart && fullMessage.firstPart.toLowerCase().indexOf(searchString) !== -1) {\r\n return includeCaptionInResult ? message : fullMessage.secondPart || fullMessage.firstPart;\r\n }\r\n }\r\n\r\n if (!seachInCaptionOnly) {\r\n for (const message of httpMessages) {\r\n if (message.toLowerCase().indexOf(searchString) !== -1) {\r\n if (includeCaptionInResult) {\r\n return message;\r\n } else {\r\n const fullMessage = Utilities.splitInTwo(message, this.captionAndMessageSeparator);\r\n return fullMessage.secondPart || fullMessage.firstPart;\r\n }\r\n }\r\n }\r\n }\r\n\r\n return null;\r\n }\r\n\r\n public static getResponseBody(response: HttpResponseBase) {\r\n if (response instanceof HttpResponse) {\r\n return response.body;\r\n }\r\n\r\n if (response instanceof HttpErrorResponse) {\r\n return response.error || response.message || response.statusText;\r\n }\r\n }\r\n\r\n public static checkNoNetwork(response: HttpResponseBase) {\r\n if (response instanceof HttpResponseBase) {\r\n return response.status === 0;\r\n }\r\n\r\n return false;\r\n }\r\n\r\n public static checkAccessDenied(response: HttpResponseBase) {\r\n if (response instanceof HttpResponseBase) {\r\n return response.status === 403;\r\n }\r\n\r\n return false;\r\n }\r\n\r\n public static checkNotFound(response: HttpResponseBase) {\r\n if (response instanceof HttpResponseBase) {\r\n return response.status === 404;\r\n }\r\n\r\n return false;\r\n }\r\n\r\n public static checkIsLocalHost(url: string, base?: string) {\r\n if (url) {\r\n const location = new URL(url, base);\r\n return location.hostname === 'localhost' || location.hostname === '127.0.0.1';\r\n }\r\n\r\n return false;\r\n }\r\n\r\n public static getQueryParamsFromString(paramString: string) {\r\n if (!paramString) {\r\n return null;\r\n }\r\n\r\n const params: { [key: string]: string } = {};\r\n\r\n for (const param of paramString.split('&')) {\r\n const keyValue = Utilities.splitInTwo(param, '=');\r\n params[keyValue.firstPart] = keyValue.secondPart;\r\n }\r\n\r\n return params;\r\n }\r\n\r\n public static splitInTwo(text: string, separator: string): { firstPart: string, secondPart: string } {\r\n const separatorIndex = text.indexOf(separator);\r\n\r\n if (separatorIndex === -1) {\r\n return { firstPart: text, secondPart: null };\r\n }\r\n\r\n const part1 = text.substr(0, separatorIndex).trim();\r\n const part2 = text.substr(separatorIndex + 1).trim();\r\n\r\n return { firstPart: part1, secondPart: part2 };\r\n }\r\n\r\n public static safeStringify(object) {\r\n let result: string;\r\n\r\n try {\r\n result = JSON.stringify(object);\r\n return result;\r\n } catch (error) {\r\n }\r\n\r\n const simpleObject = {};\r\n\r\n for (const prop in object) {\r\n if (!object.hasOwnProperty(prop)) {\r\n continue;\r\n }\r\n if (typeof (object[prop]) === 'object') {\r\n continue;\r\n }\r\n if (typeof (object[prop]) === 'function') {\r\n continue;\r\n }\r\n simpleObject[prop] = object[prop];\r\n }\r\n\r\n result = '[***Sanitized Object***]: ' + JSON.stringify(simpleObject);\r\n\r\n return result;\r\n }\r\n\r\n public static JsonTryParse(value: string) {\r\n try {\r\n return JSON.parse(value);\r\n } catch (e) {\r\n if (value === 'undefined') {\r\n return void 0;\r\n }\r\n return value;\r\n }\r\n }\r\n\r\n public static TestIsObjectEmpty(obj: any) {\r\n for (const prop in obj) {\r\n if (obj.hasOwnProperty(prop)) {\r\n return false;\r\n }\r\n }\r\n\r\n return true;\r\n }\r\n\r\n public static TestIsUndefined(value: any) {\r\n return typeof value === 'undefined';\r\n // return value ===undefined;\r\n }\r\n\r\n public static TestIsString(value: any) {\r\n return typeof value === 'string' || value instanceof String;\r\n }\r\n\r\n public static capitalizeFirstLetter(text: string) {\r\n if (text) {\r\n return text.charAt(0).toUpperCase() + text.slice(1);\r\n } else {\r\n return text;\r\n }\r\n }\r\n\r\n public static toTitleCase(text: string) {\r\n return text.replace(/\\w\\S*/g, (subString) => {\r\n return subString.charAt(0).toUpperCase() + subString.substr(1).toLowerCase();\r\n });\r\n }\r\n\r\n public static toLowerCase(items: string);\r\n public static toLowerCase(items: string[]);\r\n public static toLowerCase(items: any): string | string[] {\r\n if (items instanceof Array) {\r\n const loweredRoles: string[] = [];\r\n\r\n for (let i = 0; i < items.length; i++) {\r\n loweredRoles[i] = items[i].toLowerCase();\r\n }\r\n\r\n return loweredRoles;\r\n } else if (typeof items === 'string' || items instanceof String) {\r\n return items.toLowerCase();\r\n }\r\n }\r\n\r\n public static uniqueId() {\r\n return this.randomNumber(1000000, 9000000).toString();\r\n }\r\n\r\n public static randomNumber(min: number, max: number) {\r\n return Math.floor(Math.random() * (max - min + 1) + min);\r\n }\r\n\r\n public static baseUrl() {\r\n let base = '';\r\n\r\n if (window.location.origin) {\r\n base = window.location.origin;\r\n } else {\r\n base = window.location.protocol + '//' + window.location.hostname + (window.location.port ? ':' + window.location.port : '');\r\n }\r\n\r\n return base.replace(/\\/$/, '');\r\n }\r\n\r\n public static printDateOnly(date: Date) {\r\n date = new Date(date);\r\n\r\n const dayNames = new Array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');\r\n const monthNames = new Array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');\r\n\r\n const dayOfWeek = date.getDay();\r\n const dayOfMonth = date.getDate();\r\n let sup = '';\r\n const month = date.getMonth();\r\n const year = date.getFullYear();\r\n\r\n if (dayOfMonth === 1 || dayOfMonth === 21 || dayOfMonth === 31) {\r\n sup = 'st';\r\n } else if (dayOfMonth === 2 || dayOfMonth === 22) {\r\n sup = 'nd';\r\n } else if (dayOfMonth === 3 || dayOfMonth === 23) {\r\n sup = 'rd';\r\n } else {\r\n sup = 'th';\r\n }\r\n\r\n const dateString = dayNames[dayOfWeek] + ', ' + dayOfMonth + sup + ' ' + monthNames[month] + ' ' + year;\r\n\r\n return dateString;\r\n }\r\n\r\n public static printTimeOnly(date: Date) {\r\n date = new Date(date);\r\n\r\n let period = '';\r\n let minute = date.getMinutes().toString();\r\n let hour = date.getHours();\r\n\r\n period = hour < 12 ? 'AM' : 'PM';\r\n\r\n if (hour === 0) {\r\n hour = 12;\r\n }\r\n if (hour > 12) {\r\n hour = hour - 12;\r\n }\r\n\r\n if (minute.length === 1) {\r\n minute = '0' + minute;\r\n }\r\n\r\n const timeString = hour + ':' + minute + ' ' + period;\r\n\r\n return timeString;\r\n }\r\n\r\n public static printDate(date: Date, separator = 'at') {\r\n return `${Utilities.printDateOnly(date)} ${separator} ${Utilities.printTimeOnly(date)}`;\r\n }\r\n\r\n public static printFriendlyDate(date: Date, separator = '-') {\r\n const today = new Date(); today.setHours(0, 0, 0, 0);\r\n const yesterday = new Date(today); yesterday.setDate(yesterday.getDate() - 1);\r\n const test = new Date(date.getFullYear(), date.getMonth(), date.getDate());\r\n\r\n if (test.toDateString() === today.toDateString()) {\r\n return `Today ${separator} ${Utilities.printTimeOnly(date)}`;\r\n }\r\n if (test.toDateString() === yesterday.toDateString()) {\r\n return `Yesterday ${separator} ${Utilities.printTimeOnly(date)}`;\r\n } else {\r\n return Utilities.printDate(date, separator);\r\n }\r\n }\r\n\r\n public static printShortDate(date: Date, separator = '/', dateTimeSeparator = '-') {\r\n let day = date.getDate().toString();\r\n let month = (date.getMonth() + 1).toString();\r\n const year = date.getFullYear();\r\n\r\n if (day.length === 1) {\r\n day = '0' + day;\r\n }\r\n\r\n if (month.length === 1) {\r\n month = '0' + month;\r\n }\r\n\r\n return `${month}${separator}${day}${separator}${year} ${dateTimeSeparator} ${Utilities.printTimeOnly(date)}`;\r\n }\r\n\r\n public static parseDate(date) {\r\n if (date) {\r\n if (date instanceof Date) {\r\n return date;\r\n }\r\n\r\n if (typeof date === 'string' || date instanceof String) {\r\n if (date.search(/[a-su-z+]/i) === -1) {\r\n date = date + 'Z';\r\n }\r\n\r\n return new Date(date);\r\n }\r\n\r\n if (typeof date === 'number' || date instanceof Number) {\r\n return new Date(date as any);\r\n }\r\n }\r\n }\r\n\r\n public static printDuration(start: Date, end: Date) {\r\n start = new Date(start);\r\n end = new Date(end);\r\n\r\n // get total seconds between the times\r\n let delta = Math.abs(start.valueOf() - end.valueOf()) / 1000;\r\n\r\n // calculate (and subtract) whole days\r\n const days = Math.floor(delta / 86400);\r\n delta -= days * 86400;\r\n\r\n // calculate (and subtract) whole hours\r\n const hours = Math.floor(delta / 3600) % 24;\r\n delta -= hours * 3600;\r\n\r\n // calculate (and subtract) whole minutes\r\n const minutes = Math.floor(delta / 60) % 60;\r\n delta -= minutes * 60;\r\n\r\n // what's left is seconds\r\n const seconds = delta % 60; // in theory the modulus is not required\r\n\r\n let printedDays = '';\r\n\r\n if (days) {\r\n printedDays = `${days} days`;\r\n }\r\n\r\n if (hours) {\r\n printedDays += printedDays ? `, ${hours} hours` : `${hours} hours`;\r\n }\r\n\r\n if (minutes) {\r\n printedDays += printedDays ? `, ${minutes} minutes` : `${minutes} minutes`;\r\n }\r\n\r\n if (seconds) {\r\n printedDays += printedDays ? ` and ${seconds} seconds` : `${seconds} seconds`;\r\n }\r\n\r\n if (!printedDays) {\r\n printedDays = '0';\r\n }\r\n\r\n return printedDays;\r\n }\r\n\r\n public static getAge(birthDate, otherDate) {\r\n birthDate = new Date(birthDate);\r\n otherDate = new Date(otherDate);\r\n\r\n let years = (otherDate.getFullYear() - birthDate.getFullYear());\r\n\r\n if (otherDate.getMonth() < birthDate.getMonth() ||\r\n otherDate.getMonth() === birthDate.getMonth() && otherDate.getDate() < birthDate.getDate()) {\r\n years--;\r\n }\r\n\r\n return years;\r\n }\r\n\r\n public static searchArray(searchTerm: string, caseSensitive: boolean, ...values: any[]) {\r\n if (!searchTerm) {\r\n return true;\r\n }\r\n\r\n let filter = searchTerm.trim();\r\n let data = values.join();\r\n\r\n if (!caseSensitive) {\r\n filter = filter.toLowerCase();\r\n data = data.toLowerCase();\r\n }\r\n\r\n return data.indexOf(filter) !== -1;\r\n }\r\n\r\n public static moveArrayItem(array: any[], oldIndex, newIndex) {\r\n if (oldIndex < 0) {\r\n return;\r\n }\r\n\r\n if (newIndex < 0) {\r\n newIndex += array.length;\r\n }\r\n\r\n if (newIndex >= array.length) {\r\n let k = newIndex - array.length;\r\n while ((k--) + 1) {\r\n array.push(undefined);\r\n }\r\n }\r\n\r\n array.splice(newIndex, 0, array.splice(oldIndex, 1)[0]);\r\n }\r\n\r\n public static expandCamelCase(text: string) {\r\n if (!text) {\r\n return text;\r\n }\r\n\r\n return text.replace(/([A-Z][a-z]+)/g, ' $1')\r\n .replace(/([A-Z][A-Z]+)/g, ' $1')\r\n .replace(/([^A-Za-z ]+)/g, ' $1');\r\n }\r\n\r\n public static testIsAbsoluteUrl(url: string) {\r\n const r = new RegExp('^(?:[a-z]+:)?//', 'i');\r\n return r.test(url);\r\n }\r\n\r\n public static convertToAbsoluteUrl(url: string) {\r\n return Utilities.testIsAbsoluteUrl(url) ? url : '//' + url;\r\n }\r\n\r\n public static removeNulls(obj) {\r\n const isArray = obj instanceof Array;\r\n\r\n for (let k = 0; k < obj.length; k++) {\r\n if (obj[k] === null) {\r\n isArray ? obj.splice(k, 1) : delete obj[k];\r\n } else if (typeof obj[k] === 'object') {\r\n Utilities.removeNulls(obj[k]);\r\n }\r\n\r\n if (isArray && obj.length === k) {\r\n Utilities.removeNulls(obj);\r\n }\r\n }\r\n\r\n return obj;\r\n }\r\n\r\n public static debounce(func: (...args) => any, wait: number, immediate?: boolean) {\r\n let timeout;\r\n\r\n return function () {\r\n const context = this;\r\n const args_ = arguments;\r\n\r\n const later = function () {\r\n timeout = null;\r\n if (!immediate) {\r\n func.apply(context, args_);\r\n }\r\n };\r\n\r\n const callNow = immediate && !timeout;\r\n\r\n clearTimeout(timeout);\r\n timeout = setTimeout(later, wait);\r\n\r\n if (callNow) {\r\n func.apply(context, args_);\r\n }\r\n };\r\n }\r\n}\r\n","// ===========================================\r\n// Email: info@ebenmonney.com\r\n// www.ebenmonney.com/templates\r\n// ===========================================\r\n\r\nimport { Injectable } from '@angular/core';\r\nimport { Observable, Subject } from 'rxjs';\r\n\r\nimport { Utilities } from './utilities';\r\n\r\n@Injectable()\r\n/**\r\n* Provides a wrapper for accessing the web storage API and synchronizing session storage across tabs/windows.\r\n*/\r\nexport class LocalStoreManager {\r\n private static syncListenerInitialised = false;\r\n\r\n public static readonly DBKEY_USER_DATA = 'user_data';\r\n private static readonly DBKEY_SYNC_KEYS = 'sync_keys';\r\n private syncKeys: string[] = [];\r\n private initEvent = new Subject();\r\n\r\n private reservedKeys: string[] =\r\n [\r\n 'sync_keys',\r\n 'addToSyncKeys',\r\n 'removeFromSyncKeys',\r\n 'getSessionStorage',\r\n 'setSessionStorage',\r\n 'addToSessionStorage',\r\n 'removeFromSessionStorage',\r\n 'clearAllSessionsStorage'\r\n ];\r\n\r\n public initialiseStorageSyncListener() {\r\n if (LocalStoreManager.syncListenerInitialised === true) {\r\n return;\r\n }\r\n\r\n LocalStoreManager.syncListenerInitialised = true;\r\n window.addEventListener('storage', this.sessionStorageTransferHandler, false);\r\n this.syncSessionStorage();\r\n }\r\n\r\n public deinitialiseStorageSyncListener() {\r\n window.removeEventListener('storage', this.sessionStorageTransferHandler, false);\r\n LocalStoreManager.syncListenerInitialised = false;\r\n }\r\n\r\n public clearAllStorage() {\r\n this.clearAllSessionsStorage();\r\n this.clearLocalStorage();\r\n }\r\n public set(key, value, ttl = null) {\r\n if (ttl) {\r\n const expires = new Date();\r\n expires.setSeconds(expires.getSeconds() + ttl);\r\n localStorage.set(key, [expires, value]);\r\n } else {\r\n localStorage.set(key, [null, value]);\r\n }\r\n }\r\n public clearAllSessionsStorage() {\r\n this.clearInstanceSessionStorage();\r\n localStorage.removeItem(LocalStoreManager.DBKEY_SYNC_KEYS);\r\n\r\n localStorage.setItem('clearAllSessionsStorage', '_dummy');\r\n localStorage.removeItem('clearAllSessionsStorage');\r\n }\r\n\r\n public clearInstanceSessionStorage() {\r\n sessionStorage.clear();\r\n this.syncKeys = [];\r\n }\r\n\r\n public clearLocalStorage() {\r\n localStorage.clear();\r\n }\r\n\r\n public saveSessionData(data: any, key = LocalStoreManager.DBKEY_USER_DATA) {\r\n this.testForInvalidKeys(key);\r\n\r\n this.removeFromSyncKeys(key);\r\n localStorage.removeItem(key);\r\n this.sessionStorageSetItem(key, data);\r\n }\r\n\r\n public saveSyncedSessionData(data: any, key = LocalStoreManager.DBKEY_USER_DATA) {\r\n this.testForInvalidKeys(key);\r\n\r\n localStorage.removeItem(key);\r\n this.addToSessionStorage(data, key);\r\n }\r\n\r\n public savePermanentData(data: any, key = LocalStoreManager.DBKEY_USER_DATA) {\r\n this.testForInvalidKeys(key);\r\n\r\n this.removeFromSessionStorage(key);\r\n this.localStorageSetItem(key, data);\r\n }\r\n\r\n public moveDataToSessionStorage(key = LocalStoreManager.DBKEY_USER_DATA) {\r\n this.testForInvalidKeys(key);\r\n\r\n const data = this.getData(key);\r\n\r\n if (data === null) {\r\n return;\r\n }\r\n\r\n this.saveSessionData(data, key);\r\n }\r\n\r\n public moveDataToSyncedSessionStorage(key = LocalStoreManager.DBKEY_USER_DATA) {\r\n this.testForInvalidKeys(key);\r\n\r\n const data = this.getData(key);\r\n\r\n if (data === null) {\r\n return;\r\n }\r\n\r\n this.saveSyncedSessionData(data, key);\r\n }\r\n\r\n public moveDataToPermanentStorage(key = LocalStoreManager.DBKEY_USER_DATA) {\r\n this.testForInvalidKeys(key);\r\n\r\n const data = this.getData(key);\r\n\r\n if (data === null) {\r\n return;\r\n }\r\n\r\n this.savePermanentData(data, key);\r\n }\r\n\r\n public exists(key = LocalStoreManager.DBKEY_USER_DATA) {\r\n let data = sessionStorage.getItem(key);\r\n\r\n if (data === null) {\r\n data = localStorage.getItem(key);\r\n }\r\n\r\n return data;\r\n }\r\n\r\n public getData(key = LocalStoreManager.DBKEY_USER_DATA) {\r\n this.testForInvalidKeys(key);\r\n\r\n let data = this.sessionStorageGetItem(key);\r\n\r\n if (data === null) {\r\n data = this.localStorageGetItem(key);\r\n }\r\n\r\n return data;\r\n }\r\n\r\n public getDataObject(key = LocalStoreManager.DBKEY_USER_DATA, isDateType = false): T {\r\n let data = this.getData(key);\r\n\r\n if (data !== null) {\r\n if (isDateType) {\r\n data = new Date(data);\r\n }\r\n return data as T;\r\n } else {\r\n return null;\r\n }\r\n }\r\n\r\n public deleteData(key = LocalStoreManager.DBKEY_USER_DATA) {\r\n this.testForInvalidKeys(key);\r\n\r\n this.removeFromSessionStorage(key);\r\n localStorage.removeItem(key);\r\n }\r\n\r\n public getInitEvent(): Observable<{}> {\r\n return this.initEvent.asObservable();\r\n }\r\n\r\n private sessionStorageTransferHandler = (event: StorageEvent) => {\r\n if (!event.newValue) {\r\n return;\r\n }\r\n\r\n if (event.key === 'getSessionStorage') {\r\n if (sessionStorage.length) {\r\n this.localStorageSetItem('setSessionStorage', sessionStorage);\r\n localStorage.removeItem('setSessionStorage');\r\n }\r\n } else if (event.key === 'setSessionStorage') {\r\n if (!this.syncKeys.length) {\r\n this.loadSyncKeys();\r\n }\r\n const data = JSON.parse(event.newValue);\r\n // console.info(\"Set => Key: Transfer setSessionStorage\" + \", data: \" + JSON.stringify(data));\r\n\r\n for (const key in data) {\r\n if (this.syncKeysContains(key)) {\r\n this.sessionStorageSetItem(key, JSON.parse(data[key]));\r\n }\r\n }\r\n\r\n this.onInit();\r\n } else if (event.key === 'addToSessionStorage') {\r\n const data = JSON.parse(event.newValue);\r\n\r\n // console.warn(\"Set => Key: Transfer addToSessionStorage\" + \", data: \" + JSON.stringify(data));\r\n\r\n this.addToSessionStorageHelper(data.data, data.key);\r\n } else if (event.key === 'removeFromSessionStorage') {\r\n this.removeFromSessionStorageHelper(event.newValue);\r\n } else if (event.key === 'clearAllSessionsStorage' && sessionStorage.length) {\r\n this.clearInstanceSessionStorage();\r\n } else if (event.key === 'addToSyncKeys') {\r\n this.addToSyncKeysHelper(event.newValue);\r\n } else if (event.key === 'removeFromSyncKeys') {\r\n this.removeFromSyncKeysHelper(event.newValue);\r\n }\r\n }\r\n\r\n private syncSessionStorage() {\r\n localStorage.setItem('getSessionStorage', '_dummy');\r\n localStorage.removeItem('getSessionStorage');\r\n }\r\n\r\n private addToSessionStorage(data: any, key: string) {\r\n this.addToSessionStorageHelper(data, key);\r\n this.addToSyncKeysBackup(key);\r\n\r\n this.localStorageSetItem('addToSessionStorage', { key, data });\r\n localStorage.removeItem('addToSessionStorage');\r\n }\r\n\r\n private addToSessionStorageHelper(data: any, key: string) {\r\n this.addToSyncKeysHelper(key);\r\n this.sessionStorageSetItem(key, data);\r\n }\r\n\r\n private removeFromSessionStorage(keyToRemove: string) {\r\n this.removeFromSessionStorageHelper(keyToRemove);\r\n this.removeFromSyncKeysBackup(keyToRemove);\r\n\r\n localStorage.setItem('removeFromSessionStorage', keyToRemove);\r\n localStorage.removeItem('removeFromSessionStorage');\r\n }\r\n\r\n private removeFromSessionStorageHelper(keyToRemove: string) {\r\n sessionStorage.removeItem(keyToRemove);\r\n this.removeFromSyncKeysHelper(keyToRemove);\r\n }\r\n\r\n private testForInvalidKeys(key: string) {\r\n if (!key) {\r\n throw new Error('key cannot be empty');\r\n }\r\n\r\n if (this.reservedKeys.some(x => x === key)) {\r\n throw new Error(`The storage key \"${key}\" is reserved and cannot be used. Please use a different key`);\r\n }\r\n }\r\n\r\n private syncKeysContains(key: string) {\r\n return this.syncKeys.some(x => x === key);\r\n }\r\n\r\n private loadSyncKeys() {\r\n if (this.syncKeys.length) {\r\n return;\r\n }\r\n\r\n this.syncKeys = this.getSyncKeysFromStorage();\r\n }\r\n\r\n private getSyncKeysFromStorage(defaultValue: string[] = []): string[] {\r\n const data = this.localStorageGetItem(LocalStoreManager.DBKEY_SYNC_KEYS);\r\n\r\n if (data === null) {\r\n return defaultValue;\r\n } else {\r\n return data as string[];\r\n }\r\n }\r\n\r\n private addToSyncKeys(key: string) {\r\n this.addToSyncKeysHelper(key);\r\n this.addToSyncKeysBackup(key);\r\n\r\n localStorage.setItem('addToSyncKeys', key);\r\n localStorage.removeItem('addToSyncKeys');\r\n }\r\n\r\n private addToSyncKeysBackup(key: string) {\r\n const storedSyncKeys = this.getSyncKeysFromStorage();\r\n\r\n if (!storedSyncKeys.some(x => x === key)) {\r\n storedSyncKeys.push(key);\r\n this.localStorageSetItem(LocalStoreManager.DBKEY_SYNC_KEYS, storedSyncKeys);\r\n }\r\n }\r\n\r\n private removeFromSyncKeysBackup(key: string) {\r\n const storedSyncKeys = this.getSyncKeysFromStorage();\r\n\r\n const index = storedSyncKeys.indexOf(key);\r\n\r\n if (index > -1) {\r\n storedSyncKeys.splice(index, 1);\r\n this.localStorageSetItem(LocalStoreManager.DBKEY_SYNC_KEYS, storedSyncKeys);\r\n }\r\n }\r\n\r\n private addToSyncKeysHelper(key: string) {\r\n if (!this.syncKeysContains(key)) {\r\n this.syncKeys.push(key);\r\n }\r\n }\r\n\r\n private removeFromSyncKeys(key: string) {\r\n this.removeFromSyncKeysHelper(key);\r\n this.removeFromSyncKeysBackup(key);\r\n\r\n localStorage.setItem('removeFromSyncKeys', key);\r\n localStorage.removeItem('removeFromSyncKeys');\r\n }\r\n\r\n private removeFromSyncKeysHelper(key: string) {\r\n const index = this.syncKeys.indexOf(key);\r\n\r\n if (index > -1) {\r\n this.syncKeys.splice(index, 1);\r\n }\r\n }\r\n\r\n private localStorageSetItem(key: string, data: any) {\r\n localStorage.setItem(key, JSON.stringify(data));\r\n }\r\n\r\n private sessionStorageSetItem(key: string, data: any) {\r\n sessionStorage.setItem(key, JSON.stringify(data));\r\n }\r\n\r\n private localStorageGetItem(key: string) {\r\n return Utilities.JsonTryParse(localStorage.getItem(key));\r\n }\r\n\r\n private sessionStorageGetItem(key: string) {\r\n return Utilities.JsonTryParse(sessionStorage.getItem(key));\r\n }\r\n\r\n private onInit() {\r\n setTimeout(() => {\r\n this.initEvent.next();\r\n this.initEvent.complete();\r\n });\r\n }\r\n}\r\n","import { Injectable } from '@angular/core';\r\n@Injectable({\r\n providedIn: 'root'\r\n})\r\nexport class GroupByService {\r\n groupby(value: Array, field: string): Array {\r\n const groupedObj = value.reduce((prev, cur) => {\r\n if (!prev[cur[field]]) {\r\n prev[cur[field]] = [cur];\r\n } else {\r\n prev[cur[field]].push(cur);\r\n }\r\n return prev;\r\n }, {});\r\n return Object.keys(groupedObj).map(key => ({\r\n key,\r\n value: groupedObj[key]\r\n }));\r\n }\r\n}\r\n","import { Injectable } from '@angular/core';\r\nimport { FactorModel } from 'src/models/factor.model';\r\nimport { TableGroupModel } from 'src/models/tablegroup.model';\r\n\r\nimport { TableModel } from 'src/models/table.model';\r\nimport { RestApiService } from './rest-api.service';\r\nimport { NgxUiLoaderService } from 'ngx-ui-loader';\r\nimport { StateEnum } from 'src/models/enum/state.enum';\r\nimport { ShareDataService } from '../providers/sharedata.service';\r\nimport { GroupByService } from '../providers/groupby.service';\r\nimport { state } from '@angular/animations';\r\nimport { MatSnackBar } from '@angular/material';\r\nimport { ToastrService } from 'ngx-toastr';\r\nimport { Router } from '@angular/router';\r\nimport { debug } from 'console';\r\nimport { PushNotificationsService } from './push.notification.service';\r\nimport { SwPush } from '@angular/service-worker';\r\n\r\n@Injectable({\r\n providedIn: 'root'\r\n})\r\n\r\nexport class OrderService {\r\n private connection: signalR.HubConnection;\r\n tableGroup: TableGroupModel[];\r\n selectedGroup: TableModel[];\r\n groupFactors: any[];\r\n selectedFilter: string;\r\n factors: FactorModel[];\r\n selecteditem: any;\r\n tableCall: string;\r\n //selecteditem: boolean;\r\n forbidden: boolean;\r\n isConnect : boolean;\r\n constructor(\r\n private api: RestApiService,\r\n private spinner: NgxUiLoaderService,\r\n private share: ShareDataService,\r\n public grouplist: GroupByService,\r\n protected _snackBar: MatSnackBar,\r\n public toastr: ToastrService,\r\n public router: Router,\r\n private _notificationService: PushNotificationsService\r\n ) {\r\n // this._notificationService.requestPermission();\r\n }\r\n // public hubConnection: signalR.HubConnection;\r\n // public startConnection = () => {\r\n // if (!this.connection && !this.isConnect ) {\r\n // // this.getSetting();\r\n // this.hubConnection = new signalR.HubConnectionBuilder()\r\n // .withUrl(this.api.apiUrl + '/TableHub')\r\n // .configureLogging(signalR.LogLevel.Trace)\r\n // .build();\r\n // this.hubConnection.serverTimeoutInMilliseconds = 1000 * 60 * 1.2; // 1 second * 60 * 10 = 10 minutes.\r\n // this.hubConnection\r\n // .start()\r\n // .then(() => { console.log('Connection started'); this.isConnect = true; this.addTransferDataListener(); })\r\n // .catch(err => console.log('Error while starting connection: ' + err));\r\n // }\r\n // this.hubConnection.keepAliveIntervalInMilliseconds = 31104000000;\r\n // this.hubConnection\r\n // .onclose(() => {\r\n // setTimeout(() => {\r\n // if (!this.forbidden) {\r\n // this.isConnect = false;\r\n // this.startConnection();\r\n // }\r\n // }, 2000);\r\n // });\r\n // }\r\n disconnect() {\r\n if (this.connection) {\r\n this.connection.stop();\r\n this.connection = null;\r\n }\r\n }\r\n\r\n isEnabled() {\r\n return Notification.permission == \"granted\" ? true : false;\r\n }\r\n\r\n request() {\r\n this._notificationService.requestPermission();\r\n }\r\n\r\n notify(t: string, c: string) {\r\n let data: Array = [];\r\n data.push({\r\n title: t,\r\n alertContent: c,\r\n tag: \"گارسون\",\r\n sound: `${this.share.api.apiUrl}/assets/audio/notification.mp3`,\r\n dir: \"rtl\"\r\n });\r\n // data.push({\r\n // title: \"2 Title with badge\",\r\n // badge: \"https://img.icons8.com/plasticine/2x/google-logo.png\",\r\n // tag: \"tag_2\"\r\n // });\r\n\r\n // data.push({\r\n // title: \"3 Title, badge & body\",\r\n // alertContent: \"Notification body\",\r\n // badge: \"https://img.icons8.com/plasticine/2x/google-logo.png\",\r\n // tag: \"tag_3\"\r\n // });\r\n // data.push({\r\n // title: \"4 Tile, badge, body & icon\",\r\n // alertContent: \"Notification body\",\r\n // badge: \"https://img.icons8.com/plasticine/2x/google-logo.png\",\r\n // icon: \"https://avatars1.githubusercontent.com/u/28635252?s=400&v=4\",\r\n // tag: \"tag_4\"\r\n // });\r\n // data.push({\r\n // title: \"5 Title, badge, body, icon & image\",\r\n // alertContent: \"Notification body\",\r\n // badge: \"https://img.icons8.com/plasticine/2x/google-logo.png\",\r\n // icon: \"https://avatars1.githubusercontent.com/u/28635252?s=400&v=4\",\r\n // image: \"https://live.staticflickr.com/4134/4897775884_0d3b982b2f_b.jpg\",\r\n // tag: \"tag_5\"\r\n // });\r\n // data.push({\r\n // title: \"4 Tile, badge, body & icon\",\r\n // alertContent: \"Notification body - updated!\",\r\n // badge: \"https://img.icons8.com/plasticine/2x/google-logo.png\",\r\n // icon: \"https://avatars1.githubusercontent.com/u/28635252?s=400&v=4\",\r\n // tag: \"tag_4\"\r\n // });\r\n // data.push({\r\n // title: \"6 Tile, badge, body & icon\",\r\n // alertContent: \"Notification body - Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.\",\r\n // badge: \"https://img.icons8.com/plasticine/2x/google-logo.png\",\r\n // icon: \"https://avatars1.githubusercontent.com/u/28635252?s=400&v=4\",\r\n // tag: \"tag_6\"\r\n // });\r\n this._notificationService.generateNotification(data);\r\n }\r\n\r\n\r\n // addTransferDataListener = () => {\r\n // this.hubConnection.on('transferNotification', (res: number) => {\r\n // // for (let i = 0; i < this.tableGroup.length; i++) {\r\n // // const find = this.tableGroup[i].tables.find(f => f.tableId === res);\r\n // // if (find && find.tableName && find.tableName !== '') {\r\n // // this.tableCall = find.tableName;\r\n // // break;\r\n // // }\r\n // // }\r\n // const find = this.selectedGroup.find(f => f.tableId === res);\r\n // if (find && find.tableName && find.tableName !== '') {\r\n // this.request();\r\n // this.notify(find.tableName);\r\n // this.playAudio();\r\n // this.toastr.warning(`${find.tableName} در خواست مراجعه دارد`, 'توجه', { timeOut: 1000000, closeButton: true, positionClass: 'toast-bottom-right', });\r\n // }\r\n // });\r\n // this.hubConnection.on('transferOrderData', (data: FactorModel) => {\r\n // if (data.status != 0 && ((this.tableGroup) && (data.status === StateEnum.Save || data.status === StateEnum.SaveMerge))) {\r\n // for (let i = 0; i < this.tableGroup.length; i++) {\r\n // const find = this.tableGroup[i].tables.filter(f => f.tableId.toString() === data.tableId && f.branchCode === data.branchCode)[0];\r\n // if ((find)) {\r\n // if (data.tas && data.tas === 1) {\r\n // find.waiterId = null;\r\n // find.waiterName = '';\r\n // find.customerName = '';\r\n // find.time = null;\r\n // find.num = null;\r\n // if (this.share.filterTableList && this.share.tableList) {\r\n // const find = this.share.tableList.find(f => f.tableId.toString() === data.tableId);\r\n // if (!this.share.filterTableList.some(s => find.tableId === s.tableId))\r\n // this.share.filterTableList.push(find);\r\n // }\r\n // this.filter(this.selectedFilter);\r\n // break;\r\n // } else {\r\n // find.waiterId = data.waiterId;\r\n // find.waiterName = data.waiterName;\r\n // find.customerName = data.customerName;\r\n // find.time = data.time;\r\n // find.num = data.num;\r\n // if (this.share.filterTableList) {\r\n // const findIndex = this.share.filterTableList.findIndex(f => f.tableId === Number(data.tableId));\r\n // if ((findIndex))\r\n // this.share.filterTableList.splice(findIndex, 1);\r\n // }\r\n // this.filter(this.selectedFilter);\r\n // break;\r\n // }\r\n // }\r\n // }\r\n // if (this.share.setting?.systemLayer?.hasTabletOrder) {\r\n // this.refreshTableTimeLeft();\r\n // }\r\n // }\r\n // if ((data.id) && data.id !== 0 && (this.groupFactors) && data.status === StateEnum.Add) {\r\n // if (!this.groupFactors.some(s => s.key === data.tableId) && data.status === StateEnum.Add) {\r\n // this.factors.push(data);\r\n // this.groupFactors = this.grouplist.groupby(this.factors, 'tableId');\r\n // if (this.groupFactors.length === 1)\r\n // this.selecteditem = this.groupFactors[0].value;\r\n // }\r\n // else {\r\n // for (let j = 0; j < this.groupFactors.length; j++) {\r\n // if (!this.groupFactors.some(s => s.key === data.tableId)) {\r\n // this.factors.push(data);\r\n // this.groupFactors = this.grouplist.groupby(this.factors, 'tableId');\r\n // break;\r\n // }\r\n // if (this.groupFactors[j].value[0].tableId === data.tableId) {\r\n // if (data.status === StateEnum.Add) {\r\n // this.factors.push(data);\r\n // if (this.selecteditem[0].tableId === data.tableId)\r\n // this.selecteditem.push(data);\r\n // this.groupFactors = this.grouplist.groupby(this.factors, 'tableId');\r\n // break;\r\n // }\r\n // if (data.status === StateEnum.Deleted || data.status === StateEnum.Save || data.status === StateEnum.SaveMerge) {\r\n // this.groupFactors.splice(j, 1);\r\n // break;\r\n // }\r\n // }\r\n // }\r\n // //if (!this.groupFactors || this.groupFactors.length <= 0) {\r\n // // this.selecteditem = false;\r\n // //}\r\n // }\r\n // if (this.share.loginuser && this.share.loginuser.code)\r\n // this.playAudio();\r\n // }\r\n // this.spinner.stopAll();\r\n // this.share.getDigitalMenuCount();\r\n // });\r\n // this.hubConnection.on('RedirectResult', (data: any) => {\r\n // this.router.navigate([`/payment`]);\r\n // });\r\n // }\r\n filter(event: string) {\r\n this.selectedGroup = [];\r\n if (!(event)) {\r\n this.selectedFilter = 'All';\r\n } else {\r\n this.selectedFilter = event;\r\n }\r\n switch (this.selectedFilter) {\r\n case 'All':\r\n this.selectedGroup = Object.assign([], this.tableGroup[this.share.selectedGroupIndex].tables);\r\n break;\r\n case 'Busy':\r\n this.selectedGroup = Object.assign([], this.tableGroup[this.share.selectedGroupIndex].tables.filter(f => (f.num)));\r\n break;\r\n case 'Free':\r\n this.selectedGroup = Object.assign([], this.tableGroup[this.share.selectedGroupIndex].tables.filter(f => !(f.num)));\r\n break;\r\n default:\r\n this.selectedGroup = Object.assign([], this.tableGroup[this.share.selectedGroupIndex].tables);\r\n break;\r\n }\r\n }\r\n refreshTableTimeLeft() {\r\n this.api.getEntity('GetTableTimeLeft').subscribe((res: TableModel[]) => {\r\n if (res && res.length > 0 && this.tableGroup && this.tableGroup.length > 0) {\r\n for (let i = 0; i < this.tableGroup.length; i++) {\r\n res.forEach(el => {\r\n const find = this.tableGroup[i].tables.find(f => f.tableId === el.tableId);\r\n if (find)\r\n find.time = el.time;\r\n });\r\n }\r\n }\r\n });\r\n }\r\n playAudio() {\r\n let audio = new Audio();\r\n audio.src = \"../../../assets/audio/alarm.mp4\";\r\n audio.load();\r\n audio.play();\r\n }\r\n playNAudio() {\r\n let audio = new Audio();\r\n audio.src = \"../../../assets/audio/notification.mp3\";\r\n audio.load();\r\n audio.play();\r\n }\r\n //stopConnection() {\r\n // this.hubConnection.stop();\r\n //}\r\n}\r\n","import { Injectable } from \"@angular/core\";\r\nimport { MatDialog } from \"@angular/material\";\r\nimport { NgxUiLoaderService } from \"ngx-ui-loader\";\r\nimport { Subject } from \"rxjs/Rx\";\r\nimport { DialogComponent } from \"src/app/dialog/dialog.component\";\r\nimport { InvoiceModel } from \"../models/factor.model\";\r\nimport { WebsocketService } from \"./websocket.service\";\r\n\r\nconst CHAT_URL = \"ws://127.0.0.1:1372/\";\r\n//const CHAT_URL = \"ws://192.168.247.65:1372/\";\r\n\r\nexport class ParsianPaymentModel {\r\n CompanyName: string;\r\n RequestType: string;\r\n AM: string;\r\n paymentType: string;\r\n GovID: string;\r\n SC: string;\r\n ID: string;\r\n constructor() {\r\n this.CompanyName = \"SEPIDZ\";\r\n this.RequestType = \"Sale\";\r\n this.AM = \"0\";\r\n this.paymentType = \"CARD\";\r\n this.ID = \"\";\r\n this.GovID = \"\";\r\n this.SC = \"4020\";\r\n }\r\n}\r\nexport class ParsianPosInfoModel {\r\n CompanyName: string;\r\n RequestType: string;\r\n constructor() {\r\n this.CompanyName = \"SEPIDZ\";\r\n this.RequestType = 'getMerchantInfo';\r\n }\r\n}\r\nexport class ParsianHasPaperModel {\r\n CompanyName: string;\r\n RequestType: string;\r\n constructor() {\r\n this.CompanyName = \"SEPIDZ\";\r\n this.RequestType = 'checkPaper';\r\n }\r\n}\r\nexport class ParsianReceiptBitMapModel {\r\n CompanyName: string;\r\n RequestType: string;\r\n invoice: InvoiceModel;\r\n constructor() {\r\n this.CompanyName = \"SEPIDZ\";\r\n this.RequestType = 'receiptBitMap';\r\n this.invoice = null;\r\n }\r\n}\r\nexport class ParsianResponseModel {\r\n compName: string;\r\n trxType: string;\r\n RS: any;\r\n CN: any;\r\n RN: any;\r\n SN: any;\r\n TN: any;\r\n DT: any;\r\n AM: any;\r\n PS: any;\r\n CP: any;\r\n GI: any;\r\n TO: any;\r\n BR: any;\r\n MI: any;\r\n TS: any;\r\n TF: any;\r\n ER: any;\r\n RC: any;\r\n}\r\n@Injectable()\r\nexport class ParsianPosService {\r\n public messages: Subject;\r\n public factorPrin = '';\r\n constructor(private wsService: WebsocketService, private dialog: MatDialog, private spinner: NgxUiLoaderService) { }\r\n\r\n connect(){\r\n this.messages = >this.wsService.connect(CHAT_URL).map(\r\n (response: MessageEvent): ParsianResponseModel => {\r\n let data: ParsianResponseModel = JSON.parse(response.data);\r\n let res: boolean = false;\r\n if (data.ER !== 'null') {\r\n const dialogRef = this.dialog.open(DialogComponent);\r\n dialogRef.componentInstance.title = 'توجه';\r\n dialogRef.componentInstance.hasCancel = true;\r\n dialogRef.componentInstance.message = `${data.ER}`;\r\n dialogRef.afterClosed().subscribe(result => {\r\n res = false;\r\n this.spinner.stopAll();\r\n return;\r\n\r\n });\r\n }\r\n else {\r\n if (data.RS !== 'null') {\r\n if (data.RS === '00') {\r\n const dialogRef = this.dialog.open(DialogComponent);\r\n dialogRef.componentInstance.title = 'توجه';\r\n dialogRef.componentInstance.hasCancel = true;\r\n dialogRef.componentInstance.message = `پرداخت با موفقیت انجام شد شماره پیگیری : ${data.SN}`;\r\n res = true;\r\n dialogRef.afterClosed().subscribe(result => {\r\n res = true;\r\n this.spinner.stopAll();\r\n\r\n });\r\n }\r\n else {\r\n const dialogRef = this.dialog.open(DialogComponent);\r\n dialogRef.componentInstance.title = 'توجه';\r\n dialogRef.componentInstance.hasCancel = true;\r\n dialogRef.componentInstance.message = `پرداخت با خطا روبرو شد `;\r\n dialogRef.afterClosed().subscribe(result => {\r\n res = false;\r\n this.spinner.stopAll();\r\n });\r\n }\r\n }\r\n }\r\n\r\n this.spinner.stopAll();\r\n return data;\r\n }\r\n );\r\n }\r\n}\r\n","import { Pipe, PipeTransform } from '@angular/core';\r\nimport { TranslateService } from '@ngx-translate/core';\r\n\r\n@Pipe({\r\n name: 'persianNumber',\r\n pure: false\r\n})\r\nexport class PersianNumberPipe implements PipeTransform {\r\n constructor(private translate: TranslateService) { }\r\n\r\n transform(value: any): string {\r\n if ((value === undefined || value === null) ||\r\n (this.translate.currentLang && this.translate.currentLang.toLowerCase() !== \"fa\")) {\r\n // return this.toEnglishNumber(value.toString());\r\n return value;\r\n }\r\n return this.toPersianNumber(value.toString());\r\n }\r\n public toPersianNumber(number: string): string {\r\n if (number === undefined) {\r\n return '';\r\n }\r\n let str = number.toString().trim();\r\n if (str === '') {\r\n return '';\r\n }\r\n str = str.replace(/0/g, '۰');\r\n str = str.replace(/1/g, '۱');\r\n str = str.replace(/2/g, '۲');\r\n str = str.replace(/3/g, '۳');\r\n str = str.replace(/4/g, '۴');\r\n str = str.replace(/5/g, '۵');\r\n str = str.replace(/6/g, '۶');\r\n str = str.replace(/7/g, '۷');\r\n str = str.replace(/8/g, '۸');\r\n str = str.replace(/9/g, '۹');\r\n return str;\r\n }\r\n public toEnglishNumber(number: string): string {\r\n if (number === undefined) {\r\n return '';\r\n }\r\n let str = number.toString().trim();\r\n if (str === '') {\r\n return '';\r\n }\r\n str = str.replace('۰', '0');\r\n str = str.replace('۱', '1');\r\n str = str.replace('۲', '2');\r\n str = str.replace('۳', '3');\r\n str = str.replace('۴', '4');\r\n str = str.replace('۵', '5');\r\n str = str.replace('۶', '6');\r\n str = str.replace('۷', '7');\r\n str = str.replace('۸', '8');\r\n str = str.replace('۹', '9');\r\n return str;\r\n }\r\n}\r\n","import { Injectable, OnDestroy } from \"@angular/core\";\r\nimport { Subject } from \"rxjs-compat\";\r\nimport { FactorModel, InvoiceDetailsModel, InvoiceModel, PrintInvoiceModel } from \"src/models/factor.model\";\r\nimport { LocalStoreManager } from \"./local-store-manager.service\";\r\nimport { ParsianHasPaperModel, ParsianPaymentModel, ParsianPosService, ParsianReceiptBitMapModel, ParsianResponseModel } from \"./parsianpos.service\";\r\nimport { RestApiService } from \"./rest-api.service\";\r\nimport { takeUntil } from 'rxjs/operators';\r\nimport { MatDialog, MatSnackBar } from '@angular/material';\r\nimport { DialogComponent } from \"../app/dialog/dialog.component\";\r\nimport { TranslateService } from \"@ngx-translate/core\";\r\nimport { TableGroupModel } from \"../models/tablegroup.model\";\r\nimport { OrderService } from \"./order.service\";\r\nimport { ShareDataService } from \"../providers/sharedata.service\";\r\n\r\n@Injectable()\r\nexport class PosClearingService implements OnDestroy {\r\n tasvieh: any;\r\n constructor(private parsianSerice: ParsianPosService,\r\n private api: RestApiService,\r\n private storage: LocalStoreManager,\r\n protected translateText: TranslateService,\r\n private dialog: MatDialog,\r\n protected _snackBar: MatSnackBar,\r\n private order: OrderService,\r\n private share: ShareDataService) {\r\n }\r\n ngUnsubscribe = new Subject();\r\n ngOnDestroy(): void {\r\n this.ngUnsubscribe.next();\r\n this.ngUnsubscribe.complete();\r\n }\r\n clear(factor?: FactorModel,) {\r\n\r\n this.tasvieh = this.storage.getData('Settlement');\r\n // Matin Req For zero Price Print\r\n if ((this.tasvieh && this.tasvieh?.Id <= 1) || !this.tasvieh || factor.price === 0) {\r\n this.clearing(factor);\r\n return;\r\n }\r\n switch (this.tasvieh?.Id) {\r\n case 2:\r\n this.parsianpayment(factor);\r\n break;\r\n case 3:\r\n this.parsianpayment(factor);\r\n break;\r\n case 4:\r\n this.parsianpayment(factor);\r\n break;\r\n default:\r\n console.warn('نحوه پرداخت پیدا نشد');\r\n break;\r\n }\r\n }\r\n parsianpayment(factor: FactorModel) {\r\n this.parsianSerice.connect();\r\n this.parsianSerice.messages.next(new ParsianHasPaperModel);\r\n this.parsianSerice.messages.subscribe((res: ParsianResponseModel) => {\r\n if (res?.CP === '-1') {\r\n const dialogRef = this.dialog.open(DialogComponent);\r\n dialogRef.componentInstance.title = 'توجه';\r\n dialogRef.componentInstance.hasCancel = true;\r\n dialogRef.componentInstance.message = `پرینتر کاغذ ندارد`;\r\n dialogRef.afterClosed().subscribe(result => {\r\n return;\r\n });\r\n }\r\n else {\r\n const payment = new ParsianPaymentModel();\r\n payment.AM = factor.price.toString();\r\n this.parsianSerice.connect();\r\n this.parsianSerice.messages.next(payment);\r\n this.parsianSerice.messages.subscribe((res: ParsianResponseModel) => {\r\n this._snackBar.open('', this.translateText.instant('Message.SaveData'), {\r\n duration: 10000,\r\n });\r\n factor.transactionNo = res?.SN;\r\n factor.errorMessagePay = res?.ER;\r\n factor.transactionNo = res?.SN;\r\n if (res?.RS === '00')\r\n this.clearing(factor);\r\n });\r\n }\r\n });\r\n }\r\n clearing(factor: FactorModel) {\r\n this.api.postEntity(factor, 'UpdateFactorState')\r\n .pipe(takeUntil(this.ngUnsubscribe))\r\n .subscribe((res: FactorModel) => {\r\n this._snackBar.open('', this.translateText.instant('Message.SaveData'), {\r\n duration: 10000,\r\n });\r\n this.print(res)\r\n\r\n }\r\n );\r\n }\r\n print(factor: FactorModel) {\r\n if (this.tasvieh && this.tasvieh?.Id === 2 || this.tasvieh?.Id === 3 || this.tasvieh?.Id === 4 || this.tasvieh?.Id === 5) { //2_saman & 4_irankish also use the same method as parsian\r\n this.ParsianPrint(factor)\r\n }\r\n }\r\n ParsianPrint(factor: FactorModel) {\r\n const factorList = [];\r\n const payment = new ParsianReceiptBitMapModel();\r\n factorList.push(factor);\r\n payment.invoice = factorList.maper(new InvoiceModel())[0];\r\n payment.invoice.invoiceDetail = factorList[0].factorDetail.maper(new InvoiceDetailsModel());\r\n payment.invoice.restaurantName = this.share.setting.brandName;\r\n for (const element of payment.invoice.invoiceDetail) {\r\n if (this.share.setting.currency === 1) element.unitPrice /= 10; //if Toman, convert price to toman\r\n element.qty = element.qty ;\r\n payment.invoice.sumQty += element.qty;\r\n payment.invoice.sumPrice += element.qty * element.unitPrice * 10;\r\n element.sumUnitPrice = element.qty * element.unitPrice * 10;\r\n }\r\n if (!payment.invoice.usedCredit)\r\n payment.invoice.usedCredit = 0;\r\n payment.invoice.creditPrice = payment.invoice.usedCredit;\r\n this.parsianSerice.connect();\r\n this.parsianSerice.messages.next(payment);\r\n this.parsianSerice.messages.subscribe((res: ParsianResponseModel) => {\r\n //this.dialogRef.close();\r\n const print = new PrintInvoiceModel();\r\n print.branchCode = factor.branchCode;\r\n print.num = factor.num;\r\n print.pr =1;\r\n this.api.postEntity(print, 'UpdateInvoicePrintFlag')\r\n .pipe(takeUntil(this.ngUnsubscribe))\r\n .subscribe((res: FactorModel) => {\r\n this.refresh();\r\n });\r\n });\r\n }\r\n refresh() {\r\n this.api.getEntity('TablesGroup')\r\n .pipe(takeUntil(this.ngUnsubscribe))\r\n .subscribe((res: TableGroupModel[]) => {\r\n if (!res) {\r\n throw new Error('');\r\n }\r\n this.order.tableGroup = res;\r\n if (!this.share.selectedGroupIndex) {\r\n this.order.selectedGroup = Object.assign([], this.order.tableGroup[0].tables);\r\n this.share.selectedGroupIndex = 0;\r\n }\r\n else {\r\n this.order.selectedGroup = Object.assign([], this.order.tableGroup[this.share.selectedGroupIndex].tables);\r\n }\r\n this.order.forbidden = false;\r\n // this.order.startConnection();\r\n this.order.refreshTableTimeLeft();\r\n this.order.filter(this.order.selectedFilter);\r\n //this.tabGroup.selectedIndex = this.share.selectedGroupIndex;\r\n });\r\n }\r\n}\r\n","import { Observable } from \"rxjs\";\r\nimport { Injectable } from \"@angular/core\";\r\n\r\n@Injectable()\r\nexport class PushNotificationsService {\r\n public permission: Permission;\r\n\r\n constructor() {\r\n this.permission = this.isSupported() ? \"default\" : \"denied\";\r\n }\r\n\r\n public isSupported(): boolean {\r\n return \"Notification\" in window;\r\n }\r\n\r\n requestPermission(): void {\r\n let self = this;\r\n if (\"Notification\" in window) {\r\n Notification.requestPermission(function(status) {\r\n return (self.permission = status);\r\n });\r\n }\r\n }\r\n\r\n create(title: string, options?: PushNotification): any {\r\n let self = this;\r\n return new Observable(function(obs) {\r\n if (!(\"Notification\" in window)) {\r\n console.log(\"Notifications are not available in this environment\");\r\n obs.complete();\r\n }\r\n\r\n if (self.permission !== \"granted\") {\r\n console.log(\r\n \"The user hasn't granted you permission to send push notifications\"\r\n );\r\n obs.complete();\r\n }\r\n\r\n let _notify = new Notification(title, options);\r\n _notify.onshow = function(e) {\r\n setTimeout(function() {\r\n _notify.close();\r\n }, 7500);\r\n return obs.next({\r\n notification: _notify,\r\n event: e\r\n });\r\n };\r\n\r\n _notify.onclick = function(e) {\r\n _notify.close();\r\n return obs.next({\r\n notification: _notify,\r\n event: e\r\n });\r\n };\r\n\r\n _notify.onerror = function(e) {\r\n return obs.error({\r\n notification: _notify,\r\n event: e\r\n });\r\n };\r\n\r\n _notify.onclose = function() {\r\n return obs.complete();\r\n };\r\n });\r\n }\r\n\r\n generateNotification(source: Array): void {\r\n if (this.permission == \"granted\") {\r\n source.forEach((item, i) => {\r\n let options = {\r\n badge: item.badge,\r\n body: item.alertContent,\r\n icon: item.icon,\r\n image: item.image,\r\n tag: item.tag,\r\n sound: item.sound,\r\n dir: item.dir\r\n };\r\n setTimeout(() => {\r\n let ref = this.create(item.title, options).subscribe(res => {\r\n // console.log(\"res\", res);\r\n });\r\n // console.log(\"ref\", ref);\r\n }, i * 3000);\r\n });\r\n }\r\n }\r\n}\r\n\r\nexport declare type Permission = \"denied\" | \"granted\" | \"default\";\r\n\r\nexport interface PushNotification {\r\n body?: string;\r\n icon?: string;\r\n tag?: string;\r\n data?: any;\r\n renotify?: boolean;\r\n silent?: boolean;\r\n sound?: string;\r\n noscreen?: boolean;\r\n sticky?: boolean;\r\n dir?: \"auto\" | \"ltr\" | \"rtl\";\r\n lang?: string;\r\n vibrate?: number[];\r\n}\r\n","import { Injectable } from '@angular/core';\r\nimport { Observable, of, throwError } from 'rxjs';\r\nimport { HttpClient, HttpHeaders, HttpErrorResponse } from '@angular/common/http';\r\nimport { catchError, tap, map } from 'rxjs/operators';\r\n\r\nimport { SettingModel } from 'src/models/setting.model';\r\nimport { LocalStoreManager } from './local-store-manager.service';\r\nimport { environment } from 'src/environments/environment';\r\n\r\nconst httpOptions = {\r\n headers: new HttpHeaders({ 'Content-Type': 'application/json; charset=utf-8' })\r\n};\r\n@Injectable({\r\n providedIn: 'root'\r\n})\r\nexport class RestApiService {\r\n apiUrl: string;\r\n setting: SettingModel;\r\n protected storage: LocalStoreManager;\r\n // accessToken:string='';\r\n constructor(private http: HttpClient) {\r\n // this.apiUrl = \"http://192.168.247.50:14000\";\r\n this.apiUrl = environment.baseUrl || this.baseUrl();\r\n }\r\n public baseUrl() {\r\n let base = '';\r\n\r\n if (window.location.origin) {\r\n base = window.location.origin;\r\n } else {\r\n base = window.location.protocol + '//' + window.location.hostname + (window.location.port ? ':' + window.location.port : '');\r\n }\r\n\r\n return base.replace(/\\/$/, '');\r\n }\r\n getToken(data: any): Observable {\r\n const fullUrl = `${this.apiUrl}Token`;\r\n const a = JSON.stringify(data);\r\n return this.http.post(fullUrl, JSON.stringify(data), httpOptions);\r\n }\r\n get(): Observable {\r\n const fullUrl = `${this.apiUrl}`;\r\n return this.http.get(fullUrl, httpOptions);\r\n }\r\n getIpCliente(): Observable {\r\n return this.http.get('http://api.ipify.org/?format=jsonp&callback=JSONP_CALLBACK') // ...using post request '\r\n .map((res: Response) => {\r\n console.log('res ', res);\r\n console.log('res.json() ', res.text());\r\n //console.log('parseado ', JSON.parse(res.text()));\r\n console.log('parseado stringify ', JSON.stringify(res.text()));\r\n let ipVar = res.text();\r\n //let num = ipVar.indexOf(\":\");\r\n //let num2 = ipVar.indexOf(\"\\\"});\");\r\n //ipVar = ipVar.slice(num + 2, num2);\r\n console.log('ipVar -- ', ipVar);\r\n return ipVar\r\n }); // ...and calling .json() on the response to return data\r\n //.catch((error:any) => Observable.throw(error.json().error || 'Server error')); //...errors if any\r\n }\r\n testConnection(testUrl: string, CntUrl: string): Observable {\r\n const fullUrl = `${testUrl}${CntUrl}`;\r\n return this.http.get(fullUrl, httpOptions);\r\n }\r\n\r\n getEntity(CntUrl: string): Observable {\r\n const fullUrl = `${this.apiUrl}/${CntUrl}`;\r\n return this.http.get(fullUrl, httpOptions);\r\n }\r\n\r\n getWaiterList(CntUrl: string): Observable {\r\n const fullUrl = `${this.apiUrl}${CntUrl}`;\r\n return this.http.get(fullUrl, httpOptions);\r\n }\r\n\r\n getFilterEntity(CntUrl: string, filter: any): Observable {\r\n const fullUrl = `${this.apiUrl}/${CntUrl}?Filter=${filter}`;\r\n return this.http.get(fullUrl, httpOptions);\r\n }\r\n\r\n getEntityById(CntUrl: string, id: number): Observable {\r\n const url = `${this.apiUrl}${CntUrl}/${id}`;\r\n return this.http.get(url, httpOptions);\r\n }\r\n\r\n postEntity(data, CntUrl: string): Observable {\r\n const fullUrl = `${this.apiUrl}/${CntUrl}`;\r\n const jason = JSON.stringify(data);\r\n return this.http.post(fullUrl, jason, httpOptions);\r\n }\r\n\r\n updateEntity(id: string, data, CntUrl: string): Observable {\r\n const url = `${this.apiUrl}${CntUrl}/${id}`;\r\n return this.http.put(url, data, httpOptions);\r\n }\r\n\r\n deleteEntity(id: string, CntUrl: string): Observable<{}> {\r\n const url = `${this.apiUrl}${CntUrl}/${id}`;\r\n return this.http.delete(url, httpOptions);\r\n }\r\n}\r\n","import { Injectable } from \"@angular/core\";\r\nimport { MatSnackBar } from \"@angular/material\";\r\nimport * as Rx from \"rxjs/Rx\";\r\nimport { NgxUiLoaderService } from 'ngx-ui-loader';\r\n\r\n\r\n@Injectable()\r\nexport class WebsocketService {\r\n constructor( protected _snackBar: MatSnackBar,\r\n private spinner: NgxUiLoaderService,) {}\r\n\r\n private subject: Rx.Subject;\r\n\r\n public connect(url): Rx.Subject {\r\n //const url = \"ws://localhost:1372/\"\r\n if (!this.subject) {\r\n this.subject = this.create(url);\r\n console.log(\"Successfully connected: \" + url);\r\n }\r\n return this.subject;\r\n }\r\n\r\n private create(url): Rx.Subject {\r\n // const url = \"ws://localhost:1372/\"\r\n\r\n\r\n let ws = new WebSocket(url);\r\n let observable = Rx.Observable.create((obs: Rx.Observer) => {\r\n ws.onmessage = obs.next.bind(obs);\r\n ws.onerror = obs.error.bind(obs);\r\n ws.onclose = obs.complete.bind(obs);\r\n return ws.close.bind(ws);\r\n });\r\n let observer = {\r\n next: (data: Object) => {\r\n if (ws.readyState === WebSocket.OPEN) {\r\n this.spinner.start();\r\n ws.send(JSON.stringify(data));\r\n }\r\n }\r\n };\r\n return Rx.Subject.create(observer, observable);\r\n }\r\n}\r\n"],"sourceRoot":"webpack:///","file":"main.js"}