Create configuration for setting map service on organization
This commit is contained in:
parent
630c6b7342
commit
13f2ade9f4
3 changed files with 49 additions and 42 deletions
|
|
@ -19,7 +19,7 @@
|
||||||
<!-- Main Card -->
|
<!-- Main Card -->
|
||||||
<div class="card shadow-sm">
|
<div class="card shadow-sm">
|
||||||
<div class="card-body p-4">
|
<div class="card-body p-4">
|
||||||
<form>
|
<form action="{{ .URL.Configuration.ArcGIS }}" method="POST">
|
||||||
<!-- OAuth Authentication Section -->
|
<!-- OAuth Authentication Section -->
|
||||||
<div class="mb-4">
|
<div class="mb-4">
|
||||||
<h5 class="card-title border-bottom pb-2 mb-3">
|
<h5 class="card-title border-bottom pb-2 mb-3">
|
||||||
|
|
@ -113,50 +113,24 @@
|
||||||
|
|
||||||
<div class="row g-3">
|
<div class="row g-3">
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
<label for="satelliteLayer" class="form-label fw-semibold">
|
<label for="map-service" class="form-label fw-semibold">
|
||||||
Satellite Imagery Layer
|
Map Service (Aerial Imagery)
|
||||||
<span class="text-danger">*</span>
|
<span class="text-danger">*</span>
|
||||||
</label>
|
</label>
|
||||||
<select class="form-select" id="satelliteLayer" required>
|
<select
|
||||||
<option value="">-- Select a feature layer --</option>
|
class="form-select"
|
||||||
<option value="layer1" selected>
|
id="map-service"
|
||||||
World Imagery (Clarity)
|
name="map-service"
|
||||||
</option>
|
required
|
||||||
<option value="layer2">
|
>
|
||||||
Sentinel-2 Satellite Imagery
|
{{ range .C.ServiceMaps }}
|
||||||
</option>
|
<option value="{{ .ArcgisID }}">
|
||||||
<option value="layer3">NAIP Aerial Imagery</option>
|
{{ .Name }}
|
||||||
<option value="layer4">Landsat 8 Multispectral</option>
|
</option>
|
||||||
<option value="layer5">
|
{{ end }}
|
||||||
High Resolution Ortho Imagery
|
|
||||||
</option>
|
|
||||||
</select>
|
</select>
|
||||||
<div class="form-text">
|
<div class="form-text">
|
||||||
Select the feature layer for satellite imagery data
|
Select the feature layer for aerial imagery data
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="col-md-12">
|
|
||||||
<label for="parcelLayer" class="form-label fw-semibold">
|
|
||||||
Parcel Data Layer
|
|
||||||
<span class="text-danger">*</span>
|
|
||||||
</label>
|
|
||||||
<select class="form-select" id="parcelLayer" required>
|
|
||||||
<option value="">-- Select a feature layer --</option>
|
|
||||||
<option value="parcel1" selected>
|
|
||||||
County Parcel Boundaries 2024
|
|
||||||
</option>
|
|
||||||
<option value="parcel2">Tax Assessor Parcels</option>
|
|
||||||
<option value="parcel3">
|
|
||||||
Property Ownership Records
|
|
||||||
</option>
|
|
||||||
<option value="parcel4">
|
|
||||||
Zoning and Land Use Parcels
|
|
||||||
</option>
|
|
||||||
<option value="parcel5">Cadastral Parcel Dataset</option>
|
|
||||||
</select>
|
|
||||||
<div class="form-text">
|
|
||||||
Select the feature layer for parcel boundary data
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -4,12 +4,14 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/Gleipnir-Technology/bob/dialect/psql"
|
||||||
|
"github.com/Gleipnir-Technology/bob/dialect/psql/um"
|
||||||
"github.com/Gleipnir-Technology/nidus-sync/arcgis"
|
"github.com/Gleipnir-Technology/nidus-sync/arcgis"
|
||||||
"github.com/Gleipnir-Technology/nidus-sync/db"
|
"github.com/Gleipnir-Technology/nidus-sync/db"
|
||||||
"github.com/Gleipnir-Technology/nidus-sync/db/models"
|
"github.com/Gleipnir-Technology/nidus-sync/db/models"
|
||||||
"github.com/Gleipnir-Technology/nidus-sync/html"
|
"github.com/Gleipnir-Technology/nidus-sync/html"
|
||||||
nhttp "github.com/Gleipnir-Technology/nidus-sync/http"
|
nhttp "github.com/Gleipnir-Technology/nidus-sync/http"
|
||||||
//"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
type contentConfigurationRoot struct{}
|
type contentConfigurationRoot struct{}
|
||||||
|
|
@ -25,6 +27,7 @@ type contentSettingOrganization struct {
|
||||||
type contentSettingIntegration struct {
|
type contentSettingIntegration struct {
|
||||||
ArcGISAccount *models.ArcgisAccount
|
ArcGISAccount *models.ArcgisAccount
|
||||||
ArcGISOAuth *models.ArcgisOauthToken
|
ArcGISOAuth *models.ArcgisOauthToken
|
||||||
|
ServiceMaps []*models.ArcgisServiceMap
|
||||||
}
|
}
|
||||||
|
|
||||||
func getConfigurationOrganization(ctx context.Context, r *http.Request, org *models.Organization, u *models.User) (*html.Response[contentSettingOrganization], *nhttp.ErrorWithStatus) {
|
func getConfigurationOrganization(ctx context.Context, r *http.Request, org *models.Organization, u *models.User) (*html.Response[contentSettingOrganization], *nhttp.ErrorWithStatus) {
|
||||||
|
|
@ -84,15 +87,23 @@ func getConfigurationIntegrationArcgis(ctx context.Context, r *http.Request, org
|
||||||
return nil, nhttp.NewError("Failed to get oauth: %w", err)
|
return nil, nhttp.NewError("Failed to get oauth: %w", err)
|
||||||
}
|
}
|
||||||
var account *models.ArcgisAccount
|
var account *models.ArcgisAccount
|
||||||
|
var service_maps []*models.ArcgisServiceMap
|
||||||
if org.ArcgisAccountID.IsValue() {
|
if org.ArcgisAccountID.IsValue() {
|
||||||
account, err = models.FindArcgisAccount(ctx, db.PGInstance.BobDB, org.ArcgisAccountID.MustGet())
|
account, err = models.FindArcgisAccount(ctx, db.PGInstance.BobDB, org.ArcgisAccountID.MustGet())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nhttp.NewError("Failed to get arcgis: %w", err)
|
return nil, nhttp.NewError("Failed to get arcgis: %w", err)
|
||||||
}
|
}
|
||||||
|
service_maps, err = models.ArcgisServiceMaps.Query(
|
||||||
|
models.SelectWhere.ArcgisServiceMaps.AccountID.EQ(account.ID),
|
||||||
|
).All(ctx, db.PGInstance.BobDB)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nhttp.NewError("Failed to get map services: %w", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
data := contentSettingIntegration{
|
data := contentSettingIntegration{
|
||||||
ArcGISAccount: account,
|
ArcGISAccount: account,
|
||||||
ArcGISOAuth: oauth,
|
ArcGISOAuth: oauth,
|
||||||
|
ServiceMaps: service_maps,
|
||||||
}
|
}
|
||||||
return html.NewResponse("sync/configuration/integration-arcgis.html", data), nil
|
return html.NewResponse("sync/configuration/integration-arcgis.html", data), nil
|
||||||
}
|
}
|
||||||
|
|
@ -115,3 +126,24 @@ func getConfigurationUserList(ctx context.Context, r *http.Request, org *models.
|
||||||
content := contentSettingPlaceholder{}
|
content := contentSettingPlaceholder{}
|
||||||
return html.NewResponse("sync/configuration/user-list.html", content), nil
|
return html.NewResponse("sync/configuration/user-list.html", content), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type formArcgisConfiguration struct {
|
||||||
|
MapService *string `schema:"map-service"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func postConfigurationIntegrationArcgis(ctx context.Context, r *http.Request, org *models.Organization, u *models.User, f formArcgisConfiguration) (string, *nhttp.ErrorWithStatus) {
|
||||||
|
if f.MapService != nil {
|
||||||
|
_, err := psql.Update(
|
||||||
|
um.Table("organization"),
|
||||||
|
um.SetCol("arcgis_map_service_id").ToArg(f.MapService),
|
||||||
|
um.Where(psql.Quote("id").EQ(psql.Arg(org.ID))),
|
||||||
|
).Exec(ctx, db.PGInstance.BobDB)
|
||||||
|
if err != nil {
|
||||||
|
return "", nhttp.NewError("Failed to update map service config: %w", err)
|
||||||
|
}
|
||||||
|
log.Info().Str("map-service", *f.MapService).Int32("org-id", org.ID).Msg("changed map service")
|
||||||
|
} else {
|
||||||
|
log.Info().Msg("no map service")
|
||||||
|
}
|
||||||
|
return "/configuration/integration/arcgis", nil
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,7 @@ func Router() chi.Router {
|
||||||
r.Method("GET", "/configuration", authenticatedHandler(getConfigurationRoot))
|
r.Method("GET", "/configuration", authenticatedHandler(getConfigurationRoot))
|
||||||
r.Method("GET", "/configuration/integration", authenticatedHandler(getConfigurationIntegration))
|
r.Method("GET", "/configuration/integration", authenticatedHandler(getConfigurationIntegration))
|
||||||
r.Method("GET", "/configuration/integration/arcgis", authenticatedHandler(getConfigurationIntegrationArcgis))
|
r.Method("GET", "/configuration/integration/arcgis", authenticatedHandler(getConfigurationIntegrationArcgis))
|
||||||
|
r.Method("POST", "/configuration/integration/arcgis", authenticatedHandlerPost(postConfigurationIntegrationArcgis))
|
||||||
r.Method("GET", "/configuration/organization", authenticatedHandler(getConfigurationOrganization))
|
r.Method("GET", "/configuration/organization", authenticatedHandler(getConfigurationOrganization))
|
||||||
r.Method("GET", "/configuration/pesticide", authenticatedHandler(getConfigurationPesticide))
|
r.Method("GET", "/configuration/pesticide", authenticatedHandler(getConfigurationPesticide))
|
||||||
r.Method("GET", "/configuration/pesticide/add", authenticatedHandler(getConfigurationPesticideAdd))
|
r.Method("GET", "/configuration/pesticide/add", authenticatedHandler(getConfigurationPesticideAdd))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue