import { Injectable } from '@angular/core';

@Injectable()
export class MenuService {

    menuItems: Array<any>;
    levelOnemenuItems: Array<any>;
    levelTwomenuItems: Array<any>;


    constructor() {
        this.menuItems = [];
        this.levelOnemenuItems = [];
        this.levelTwomenuItems = [];
    }

    addMenu(items: Array<{
        text: string,
        heading?: boolean,
        link?: string,     // internal route links
        elink?: string,    // used only for external links
        target?: string,   // anchor target="_blank|_self|_parent|_top|framename"
        icon?: string,
        alert?: string,
        submenu?: Array<any>
    }>) {
        items.forEach((item) => {
            this.menuItems.push(item);
        });
    }

    getMenu() {
        return this.menuItems;
    }


    addLevelOneMenu(items: Array<{
        text: string,
        heading?: boolean,
        link?: string,     // internal route links
        elink?: string,    // used only for external links
        target?: string,   // anchor target="_blank|_self|_parent|_top|framename"
        icon?: string,
        alert?: string,
        submenu?: Array<any>
    }>) {
        items.forEach((item) => {
            this.levelOnemenuItems.push(item);
        });
    }

    getLevelOneMenu() {
        // TODO 过渡期正式环境，横向不展示菜单
        //return [];

        return this.levelOnemenuItems;
    }

    addLevelTwoMenu(items: Array<{
        text: string,
        heading?: boolean,
        link?: string,     // internal route links
        elink?: string,    // used only for external links
        target?: string,   // anchor target="_blank|_self|_parent|_top|framename"
        icon?: string,
        alert?: string,
        submenu?: Array<any>
    }>) { 
        items.forEach((item) => {
            this.levelTwomenuItems.push(item);
        });
    }

    resetLevelTwoMenu(items: Array<{
        text: string,
        heading?: boolean,
        link?: string,     // internal route links
        elink?: string,    // used only for external links
        target?: string,   // anchor target="_blank|_self|_parent|_top|framename"
        icon?: string,
        alert?: string,
        submenu?: Array<any>
    }>) { 
        this.levelTwomenuItems=items;
        
    }

    getLevelTwoMenu() {
         // TODO 过渡期正式环境，纵向菜单展示全部菜单
        // return this.menuItems;

        return this.levelTwomenuItems;
    }

   

}
