2026-02-27 16:17:48 +00:00
|
|
|
package sync
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
|
|
"github.com/Gleipnir-Technology/nidus-sync/db/models"
|
2026-03-03 17:08:58 +00:00
|
|
|
"github.com/Gleipnir-Technology/nidus-sync/html"
|
|
|
|
|
nhttp "github.com/Gleipnir-Technology/nidus-sync/http"
|
2026-03-12 23:49:16 +00:00
|
|
|
"github.com/Gleipnir-Technology/nidus-sync/platform"
|
2026-03-05 19:04:36 +00:00
|
|
|
"github.com/rs/zerolog/log"
|
2026-02-27 16:17:48 +00:00
|
|
|
)
|
|
|
|
|
|
2026-03-05 19:04:36 +00:00
|
|
|
type contentPlanningRoot struct {
|
|
|
|
|
ArcgisAccessToken string
|
|
|
|
|
}
|
2026-02-27 16:17:48 +00:00
|
|
|
|
2026-03-12 23:49:16 +00:00
|
|
|
func getPlanningRoot(ctx context.Context, r *http.Request, user platform.User) (*html.Response[contentPlanningRoot], *nhttp.ErrorWithStatus) {
|
2026-03-05 19:04:36 +00:00
|
|
|
var oauth_token *models.ArcgisOauthToken
|
|
|
|
|
var err error
|
|
|
|
|
var access_token string
|
2026-03-12 23:49:16 +00:00
|
|
|
oauth_token, err = platform.GetOAuthForOrg(ctx, user.Organization)
|
2026-03-05 19:04:36 +00:00
|
|
|
if err != nil {
|
|
|
|
|
log.Warn().Err(err).Msg("Failed to get oauth")
|
|
|
|
|
oauth_token = nil
|
|
|
|
|
access_token = ""
|
|
|
|
|
} else {
|
|
|
|
|
access_token = oauth_token.AccessToken
|
|
|
|
|
}
|
|
|
|
|
return html.NewResponse("sync/planning-root.html", contentPlanningRoot{
|
|
|
|
|
ArcgisAccessToken: access_token,
|
|
|
|
|
}), nil
|
2026-02-27 16:17:48 +00:00
|
|
|
}
|