-
Notifications
You must be signed in to change notification settings - Fork 135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/nft showcase preview #371
base: main
Are you sure you want to change the base?
Changes from 2 commits
8fc6457
47188c2
2854bfa
8ee0784
697d9c8
dc35fce
fe5014d
7883f61
9d17fe3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -97,8 +97,9 @@ | |
<simple-center-loader *ngIf="loading"></simple-center-loader> | ||
|
||
<div class="w-100 light-grey-divider border-bottom border-top border-color-grey" style="height:10px"></div> | ||
|
||
<div *ngIf="posts.length > 0 && (!loading || loadingNewDrop)" class="p-15px fs-15px"> | ||
<tab-selector [tabs]="feedTabs" [activeTab]="activeTab" (tabClick)="_handleTabClick($event)"></tab-selector> | ||
<!--Admin panel--> | ||
<div *ngIf="showShowcaseManagementTab()" class="p-15px fs-15px"> | ||
<b *ngIf="!loadingNewDrop">NFTs in this drop:</b> | ||
<div #uiScroll *uiScroll="let post of datasource" [ngClass]="{'d-flex align-items-center mt-15px border border-color-grey br-8px': !loadingNewDrop}"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this uiScroll directive needs to be moved into a separate component. If you switch back and forth between the tabs, you're going to lose the Showcase Management view. You'll see an error that looks like the below:
|
||
<i (click)="removeNFT(post.PostHashHex)" | ||
|
@@ -115,3 +116,7 @@ | |
<span *ngIf="post.PostHashHex === nftBeingRemoved"> Removing...</span> | ||
</div> | ||
</div> | ||
<!--Showcase preview--> | ||
<div *ngIf="showShowcasePreviewTab()"> | ||
<nft-showcase [showcaseIdx]="dropNumber"></nft-showcase> | ||
</div> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,21 @@ | ||
import { Component, OnInit } from "@angular/core"; | ||
import {Component, Input, OnInit} from "@angular/core"; | ||
lazynina marked this conversation as resolved.
Show resolved
Hide resolved
|
||
import { GlobalVarsService } from "../global-vars.service"; | ||
import { BackendApiService } from "../backend-api.service"; | ||
import { SwalHelper } from "../../lib/helpers/swal-helper"; | ||
import { InfiniteScroller } from "../infinite-scroller"; | ||
import { IAdapter, IDatasource } from "ngx-ui-scroll"; | ||
import {ActivatedRoute, Router} from "@angular/router"; | ||
lazynina marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
@Component({ | ||
selector: "nft-drop-mgr", | ||
templateUrl: "./nft-drop-mgr.component.html", | ||
}) | ||
export class NftDropMgrComponent implements OnInit { | ||
static SHOWCASE_MANAGEMENT = "Manage Showcase"; | ||
static SHOWCASE_PREVIEW_TAB = "Showcase Preview"; | ||
|
||
@Input() activeTab = NftDropMgrComponent.SHOWCASE_MANAGEMENT; | ||
|
||
globalVars: GlobalVarsService; | ||
|
||
loading: boolean = false; | ||
|
@@ -47,10 +53,52 @@ export class NftDropMgrComponent implements OnInit { | |
|
||
datasource: IDatasource<IAdapter<any>> = this.infiniteScroller.getDatasource(); | ||
|
||
constructor(private _globalVars: GlobalVarsService, private backendApi: BackendApiService) { | ||
feedTabs = [NftDropMgrComponent.SHOWCASE_MANAGEMENT, NftDropMgrComponent.SHOWCASE_PREVIEW_TAB]; | ||
switchingTabs = false; | ||
|
||
constructor( | ||
private _globalVars: GlobalVarsService, | ||
private backendApi: BackendApiService, | ||
private router: Router, | ||
private route: ActivatedRoute | ||
) { | ||
this.globalVars = _globalVars; | ||
} | ||
|
||
showShowcaseManagementTab() { | ||
return ( | ||
this.activeTab === NftDropMgrComponent.SHOWCASE_MANAGEMENT && | ||
this.posts.length > 0 && | ||
(!this.loading || this.loadingNewDrop) | ||
); | ||
} | ||
|
||
showShowcasePreviewTab() { | ||
return ( | ||
this.activeTab === NftDropMgrComponent.SHOWCASE_PREVIEW_TAB && | ||
this.posts.length > 0 && | ||
(!this.loading || this.loadingNewDrop) | ||
); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should avoid using these functions to determine what should be shown. Instead, we should have a container div that is conditionally shown |
||
|
||
_handleTabClick(tab: string) { | ||
this.activeTab = tab; | ||
this.router.navigate([], { | ||
relativeTo: this.route, | ||
queryParams: { feedTab: this.activeTab }, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's not call the query param feedTab. I think we call it feedTab in the feed component and this could cause some issues when merging queryParams. |
||
queryParamsHandling: "merge", | ||
}); | ||
this._onTabSwitch(); | ||
} | ||
|
||
_onTabSwitch() { | ||
// Delay rendering the posts for a hot second so nav is fast. | ||
this.switchingTabs = true; | ||
setTimeout(() => { | ||
this.switchingTabs = false; | ||
}, 0); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hmm... I don't think this is necessary? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you may be running into some weirdness with the uiScroll directive. I'll talk with you offline about it. |
||
|
||
ngOnInit(): void { | ||
// Get the latest NFT drop | ||
this.loading = true; | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -17,7 +17,7 @@ | |||||
</div> | ||||||
</div> | ||||||
|
||||||
<div *ngIf="!loading && !nftCollections || !nftCollections.length" class="d-flex align-items-center justify-content-center"> | ||||||
<div *ngIf="showcaseComingSoon()" class="d-flex align-items-center justify-content-center"> | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should avoid using functions for conditionals. ChangeDetection is faster for variables than it is for functions. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
with the ?, we have safe access so |
||||||
|
||||||
<div class="d-flex flex-column align-items-center justify-content-center fc-muted fs-15px p-15px text-center" style="height: 400px;"> | ||||||
<div>The NFT Showcase is coming soon!</div> | ||||||
|
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
@@ -1,14 +1,17 @@ | ||||||||
import { Component, OnInit } from "@angular/core"; | ||||||||
import {Component, Input, OnInit} from "@angular/core"; | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
import { BackendApiService, NFTCollectionResponse } from "../backend-api.service"; | ||||||||
import { GlobalVarsService } from "../global-vars.service"; | ||||||||
import { InfiniteScroller } from "../infinite-scroller"; | ||||||||
import { IAdapter, IDatasource } from "ngx-ui-scroll"; | ||||||||
import { has } from "lodash"; | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
|
||||||||
@Component({ | ||||||||
selector: "nft-showcase", | ||||||||
templateUrl: "./nft-showcase.component.html", | ||||||||
}) | ||||||||
export class NftShowcaseComponent implements OnInit { | ||||||||
@Input() showcaseIdx: number; | ||||||||
|
||||||||
globalVars: GlobalVarsService; | ||||||||
loading: boolean = false; | ||||||||
nftCollections: NFTCollectionResponse[]; | ||||||||
|
@@ -32,8 +35,11 @@ export class NftShowcaseComponent implements OnInit { | |||||||
this.globalVars = _globalVars; | ||||||||
} | ||||||||
|
||||||||
ngOnInit(): void { | ||||||||
this.loading = true; | ||||||||
showcaseComingSoon() { | ||||||||
return !this.loading && (!this.nftCollections || !has(this.nftCollections, length)); | ||||||||
} | ||||||||
|
||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should be able to kill this function and just use the constants to define the conditional |
||||||||
getCurrentShowcase() { | ||||||||
this.backendApi | ||||||||
.GetNFTShowcase( | ||||||||
this.globalVars.localNode, | ||||||||
|
@@ -57,6 +63,43 @@ export class NftShowcaseComponent implements OnInit { | |||||||
}); | ||||||||
} | ||||||||
|
||||||||
getShowcaseByIdx(dropIdx) { | ||||||||
this.backendApi | ||||||||
.GetNFTShowcaseAdminPreview( | ||||||||
this.globalVars.localNode, | ||||||||
this.globalVars.loggedInUser?.PublicKeyBase58Check, | ||||||||
this.globalVars.loggedInUser?.PublicKeyBase58Check, | ||||||||
dropIdx | ||||||||
) | ||||||||
.subscribe( | ||||||||
(res: any) => { | ||||||||
this.nftCollections = res.NFTCollections; | ||||||||
if (this.nftCollections) { | ||||||||
this.nftCollections.sort((a, b) => b.HighestBidAmountNanos - a.HighestBidAmountNanos); | ||||||||
} | ||||||||
this.lastPage = Math.floor(this.nftCollections.length / NftShowcaseComponent.PAGE_SIZE); | ||||||||
}, | ||||||||
(error) => { | ||||||||
this.globalVars._alertError(error.error.error); | ||||||||
} | ||||||||
) | ||||||||
.add(() => { | ||||||||
this.loading = false; | ||||||||
}); | ||||||||
} | ||||||||
|
||||||||
ngOnInit(): void { | ||||||||
console.log('Here is the showcase idx'); | ||||||||
console.log(this.showcaseIdx); | ||||||||
console.log(this.showcaseIdx === undefined); | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
this.loading = true; | ||||||||
if (this.showcaseIdx === undefined) { | ||||||||
this.getCurrentShowcase(); | ||||||||
} else { | ||||||||
this.getShowcaseByIdx(this.showcaseIdx); | ||||||||
} | ||||||||
} | ||||||||
|
||||||||
getPage(page: number) { | ||||||||
if (this.lastPage != null && page > this.lastPage) { | ||||||||
return []; | ||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move this to live with the rest of the admin routes below.