<div class="grid pt-6 pl-6 flex">
  <div class="flex col-12 justify-content-center">
    <p class="text-3xl">{{resource.resourceName}}</p>
  </div>
  <div class="col-6 flex flex-column justify-content-center">
    <div class="col-12 text-center">
      <img [src]="imagePath+'/'+resource.idResource" class="imageSize" >
    </div>
    <div class="col-12">
      <p-panel class="col-12 inline">
        <div class="flex align-items-center"><div class="col-3 inline my-0" [ngStyle]="{color:'var(--surface-500)'}">Resource language</div><div class="my-0">{{resource.language?.name}}</div></div>
        <div class="flex align-items-center"><div class="col-3 inline my-0" [ngStyle]="{color:'var(--surface-500)'}">Resource origin</div> <div class="my-0 overflow-text"><a href="{{resource.resourceOrigin}}">{{resource.resourceOrigin}}</a></div></div>
        <div class="flex align-items-center"> <div class="col-3 inline my-0" [ngStyle]="{color:'var(--surface-500)'}">Resource type</div><div class="my-0">{{resource.resourceType?.name}}</div></div>
        <div class="flex align-items-center"><div class="col-3 inline my-0" [ngStyle]="{color:'var(--surface-500)'}">Organization name</div><div class="my-0">{{resource.contactInstitution}}</div></div>
        <div class="flex align-items-center"><div class="col-3 inline my-0"[ngStyle]="{color:'var(--surface-500)'}">Contact email</div><div class="my-0"></div>{{resource.contactEmail}}</div>
        <div class="flex align-items-center"><div class="col-3 inline my-0"[ngStyle]="{color:'var(--surface-500)'}">Contact phone</div><div class="my-0">{{resource.contactPhone}}</div></div>
        <div class="flex align-items-center"><div class="col-3 inline my-0" [ngStyle]="{color:'var(--surface-500)'}">Resource main url</div><div class="overflow-text my-0"><a href="{{resource.mainURL}}">{{resource.mainURL}}</a></div></div>
        <div class="flex align-items-center"><div class="col-3 inline my-0" [ngStyle]="{color:'var(--surface-500)'}">Citation (DOI)</div><div class="overflow-text my-0">{{resource.citation}}</div></div>
      </p-panel>
    </div>
  </div>
  <div class="col-6 flex flex-column">
  <p-panel header="Short summary" class="col-12 p-d-block">
      <div class="flex "> {{resource.description}}</div>
      <div class="flex  mt-5 ">
        <div class="inline col-3 my-0"[ngStyle]="{color:'var(--surface-500)'}">Sectors</div>
        <div class="inline my-0" *ngFor="let sector of resource.sectors">
          <img class="sector mx-2" [src]="'assets/sectors/'+sector.sectorIcon" pTooltip="{{sector.name}}">
        </div>
      </div>
      <div class="flex ">
        <div class="inline col-3 my-0" [ngStyle]="{color:'var(--surface-500)'}">Regions</div>

        <div *ngFor="let region of resource.regions" class="inline my-0">
          <p class=" my-0 py-2 mx-2" >{{region.name}}</p>
        </div>
      </div>
      <div class="flex flex-wrap">
        <div class="inline col-3 my-0" [ngStyle]="{color:'var(--surface-500)'}">Relevant pest(s)</div>
        <div *ngFor="let pest of resource.pests" class="inline my-0">
          <div class=" my-0 py-2 mx-2" >{{pest.commonName}}</div>
        </div>
      </div>
      <div class="flex flex-wrap">
        <div class="inline col-3 my-0" [ngStyle]="{color:'var(--surface-500)'}"> Relevant crop(s)</div>

        <div *ngFor="let crop of resource.crops" class="inline my-0">
          <p class="my-0 py-2 mx-2" >{{crop.commonName}}</p>

        </div>
      </div>
    </p-panel>
    <p-panel class="col-12" header="Find out more">
      <div *ngFor="let file of resource.fileNames" >
        <i class="pi pi-file p-mr-2" style="font-size: 2rem"></i>
        <button pButton type="button" label="{{file}}" class="p-button-link button-link" (click)="downloadFile(file)"></button>
      </div>
      <div class="mt-2" *ngFor="let link of resource.links" >
        <i class="pi pi-link p-mr-2" style="font-size: 2rem"></i>
        <a href="{{link}}">{{link}}</a>
      </div>
    </p-panel>
</div>
  <div class="col-12 pt-3 flex justify-content-center">
    <div class="pr-2">
      <p-button  label="Back to search" icon="pi pi-search" routerLink="/home" [loading]="false"></p-button>
    </div>
    <div class="pr-2" *ngIf="!resource.approved && (loggeduser| async)?.roles?.includes('ADMIN')">
      <p-button  label="Approve" icon="pi pi-check" (onClick)="approve($event)" [loading]="false"></p-button>
    </div>
    <div *ngIf="(loggeduser| async)?.roles?.includes('ADMIN')">
      <p-button  label="Edit" icon="pi pi-pencil" (onClick)="showInfo()" routerLink="/resource/edit" [loading]="false"></p-button>
    </div>
  </div>
</div>
<p-toast position="bottom-center" key="bc"></p-toast>
<p-confirmDialog></p-confirmDialog>
