import { CommonModule } from '@angular/common';
import { Component, OnInit, ViewChild, inject } from '@angular/core';
import { Router, RouterOutlet } from '@angular/router';
import { STColumn, STComponent } from '@delon/abc/st';
import { SFSchema } from '@delon/form';
import { ModalHelper, _HttpClient } from '@delon/theme';
import { SHARED_IMPORTS } from '@shared';

@Component({
  selector: 'data-v-navigation',
  standalone: true,
  imports: [RouterOutlet, CommonModule, ...SHARED_IMPORTS],
  template: ` <div class="navigation-container">
    <ul>
      <li class="dropdown-submenu" *ngFor="let menu of menuList" (mouseover)="menuOver(menu, $event)">
        <a href="javascript:void(0);" class="menu-group" [class.active]="isActive(menu.MenuGrpCd)"
        (click)="navigate(menu)">{{ menu.text }}</a>
      </li>
    </ul>
  </div>`,
  styleUrls: ['./navigation.component.less']
})
export class DataVNavigationComponent implements OnInit {
  private readonly http = inject(_HttpClient);
  private readonly modal = inject(ModalHelper);
  private readonly router = inject(Router);

  menuList: any = [
    {
      code: '01',
      text: '我的工作站',
      url: '/'
    },
    {
      code: '02',
      text: '化验总览',
      url: '/data-v/s1'
    },
    {
      code: '03',
      text: '3D',
      url: '/data-v/threejs'
    },
    {
      text: '...'
    }
  ];

  imageUrl: string = 'assets/dashboard/menu_btn_l.png';
  title: string = 'Label';

  context: string = '2024-02-29 10:00';

  ngOnInit(): void { }

  add(): void { }

  menuOver(menu: any, $event: any) { }

  isActive(menu: any) { }

  // 新的 navigate 方法
  navigate(menu: any) {
    if (menu.url) {
      this.router.navigateByUrl(menu.url);
    }

    // if (menu.code == '01') {
    //   // 你可能想根据菜单项来确定导航的路径
    //   this.router.navigateByUrl('/'); // 将'/data-v/s1'替换为正确的路径
    // } else if (menu.code == '02') {
    //   // 你可能想根据菜单项来确定导航的路径
    //   this.router.navigateByUrl('/data-v/s1'); // 将'/data-v/s1'替换为正确的路径
    // }
  }
}
