UNPKG

tfabrica

Version:

library for TFabrica - TechSol

119 lines 5.35 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 tfabrica_shared_service_1 = require("./tfabrica.shared.service"); var router_1 = require("@angular/router"); var tfabrica_usermenu_service_1 = require("../main/tfabrica.usermenu.service"); var TfabricaSidenavComponent = (function () { function TfabricaSidenavComponent(tfabricaSharedService, tfabricaUserMenuService, router) { var _this = this; this.tfabricaSharedService = tfabricaSharedService; this.tfabricaUserMenuService = tfabricaUserMenuService; this.router = router; this.userData = tfabricaSharedService.getUser(); this.loading = false; this.menuVoices = []; if (this.userData.isLogged) { this.createMenu(); } this.subscriptionShared = tfabricaSharedService.userDataLogged$.subscribe(function (userData) { _this.userData = userData; if (_this.userData != null) { if (_this.userData.isLogged) { _this.createMenu(); } } }); this.subscription = tfabricaSharedService.mainLeftSidenavToggled$.subscribe(function (toogle) { _this.toggleSidenavMenu(); }); } TfabricaSidenavComponent.prototype.toggleSidenavMenu = function () { }; TfabricaSidenavComponent.prototype.backToHome = function () { this.tfabricaSharedService.toggleMainLeftSidenav(true); this.router.navigate(['/main', { outlets: { 'main': ['home'] } }]); }; TfabricaSidenavComponent.prototype.goToVoice = function (voiceName) { console.log(voiceName); this.tfabricaSharedService.toggleMainLeftSidenav(true); this.router.navigate(['/main', { outlets: { 'main': [voiceName] } }]); }; TfabricaSidenavComponent.prototype.createMenu = function () { var _this = this; if (!this.userData.isLogged) return; this.menuVoices = Array(); this.tfabricaUserMenuService.menu() .subscribe(function (userMenus) { console.log(userMenus); _this.menuVoices = userMenus; _this.loading = false; _this.designMenu(); }, function (err) { // Log errors if any console.log(err); _this.loading = false; }); }; TfabricaSidenavComponent.prototype.designMenu = function () { var actThis = this; this.displayVoices = Array(); actThis.attachSubMenu(this.menuVoices); console.log(this.displayVoices); }; TfabricaSidenavComponent.prototype.attachSubMenu = function (subMenu) { var actThis = this; subMenu.forEach(function (entry) { actThis.displayVoices.push(entry); if (entry.isOpen) { actThis.attachSubMenu(entry.subMenu); } }); }; TfabricaSidenavComponent.prototype.selectSingleVoice = function (singleVoice) { console.log(singleVoice); singleVoice.isOpen = !singleVoice.isOpen; if (singleVoice.subMenu.length == 0) { this.tfabricaSharedService.toggleMainLeftSidenav(true); var path = singleVoice.path; if (path.startsWith("/")) { this.tfabricaSharedService.selectedVoice = singleVoice; this.tfabricaSharedService.setSelectedVoice(singleVoice); path = path.substring(1); } if (path.startsWith("http")) { this.loading = true; window.location.href = path; return; } this.router.navigate(['main', { outlets: { 'main': path } }]); } this.designMenu(); }; return TfabricaSidenavComponent; }()); __decorate([ core_1.ViewChild('tleftmenu'), __metadata("design:type", Object) ], TfabricaSidenavComponent.prototype, "tleftmenu", void 0); TfabricaSidenavComponent = __decorate([ core_1.Component({ selector: 't-sidenav', template: require('./tfabrica.sidenav.component.html') }), __metadata("design:paramtypes", [tfabrica_shared_service_1.TfabricaSharedService, tfabrica_usermenu_service_1.TfabricaUserMenuService, router_1.Router]) ], TfabricaSidenavComponent); exports.TfabricaSidenavComponent = TfabricaSidenavComponent; //# sourceMappingURL=tfabrica.sidenav.component.js.map