import {module} from '../module'; /** * The main application class. * * @property {String} name The application name. * @property {Snackbar} snackbar The main object to show messages. */ export default class App { constructor($rootScope) { this.loaderStatus = 0; this.$rootScope = $rootScope; this.timeout = window.snackbarTimeout || 2000; } show(message) { if (this.snackbar) this.snackbar.show({message: message, timeout: this.timeout}); } showMessage(message) { this.show(message); } showError(message) { this.show(`Error: ${message}`); } pushLoader() { this.loaderStatus++; if (this.loaderStatus === 1) this.$rootScope.loading = true; } popLoader() { this.loaderStatus--; if (this.loaderStatus === 0) this.$rootScope.loading = false; } } App.$inject = ['$rootScope']; module.service('vnApp', App);