site-menu.component.ts 9.69 KB
import { Component, AfterViewInit, Input, OnInit } from '@angular/core';
import { ApplicationService } from '../services/application.service';
import { Router } from '@angular/router';

declare var jQuery: any;

@Component({
    selector: 'site-menu',    
    template: `
<nav class="navbar navbar-inverse navbar-fixed-top">
        <div class="container-fluid">
            <div class="navbar-header">

                <a class="navbar-brand" href="#"><img src="app/assets/img/logo-main.png" class="img-responsive" alt=""></a>
                <div class="">
                    <div class="btn-group pull-right">
                        <ul class="nav navbar-nav navbar-right visible-sm visible-md">
                            <li class="marginR5" data-toggle="tooltip" data-placement="top" title="Logout"><a href="login.html"><i class="fa fa-power-off"></i></a></li>
                        </ul>
                    </div>
                    <div class="btn-group pull-right mar-top17 visible-sm visible-md">
                        <button type="button" class="btn btn-primary dropdown-toggle " data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                            Welcome Maribel Brogden <span class="caret"></span>
                        </button>
                        <ul class="dropdown-menu">
                            <li><a href="#"><strong>Date:</strong> 11/21/2016</a></li>
                        </ul>
                    </div>
                </div>
                <button type="button" class="navbar-toggle collapsed mar-top17" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
            </div>

            <div id="navbar" class="navbar-collapse collapse">
                <ul class="nav navbar-nav toperMenu-spaceleft">
                    <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Profile<span class="caret"></span></a>
                        <ul class="dropdown-menu">
                            <li><a routerLink="admin-update-profile" routerLinkActive="active">Update Profile</a></li>
                            <li><a routerLink="admin-change-password" routerLinkActive="active">Change Password</a></li>
                            <li><a routerLink="admin-change-user-id" routerLinkActive="active">Change User ID</a></li>
                        </ul>
                    </li>
                    <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Licenses<span class="caret"></span></a>
                        <ul class="dropdown-menu">
                            <li><a routerLink="admin-search-license" routerLinkActive="active">Search License</a></li>
                            <li><a routerLink="admin-add-new-license" routerLinkActive="active">Add New License</a></li>
                            <li><a routerLink="admin-setup-test-account" routerLinkActive="active">Setup Test Account</a></li>
                        </ul>
                    </li>
                    <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Product Features<span class="caret"></span></a>
                        <ul class="dropdown-menu">
                            <li><a routerLink="admin-manage-discount-code" routerLinkActive="active">Manage Discount Code</a></li>
                            <li><a routerLink="admin-subscription-price" routerLinkActive="active">Subscription Price</a></li>
                        </ul>
                    </li>
                    <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Users<span class="caret"></span></a>
                        <ul class="dropdown-menu">
                            <li><a routerLink="admin-list-user" routerLinkActive="active">List User</a></li>
                            <li><a routerLink="admin-add-user" routerLinkActive="active">Add User</a></li>
                            <li><a routerLink="admin-unblock-user" routerLinkActive="active">Unblock User</a></li>
                            <li><a routerLink="admin-user-group" routerLinkActive="active">User Group</a></li>
                        </ul>
                    </li>
                    <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Reports<span class="caret"></span></a>
                        <ul class="dropdown-menu">
                            <li><a routerLink="admin-usage-report" routerLinkActive="active">Usage Report</a></li>
                            <li><a routerLink="customer-summary-report" routerLinkActive="active">Customer Summary Report</a></li>
                            <li><a routerLink="admin-expiring-subscription-report" routerLinkActive="active">Expiring Subscription Report</a></li>
                            <li><a routerLink="admin-new-subscription-report" routerLinkActive="active">New Subscription Report</a></li>
                            <li><a routerLink="admin-subscription-cancellation-report" routerLinkActive="active">Subscription Cancellation Report</a></li>
                            <li><a routerLink="admin-net-ad-subscription-report" routerLinkActive="active">Net AD Subscription Report</a></li>
                            <li><a routerLink="admin-site-license-usage-report" routerLinkActive="active">Site License Usage Report</a></li>
                            <li><a routerLink="admin-discount-code-report" routerLinkActive="active">Discount Code Report</a></li>
                            <li><a routerLink="admin-image-export-report" routerLinkActive="active">Image Export Report</a></li>
                        </ul>
                    </li>
                    <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Site Account<span class="caret"></span></a>
                        <ul class="dropdown-menu">
                            <li><a routerLink="admin-add-building-level-account" routerLinkActive="active">Add Building Level Account</a></li>
                        </ul>
                    </li>
                    <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Profile<span class="caret"></span></a>
                        <ul class="dropdown-menu">
                            <li><a routerLink="admin-view-update-profile" >View/Update Profile</a></li>
                            <li><a routerLink="admin-manage-modesty-settings" >Manage Modesty Settings</a></li>
                            <li><a routerLink="admin-manage-module" >Manage Module</a></li>
                        </ul>
                    </li>
                    <li><a href="#">Product</a></li>
                </ul>
                <!--logout-->
                <div class="wel-brog">
                    <div class="btn-group pull-right mob1">
                        <ul class="nav navbar-nav navbar-right hidden-sm">
                            <li class="marginR5" data-toggle="tooltip" data-placement="top" title="Logout"><a href="login.html"><i class="fa fa-power-off"></i></a></li>
                        </ul>
                    </div>
                    <div class="btn-group pull-right hidden-sm mar-top17 mob2">
                        <button type="button" class="btn btn-primary dropdown-toggle btn-sm" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                            Welcome Maribel Brogden <span class="caret"></span>
                        </button>
                        <ul class="dropdown-menu">
                            <li><a href="#"><strong>Date:</strong> 05/08/2017</a></li>
                        </ul>
                    </div>
                </div>
                <!--logout-->
            </div>
        </div>
    </nav>
`
})
export class SiteMenuComponent implements AfterViewInit {

    @Input('type')
    type: string = 'fixed';

    @Input('hidden')
    hidden: boolean = true;

    constructor(public application: ApplicationService, private router: Router) { }

    hiddenClass(): string {
        if (this.hidden)
            return "hidden";
        else
            "";
    }

    ngAfterViewInit(): void {
        setTimeout(() => this.attachSideBar(), 2000);
    }

    getMenuIconOrText(menuItem: any): string {
        if (menuItem.icon == null)
            return menuItem.name;
        else
            return "<i class='large " + menuItem.icon + " icon'></i>";
    }

    makeActive(index: number): string {
        if (index == 0)
            return "active";
        else
            return "";
    }

    attachSideBar(): void {
        if (jQuery != null) {
            jQuery('.ui.sidebar')
                .sidebar('attach events', '.toc.item');

            jQuery('.ui.dropdown')
                .dropdown();
        }
    }

    navigateToUrl(url: string): void {
        this.router.navigate([url]);
    }

}