<!-- Movie tab -->
<div role="tabpanel" class="tab-pane active" id="MoviesTab">
    <div class="input-group">
        <input id="search" type="text" class="form-control form-control-custom form-control-search form-control-withbuttons" (keyup)="search($event)">
        <div class="input-group-addon right-radius">
            <div class="btn-group">
                <a href="#" class="btn btn-sm btn-primary-outline dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
                    {{ 'Search.Suggestions' | translate }}
                    <i class="fa fa-chevron-down"></i>
                </a>
                <ul class="dropdown-menu">
                    <li><a (click)="popularMovies()" [translate]="'Search.Movies.PopularMovies'"></a></li>
                    <li><a (click)="upcomingMovies()" [translate]="'Search.Movies.UpcomingMovies'"></a></li>
                    <li><a (click)="topRatedMovies()" [translate]="'Search.Movies.TopRatedMovies'"></a></li>
                    <li><a (click)="nowPlayingMovies()" [translate]="'Search.Movies.NowPlayingMovies'"></a></li>
                </ul>
            </div>
            <i class="fa fa-search"></i>
        </div>
    </div>
    <br />
    <br />
    <!-- Movie content -->
    <div id="movieList">
        <div *ngIf="searchApplied && movieResults?.length <= 0" class='no-search-results'>
            <i class='fa fa-film no-search-results-icon'></i><div class='no-search-results-text' [translate]="'Search.NoResults'"></div>
        </div>

        <div *ngFor="let result of movieResults">
        
            <div class="row" >
                
                    <div class="myBg backdrop" [style.background-image]="result.background"></div>
                    <div class="tint" style="background-image: linear-gradient(to bottom, rgba(0,0,0,0.6) 0%,rgba(0,0,0,0.6) 100%);"></div>
                <div class="col-sm-2 small-padding">
                    <img *ngIf="result.posterPath"  class="img-responsive poster" src="{{result.posterPath}}" alt="poster">

                </div>
                <div class="col-sm-8 small-padding">
                    <div>
                        <a href="https://www.themoviedb.org/movie/{{result.id}}/" target="_blank">
                            <h4>{{result.title}} ({{result.releaseDate | date: 'yyyy'}})</h4>
                        </a>
                    <span class="tags">
                        <span *ngIf="result.releaseDate" class="label label-info" id="releaseDateLabel" target="_blank">{{ 'Search.TheatricalRelease' | translate: {date: result.releaseDate | date: 'mediumDate'} }}</span>
                        <span *ngIf="result.digitalReleaseDate" class="label label-info" id="releaseDateLabel" target="_blank">{{ 'Search.DigitalDate' | translate: {date: result.digitalReleaseDate | date: 'mediumDate'} }}</span>

                        <a *ngIf="result.homepage" href="{{result.homepage}}" id="homePageLabel" target="_blank"><span class="label label-info" [translate]="'Search.Movies.HomePage'"></span></a>

                        <a *ngIf="result.trailer" href="{{result.trailer}}" id="trailerLabel" target="_blank"><span class="label label-info" [translate]="'Search.Movies.Trailer'"></span></a>
                        <span *ngIf="result.quality" id="qualityLabel" class="label label-success">{{result.quality}}p</span>
                        
                        <ng-template [ngIf]="result.available"><span class="label label-success" id="availableLabel" [translate]="'Common.Available'"></span></ng-template>
                        <ng-template [ngIf]="result.approved && !result.available"><span class="label label-info" id="processingRequestLabel" [translate]="'Common.ProcessingRequest'"></span></ng-template>
                        <ng-template [ngIf]="result.requested && !result.approved && !result.available"><span class="label label-warning" id="pendingApprovalLabel" [translate]="'Common.PendingApproval'"></span></ng-template>
                        <ng-template [ngIf]="!result.requested && !result.available && !result.approved"><span class="label label-danger" id="notRequestedLabel" [translate]="'Common.NotRequested'"></span></ng-template>


                    </span>

                        <br/>
                    </div>
                    <p style="font-size: 0.9rem !important">{{result.overview}}</p>
                </div>


                <div class="col-sm-2 small-padding">
                    <div class="row" *ngIf="result.requested">
                        <div class="col-md-2 col-md-push-10">
    
                            <a *ngIf="result.showSubscribe && !result.subscribed" style="color:white" (click)="subscribe(result)" pTooltip="Subscribe for notifications"> <i class="fa fa-rss"></i></a>
                            <a *ngIf="result.showSubscribe && result.subscribed" style="color:red" (click)="unSubscribe(result)" pTooltip="Unsubscribe notification"> <i class="fa fa-rss"></i></a>
                        </div>
                    </div>
                    <div *ngIf="result.available">
                        <button style="text-align: right" class="btn btn-success-outline disabled" disabled><i class="fa fa-check"></i> {{ 'Common.Available' | translate }}</button>
                    </div>
                    <div *ngIf="!result.available">
                    <div *ngIf="result.requested || result.approved; then requestedBtn else notRequestedBtn"></div>
                    <ng-template #requestedBtn>
                        <button style="text-align: right" class="btn btn-primary-outline disabled" [disabled]><i class="fa fa-check"></i> {{ 'Common.Requested' | translate }}</button>
                    </ng-template>
                    <ng-template #notRequestedBtn>
                        <button id="{{result.id}}" style="text-align: right" class="btn btn-primary-outline" (click)="request(result)">
                            <i *ngIf="result.requestProcessing" class="fa fa-circle-o-notch fa-spin fa-fw"></i> <i *ngIf="!result.requestProcessing && !result.processed" class="fa fa-plus"></i>
                            <i *ngIf="result.processed && !result.requestProcessing" class="fa fa-check"></i>{{ 'Common.Request' | translate }}</button>
                    </ng-template>
                        </div>
                        <button style="text-align: right" class="btn btn-sm btn-info-outline" (click)="similarMovies(result.id)"> <i class="fa fa-eye"></i> {{ 'Search.Similar' | translate }}</button>
                    
                    <br/>
                    <div *ngIf="result.available">
                        <a *ngIf="result.plexUrl" style="text-align: right" class="btn btn-sm btn-success-outline" href="{{result.plexUrl}}" target="_blank"><i class="fa fa-eye"></i> View On Plex</a>
                        <a *ngIf="result.embyUrl" style="text-align: right" id="embybtn" class="btn btn-sm btn-success-outline" href="{{result.embyUrl}}" target="_blank"><i class="fa fa-eye"></i> View On Emby</a>
                    </div>
                    <div class="dropdown" *ngIf="result.available && issueCategories && issuesEnabled">
                        <button class="btn btn-sm btn-primary-outline dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
                            <i class="fa fa-plus"></i> Report Issue
                            <span class="caret"></span>
                        </button>
                        <ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
                            <li *ngFor="let cat of issueCategories"><a [routerLink]="" (click)="reportIssue(cat, result)">{{cat.value}}</a></li>
                        </ul>
                    </div>

                </div>

            </div>
            <br/>
            <br/>
        </div>

    </div>
</div>


<issue-report [movie]="true" [visible]="issuesBarVisible" (visibleChange)="issuesBarVisible = $event;" [title]="issueRequestTitle"
[issueCategory]="issueCategorySelected" [id]="issueRequestId" [providerId]="issueProviderId"></issue-report>
