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 -->
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-body p-4">
|
||||
<form>
|
||||
<form action="{{ .URL.Configuration.ArcGIS }}" method="POST">
|
||||
<!-- OAuth Authentication Section -->
|
||||
<div class="mb-4">
|
||||
<h5 class="card-title border-bottom pb-2 mb-3">
|
||||
|
|
@ -113,50 +113,24 @@
|
|||
|
||||
<div class="row g-3">
|
||||
<div class="col-md-12">
|
||||
<label for="satelliteLayer" class="form-label fw-semibold">
|
||||
Satellite Imagery Layer
|
||||
<label for="map-service" class="form-label fw-semibold">
|
||||
Map Service (Aerial Imagery)
|
||||
<span class="text-danger">*</span>
|
||||
</label>
|
||||
<select class="form-select" id="satelliteLayer" required>
|
||||
<option value="">-- Select a feature layer --</option>
|
||||
<option value="layer1" selected>
|
||||
World Imagery (Clarity)
|
||||
</option>
|
||||
<option value="layer2">
|
||||
Sentinel-2 Satellite Imagery
|
||||
</option>
|
||||
<option value="layer3">NAIP Aerial Imagery</option>
|
||||
<option value="layer4">Landsat 8 Multispectral</option>
|
||||
<option value="layer5">
|
||||
High Resolution Ortho Imagery
|
||||
</option>
|
||||
<select
|
||||
class="form-select"
|
||||
id="map-service"
|
||||
name="map-service"
|
||||
required
|
||||
>
|
||||
{{ range .C.ServiceMaps }}
|
||||
<option value="{{ .ArcgisID }}">
|
||||
{{ .Name }}
|
||||
</option>
|
||||
{{ end }}
|
||||
</select>
|
||||
<div class="form-text">
|
||||
Select the feature layer for satellite 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
|
||||
Select the feature layer for aerial imagery data
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -4,12 +4,14 @@ import (
|
|||
"context"
|
||||
"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/db"
|
||||
"github.com/Gleipnir-Technology/nidus-sync/db/models"
|
||||
"github.com/Gleipnir-Technology/nidus-sync/html"
|
||||
nhttp "github.com/Gleipnir-Technology/nidus-sync/http"
|
||||
//"github.com/rs/zerolog/log"
|
||||
"github.com/rs/zerolog/log"
|
||||
)
|
||||
|
||||
type contentConfigurationRoot struct{}
|
||||
|
|
@ -25,6 +27,7 @@ type contentSettingOrganization struct {
|
|||
type contentSettingIntegration struct {
|
||||
ArcGISAccount *models.ArcgisAccount
|
||||
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) {
|
||||
|
|
@ -84,15 +87,23 @@ func getConfigurationIntegrationArcgis(ctx context.Context, r *http.Request, org
|
|||
return nil, nhttp.NewError("Failed to get oauth: %w", err)
|
||||
}
|
||||
var account *models.ArcgisAccount
|
||||
var service_maps []*models.ArcgisServiceMap
|
||||
if org.ArcgisAccountID.IsValue() {
|
||||
account, err = models.FindArcgisAccount(ctx, db.PGInstance.BobDB, org.ArcgisAccountID.MustGet())
|
||||
if err != nil {
|
||||
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{
|
||||
ArcGISAccount: account,
|
||||
ArcGISOAuth: oauth,
|
||||
ServiceMaps: service_maps,
|
||||
}
|
||||
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{}
|
||||
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/integration", authenticatedHandler(getConfigurationIntegration))
|
||||
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/pesticide", authenticatedHandler(getConfigurationPesticide))
|
||||
r.Method("GET", "/configuration/pesticide/add", authenticatedHandler(getConfigurationPesticideAdd))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue