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

38 lines
963 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;
}
show(message) {
this.timeout = window.snackbarTimeout || 2000;
2018-01-25 10:35:41 +00:00
if (this.snackbar) this.snackbar.show({message: message, timeout: this.timeout});
}
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
2018-02-10 15:18:01 +00:00
ngModule.service('vnApp', App);