import { SNApplication, SNAlertManager, Environments, platformFromString } from 'snjs'; import angular from 'angular'; import { getPlatformString } from '@/utils'; import { AlertManager } from '@/services/alertManager'; import { WebDeviceInterface } from '@/web_device_interface'; export class Application extends SNApplication { /* @ngInject */ constructor($compile, $rootScope) { const deviceInterface = new WebDeviceInterface(); super({ environment: Environments.Web, platform: platformFromString(getPlatformString()), namespace: '', host: window._default_sync_server, deviceInterface: deviceInterface, swapClasses: [ { swap: SNAlertManager, with: AlertManager } ] }); this.$compile = $compile; this.$rootScope = $rootScope; deviceInterface.setApplication(this); this.overrideComponentManagerFunctions(); } overrideComponentManagerFunctions() { function openModalComponent(component) { const scope = this.$rootScope.$new(true); scope.component = component; const el = this.$compile("")(scope); angular.element(document.body).append(el); } function presentPermissionsDialog(dialog) { const scope = this.$rootScope.$new(true); scope.permissionsString = dialog.permissionsString; scope.component = dialog.component; scope.callback = dialog.callback; const el = this.$compile("")(scope); angular.element(document.body).append(el); } this.componentManager.openModalComponent = openModalComponent.bind(this); this.componentManager.presentPermissionsDialog = presentPermissionsDialog.bind(this); } }