salix/client/core/src/lib/app.js

36 lines
899 B
JavaScript
Raw Normal View History

2018-02-10 15:18:01 +00:00
import ngModule 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 {
2017-11-16 12:47:18 +00:00
constructor($rootScope) {
this.loaderStatus = 0;
this.$rootScope = $rootScope;
}
showMessage(message) {
if (this.snackbar)
this.snackbar.show({message: message});
}
showError(message) {
if (this.snackbar)
this.snackbar.showError({message: `Error: ${message}`});
}
2017-11-16 12:47:18 +00:00
pushLoader() {
this.loaderStatus++;
if (this.loaderStatus === 1)
this.$rootScope.loading = true;
}
popLoader() {
this.loaderStatus--;
if (this.loaderStatus === 0)
this.$rootScope.loading = false;
}
}
2017-11-16 13:30:17 +00:00
App.$inject = ['$rootScope'];
2017-11-16 12:47:18 +00:00
2018-02-10 15:18:01 +00:00
ngModule.service('vnApp', App);