public filterLibs()

in services/self-service/src/main/resources/webapp/src/app/resources/exploratory/install-libraries/install-libraries.component.ts [497:525]


  public filterLibs(updCachedForm?): void {
    if (!this.cashedFilterForm || updCachedForm) {
      this.cashedFilterForm = JSON.parse(JSON.stringify(this.filterModel));
      Object.setPrototypeOf(this.cashedFilterForm, Object.getPrototypeOf(this.filterModel));
    }
    this.filtredNotebookLibs = this.notebookLibs.filter((lib) => {
      const isName = this.cashedFilterForm.name
        ? lib.name.toLowerCase().indexOf(this.cashedFilterForm.name.toLowerCase().trim()) !== -1
          || lib.version.indexOf(this.cashedFilterForm.name.toLowerCase().trim()) !== -1
        : true;
      const isGroup = this.cashedFilterForm.group.length
        ? this.cashedFilterForm.group.includes(this.groupsListMap[lib.group])
        : true;
      lib.filteredStatus = lib.status.filter(status => {
        const isResource = this.cashedFilterForm.resource.length
          ? this.cashedFilterForm.resource.includes(status.resource)
          : true;
        const isResourceType = this.cashedFilterForm.resource_type.length
          ? this.cashedFilterForm.resource_type.includes(status.resourceType)
          : true;
        const isStatus = this.cashedFilterForm.status.length
          ? this.cashedFilterForm.status.includes(status.status)
          : true;
        return isResource && isResourceType && isStatus;
      });
      this.checkFilters();
      return isName && isGroup && lib.filteredStatus.length;
    });
  }