import { Component } from '@angular/core';
import {MatCard, MatCardContent} from '@angular/material/card';
import {MatDivider} from '@angular/material/divider';
import {MatTab, MatTabGroup} from '@angular/material/tabs';
import {
  MatCell,
  MatCellDef,
  MatColumnDef,
  MatHeaderCell, MatHeaderCellDef,
  MatHeaderRow,
  MatHeaderRowDef,
  MatRow, MatRowDef, MatTable
} from '@angular/material/table';
import {MatIconButton} from '@angular/material/button';
import {MatList, MatListItem} from '@angular/material/list';
import {Bean} from '../../models/Bean';
import {SystemService} from '../../services/system.service';
import {NameValueItem} from '../../models/name-value-item';

@Component({
  selector: 'app-settings.component',
  imports: [
    MatCard,
    MatCardContent,
    MatDivider,
    MatTab,
    MatTabGroup,
    MatCell,
    MatCellDef,
    MatColumnDef,
    MatHeaderCell,

    MatTable,
    MatHeaderCellDef,
    MatHeaderRow,
    MatHeaderRowDef,
    MatRow,
    MatRowDef
  ],
  templateUrl: './settings.component.html',
  styleUrl: './settings.component.scss'
})
export class SettingsComponent {
  properties: NameValueItem[] = [] ;

  displayedColumns: string[] = ['name', 'value'];


  constructor(private systemService: SystemService) {
    this.retrieveProperties();
  }


  retrieveProperties(): void {
    this.systemService.getDataSourceProperties()
      .subscribe(
        (data: NameValueItem[]) => {
          this.properties = data;
          console.log(data);
        },
        (error: any) => {
          console.log(error);
        }
        );
  }
}
