Merge pull request #2474 from mempool/simon/search-results-greyed
Grey out inactive search results
This commit is contained in:
		
						commit
						8a2925ab0c
					
				@ -80,7 +80,7 @@ class ChannelsApi {
 | 
			
		||||
  public async $searchChannelsById(search: string): Promise<any[]> {
 | 
			
		||||
    try {
 | 
			
		||||
      const searchStripped = search.replace('%', '') + '%';
 | 
			
		||||
      const query = `SELECT id, short_id, capacity FROM channels WHERE id LIKE ? OR short_id LIKE ? LIMIT 10`;
 | 
			
		||||
      const query = `SELECT id, short_id, capacity, status FROM channels WHERE id LIKE ? OR short_id LIKE ? LIMIT 10`;
 | 
			
		||||
      const [rows]: any = await DB.query(query, [searchStripped, searchStripped]);
 | 
			
		||||
      return rows;
 | 
			
		||||
    } catch (e) {
 | 
			
		||||
 | 
			
		||||
@ -249,7 +249,7 @@ class NodesApi {
 | 
			
		||||
    try {
 | 
			
		||||
      const publicKeySearch = search.replace('%', '') + '%';
 | 
			
		||||
      const aliasSearch = search.replace(/[-_.]/g, ' ').replace(/[^a-zA-Z0-9 ]/g, '').split(' ').map((search) => '+' + search + '*').join(' ');
 | 
			
		||||
      const query = `SELECT public_key, alias, capacity, channels FROM nodes WHERE public_key LIKE ? OR MATCH alias_search AGAINST (? IN BOOLEAN MODE) ORDER BY capacity DESC LIMIT 10`;
 | 
			
		||||
      const query = `SELECT public_key, alias, capacity, channels, status FROM nodes WHERE public_key LIKE ? OR MATCH alias_search AGAINST (? IN BOOLEAN MODE) ORDER BY capacity DESC LIMIT 10`;
 | 
			
		||||
      const [rows]: any = await DB.query(query, [publicKeySearch, aliasSearch]);
 | 
			
		||||
      return rows;
 | 
			
		||||
    } catch (e) {
 | 
			
		||||
 | 
			
		||||
@ -10,7 +10,7 @@
 | 
			
		||||
  <ng-template [ngIf]="results.nodes.length">
 | 
			
		||||
    <div class="card-title">Lightning Nodes</div>
 | 
			
		||||
    <ng-template ngFor [ngForOf]="results.nodes" let-node let-i="index">
 | 
			
		||||
      <button (click)="clickItem(results.addresses.length + i)" [class.active]="results.addresses.length + i === activeIdx" [routerLink]="['/lightning/node' | relativeUrl, node.public_key]" type="button" role="option" class="dropdown-item">
 | 
			
		||||
      <button (click)="clickItem(results.addresses.length + i)" [class.inactive]="node.status === 0" [class.active]="results.addresses.length + i === activeIdx" [routerLink]="['/lightning/node' | relativeUrl, node.public_key]" type="button" role="option" class="dropdown-item">
 | 
			
		||||
        <ngb-highlight [result]="node.alias" [term]="searchTerm"></ngb-highlight>  <span class="symbol">{{ node.public_key | shortenString : 10 }}</span>
 | 
			
		||||
      </button>
 | 
			
		||||
    </ng-template>
 | 
			
		||||
@ -18,7 +18,7 @@
 | 
			
		||||
  <ng-template [ngIf]="results.channels.length">
 | 
			
		||||
    <div class="card-title">Lightning Channels</div>
 | 
			
		||||
    <ng-template ngFor [ngForOf]="results.channels" let-channel let-i="index">
 | 
			
		||||
      <button (click)="clickItem(results.addresses.length + results.nodes.length + i)" [class.active]="results.addresses.length + results.nodes.length + i === activeIdx" type="button" role="option" class="dropdown-item">
 | 
			
		||||
      <button (click)="clickItem(results.addresses.length + results.nodes.length + i)" [class.inactive]="channel.status === 2"  [class.active]="results.addresses.length + results.nodes.length + i === activeIdx" type="button" role="option" class="dropdown-item">
 | 
			
		||||
        <ngb-highlight [result]="channel.short_id" [term]="searchTerm"></ngb-highlight>  <span class="symbol">{{ channel.id }}</span>
 | 
			
		||||
      </button>
 | 
			
		||||
    </ng-template>
 | 
			
		||||
 | 
			
		||||
@ -14,3 +14,7 @@
 | 
			
		||||
  box-shadow: 0.125rem 0.125rem 0.25rem rgba(0,0,0,0.075);
 | 
			
		||||
  width: 100%;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.inactive {
 | 
			
		||||
  opacity: 0.2;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user