2017-06-05 07:01:21 +00:00
|
|
|
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;
|
|
|
|
}
|
2017-06-05 07:01:21 +00:00
|
|
|
show(message) {
|
2018-01-26 07:01:26 +00:00
|
|
|
this.timeout = window.snackbarTimeout || 2000;
|
2018-01-25 10:35:41 +00:00
|
|
|
if (this.snackbar) this.snackbar.show({message: message, timeout: this.timeout});
|
2017-06-05 07:01:21 +00:00
|
|
|
}
|
|
|
|
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-06-05 07:01:21 +00:00
|
|
|
}
|
2017-11-16 13:30:17 +00:00
|
|
|
App.$inject = ['$rootScope'];
|
2017-11-16 12:47:18 +00:00
|
|
|
|
2017-06-05 07:01:21 +00:00
|
|
|
module.service('vnApp', App);
|