UNPKG

tfabrica

Version:

library for TFabrica - TechSol

100 lines 4.61 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 router_1 = require("@angular/router"); var tfabrica_shared_service_1 = require("../main/tfabrica.shared.service"); var tfabrica_usermenu_service_1 = require("../main/tfabrica.usermenu.service"); var TfabricaDashboardComponent = (function () { function TfabricaDashboardComponent(router, tfabricaSharedService, tfabricaUserMenuService) { var _this = this; this.router = router; this.tfabricaSharedService = tfabricaSharedService; this.tfabricaUserMenuService = tfabricaUserMenuService; this.level = 0; this.userData = tfabricaSharedService.getUser(); this.loading = false; if (this.userData.isLogged) { this.createMenu(); } console.log("TfabricaDashboardComponent constructor"); this.subscription = tfabricaSharedService.userDataLogged$.subscribe(function (userData) { _this.userData = userData; if (_this.userData != null) { if (_this.userData.isLogged) { _this.createMenu(); } } }); } TfabricaDashboardComponent.prototype.createMenu = function () { var _this = this; if (!this.userData.isLogged) return; this.tfabricaUserMenuService.menu() .subscribe(function (userMenus) { console.log(userMenus); _this.menuVoices = userMenus; _this.displayVoices = userMenus; _this.prevDisplayVoices = []; console.log(_this.menuVoices); _this.loading = false; }, function (err) { // Log errors if any console.log(err); _this.loading = false; }); }; TfabricaDashboardComponent.prototype.selectSingleVoice = function (voice) { console.log(voice); console.log(voice["subMenu"]); // if voice have subMenu go Inside at next Level if (voice["subMenu"] != null && voice["subMenu"] != undefined && voice["subMenu"].length > 0) { this.prevDisplayVoices.push({ level: this.level, displayVoices: this.displayVoices }); this.displayVoices = voice["subMenu"]; this.level = this.level + 1; } else { var path = voice['path']; if (path.charAt(0) == "/") { this.tfabricaSharedService.selectedVoice = voice; this.tfabricaSharedService.setSelectedVoice(voice); path = path.substring(1); } if (path.charAt(0) == "h") { this.loading = true; window.location.href = path; return; } this.router.navigate(['main', { outlets: { 'main': path } }]); } }; TfabricaDashboardComponent.prototype.backToPreviousMenu = function () { this.displayVoices = this.prevDisplayVoices[this.prevDisplayVoices.length - 1].displayVoices; this.prevDisplayVoices.splice(this.prevDisplayVoices.length, 1); this.level = this.level - 1; }; return TfabricaDashboardComponent; }()); TfabricaDashboardComponent = __decorate([ core_1.Component({ selector: 't-dashboard', template: require('./tfabrica.dashboard.component.html') }), __metadata("design:paramtypes", [router_1.Router, tfabrica_shared_service_1.TfabricaSharedService, tfabrica_usermenu_service_1.TfabricaUserMenuService]) ], TfabricaDashboardComponent); exports.TfabricaDashboardComponent = TfabricaDashboardComponent; //# sourceMappingURL=tfabrica.dashboard.component.js.map