import { CommonModule } from '@angular/common';
import { Component, OnInit, ViewChild, inject } from '@angular/core';
import { ActivatedRoute, Router } 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';
import { AgGridAngular } from 'ag-grid-angular';
import { ColDef } from 'ag-grid-community'; // Column Definition Type Interface
import * as echarts from 'echarts';
import { NzBadgeModule } from 'ng-zorro-antd/badge';
import { NzListModule } from 'ng-zorro-antd/list';
import { NzProgressModule } from 'ng-zorro-antd/progress';
import { IMqttMessage, MqttService } from 'ngx-mqtt';
import { Subscription } from 'rxjs';

import { ChartComponentComponent } from './chart-component/chart-component.component';
import { DataVCardComponent } from '../card/card.component';
import { Menu } from '../menu/lj-menu.interface';
import { DataVTitleComponent } from '../title/title.component';

@Component({
  selector: 'app-data-v-s1',
  standalone: true,
  templateUrl: './second1.component.html',
  styleUrls: ['./second1.component.less'],
  imports: [
    CommonModule,
    NzBadgeModule,
    NzProgressModule,
    AgGridAngular,
    DataVCardComponent,
    DataVTitleComponent,
    NzListModule,
    ...SHARED_IMPORTS,
    ChartComponentComponent
  ]
})
export class DataVSecond1Component implements OnInit {
  menu: Menu | null = null;
  children: Menu[] | null = null;

  constructor(
    private route: ActivatedRoute,
    private router: Router
  ) {}

  ngOnInit(): void {
    const currentNavigation = this.router.getCurrentNavigation();
    if (currentNavigation?.extras.state) {
      this.menu = currentNavigation.extras.state['menu'];
      // 这里假设 'menu' 是事先定义好的属性，它应该是正确的键
      this.children = this.menu?.children || null;
      console.log('穿带过来的菜单参数');
      console.log(this.menu);
      console.log(this.children);
    }
  }

  // 如果需要导航到子菜单的特定页面，继续实现该逻辑
  navigateToChild(childMenu: Menu): void {
    if (childMenu.link) {
      this.router.navigateByUrl(childMenu.link);
    }
  }

  // ngOnDestroy(): void {
  //   this.subscription.unsubscribe();
  // }
}
