From fb9941f0c6f14ca13537718086883883b929909a Mon Sep 17 00:00:00 2001
From: Xiao Gui <xgui3783@gmail.com>
Date: Fri, 1 Sep 2023 17:41:33 +0200
Subject: [PATCH] feat: add download feature

---
 src/features/feature-view/feature-view.component.html | 8 ++++++++
 src/features/feature-view/feature-view.component.ts   | 7 +++++++
 2 files changed, 15 insertions(+)

diff --git a/src/features/feature-view/feature-view.component.html b/src/features/feature-view/feature-view.component.html
index d5b0a92a2..18b7d05a3 100644
--- a/src/features/feature-view/feature-view.component.html
+++ b/src/features/feature-view/feature-view.component.html
@@ -135,6 +135,14 @@
         </a>
       </ng-template>
 
+      <ng-template [ngIf]="downloadLink$ | async" let-downloadLink>
+        <a [href]="downloadLink" mat-list-item target="_blank" class="no-hover">
+          <mat-icon mat-list-icon fontSet="fas" fontIcon="fa-download"></mat-icon>
+          <div mat-line>Download</div>
+        </a>
+      </ng-template>
+      
+
     </mat-action-list>
     
     <readmore-component [collapsedHeight]="240" class="sxplr-mb-8">
diff --git a/src/features/feature-view/feature-view.component.ts b/src/features/feature-view/feature-view.component.ts
index 73b675547..c9d6b8baf 100644
--- a/src/features/feature-view/feature-view.component.ts
+++ b/src/features/feature-view/feature-view.component.ts
@@ -50,6 +50,13 @@ export class FeatureViewComponent implements OnChanges {
     })
   )
 
+  downloadLink$ = SAPI.BsEndpoint$.pipe(
+    switchMap(endpoint => this.#featureId.pipe(
+      map(featureId => `${endpoint}/feature/${featureId}/download`),
+      shareReplay(1)
+    ))
+  ) 
+
   busy$ = new BehaviorSubject<boolean>(false)
   
   tabular$ = new BehaviorSubject<TabularFeature<number|string|number[]>>(null)
-- 
GitLab