import {ChangeDetectionStrategy, Component, Input, OnInit} from '@angular/core';
import {LocalQueryParameter} from "../../../models/enea/ParametricQuery";
import {DataService} from "../../../services/data.service";
import {Parameter, Intervals} from "../../../models/Parameter";
import {ParameterResolverService} from "../../../services/parameter-resolvers/parameter-resolver.service";
import { UtilsService } from 'src/app/services/utils.service';
import {InputTextModule} from 'primeng/inputtext';
import {AutoCompleteModule} from 'primeng/autocomplete';
import { result } from 'validate.js';
import { TranslateService } from '@ngx-translate/core';

@Component({
  selector: 'app-datasource-configuration-parameter',
  templateUrl: './datasource-configuration-parameter.component.html',
  styleUrls: ['./datasource-configuration-parameter.component.css'],
  changeDetection: ChangeDetectionStrategy.OnPush
})
export class DatasourceConfigurationParameterComponent implements OnInit {
  @Input() queryParameter?: LocalQueryParameter;
  @Input() parameter?: Parameter;
  /*@Input() types:any[]  = [];*/

  intervals = Intervals.getIntervals();  

  
  constructor(private dataService: DataService, private parameterResolver: ParameterResolverService,
    private translate: TranslateService,
    private utils: UtilsService) {
      
  }

  ngOnInit(): void {
    
  }

  get types() {
    return this.parameterResolver.getParameterOptionsByDataType(this.queryParameter?.type);
  }

  splitString (inputString : String): String {
    if(inputString === "") return "Empty String";
    
    const lang = this.translate.currentLang; 
    var resultString = "";
    var array = inputString.split('|');
    if (lang === "it") {resultString = array[0]}
    else{
      resultString = array[3];
    };
    return resultString;
  }

}
