import { IMineMeldAPIService } from './services/minemeldapi' ; import { IMinemeldStatusService } from './services/status' ; import { IMineMeldWebUIExtensionsLoaderService } from './services/webuiextensionsloader' ; ngInject export function minemeldInit ( $state , $rootScope , $cookies , MineMeldAPIService , MinemeldStatusService , MineMeldWebUIExtensionsLoaderService ) { document . getElementById ( 'loader' ) . style . display = 'none' ; $rootScope . mmBack = ( state ? ) => { if ( ( $rootScope . mmPreviousState ) && ( ! $rootScope . mmPreviousState . state . abstract ) ) { $state . go ( $rootScope . mmPreviousState . state , $rootScope . mmPreviousState . params ) ; return ; } $state . go ( state ) ; return ; } ; $rootScope . $on ( '$stateChangeStart' , ( event , toState , toParams ) => { if ( toState . name !== 'login' && ! MineMeldAPIService . isLoggedIn ( ) ) { event . preventDefault ( ) ; $state . go ( 'login' ) ; } } ) ; $rootScope . $on ( '$stateChangeSuccess' , ( event , toState , toParams , fromState , fromParams ) => { $rootScope . mmPreviousState = { state : fromState , params : fromParams } ; MineMeldAPIService . cancelAPICalls ( ) ; } ) ; }