refactor miner name truncation
This commit is contained in:
		
							parent
							
								
									1f84e1722f
								
							
						
					
					
						commit
						b29c4cf228
					
				| @ -223,5 +223,5 @@ export function parseDATUMTemplateCreator(coinbaseRaw: string): string[] | null | ||||
|   let tagString = String.fromCharCode(...tags); | ||||
|   tagString = tagString.replace('\x00', ''); | ||||
| 
 | ||||
|   return tagString.split('\x0f'); | ||||
|   return tagString.split('\x0f').map((name) => name.replace(/[^a-zA-Z0-9 ]/g, '')); | ||||
| } | ||||
| @ -53,32 +53,28 @@ | ||||
|             <td i18n="block.miner">Miner</td> | ||||
|             <td *ngIf="stateService.env.MINING_DASHBOARD"> | ||||
|               <a placement="bottom" [routerLink]="['/mining/pool' | relativeUrl, block.extras.pool.slug]" class="badge" style="color: #FFF;padding:0;"> | ||||
|                 <ng-container *ngIf="block.extras.pool.minerNames != undefined && block.extras.pool.minerNames.length > 1 && block.extras.pool.minerNames[1] != ''; else centralisedPool"> | ||||
|                 <span class="miner-name" *ngIf="block.extras.pool.minerNames?.length > 1 && block.extras.pool.minerNames[1] != ''"> | ||||
|                   @if (block.extras.pool.minerNames[1].length > 16) { | ||||
|                     {{ block.extras.pool.minerNames[1].slice(0, 15) }}… | ||||
|                   } @else { | ||||
|                     {{ block.extras.pool.minerNames[1] }} | ||||
|                   <div class="on-pool"> | ||||
|                     on | ||||
|                   } | ||||
|                 </span> | ||||
|                 <img class="pool-logo" [src]="'/resources/mining-pools/' + block.extras.pool.slug + '.svg'" onError="this.src = '/resources/mining-pools/default.svg'" [alt]="'Logo of ' + block.extras.pool.name + ' mining pool'"> | ||||
|                 {{ block.extras.pool.name }} | ||||
|                   </div> | ||||
|                 </ng-container> | ||||
|                 <ng-template #centralisedPool> | ||||
|                   <img class="pool-logo" [src]="'/resources/mining-pools/' + block.extras.pool.slug + '.svg'" onError="this.src = '/resources/mining-pools/default.svg'" [alt]="'Logo of ' + block.extras.pool.name + ' mining pool'"> | ||||
|                   {{ block.extras.pool.name }} | ||||
|                 </ng-template> | ||||
|               </a> | ||||
|             </td> | ||||
|             <td *ngIf="!stateService.env.MINING_DASHBOARD && stateService.env.BASE_MODULE === 'mempool'"> | ||||
|               <span [attr.data-cy]="'block-details-miner-badge'" placement="bottom" class="badge" | ||||
|                 [class]="!block?.extras.pool.name || block?.extras.pool.slug === 'unknown' ? 'badge-secondary' : 'badge-primary'"> | ||||
|                 <ng-container *ngIf="block?.extras.pool.minerNames != undefined && block?.extras.pool.minerNames.length > 1 && block?.extras.pool.minerNames[1] != ''; else centralisedPool"> | ||||
|                   {{ block?.extras.pool.minerNames[1] }} | ||||
|                   <div class="on-pool"> | ||||
|                     on {{ block?.extras.pool.name }} | ||||
|                   </div> | ||||
|                 </ng-container> | ||||
|                 <ng-template #centralisedPool> | ||||
|                   {{ block?.extras.pool.name }} | ||||
|                 </ng-template> | ||||
|                 <span class="miner-name" *ngIf="block.extras.pool.minerNames?.length > 1 && block.extras.pool.minerNames[1] != ''"> | ||||
|                   @if (block.extras.pool.minerNames[1].length > 16) { | ||||
|                     {{ block.extras.pool.minerNames[1].slice(0, 15) }}… | ||||
|                   } @else { | ||||
|                     {{ block.extras.pool.minerNames[1] }} | ||||
|                   } | ||||
|                 </span> | ||||
|                 {{ block.extras.pool.name }} | ||||
|               </span> | ||||
|             </td> | ||||
|           </tr> | ||||
|  | ||||
| @ -182,16 +182,15 @@ | ||||
|         <td i18n="block.miner">Miner</td> | ||||
|         <td *ngIf="stateService.env.MINING_DASHBOARD"> | ||||
|           <a placement="bottom" [routerLink]="['/mining/pool' | relativeUrl, block.extras.pool.slug]" class="badge" style="color: #FFF;padding:0;"> | ||||
|             <div class="on-pool-container" *ngIf="block.extras.pool.minerNames != undefined && block.extras.pool.minerNames.length > 1 && block.extras.pool.minerNames[1] != ''; else centralisedPool"> | ||||
|             <span class="miner-name" *ngIf="block.extras.pool.minerNames?.length > 1 && block.extras.pool.minerNames[1] != ''"> | ||||
|               @if (block.extras.pool.minerNames[1].length > 16) { | ||||
|                 {{ block.extras.pool.minerNames[1].slice(0, 15) }}… | ||||
|               } @else { | ||||
|                 {{ block.extras.pool.minerNames[1] }} | ||||
|               <div class="on-pool"> | ||||
|               } | ||||
|             </span> | ||||
|             <img class="pool-logo" [src]="'/resources/mining-pools/' + block.extras.pool.slug + '.svg'" onError="this.src = '/resources/mining-pools/default.svg'" [alt]="'Logo of ' + block.extras.pool.name + ' mining pool'"> | ||||
|             {{ block.extras.pool.name }} | ||||
|               </div> | ||||
|             </div> | ||||
|             <ng-template #centralisedPool> | ||||
|               <img class="pool-logo" [src]="'/resources/mining-pools/' + block.extras.pool.slug + '.svg'" onError="this.src = '/resources/mining-pools/default.svg'" [alt]="'Logo of ' + block.extras.pool.name + ' mining pool'"> {{ block.extras.pool.name }} | ||||
|             </ng-template> | ||||
|           </a> | ||||
|         </td> | ||||
|         <td *ngIf="!stateService.env.MINING_DASHBOARD && stateService.env.BASE_MODULE === 'mempool'"> | ||||
|  | ||||
| @ -81,17 +81,9 @@ h1 { | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| .on-pool-container { | ||||
|   display: inline; | ||||
|   flex-direction: row; | ||||
| } | ||||
| 
 | ||||
| .on-pool { | ||||
|   background-color: var(--bg); | ||||
|   display: inline-block; | ||||
|   margin-top: 4px; | ||||
|   padding: .25em .4em; | ||||
|   border-radius: .25rem; | ||||
| .miner-name { | ||||
|   margin-right: 4px; | ||||
|   vertical-align: top; | ||||
| } | ||||
| 
 | ||||
| .pool-logo { | ||||
|  | ||||
| @ -60,11 +60,11 @@ | ||||
|           </ng-container> | ||||
|         </div> | ||||
|         <div class="animated" *ngIf="block.extras?.pool != undefined && showPools"> | ||||
|           <a [attr.data-cy]="'bitcoin-block-' + offset + '-index-' + i + '-pool'" class="badge" [routerLink]="[('/mining/pool/' + block.extras.pool.slug) | relativeUrl]"> | ||||
|             <div *ngIf="block.extras.pool.minerNames != undefined && block.extras.pool.minerNames.length > 1 && block.extras.pool.minerNames[1] != ''; else centralisedPool"> | ||||
|           <a [attr.data-cy]="'bitcoin-block-' + offset + '-index-' + i + '-pool'" class="badge" [class.miner-name]="block.extras.pool.minerNames?.length > 1 && block.extras.pool.minerNames[1] != ''" [routerLink]="[('/mining/pool/' + block.extras.pool.slug) | relativeUrl]"> | ||||
|             <ng-container *ngIf="block.extras.pool.minerNames?.length > 1 && block.extras.pool.minerNames[1] != ''; else centralisedPool"> | ||||
|               <img [ngbTooltip]="block.extras.pool.name" class="pool-logo faded" [src]="'/resources/mining-pools/' + block.extras.pool.slug + '.svg'" onError="this.src = '/resources/mining-pools/default.svg'" [alt]="'Logo of ' + block.extras.pool.name + ' mining pool'"> | ||||
|               {{ block.extras.pool.minerNames[1] }} | ||||
|             </div> | ||||
|             </ng-container> | ||||
|             <ng-template #centralisedPool> | ||||
|               <img class="pool-logo" [src]="'/resources/mining-pools/' + block.extras.pool.slug + '.svg'" onError="this.src = '/resources/mining-pools/default.svg'" [alt]="'Logo of ' + block.extras.pool.name + ' mining pool'"> {{ block.extras.pool.name }} | ||||
|             </ng-template> | ||||
|  | ||||
| @ -187,9 +187,16 @@ | ||||
| 
 | ||||
| .badge { | ||||
|   position: relative; | ||||
|   top: 15px; | ||||
|   top: 19px; | ||||
|   z-index: 101; | ||||
|   color: #FFF; | ||||
|   overflow: hidden; | ||||
|   text-overflow: ellipsis; | ||||
|   max-width: 145px; | ||||
| 
 | ||||
|   &.miner-name { | ||||
|     max-width: 125px; | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| .pool-logo { | ||||
|  | ||||
| @ -281,15 +281,6 @@ export class BlockchainBlocksComponent implements OnInit, OnChanges, OnDestroy { | ||||
|         if (block?.extras) { | ||||
|           block.extras.minFee = this.getMinBlockFee(block); | ||||
|           block.extras.maxFee = this.getMaxBlockFee(block); | ||||
|           if (block.extras.pool?.minerNames) { | ||||
|             block.extras.pool.minerNames = block.extras.pool.minerNames.map((name) => { | ||||
|               name = name.replace(/[^a-zA-Z0-9 ]/g, ''); | ||||
|               if (name.length > 16) { | ||||
|                 return name.slice(0, 16) + '…'; | ||||
|               } | ||||
|               return name; | ||||
|             }); | ||||
|           } | ||||
|         } | ||||
|       } | ||||
|       this.blocks.push(block || { | ||||
| @ -332,14 +323,6 @@ export class BlockchainBlocksComponent implements OnInit, OnChanges, OnDestroy { | ||||
|       if (block?.extras) { | ||||
|         block.extras.minFee = this.getMinBlockFee(block); | ||||
|         block.extras.maxFee = this.getMaxBlockFee(block); | ||||
|         if (block.extras.pool?.minerNames) { | ||||
|           block.extras.pool.minerNames = block.extras.pool.minerNames.map((name) => { | ||||
|             if (name.length > 16) { | ||||
|               return name.slice(0, 16) + '…'; | ||||
|             } | ||||
|             return name; | ||||
|           }); | ||||
|         } | ||||
|       } | ||||
|       this.blocks[blockIndex] = block; | ||||
|       this.blockStyles[blockIndex] = this.getStyleForBlock(block, blockIndex); | ||||
|  | ||||
| @ -684,17 +684,15 @@ | ||||
|         @if (pool) { | ||||
|           <td class="wrap-cell"> | ||||
|             <a placement="bottom" [routerLink]="['/mining/pool' | relativeUrl, pool.slug]" class="badge" style="color: #FFF;padding:0;"> | ||||
|               <div class="on-pool-container" *ngIf="pool.minerNames != undefined && pool.minerNames.length > 1 && pool.minerNames[1] != ''; else centralisedPool"> | ||||
|               <span class="miner-name" *ngIf="pool.minerNames?.length > 1 && pool.minerNames[1] != ''"> | ||||
|                 @if (pool.minerNames[1].length > 16) { | ||||
|                   {{ pool.minerNames[1].slice(0, 15) }}… | ||||
|                 } @else { | ||||
|                   {{ pool.minerNames[1] }} | ||||
|                 <div class="on-pool"> | ||||
|                 } | ||||
|               </span> | ||||
|               <img class="pool-logo" [src]="'/resources/mining-pools/' + pool.slug + '.svg'" onError="this.src = '/resources/mining-pools/default.svg'" [alt]="'Logo of ' + pool.name + ' mining pool'"> | ||||
|               {{ pool.name }} | ||||
|                 </div> | ||||
|               </div> | ||||
|               <ng-template #centralisedPool> | ||||
|                 <img class="pool-logo" [src]="'/resources/mining-pools/' + pool.slug + '.svg'" onError="this.src = '/resources/mining-pools/default.svg'" [alt]="'Logo of ' + pool.name + ' mining pool'"> | ||||
|                 {{ pool.name }} | ||||
|               </ng-template> | ||||
|             </a> | ||||
|           </td> | ||||
|         } @else { | ||||
|  | ||||
| @ -60,17 +60,9 @@ | ||||
| 	top: -1px; | ||||
| } | ||||
| 
 | ||||
| .on-pool-container { | ||||
|   display: inline; | ||||
|   flex-direction: row; | ||||
| } | ||||
| 
 | ||||
| .on-pool { | ||||
|   background-color: var(--bg); | ||||
|   display: inline-block; | ||||
|   margin-top: 4px; | ||||
|   padding: .25em .4em; | ||||
|   border-radius: .25rem; | ||||
| .miner-name { | ||||
|   margin-right: 4px; | ||||
|   vertical-align: top; | ||||
| } | ||||
| 
 | ||||
| .pool-logo { | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user