From c7e376edbe70ace99fff876f2e5b040223b1f715 Mon Sep 17 00:00:00 2001 From: Boldizsar Mezei Date: Thu, 18 Jan 2024 14:51:55 +0100 Subject: [PATCH 1/2] Use uploadFile from sdk --- src/app/@api/file.api.ts | 27 +++++++------------ .../pages/space/pages/upsert/upsert.page.html | 4 +-- .../pages/space/pages/upsert/upsert.page.ts | 2 +- .../pages/new/metrics/metrics.component.html | 2 +- .../new/overview/overview.component.html | 2 +- src/app/pages/token/services/new.service.ts | 5 +--- 6 files changed, 15 insertions(+), 27 deletions(-) diff --git a/src/app/@api/file.api.ts b/src/app/@api/file.api.ts index 5762611..529f2a4 100644 --- a/src/app/@api/file.api.ts +++ b/src/app/@api/file.api.ts @@ -1,16 +1,13 @@ import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { environment } from '@env/environment'; -import { - FILE_SIZES, - BUILD5_PROD_ADDRESS_API, - BUILD5_TEST_ADDRESS_API, - WEN_FUNC, -} from '@build-5/interfaces'; +import { FILE_SIZES } from '@build-5/interfaces'; import { NzUploadXHRArgs } from 'ng-zorro-antd/upload'; import { Observable, map, of } from 'rxjs'; +import { Build5, https } from '@build-5/sdk'; const EXTENSION_PAT = /\.[^/.]+$/; +const ORIGIN = environment.production ? Build5.PROD : Build5.TEST; @Injectable({ providedIn: 'root', @@ -42,22 +39,16 @@ export class FileApi { return of(url.match('.mp4$') ? 'video' : 'image'); }; - public upload(memberId: string, item: NzUploadXHRArgs) { - const formData = new FormData(); - formData.append('file', item.postFile); - formData.append('member', memberId); - formData.append('uid', item.file.uid); - formData.append('projectApiKey', environment.build5Token); - const origin = environment.production ? BUILD5_PROD_ADDRESS_API : BUILD5_TEST_ADDRESS_API; - return this.httpClient - .post(origin + WEN_FUNC.uploadFile, formData) + public upload = (memberId: string, item: NzUploadXHRArgs) => + https(ORIGIN) + .project(environment.build5Token) + .uploadFile(item.postFile, memberId, item.file.uid) .pipe( - map((b: any) => { + map((r) => { if (item.onSuccess) { - item.onSuccess(b.data.url, item.file, b.data.url); + item.onSuccess(r.url, item.file, r.url); } }), ) .subscribe(); - } } diff --git a/src/app/pages/space/pages/upsert/upsert.page.html b/src/app/pages/space/pages/upsert/upsert.page.html index 9ab9780..b0eeab7 100644 --- a/src/app/pages/space/pages/upsert/upsert.page.html +++ b/src/app/pages/space/pages/upsert/upsert.page.html @@ -180,7 +180,7 @@

Edit space

[nzDirectory]="false" nzType="drag" [nzLimit]="1" - [nzCustomRequest]="uploadFile.bind(this, 'space_avatar')" + [nzCustomRequest]="uploadFile.bind(this)" (nzChange)="uploadChangeAvatar($event)" nzFileType="image/png,image/jpg,image/jpeg,image/webp" [nzShowUploadList]="true" @@ -210,7 +210,7 @@

Edit space

nzListType="picture-card" [nzDirectory]="false" [nzLimit]="1" - [nzCustomRequest]="uploadFile.bind(this, 'space_banner')" + [nzCustomRequest]="uploadFile.bind(this)" (nzChange)="uploadChangeBanner($event)" nzFileType="image/png,image/jpg,image/jpeg,image/webp" [nzPreviewFile]="previewFile" diff --git a/src/app/pages/space/pages/upsert/upsert.page.ts b/src/app/pages/space/pages/upsert/upsert.page.ts index 354532e..888b02c 100644 --- a/src/app/pages/space/pages/upsert/upsert.page.ts +++ b/src/app/pages/space/pages/upsert/upsert.page.ts @@ -142,7 +142,7 @@ export class UpsertPage implements OnInit { } } - public uploadFile(type: 'space_avatar' | 'space_banner', item: NzUploadXHRArgs): Subscription { + public uploadFile(item: NzUploadXHRArgs): Subscription { if (!this.auth.member$.value) { const err = $localize`Member seems to log out during the file upload request.`; this.nzNotification.error(err, ''); diff --git a/src/app/pages/token/pages/new/metrics/metrics.component.html b/src/app/pages/token/pages/new/metrics/metrics.component.html index b1bd639..dc5efdf 100644 --- a/src/app/pages/token/pages/new/metrics/metrics.component.html +++ b/src/app/pages/token/pages/new/metrics/metrics.component.html @@ -254,7 +254,7 @@ [nzDirectory]="false" nzType="drag" [nzLimit]="1" - [nzCustomRequest]="newService.uploadFile.bind(newService, 'token_icon')" + [nzCustomRequest]="newService.uploadFile.bind(newService)" (nzChange)="newService.uploadChangeIcon($event)" nzFileType="image/png,image/jpg,image/jpeg,image/webp" [nzShowUploadList]="true" diff --git a/src/app/pages/token/pages/new/overview/overview.component.html b/src/app/pages/token/pages/new/overview/overview.component.html index cbdd5e8..a231758 100644 --- a/src/app/pages/token/pages/new/overview/overview.component.html +++ b/src/app/pages/token/pages/new/overview/overview.component.html @@ -137,7 +137,7 @@ nzType="drag" nzListType="picture-card" [nzLimit]="1" - [nzCustomRequest]="newService.uploadFile.bind(newService, 'token_introductionary')" + [nzCustomRequest]="newService.uploadFile.bind(newService)" (nzChange)="newService.uploadChangeIntroductionary($event)" nzFileType="image/png,image/jpg,image/jpeg,image/webp,video/mp4" [nzShowUploadList]="{ diff --git a/src/app/pages/token/services/new.service.ts b/src/app/pages/token/services/new.service.ts index 97b4658..036490b 100644 --- a/src/app/pages/token/services/new.service.ts +++ b/src/app/pages/token/services/new.service.ts @@ -198,10 +198,7 @@ export class NewService { } } - public uploadFile( - type: 'token_icon' | 'token_introductionary', - item: NzUploadXHRArgs, - ): Subscription { + public uploadFile(item: NzUploadXHRArgs): Subscription { if (!this.auth.member$.value) { const err = $localize`Member seems to log out during the file upload request.`; this.nzNotification.error(err, ''); From efb1ccbd4a151633548a2614d32505e56d07462a Mon Sep 17 00:00:00 2001 From: Tuditi Date: Thu, 1 Feb 2024 10:21:29 +0100 Subject: [PATCH 2/2] feat: enable bloom iota link --- .../components/wallet-deeplink/wallet-deeplink.component.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/app/components/wallet-deeplink/wallet-deeplink.component.ts b/src/app/components/wallet-deeplink/wallet-deeplink.component.ts index 402b506..0f3a0a1 100644 --- a/src/app/components/wallet-deeplink/wallet-deeplink.component.ts +++ b/src/app/components/wallet-deeplink/wallet-deeplink.component.ts @@ -1,6 +1,6 @@ import { ChangeDetectionStrategy, ChangeDetectorRef, Component, Input } from '@angular/core'; import { DomSanitizer, SafeUrl } from '@angular/platform-browser'; -import { DEFAULT_NETWORK, NETWORK_DETAIL, Network, WEN_NAME } from '@build-5/interfaces'; +import { NETWORK_DETAIL, Network, WEN_NAME } from '@build-5/interfaces'; @Component({ selector: 'wen-wallet-deeplink', @@ -90,11 +90,9 @@ export class WalletDeeplinkComponent { } private getBloomDeepLink(): SafeUrl { - if (!this._network || this._network === Network.IOTA || this._network === Network.ATOI) { - // TODO: IOTA network support in Bloom + if (!this._network) { return ''; } else { - // Shimmer Network const parameters = { address: this.targetAddress, baseCoinAmount: