All files / src/components/app appCtrl.ts

66.67% Statements 8/12
16.67% Branches 1/6
100% Functions 1/1
66.67% Lines 8/12

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 694x   4x                                                             4x   4x                                               4x         4x   4x   4x
import AppErrorHandler from "../../error/AppErrorHandler";
import ErrorHandler from "../../error/ErrorHandler";
import IntlProvider from "./services/IntlProvider";
 
/**
 * The singleton application controller so it is accessable from everywhere
 */
class AppCtrl {
	/**
	 * The auth provider of the application
	 */
	//authProvider?: AuthProvider;
 
	/**
	 * The error handler of the application
	 */
	errorHandler: ErrorHandler;
 
	/**
	 * The logged in user of the application
	 */
	//user?: AppUser;
 
	/**
	 * The internationalization provider of the app
	 */
	intlProvider?: IntlProvider;
 
	/**
	 * Initializes the application controller
	 */
	init() {
 
		console.log('Initializing appCtrl...');
 
		Iif ((window as any).getAppConfig !== undefined) {
 
			const {
				// auth,
				errorHandler,
				intl
			} = (window as any).getAppConfig();
 
			// if (auth !== undefined) {
 
			// 	appCtrl.authProvider = new OidcProvider(auth);
			// }
 
			if (intl !== undefined) {
 
				appCtrl.intlProvider = new IntlProvider(intl.lang, intl.data);
			}
 
			appCtrl.errorHandler = errorHandler !== undefined ?
				errorHandler :
				new AppErrorHandler();
		}
		else { // No configuration was provided
 
			appCtrl.errorHandler = new AppErrorHandler();
		}
	}
}
 
const appCtrl = new AppCtrl();
 
appCtrl.init();
 
export default appCtrl;