UNPKG

bitcitawebfrontlib-ibsalut

Version:

Angular CLI project used by other Angular projects in the bitcita web project.<br />

67 lines 3.77 kB
"use strict"; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; Object.defineProperty(exports, "__esModule", { value: true }); var core_1 = require("@angular/core"); var rxjs_1 = require("rxjs"); /** * * TODO: better modal implementation that doesn't use window.confirm */ var MessageService = /** @class */ (function () { function MessageService() { // Observable string sources this.observableMessagesSource = new rxjs_1.Subject(); //mensajes generales que se mostrarán como un dialog en el centro de la pantalla this.observableNotificationsSource = new rxjs_1.Subject(); //notifiaciones que se mostrarán como un growl this.observableErrorsSource = new rxjs_1.Subject(); //errores del servidor que se mostrarán como un dialog igual con la traza del error this.observableNotificacionsErrorsSource = new rxjs_1.Subject(); //errores controlados enviados del servidor que se mostrarán como una ventanita similar al growl this.observableMessages = this.observableMessagesSource.asObservable(); this.observableErrors = this.observableErrorsSource.asObservable(); this.observableNotificationsErrors = this.observableNotificacionsErrorsSource.asObservable(); this.observableNotifications = this.observableNotificationsSource.asObservable(); } /** * Ask user to confirm an action. `message` explains the action and choices. * Returns promise resolving to `true`=confirm or `false`=cancel */ MessageService.prototype.confirm = function (message) { return new Promise(function (resolve) { return resolve(window.confirm(message || " OK?")); }); }; /** Enviamos un mensaje. Como mínimo el componente DialogComponent lo recibirá y lo mostrará al usuario */ MessageService.prototype.sendMessage = function (message) { this.observableMessagesSource.next(message); }; /** * Enviamos un error. Si el objeto es de tipo notificación se mostrará como una ventana arriba a la derecha con un close para * cerrarlo. Si no es de tipo notificación el componente DialogComponent lo recibirá y lo mostrará al usuario en el centro del usuario **/ MessageService.prototype.sendError = function (error) { //console.log('sendError', error); if (error.notificacion) { this.observableNotificacionsErrorsSource.next(error); } else { this.observableErrorsSource.next(error); } }; /** Enviamos una notificación. El componente NotificationComponent lo recibirá y la mostrará en pantalla */ MessageService.prototype.sendNotification = function (message) { this.observableNotificationsSource.next(message); }; MessageService = __decorate([ core_1.Injectable(), __metadata("design:paramtypes", []) ], MessageService); return MessageService; }()); exports.MessageService = MessageService; //# sourceMappingURL=message.service.js.map