From 55d1e222554ef5f5ec8ffcaa6992dce0bf1fcb86 Mon Sep 17 00:00:00 2001 From: sagely1 <114952739+sagely1@users.noreply.github.com> Date: Fri, 3 Jan 2025 23:49:18 +0000 Subject: [PATCH 1/8] fix loading animation for gct, cards in details page, shortened sha --- apps/agora/app/src/app/app.component.html | 1 - apps/agora/app/src/app/app.component.ts | 8 +- .../lib/gene-comparison-tool.component.html | 49 ++++++----- .../lib/gene-comparison-tool.component.scss | 19 +++++ .../src/lib/gene-comparison-tool.component.ts | 46 +++++++---- .../download-dom-image.component.html | 4 +- .../download-dom-image.component.scss | 1 + .../download-dom-image.component.ts | 23 +++++- .../gene-resources.component.html | 42 ++++------ .../gene-resources.component.scss | 82 +++++-------------- libs/agora/services/src/lib/error.service.ts | 4 +- libs/agora/services/src/lib/github.service.ts | 14 ++-- libs/agora/services/src/lib/helper.service.ts | 4 +- libs/agora/shared/src/index.ts | 1 + .../loading-icon/loading-icon.component.ts | 3 +- .../loading-overlay.component.html | 5 ++ .../loading-overlay.component.scss | 0 .../loading-overlay.component.spec.ts | 0 .../loading-overlay.component.ts | 4 +- libs/agora/ui/src/index.ts | 1 - 20 files changed, 164 insertions(+), 147 deletions(-) rename libs/agora/{ui/src/lib/components => shared/src/lib}/loading-overlay/loading-overlay.component.html (72%) rename libs/agora/{ui/src/lib/components => shared/src/lib}/loading-overlay/loading-overlay.component.scss (100%) rename libs/agora/{ui/src/lib/components => shared/src/lib}/loading-overlay/loading-overlay.component.spec.ts (100%) rename libs/agora/{ui/src/lib/components => shared/src/lib}/loading-overlay/loading-overlay.component.ts (82%) diff --git a/apps/agora/app/src/app/app.component.html b/apps/agora/app/src/app/app.component.html index ede758841c..3331936a4c 100644 --- a/apps/agora/app/src/app/app.component.html +++ b/apps/agora/app/src/app/app.component.html @@ -6,4 +6,3 @@ - diff --git a/apps/agora/app/src/app/app.component.ts b/apps/agora/app/src/app/app.component.ts index e0d484a7fb..55b5f8961c 100644 --- a/apps/agora/app/src/app/app.component.ts +++ b/apps/agora/app/src/app/app.component.ts @@ -1,18 +1,14 @@ import { Component, inject, OnInit } from '@angular/core'; import { Meta, Title } from '@angular/platform-browser'; import { ActivatedRoute, NavigationEnd, Router, RouterModule } from '@angular/router'; -import { - FooterComponent, - HeaderComponent, - LoadingOverlayComponent, -} from '@sagebionetworks/agora/ui'; +import { FooterComponent, HeaderComponent } from '@sagebionetworks/agora/ui'; import { filter } from 'rxjs'; import { ToastModule } from 'primeng/toast'; import { MessageService } from 'primeng/api'; @Component({ standalone: true, - imports: [RouterModule, HeaderComponent, FooterComponent, LoadingOverlayComponent, ToastModule], + imports: [RouterModule, HeaderComponent, FooterComponent, ToastModule], providers: [MessageService], selector: 'app-root', templateUrl: './app.component.html', diff --git a/libs/agora/gene-comparison-tool/src/lib/gene-comparison-tool.component.html b/libs/agora/gene-comparison-tool/src/lib/gene-comparison-tool.component.html index 6a3ddd629a..888dabfc31 100644 --- a/libs/agora/gene-comparison-tool/src/lib/gene-comparison-tool.component.html +++ b/libs/agora/gene-comparison-tool/src/lib/gene-comparison-tool.component.html @@ -1,3 +1,8 @@ +@if (isLoading) { +
+ +
+}
@@ -53,7 +58,7 @@

Gene Comparison Tool

-
+
DISPLAYED GENES
@@ -479,6 +484,8 @@

Gene Comparison Tool

breakpoint="0" (sortFunction)="sortCallback($event)" [customSort]="true" + [loading]="isLoading" + loadingIcon="" >
No results found...
@@ -615,7 +622,7 @@

Gene Comparison Tool

- + + + + + +
diff --git a/libs/agora/gene-comparison-tool/src/lib/gene-comparison-tool.component.scss b/libs/agora/gene-comparison-tool/src/lib/gene-comparison-tool.component.scss index aec2741bc0..cf6c867f6f 100644 --- a/libs/agora/gene-comparison-tool/src/lib/gene-comparison-tool.component.scss +++ b/libs/agora/gene-comparison-tool/src/lib/gene-comparison-tool.component.scss @@ -3,6 +3,25 @@ @import 'libs/agora/styles/src/lib/variables'; @import 'libs/agora/styles/src/lib/mixins'; +#loading { + position: absolute; + inset: calc(var(--header-height)) 0 0; + background: rgb(255 255 255 / 100%); + z-index: 100; + display: flex; + justify-content: center; + align-items: center; + height: calc(100vh - var(--footer-height) - var(--header-height)); +} + +.loading-icon-size { + display: flex; + justify-content: center; + align-items: center; + height: calc(100vh - var(--footer-height) - var(--header-height) - 20px); + font-size: 50px !important; +} + .gct-tooltip-filter { max-width: 350px; diff --git a/libs/agora/gene-comparison-tool/src/lib/gene-comparison-tool.component.ts b/libs/agora/gene-comparison-tool/src/lib/gene-comparison-tool.component.ts index ca61b947f4..9a739fa07f 100644 --- a/libs/agora/gene-comparison-tool/src/lib/gene-comparison-tool.component.ts +++ b/libs/agora/gene-comparison-tool/src/lib/gene-comparison-tool.component.ts @@ -1,5 +1,13 @@ import { CommonModule } from '@angular/common'; -import { AfterViewInit, Component, inject, OnDestroy, OnInit, ViewChild } from '@angular/core'; +import { + AfterViewInit, + Component, + inject, + OnDestroy, + OnInit, + ViewChild, + ViewEncapsulation, +} from '@angular/core'; import { ActivatedRoute, Router, RouterModule } from '@angular/router'; import { DistributionService, @@ -25,19 +33,6 @@ import { combineLatest, Subscription } from 'rxjs'; import * as variables from './gene-comparison-tool.variables'; import * as helpers from './gene-comparison-tool.helpers'; -// import { -// GeneComparisonToolScorePanelComponent as ScorePanelComponent, -// GeneComparisonToolDetailsPanelComponent as DetailsPanelComponent, -// GeneComparisonToolFilterPanelComponent as FilterPanelComponent, -// GeneComparisonToolPinnedGenesModalComponent as PinnedGenesModalComponent, -// GeneComparisonToolFilterListComponent, -// GeneComparisonToolFilterPanelComponent, -// GeneComparisonToolDetailsPanelComponent, -// GeneComparisonToolScorePanelComponent, -// GeneComparisonToolHowToPanelComponent, -// GeneComparisonToolLegendPanelComponent, -// GeneComparisonToolPinnedGenesModalComponent, -// } from './components'; import { GeneComparisonToolScorePanelComponent as ScorePanelComponent } from './components/gene-comparison-tool-score-panel/gene-comparison-tool-score-panel.component'; import { GeneComparisonToolDetailsPanelComponent as DetailsPanelComponent } from './components/gene-comparison-tool-details-panel/gene-comparison-tool-details-panel.component'; import { GeneComparisonToolFilterPanelComponent as FilterPanelComponent } from './components/gene-comparison-tool-filter-panel/gene-comparison-tool-filter-panel.component'; @@ -56,7 +51,7 @@ import { GeneComparisonToolHowToPanelComponent } from './components/gene-compari import { GeneComparisonToolLegendPanelComponent } from './components/gene-comparison-tool-legend-panel/gene-comparison-tool-legend-panel.component'; import { GeneComparisonToolFilterListComponent } from './components/gene-comparison-tool-filter-list/gene-comparison-tool-filter-list.component'; import { OverlayPanelLinkComponent } from '@sagebionetworks/agora/genes'; -import { SvgIconComponent } from '@sagebionetworks/agora/shared'; +import { LoadingIconComponent, SvgIconComponent } from '@sagebionetworks/agora/shared'; @Component({ selector: 'agora-gene-comparison-tool', @@ -79,10 +74,12 @@ import { SvgIconComponent } from '@sagebionetworks/agora/shared'; GeneComparisonToolDetailsPanelComponent, GeneComparisonToolFilterPanelComponent, GeneComparisonToolPinnedGenesModalComponent, + LoadingIconComponent, ], providers: [GenesService, DistributionService, HelperService, MessageService, FilterService], templateUrl: './gene-comparison-tool.component.html', styleUrls: ['./gene-comparison-tool.component.scss'], + encapsulation: ViewEncapsulation.None, }) export class GeneComparisonToolComponent implements OnInit, AfterViewInit, OnDestroy { router = inject(Router); @@ -93,6 +90,8 @@ export class GeneComparisonToolComponent implements OnInit, AfterViewInit, OnDes messageService = inject(MessageService); filterService = inject(FilterService); + isLoading = true; + /* Genes ----------------------------------------------------------------- */ genes: GCTGene[] = []; @@ -204,7 +203,7 @@ export class GeneComparisonToolComponent implements OnInit, AfterViewInit, OnDes ngAfterViewInit() { setTimeout(() => { this.updateColumnWidth(); - }, 1); + }, 50); } ngOnDestroy() { @@ -254,7 +253,9 @@ export class GeneComparisonToolComponent implements OnInit, AfterViewInit, OnDes } loadGenes() { - this.helperService.setLoading(true); + // this.helperService.setLoading(true); + this.isLoading = true; + // this.genesTable.showLoader = true; this.genes = []; const genesApi$ = this.geneService.getComparisonGenes(this.category, this.subCategory); @@ -262,13 +263,16 @@ export class GeneComparisonToolComponent implements OnInit, AfterViewInit, OnDes combineLatest([genesApi$, distributionApi$]).subscribe(([genesResult, distributionResult]) => { if (genesResult.items) { + console.log('# of items', genesResult.items.length); this.initData(genesResult.items); this.sortTable(this.headerTable); this.refresh(); this.scoresDistribution = distributionResult.overall_scores; - this.helperService.setLoading(false); + this.isLoading = false; + // console.log('calling setLoading false'); + // this.helperService.setLoading(false); } }); } @@ -1291,8 +1295,14 @@ export class GeneComparisonToolComponent implements OnInit, AfterViewInit, OnDes updateColumnWidth() { const count = this.columns.length < 5 ? 5 : this.columns.length; + console.log('count is: ', count); + const width = this.headerTable?.containerViewChild?.nativeElement?.offsetWidth || 0; + console.log('ht', this.headerTable?.containerViewChild?.nativeElement?.offsetWidth); + console.log('width is: ', width); + this.columnWidth = Math.ceil((width - 300) / count) + 'px'; + console.log('column width is: ', this.columnWidth); } onResize() { diff --git a/libs/agora/genes/src/lib/components/download-dom-image/download-dom-image.component.html b/libs/agora/genes/src/lib/components/download-dom-image/download-dom-image.component.html index 7753dab5a9..da793bf809 100644 --- a/libs/agora/genes/src/lib/components/download-dom-image/download-dom-image.component.html +++ b/libs/agora/genes/src/lib/components/download-dom-image/download-dom-image.component.html @@ -1,5 +1,5 @@ - +
{{ error }}
diff --git a/libs/agora/genes/src/lib/components/download-dom-image/download-dom-image.component.scss b/libs/agora/genes/src/lib/components/download-dom-image/download-dom-image.component.scss index a32f45d182..2863d66ebc 100644 --- a/libs/agora/genes/src/lib/components/download-dom-image/download-dom-image.component.scss +++ b/libs/agora/genes/src/lib/components/download-dom-image/download-dom-image.component.scss @@ -29,6 +29,7 @@ .p-button { width: 100%; + height: 100%; i { position: absolute; diff --git a/libs/agora/genes/src/lib/components/download-dom-image/download-dom-image.component.ts b/libs/agora/genes/src/lib/components/download-dom-image/download-dom-image.component.ts index dd04db462d..1d481edbe1 100644 --- a/libs/agora/genes/src/lib/components/download-dom-image/download-dom-image.component.ts +++ b/libs/agora/genes/src/lib/components/download-dom-image/download-dom-image.component.ts @@ -7,6 +7,9 @@ import { saveAs } from 'file-saver'; import { RadioButtonModule } from 'primeng/radiobutton'; import { CommonModule } from '@angular/common'; import { FormsModule } from '@angular/forms'; +import { ButtonModule } from 'primeng/button'; +import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; +import { faDownload, faSpinner } from '@fortawesome/free-solid-svg-icons'; interface Type { value: string; @@ -16,7 +19,14 @@ interface Type { @Component({ selector: 'agora-download-dom-image', standalone: true, - imports: [CommonModule, FormsModule, OverlayPanelModule, RadioButtonModule], + imports: [ + CommonModule, + FormsModule, + OverlayPanelModule, + RadioButtonModule, + ButtonModule, + FontAwesomeModule, + ], templateUrl: './download-dom-image.component.html', styleUrls: ['./download-dom-image.component.scss'], encapsulation: ViewEncapsulation.None, @@ -26,6 +36,9 @@ export class DownloadDomImageComponent { @Input() heading = 'Download this plot as:'; @Input() filename = 'agora'; + downloadIcon = faDownload; + spinnerIcon = faSpinner; + selectedType = '.png'; types: Type[] = [ { @@ -53,8 +66,14 @@ export class DownloadDomImageComponent { this.error = ''; this.isLoading = true; + // width and height need to be specified + // known issue: https://github.com/1904labs/dom-to-image-more/issues/198 domtoimage - .toBlob(this.target, { bgcolor: '#fff' }) + .toBlob(this.target, { + bgcolor: '#fff', + width: this.target.offsetWidth, + height: this.target.offsetHeight, + }) .then((blob: any) => { saveAs(blob, this.filename + this.selectedType); this.isLoading = false; diff --git a/libs/agora/genes/src/lib/components/gene-resources/gene-resources.component.html b/libs/agora/genes/src/lib/components/gene-resources/gene-resources.component.html index 803d38d641..aa52e909e9 100644 --- a/libs/agora/genes/src/lib/components/gene-resources/gene-resources.component.html +++ b/libs/agora/genes/src/lib/components/gene-resources/gene-resources.component.html @@ -9,11 +9,11 @@

Target Enabling Resources

{{ gene.hgnc_symbol || gene.ensembl_gene_id }} that are currently available, under development, or planned.

-
-
+
+
Target Enabling Resources
-