github.com/readium/readium-lcp-server@v0.0.0-20240509124024-799e77a0bbd6/frontend/manage/app/publication/publication-list.component.ts (about)

     1  import { Component, OnInit }    from '@angular/core';
     2  import { Publication }          from './publication';
     3  import { PublicationService }   from './publication.service';
     4  import { Pipe } from "@angular/core";
     5  
     6  @Component({
     7      moduleId: module.id,
     8      selector: 'lcp-publication-list',
     9      templateUrl: 'publication-list.component.html',
    10  })
    11  
    12  export class PublicationListComponent implements OnInit {
    13      publications: Publication[];
    14      search: string = "";
    15      order: string;
    16      reverse: boolean = false;
    17  
    18      constructor(private publicationService: PublicationService) {
    19          this.publications = [];
    20          this.order = "id";
    21          this.reverse = true;
    22      }
    23  
    24      refreshPublications(): void {
    25          this.publicationService.list().then(
    26              publications => {
    27                  this.publications = publications;
    28              }
    29          );
    30      }
    31  
    32      orderBy(newOrder: string)
    33      {
    34        if (newOrder == this.order)
    35        {
    36          this.reverse = !this.reverse;
    37        }
    38        else
    39        {
    40          this.reverse = false;
    41          this.order = newOrder
    42        }
    43      }
    44  
    45      keptWithFilter (pub :{title: string}): boolean
    46      {
    47          if (pub.title.toUpperCase().includes(this.search.toUpperCase()))
    48          {
    49              return true;
    50          }
    51  
    52          return false;
    53      }
    54  
    55      ngOnInit(): void {
    56          this.refreshPublications();
    57      }
    58  
    59      onRemove(objId: any): void {
    60          this.publicationService.delete(objId).then(
    61              publication => {
    62                  this.refreshPublications();
    63              }
    64          );
    65      }
    66   }