diff --git a/resource/publicreport.go b/resource/publicreport.go index dc9b4c52..af069928 100644 --- a/resource/publicreport.go +++ b/resource/publicreport.go @@ -2,8 +2,11 @@ package resource import ( "context" + "time" + nhttp "github.com/Gleipnir-Technology/nidus-sync/http" "github.com/Gleipnir-Technology/nidus-sync/platform" + "github.com/Gleipnir-Technology/nidus-sync/platform/types" "net/http" //"github.com/rs/zerolog/log" "github.com/gorilla/mux" @@ -14,9 +17,15 @@ type publicreportR struct { } type publicreport struct { - ID string `json:"id"` - District string `json:"district"` - URI string `json:"uri"` + Address string `json:"address"` + Created time.Time `json:"created"` + District string `json:"district"` + ID string `json:"id"` + ImageCount int `json:"image_count"` + Location types.Location `json:"location"` + Status string `json:"status"` + Type string `json:"type"` + URI string `json:"uri"` } func Publicreport(r *router) *publicreportR { @@ -39,8 +48,23 @@ func (res *publicreportR) ByID(ctx context.Context, r *http.Request, query Query if err != nil { return nil, nhttp.NewError("district uri: %w", err) } + uri, err := res.router.IDStrToURI("publicreport.ByIDGet", report.PublicID) + if err != nil { + return nil, nhttp.NewError("uri: %w", err) + } + location := types.Location{ + Latitude: report.LocationLatitude.GetOr(0.0), + Longitude: report.LocationLongitude.GetOr(0.0), + } return &publicreport{ - District: district_uri, - ID: report.PublicID, + District: district_uri, + ID: report.PublicID, + Address: report.AddressRaw, + Created: report.Created, + ImageCount: len(report.R.Images), + Location: location, + Status: report.Status.String(), + Type: report.ReportType.String(), + URI: uri, }, nil } diff --git a/ts/components/MapLocatorDisplay.vue b/ts/components/MapLocatorDisplay.vue new file mode 100644 index 00000000..41707f48 --- /dev/null +++ b/ts/components/MapLocatorDisplay.vue @@ -0,0 +1,178 @@ + + + + + diff --git a/ts/rmo/router.ts b/ts/rmo/router.ts index 59896a38..cb2a968f 100644 --- a/ts/rmo/router.ts +++ b/ts/rmo/router.ts @@ -16,6 +16,7 @@ import NuisanceBase from "@/rmo/view/Nuisance.vue"; import NuisanceDistrict from "@/rmo/view/district/Nuisance.vue"; import ReportSubmitted from "@/rmo/view/ReportSubmitted.vue"; import StatusBase from "@/rmo/view/Status.vue"; +import StatusByID from "@/rmo/view/StatusByID.vue"; import StatusDistrict from "@/rmo/view/district/Status.vue"; import Water from "@/rmo/view/Water.vue"; import WaterDistrict from "@/rmo/view/district/Water.vue"; @@ -118,6 +119,12 @@ const routes: RouteRecordRaw[] = [ name: "StatusBase", component: StatusBase, }, + { + component: StatusByID, + name: "StatusbyID", + path: "/status/:id", + props: true, + }, { path: "/water", name: "Water", diff --git a/ts/rmo/view/StatusByID.vue b/ts/rmo/view/StatusByID.vue new file mode 100644 index 00000000..b9ca2ae9 --- /dev/null +++ b/ts/rmo/view/StatusByID.vue @@ -0,0 +1,161 @@ + + + diff --git a/ts/store/publicreport.ts b/ts/store/publicreport.ts index 783f2813..4834fcc7 100644 --- a/ts/store/publicreport.ts +++ b/ts/store/publicreport.ts @@ -1,6 +1,6 @@ import { defineStore } from "pinia"; import { ref } from "vue"; -import type { Publicreport } from "@/type/api"; +import { Publicreport, type PublicreportDTO } from "@/type/api"; export const useStorePublicreport = defineStore("publicreport", () => { // State @@ -23,9 +23,10 @@ export const useStorePublicreport = defineStore("publicreport", () => { if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } - const body = await response.json(); - _byID.value.set(id, body); - return body; + const body: PublicreportDTO = await response.json(); + const report = Publicreport.fromJSON(body); + _byID.value.set(id, report); + return report; } catch (err) { console.error("Error loading users:", err); throw err; diff --git a/ts/type/api.ts b/ts/type/api.ts index bc22d6c5..1dc8260b 100644 --- a/ts/type/api.ts +++ b/ts/type/api.ts @@ -32,8 +32,40 @@ export interface Geocode { cell: number; location: Location; } -export interface Publicreport { +export interface PublicreportDTO { + address: string; + created: string; district: string; id: string; + image_count: number; + location: Location; + status: string; + type: string; uri: string; } +export class Publicreport { + constructor( + public address: string, + public created: Date, + public district: string, + public id: string, + public image_count: number, + public location: Location, + public status: string, + public type: string, + public uri: string, + ) {} + static fromJSON(json: PublicreportDTO): Publicreport { + return new Publicreport( + json.address, + new Date(json.created), + json.district, + json.id, + json.image_count, + json.location, + json.status, + json.type, + json.uri, + ); + } +}