Include client ID in nuisance and water reports
This commit is contained in:
parent
a23866619d
commit
84db38c985
4 changed files with 19 additions and 1 deletions
|
|
@ -14,6 +14,7 @@ import (
|
|||
"github.com/Gleipnir-Technology/nidus-sync/platform/types"
|
||||
"github.com/aarondl/opt/omit"
|
||||
"github.com/aarondl/opt/omitnull"
|
||||
"github.com/google/uuid"
|
||||
"github.com/rs/zerolog/log"
|
||||
)
|
||||
|
||||
|
|
@ -37,6 +38,7 @@ type Locator struct {
|
|||
}
|
||||
type nuisanceForm struct {
|
||||
AdditionalInfo string `schema:"additional-info"`
|
||||
ClientID uuid.UUID `schema:"client_id" json:"client_id"`
|
||||
Duration string `schema:"duration"`
|
||||
Location types.Location `schema:"location"`
|
||||
Locator Locator `schema:"locator"`
|
||||
|
|
@ -53,6 +55,8 @@ type nuisanceForm struct {
|
|||
}
|
||||
|
||||
func (res *nuisanceR) Create(ctx context.Context, r *http.Request, n nuisanceForm) (*nuisance, *nhttp.ErrorWithStatus) {
|
||||
user_agent := r.Header.Get("User-Agent")
|
||||
platform.EnsureClient(ctx, n.ClientID, user_agent)
|
||||
duration := enums.PublicreportNuisancedurationtypeNone
|
||||
is_location_frontyard := slices.Contains(n.SourceLocations, "frontyard")
|
||||
is_location_backyard := slices.Contains(n.SourceLocations, "backyard")
|
||||
|
|
@ -83,6 +87,7 @@ func (res *nuisanceR) Create(ctx context.Context, r *http.Request, n nuisanceFor
|
|||
//AddressID: omitnull.From(latlng.Cell.String()),
|
||||
AddressGid: omit.From(address.GID),
|
||||
AddressRaw: omit.From(address.Raw),
|
||||
ClientUUID: omitnull.From(n.ClientID),
|
||||
Created: omit.From(time.Now()),
|
||||
//H3cell: omitnull.From(latlng.Cell.String()),
|
||||
LatlngAccuracyType: omit.From(enums.PublicreportAccuracytypeBrowser),
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import (
|
|||
"github.com/Gleipnir-Technology/nidus-sync/platform/types"
|
||||
"github.com/aarondl/opt/omit"
|
||||
"github.com/aarondl/opt/omitnull"
|
||||
"github.com/google/uuid"
|
||||
"github.com/rs/zerolog/log"
|
||||
)
|
||||
|
||||
|
|
@ -39,6 +40,7 @@ type waterForm struct {
|
|||
AccessOther bool `schema:"access-other"`
|
||||
Address string `schema:"address"`
|
||||
AddressGID string `schema:"address-gid"`
|
||||
ClientID uuid.UUID `schema:"client_id" json:"client_id"`
|
||||
Comments string `schema:"comments"`
|
||||
HasAdult bool `schema:"has-adult"`
|
||||
HasBackyardPermission bool `schema:"backyard-permission"`
|
||||
|
|
@ -54,6 +56,8 @@ type waterForm struct {
|
|||
}
|
||||
|
||||
func (res *waterR) Create(ctx context.Context, r *http.Request, w waterForm) (*water, *nhttp.ErrorWithStatus) {
|
||||
user_agent := r.Header.Get("User-Agent")
|
||||
platform.EnsureClient(ctx, w.ClientID, user_agent)
|
||||
|
||||
uploads, err := html.ExtractImageUploads(r)
|
||||
log.Info().Int("len", len(uploads)).Msg("extracted water uploads")
|
||||
|
|
@ -72,6 +76,7 @@ func (res *waterR) Create(ctx context.Context, r *http.Request, w waterForm) (*w
|
|||
setter_report := models.PublicreportReportSetter{
|
||||
AddressGid: omit.From(address.GID),
|
||||
AddressRaw: omit.From(address.Raw),
|
||||
ClientUUID: omitnull.From(w.ClientID),
|
||||
Created: omit.From(time.Now()),
|
||||
//H3cell: omitnull.From(geospatial.Cell.String()),
|
||||
LatlngAccuracyType: omit.From(enums.PublicreportAccuracytypeBrowser),
|
||||
|
|
|
|||
|
|
@ -469,6 +469,7 @@ import ImageUpload, { Image } from "@/components/ImageUpload.vue";
|
|||
import MapLocator from "@/components/MapLocator.vue";
|
||||
import AddressAndMapLocator from "@/rmo/components/AddressAndMapLocator.vue";
|
||||
import { useGeocodeStore } from "@/store/geocode";
|
||||
import { useStoreLocal } from "@/store/local";
|
||||
import { useStoreLocation } from "@/store/location";
|
||||
import { useStorePublicReport } from "@/store/publicreport";
|
||||
import type { Marker } from "@/types";
|
||||
|
|
@ -488,9 +489,10 @@ const errorMessage = ref("");
|
|||
const formElement = ref<HTMLFormElement | null>(null);
|
||||
const images = ref<Image[]>([]);
|
||||
const isSubmitting = ref(false);
|
||||
const storeLocation = useStoreLocation();
|
||||
|
||||
const showMore = ref<boolean>(false);
|
||||
const storeLocal = useStoreLocal();
|
||||
const storeLocation = useStoreLocation();
|
||||
const storePublicReport = useStorePublicReport();
|
||||
const geocode = useGeocodeStore();
|
||||
const router = useRouter();
|
||||
|
|
@ -500,7 +502,9 @@ async function doSubmit() {
|
|||
isSubmitting.value = true;
|
||||
errorMessage.value = "";
|
||||
try {
|
||||
const client_id = storeLocal.getClientID();
|
||||
const formData = new FormData(formElement.value);
|
||||
formData.append("client_id", client_id);
|
||||
if (address.value) {
|
||||
formData.append("address.gid", address.value.gid);
|
||||
formData.append("address.raw", address.value.raw);
|
||||
|
|
|
|||
|
|
@ -622,6 +622,7 @@ import { useRouter } from "vue-router";
|
|||
import ImageUpload, { Image } from "@/components/ImageUpload.vue";
|
||||
import Tooltip from "@/components/Tooltip.vue";
|
||||
import { useGeocodeStore } from "@/store/geocode";
|
||||
import { useStoreLocal } from "@/store/local";
|
||||
import { useStoreLocation } from "@/store/location";
|
||||
import { useStorePublicReport } from "@/store/publicreport";
|
||||
import type { Marker } from "@/types";
|
||||
|
|
@ -650,6 +651,7 @@ const markers = computed((): Marker[] => {
|
|||
return [];
|
||||
}
|
||||
});
|
||||
const storeLocal = useStoreLocal();
|
||||
const storeLocation = useStoreLocation();
|
||||
const router = useRouter();
|
||||
const showMore = ref<boolean>(false);
|
||||
|
|
@ -660,7 +662,9 @@ async function doSubmit() {
|
|||
isSubmitting.value = true;
|
||||
errorMessage.value = "";
|
||||
try {
|
||||
const client_id = storeLocal.getClientID();
|
||||
const formData = new FormData(formElement.value);
|
||||
formData.append("client_id", client_id);
|
||||
if (address.value) {
|
||||
formData.append("address.gid", address.value.gid);
|
||||
formData.append("address.raw", address.value.raw);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue