import { Component, Input, OnInit } from '@angular/core';
import { RouterHandler } from '../../../shared/services/router-handler.service';
import { SearchResult } from '../../../shared/server-services/search-service';

@Component({
  selector: 'app-search-view-result',
  templateUrl: './search-view-result.component.html',
  styleUrls: ['./search-view-result.component.scss']
})
export class SearchViewResultComponent implements OnInit {

  @Input() result: SearchResult;

  constructor(private routerHandler: RouterHandler) { }

  ngOnInit(): void {
  }

  public openPath(){
    let fragment = this.routerHandler.getRoute().fragment;
    fragment['path'] = this.result.dir;
    fragment['file'] = this.result.file.fullName;

    this.routerHandler.navigate(['/room/', this.result.resourceId, 'drive'], {fragment: this.routerHandler.fragmentToRaw(fragment)});
  }

}
