Skip to content

Commit

Permalink
Report language. v5.10.10
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Oct 21, 2023
1 parent 7700e2c commit 4d550d6
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
7 changes: 7 additions & 0 deletions platform/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,13 @@ func queryLatestVersion(ctx context.Context) (*Versions, error) {
params["https"] = r0
}

// Report about locale feature.
if r0, err := rdb.Get(ctx, SRS_LOCALE).Result(); err != nil && err != redis.Nil {
return nil, errors.Wrapf(err, "get %v", SRS_LOCALE)
} else if r0 != "" {
params["lan"] = r0
}

// Report about upgrade window feature.
if r0, err := rdb.HGet(ctx, SRS_UPGRADE_WINDOW, "update").Result(); err != nil && err != redis.Nil {
return nil, errors.Wrapf(err, "hget %v update", SRS_UPGRADE_WINDOW)
Expand Down
15 changes: 15 additions & 0 deletions platform/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -476,11 +476,26 @@ func handleMgmtEnvs(ctx context.Context, handler *http.ServeMux) {
logger.Tf(ctx, "Handle %v", ep)
handler.HandleFunc(ep, func(w http.ResponseWriter, r *http.Request) {
if err := func() error {
var locale string
if err := ParseBody(ctx, r.Body, &struct {
Locale *string `json:"locale"`
}{
Locale: &locale,
}); err != nil {
return errors.Wrapf(err, "parse body")
}

if err := rdb.Set(ctx, SRS_LOCALE, locale, 0).Err(); err != nil && err != redis.Nil {
return errors.Wrapf(err, "set %v %v", SRS_LOCALE, locale)
}

ohttp.WriteData(ctx, w, r, &struct {
MgmtDocker bool `json:"mgmtDocker"`
}{
MgmtDocker: true,
})

logger.Tf(ctx, "mgmt envs ok, locale=%v", locale)
return nil
}(); err != nil {
ohttp.WriteError(ctx, w, r, err)
Expand Down
1 change: 1 addition & 0 deletions platform/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ const (
// For container and images.
SRS_CONTAINER_DISABLED = "SRS_CONTAINER_DISABLED"
// For system settings.
SRS_LOCALE = "SRS_LOCALE"
SRS_SECRET_PUBLISH = "SRS_SECRET_PUBLISH"
SRS_DOCKER_IMAGES = "SRS_DOCKER_IMAGES"
SRS_AUTH_SECRET = "SRS_AUTH_SECRET"
Expand Down
4 changes: 3 additions & 1 deletion ui/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ function AppPreImpl() {
React.useEffect(() => {
if (!setEnv) return;

axios.get('/terraform/v1/mgmt/envs').then(res => {
axios.post('/terraform/v1/mgmt/envs', {
locale: Locale.current()
}).then(res => {
setEnv(res.data.data);
console.log(`Env ok, ${JSON.stringify(res.data)}`);
}).catch(handleError);
Expand Down

0 comments on commit 4d550d6

Please sign in to comment.