<div class="uk-child-width-expand@s uk-text-center uk-margin-bottom" uk-grid>
  <div>
    <form class="uk-text-center uk-animation uk-card uk-card-default uk-padding">
      <div>
        <input type="text" class="uk-input  uk-width-1-2" placeholder="Search content providers in OpenAIRE..." aria-describedby="sizing-addon2"  [(ngModel)]="openaireSearchUtils.keyword"  name="keyword" >
        <button (click)="keywordChanged(openaireSearchUtils.keyword)"  type="submit" class=" uk-button">
           <span class="uk-icon">
           <svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="search" ratio="1"><circle fill="none" stroke="#000" stroke-width="1.1" cx="9" cy="9" r="7"></circle><path fill="none" stroke="#000" stroke-width="1.1" d="M14,14 L18,18 L14,14 Z"></path></svg>
           </span>Search
         </button>
      </div>
    </form>
  </div>
</div>

<div *ngIf="openaireSearchUtils.status != errorCodes.LOADING" class="uk-alert uk-alert-primary">
  <span class="uk-margin-small-right uk-icon" uk-icon="warning"></span>
  Newly added content providers will be linked to your community on the next run of our algorithms.
</div>

<errorMessages [status]="[openaireSearchUtils.status]" [type]="'OpenAIRE content providers'"></errorMessages>
<div *ngIf="openaireSearchUtils.status != errorCodes.LOADING" class="uk-alert uk-alert-primary">
  <span class="uk-margin-small-right uk-icon" uk-icon="warning"></span>
  If you cannot find a content provider relevant to your community, probably it is not OpenAIRE compliant.
   Feel free to contact us (<a [href]="'mailto:' + properties.feedbackmailForMissingEntities +'?Subject=[OpenAIRE Connect - '+ community + '] report missing content provider' + '&body=' + body" target="_top">feedback@openaire.eu</a>) to let us know and we'll try to get the provider on board!
</div>

<div *ngIf="openaireSearchUtils.totalResults > 0" class="uk-align-center uk-margin-remove-bottom">
  <div class="searchPaging uk-panel uk-margin-top uk-grid uk-margin-bottom">
    <span class="uk-h6 uk-width-1-1@s uk-width-1-2@m">
      {{openaireSearchUtils.totalResults | number}} content providers, page {{openaireSearchUtils.page | number}} of {{(totalPages()) | number}}
    </span>
    <span class="float-children-right-at-medium margin-small-top-at-small uk-width-1-1@s uk-width-1-2@m">
      <paging-no-load [limitPaging]=true [currentPage]="openaireSearchUtils.page" [totalResults]="openaireSearchUtils.totalResults" [size]="rowsOnPage" (pageChange)="goTo($event.value)"></paging-no-load>
    </span>
  </div>
</div>

<ul *ngIf="(openaireSearchUtils.page <= pagingLimit)" [class]="'uk-list uk-list-divider  uk-margin '+custom_class">
 <!-- <errorMessages [status]="[status]" [type]="'results'"></errorMessages> -->

   <li *ngFor="let result of openaireContentProviders" class="uk-animation-fade">
       <h6 class="uk-grid" uk-grid>
           <span class="uk-width-5-6">
             <a class="custom-external" target="_blank" [href]="properties.baseOpenaireLink+'/search/dataprovider?datasourceId='+result.id">
               <span *ngIf="result['title'].name">
                 <span [innerHTML]="result['title'].name"></span>
               </span>
               <span *ngIf="!result['title'].name">
                 [no title available]
              </span>
             </a>
           </span>

           <span class="uk-width-1-6 uk-text-center">
<!--               green_background_color green_color-->
             <a *ngIf="!inCommunity(result)" (click)="addContentProvider(result)" class="uk-icon-button add uk-button-primary" uk-icon="plus" title="Add"></a>

             <span *ngIf="inCommunity(result)" class="uk-label uk-label-success">Added</span>
<!--               red_background_color red_color-->
             <a *ngIf="undo[result.id]" (click)="removeContentProvider(undo[result.id], result.id)" class="uk-icon-button remove uk-button-danger" uk-icon="close" title="Undo"></a>

          </span>
       </h6>

       <span *ngIf="result['type'] != undefined && result['type'] != ''" class="uk-label custom-label label-blue label-dataprovider" title="Type"> {{result['type']}}</span>
       <span *ngIf="result['compatibility'] != undefined && result['compatibility'] != ''" class="uk-label custom-label  label-compatibility" title="Compatibility">{{result.compatibility}}</span>
       <div *ngIf="result.startYear && result.endYear"> Start year: {{result.startYear}} - End year: {{result.endYear}}</div>

       <div *ngIf="result['organizations'] != undefined && result['organizations'].length > 0">
           <span> Organization: </span>
           <span *ngFor="let organization of result['organizations'].slice(0,10) let i=index">
               <a *ngIf="organization.id" class="custom-external custom-icon" target="_blank"
                  [href]="properties.baseOpenaireLink+'/search/organization?organizationId='+organization.id">
                       {{organization.name}}</a><span

                   *ngIf="!organization.id">
                       {{organization.name}}</span><span

                   *ngIf="(i < result['organizations'].length-1) && (i < 9)">,</span>
           </span>
           <span *ngIf="result['organizations'].length > 10">...</span>
       </div>

       <div *ngIf="result['countries'] && result['countries'].length > 0">
           Country: <span *ngFor="let country of  result['countries'].slice(0,10) let i = index">{{country}}{{(i < ( result['countries'].slice(0,10).length-1))?", ":""}}{{(i ==  result['countries'].slice(0,10).length-1 &&  result['countries'].length > 10)?"...":""}}</span>
       </div>
       <div *ngIf="result['websiteURL'] != undefined && result['websiteURL'] != ''">
           <span>Website URL: </span>
           <span>
               <a href="{{result['websiteURL']}}" target="_blank" class="custom-external custom-icon">
                   {{result['websiteURL']}}
               </a>
           </span>
       </div>

       <div *ngIf="result['OAIPMHURL'] != undefined && result['OAIPMHURL'] != ''">
           <span>OAI-PMH URL: </span>
           <span>
               <a href="{{result['OAIPMHURL']}}" target="_blank" class="custom-external custom-icon">
                   {{result['OAIPMHURL']}}
               </a>
           </span>
       </div>

       <!-- <div *ngIf="result['subjects'] && result['subjects'].length > 0">
           Subject: <span *ngFor="let subject of  result['subjects'].slice(0,10) let i = index">{{subject}}{{(i < ( result['subjects'].slice(0,10).length-1))?", ":""}}{{(i ==  result['subjects'].slice(0,10).length-1 &&  result['subjects'].length > 10)?"...":""}}</span>
       </div> -->
   </li>
</ul>

<div [class]="openaireSearchUtils.page > pagingLimit ? 'search-results' : ''" *ngIf="(openaireSearchUtils.page >= pagingLimit) && (openaireSearchUtils.totalResults > resultsPerPage*pagingLimit)">
    <p class="uk-alert-warning" uk-alert>For more results please try a new, more specific query</p>
</div>

<div *ngIf="openaireSearchUtils.totalResults > 0" class="uk-align-center uk-margin-remove-bottom">
  <div class="searchPaging uk-panel uk-margin-top uk-grid uk-margin-bottom">
    <span class="uk-h6 uk-width-1-1@s uk-width-1-2@m">
      {{openaireSearchUtils.totalResults | number}} content providers, page {{openaireSearchUtils.page | number}} of {{(totalPages()) | number}}
    </span>
    <span class="float-children-right-at-medium margin-small-top-at-small uk-width-1-1@s uk-width-1-2@m">
      <paging-no-load [limitPaging]=true [currentPage]="openaireSearchUtils.page" [totalResults]="openaireSearchUtils.totalResults" [size]="rowsOnPage" (pageChange)="goTo($event.value)"></paging-no-load>
    </span>
  </div>
</div>
