storj/satellite/console/consoleweb/config.go
Vitalii 6e1fd12930 web/satellite: paginate ListObjects request to show more than 1000 objects
With this change, we are able to fetch all objects to show in the object browser.
AWS SDK V3 provides paginator functionality to automatically make additional requests for every MaxKeys value (we use 500 objects at a time).
By initial request we fetch first 500 objects and save continuation tokens for the rest of the object batches.
Also, we save currently active (fetched) object range.
If user tries to open a page with objects which are out of currently active range then we look for needed continuation token and fetch needed objects batch.
Added a feature flag for this funtionality.

Issue:
https://github.com/storj/storj/issues/5595

Change-Id: If63e3c2ddaac3ea9f2bc1dc63cb49007f897e3e2
2023-09-06 12:47:15 +00:00

92 lines
4.4 KiB
Go

// Copyright (C) 2023 Storj Labs, Inc.
// See LICENSE for copying information.
package consoleweb
import (
"encoding/json"
"storj.io/common/memory"
"storj.io/storj/satellite/console"
)
// FrontendConfig holds the configuration for the satellite frontend.
type FrontendConfig struct {
ExternalAddress string `json:"externalAddress"`
SatelliteName string `json:"satelliteName"`
SatelliteNodeURL string `json:"satelliteNodeURL"`
StripePublicKey string `json:"stripePublicKey"`
PartneredSatellites []PartneredSatellite `json:"partneredSatellites"`
DefaultProjectLimit int `json:"defaultProjectLimit"`
GeneralRequestURL string `json:"generalRequestURL"`
ProjectLimitsIncreaseRequestURL string `json:"projectLimitsIncreaseRequestURL"`
GatewayCredentialsRequestURL string `json:"gatewayCredentialsRequestURL"`
IsBetaSatellite bool `json:"isBetaSatellite"`
BetaSatelliteFeedbackURL string `json:"betaSatelliteFeedbackURL"`
BetaSatelliteSupportURL string `json:"betaSatelliteSupportURL"`
DocumentationURL string `json:"documentationURL"`
CouponCodeBillingUIEnabled bool `json:"couponCodeBillingUIEnabled"`
CouponCodeSignupUIEnabled bool `json:"couponCodeSignupUIEnabled"`
FileBrowserFlowDisabled bool `json:"fileBrowserFlowDisabled"`
LinksharingURL string `json:"linksharingURL"`
PublicLinksharingURL string `json:"publicLinksharingURL"`
PathwayOverviewEnabled bool `json:"pathwayOverviewEnabled"`
Captcha console.CaptchaConfig `json:"captcha"`
AllProjectsDashboard bool `json:"allProjectsDashboard"`
LimitsAreaEnabled bool `json:"limitsAreaEnabled"`
DefaultPaidStorageLimit memory.Size `json:"defaultPaidStorageLimit"`
DefaultPaidBandwidthLimit memory.Size `json:"defaultPaidBandwidthLimit"`
InactivityTimerEnabled bool `json:"inactivityTimerEnabled"`
InactivityTimerDuration int `json:"inactivityTimerDuration"`
InactivityTimerViewerEnabled bool `json:"inactivityTimerViewerEnabled"`
OptionalSignupSuccessURL string `json:"optionalSignupSuccessURL"`
HomepageURL string `json:"homepageURL"`
NativeTokenPaymentsEnabled bool `json:"nativeTokenPaymentsEnabled"`
PasswordMinimumLength int `json:"passwordMinimumLength"`
PasswordMaximumLength int `json:"passwordMaximumLength"`
ABTestingEnabled bool `json:"abTestingEnabled"`
PricingPackagesEnabled bool `json:"pricingPackagesEnabled"`
NewUploadModalEnabled bool `json:"newUploadModalEnabled"`
GalleryViewEnabled bool `json:"galleryViewEnabled"`
NeededTransactionConfirmations int `json:"neededTransactionConfirmations"`
ObjectBrowserPaginationEnabled bool `json:"objectBrowserPaginationEnabled"`
}
// Satellites is a configuration value that contains a list of satellite names and addresses.
// Format should be [{"name": "","address": ""],{"name": "","address": ""},...] in valid JSON format.
//
// Can be used as a flag.
type Satellites []PartneredSatellite
// PartneredSatellite contains the name and web address of a satellite.
type PartneredSatellite struct {
Name string `json:"name"`
Address string `json:"address"`
}
// Type implements pflag.Value.
func (Satellites) Type() string { return "consoleweb.Satellites" }
// String is required for pflag.Value.
func (sl *Satellites) String() string {
satellites, err := json.Marshal(*sl)
if err != nil {
return ""
}
return string(satellites)
}
// Set does validation on the configured JSON.
func (sl *Satellites) Set(s string) (err error) {
satellites := make([]PartneredSatellite, 3)
err = json.Unmarshal([]byte(s), &satellites)
if err != nil {
return err
}
*sl = satellites
return
}