From 3a5e53be3caf508e8f9b087cfa5668da5cc457dc Mon Sep 17 00:00:00 2001 From: Kim Rutherford Date: Tue, 26 Nov 2024 10:05:30 +1300 Subject: [PATCH] Add very hacky fix to iframe back button issue When the URL of an iframe changes, an entry is pushed onto the history stack: https://github.com/whatwg/html/issues/6501 We get two history entries if we change gene page. Then we need to oush the back button twice to go back to the previous gene page. And the first click shows the wrong iframe contents. This hack recreate the iframe component on page change so it's not added to the history. Sort of like this: https://stackoverflow.com/a/79096750 Refs pombase/website#2284 --- .../alphafold-viewer.component.html | 5 ++-- .../alphafold-viewer.component.ts | 23 ++++++------------- .../annotation-table.component.html | 2 ++ .../gene-page-widgets.component.html | 2 ++ .../gene-protein-features.component.html | 2 ++ .../go-cam-viewer.component.html | 2 ++ .../pdb-structure-viewer.component.html | 4 ++-- .../pdb-structure-viewer.component.ts | 2 +- .../protein-feature-viewer.component.html | 2 ++ .../protein-features.component.html | 2 ++ .../reference-details.component.html | 2 +- .../rna-structure.component.html | 2 ++ 12 files changed, 27 insertions(+), 23 deletions(-) diff --git a/src/app/alphafold-viewer/alphafold-viewer.component.html b/src/app/alphafold-viewer/alphafold-viewer.component.html index b7ad47c7..711c3a16 100644 --- a/src/app/alphafold-viewer/alphafold-viewer.component.html +++ b/src/app/alphafold-viewer/alphafold-viewer.component.html @@ -9,9 +9,8 @@
-
-
diff --git a/src/app/alphafold-viewer/alphafold-viewer.component.ts b/src/app/alphafold-viewer/alphafold-viewer.component.ts index d0380fbc..90b55dd3 100644 --- a/src/app/alphafold-viewer/alphafold-viewer.component.ts +++ b/src/app/alphafold-viewer/alphafold-viewer.component.ts @@ -1,5 +1,4 @@ import { Component, ElementRef, Input, OnInit, ViewChild } from '@angular/core'; -import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser'; import { GeneDetails } from '../pombase-api.service'; import { AppConfig, getAppConfig } from '../config'; @@ -16,12 +15,10 @@ export class AlphafoldViewerComponent implements OnInit { appConfig: AppConfig = getAppConfig(); - sanitizedAlphaFoldURL?: SafeResourceUrl; - alphaFoldStatus: 'loading' | 'loaded' = 'loading'; - constructor(private sanitizer: DomSanitizer) { } + constructor() { } proteinTooLong(): boolean { const protLength = this.geneDetails.transcripts[0].protein?.sequence.length; @@ -45,19 +42,13 @@ export class AlphafoldViewerComponent implements OnInit { return this.alphaFoldStatus == 'loading'; } - getAlphaFoldIFrameURL(): SafeResourceUrl | undefined { - return this.sanitizedAlphaFoldURL; - } - ngOnChanges(): void { - - if (this.geneDetails.uniprot_identifier) { - const rawUrl = 'structure_view/alphafold/' + this.geneDetails.uniprot_identifier; - this.sanitizedAlphaFoldURL = - this.sanitizer.bypassSecurityTrustResourceUrl(rawUrl); - } else { - this.sanitizedAlphaFoldURL = undefined; - } + setTimeout(() => { + if (this.geneDetails.uniprot_identifier && this.alphafoldiframe) { + const rawUrl = 'structure_view/alphafold/' + this.geneDetails.uniprot_identifier; + this.alphafoldiframe.nativeElement.contentWindow.location.replace(rawUrl); + } + }, 100); } ngOnInit(): void { diff --git a/src/app/annotation-table/annotation-table.component.html b/src/app/annotation-table/annotation-table.component.html index 8a18936c..3374a5c3 100644 --- a/src/app/annotation-table/annotation-table.component.html +++ b/src/app/annotation-table/annotation-table.component.html @@ -34,9 +34,11 @@ View all protein features ...
+
+
diff --git a/src/app/gene-page-widgets/gene-page-widgets.component.html b/src/app/gene-page-widgets/gene-page-widgets.component.html index e128e4c1..ca16caf5 100644 --- a/src/app/gene-page-widgets/gene-page-widgets.component.html +++ b/src/app/gene-page-widgets/gene-page-widgets.component.html @@ -106,10 +106,12 @@
+
+
+
+
diff --git a/src/app/go-cam-viewer/go-cam-viewer.component.html b/src/app/go-cam-viewer/go-cam-viewer.component.html index 2cca67cc..85fd7bfe 100644 --- a/src/app/go-cam-viewer/go-cam-viewer.component.html +++ b/src/app/go-cam-viewer/go-cam-viewer.component.html @@ -11,8 +11,10 @@ Documentation
+
+
diff --git a/src/app/pdb-structure-viewer/pdb-structure-viewer.component.html b/src/app/pdb-structure-viewer/pdb-structure-viewer.component.html index 0a5cab17..51cb39e7 100644 --- a/src/app/pdb-structure-viewer/pdb-structure-viewer.component.html +++ b/src/app/pdb-structure-viewer/pdb-structure-viewer.component.html @@ -3,7 +3,7 @@
-
+
@@ -85,4 +85,4 @@
- \ No newline at end of file + diff --git a/src/app/pdb-structure-viewer/pdb-structure-viewer.component.ts b/src/app/pdb-structure-viewer/pdb-structure-viewer.component.ts index 41e91973..965efe91 100644 --- a/src/app/pdb-structure-viewer/pdb-structure-viewer.component.ts +++ b/src/app/pdb-structure-viewer/pdb-structure-viewer.component.ts @@ -28,7 +28,7 @@ interface DisplayEntry { standalone: false }) export class PdbStructureViewerComponent implements OnInit { - @Input() displayName?: string; + @Input() displayName: string; @Input() pdbEntries: Array; @Input() pageType: 'gene' | 'reference'; diff --git a/src/app/protein-feature-viewer/protein-feature-viewer.component.html b/src/app/protein-feature-viewer/protein-feature-viewer.component.html index 793a3416..5df1c465 100644 --- a/src/app/protein-feature-viewer/protein-feature-viewer.component.html +++ b/src/app/protein-feature-viewer/protein-feature-viewer.component.html @@ -14,12 +14,14 @@
+
+
No features available for {{geneDisplayName}} diff --git a/src/app/protein-features/protein-features.component.html b/src/app/protein-features/protein-features.component.html index fb79b936..1c23dc3e 100644 --- a/src/app/protein-features/protein-features.component.html +++ b/src/app/protein-features/protein-features.component.html @@ -23,12 +23,14 @@ View all protein features ...
+
+
diff --git a/src/app/reference-details/reference-details.component.html b/src/app/reference-details/reference-details.component.html index 9365e5d1..5b3d9cdc 100644 --- a/src/app/reference-details/reference-details.component.html +++ b/src/app/reference-details/reference-details.component.html @@ -99,7 +99,7 @@
- +
diff --git a/src/app/rna-structure/rna-structure.component.html b/src/app/rna-structure/rna-structure.component.html index f0ca37b6..038f3fee 100644 --- a/src/app/rna-structure/rna-structure.component.html +++ b/src/app/rna-structure/rna-structure.component.html @@ -1,4 +1,6 @@
+
+