From 9af944c3b70577c066c60f67bb697e942aceab64 Mon Sep 17 00:00:00 2001 From: Peter Sanchez Date: Wed, 6 Nov 2024 18:56:49 -0600 Subject: [PATCH] Adding current org data to settings page --- accounts/routes.go | 46 +++++++++++++++++++++++++++++++---------- templates/settings.html | 32 ++++++++++++++++++++++++++++ values.go | 1 + 3 files changed, 68 insertions(+), 11 deletions(-) diff --git a/accounts/routes.go b/accounts/routes.go index 94351fa..2784954 100644 --- a/accounts/routes.go +++ b/accounts/routes.go @@ -212,29 +212,23 @@ func (s *Service) Settings(c echo.Context) error { lt := localizer.GetSessionLocalizer(c) pd := localizer.NewPageData(lt.Translate("Settings")) pd.Data["name"] = lt.Translate("Name") + pd.Data["slug"] = lt.Translate("Slug") + pd.Data["subscription"] = lt.Translate("Subscription") + pd.Data["is_active"] = lt.Translate("Is Active") pd.Data["email"] = lt.Translate("Email") pd.Data["default_lang"] = lt.Translate("Default Language") pd.Data["timezone"] = lt.Translate("Timezone") pd.Data["organizations"] = lt.Translate("Organizations") - pd.Data["type"] = lt.Translate("Type") + pd.Data["cur_organization"] = lt.Translate("Current Organization") pd.Data["action"] = lt.Translate("Action") - pd.Data["business"] = lt.Translate("Business") - pd.Data["personal"] = lt.Translate("Personal") pd.Data["edit"] = lt.Translate("Edit") pd.Data["members"] = lt.Translate("Members") - pd.Data["integrations"] = lt.Translate("Integrations") - pd.Data["platform"] = lt.Translate("Platform") - pd.Data["connect"] = lt.Translate("Connect") - pd.Data["org_connected"] = lt.Translate("Organization connected") - pd.Data["date"] = lt.Translate("Date") - pd.Data["disconnect"] = lt.Translate("Disconnect") - pd.Data["no_connections"] = lt.Translate("No connections") - pd.Data["domains"] = lt.Translate("Domains") pd.Data["actions"] = lt.Translate("Actions") pd.Data["change_password"] = lt.Translate("Change password") pd.Data["update_email"] = lt.Translate("Update email") pd.Data["edit_profile"] = lt.Translate("Edit profile") pd.Data["manage"] = lt.Translate("Manage Your Organizations") + pd.Data["upgrade"] = lt.Translate("Upgrade Org") user := gctx.User.(*models.User) langTrans := map[string]string{ @@ -242,11 +236,41 @@ func (s *Service) Settings(c echo.Context) error { "en": lt.Translate("English"), } + type GraphQLResponse struct { + Orgs []models.Organization `json:"getOrganizations"` + } + var result GraphQLResponse + op := gqlclient.NewOperation( + `query GetOrganizations($search: String) { + getOrganizations(input: {search: $search}) { + id + name + slug + settings { + billing { + status + } + } + isActive + } + }`) + op.Var("search", links.GetOrgSelection(c)) // Get currently selected org + err := links.Execute(c.Request().Context(), op, &result) + if err != nil { + return err + } + + var org *models.Organization + if len(result.Orgs) > 0 { + org = &result.Orgs[0] + } + gmap := gobwebs.Map{ "pd": pd, "user": user, "defaultLang": core.GetDefaultLang(), "defaultTZ": links.DefaultTZ, + "curOrg": org, "settingSection": true, "langTrans": langTrans, "navFlag": "settings", diff --git a/templates/settings.html b/templates/settings.html index 6a16698..b7e3598 100644 --- a/templates/settings.html +++ b/templates/settings.html @@ -44,5 +44,37 @@ + + {{ if .curOrg }} + + + + + + + + + + + + + + + + + +
{{ .pd.Data.cur_organization }} {{.pd.Data.name}}{{.pd.Data.slug}}{{.pd.Data.subscription}}{{.pd.Data.is_active}}
{{.curOrg.Name}}{{.curOrg.Slug}}{{ .curOrg.DisplayBillingStatus $.context }}{{ if .curOrg.IsFreeAccount }} ({{ .pd.Data.upgrade }}){{ end }} + {{if .curOrg.IsActive}} + + + + {{else}} + + + + {{end}} +
+ {{ end }} + {{template "base_footer" .}} diff --git a/values.go b/values.go index 82c8208..b16c2c1 100644 --- a/values.go +++ b/values.go @@ -81,6 +81,7 @@ var InvalidSlugs = []string{ "blog", "weblog", "well-known", + "api", } // Interval used to display data in analytics engagement chart -- 2.45.2