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

37 lines
883 B
JavaScript
Raw Normal View History

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 {
2017-11-16 12:47:18 +00:00
constructor($rootScope) {
this.loaderStatus = 0;
this.$rootScope = $rootScope;
}
show(message) {
2018-01-24 08:06:04 +00:00
if (this.snackbar) this.snackbar.show({message: message});
}
showMessage(message) {
this.show(message);
}
showError(message) {
this.show(`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
module.service('vnApp', App);