Add log and related resources to API in frontend
This commit is contained in:
parent
999d69365c
commit
ec98c8226e
3 changed files with 29 additions and 6 deletions
|
|
@ -203,6 +203,7 @@ func (res *communicationR) hydrateCommunication(comm modelpublic.Communication,
|
||||||
return communication{
|
return communication{
|
||||||
Created: comm.Created,
|
Created: comm.Created,
|
||||||
ID: strconv.Itoa(int(comm.ID)),
|
ID: strconv.Itoa(int(comm.ID)),
|
||||||
|
Log: []communicationLog{},
|
||||||
Related: related,
|
Related: related,
|
||||||
Response: response,
|
Response: response,
|
||||||
Source: source_uri,
|
Source: source_uri,
|
||||||
|
|
|
||||||
|
|
@ -74,12 +74,10 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="h-100 d-flex flex-column" v-else>
|
<div class="h-100 d-flex flex-column" v-else>
|
||||||
<PublicReportCard
|
<ResourceCard
|
||||||
v-if="selectedReport"
|
:resource="resource"
|
||||||
:report="selectedReport"
|
v-for="(resource, index) in selectedCommunication.related"
|
||||||
@viewImage="openPhotoViewer"
|
|
||||||
/>
|
/>
|
||||||
<p v-else>Loading details...</p>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -88,7 +86,7 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed } from "vue";
|
import { computed } from "vue";
|
||||||
|
|
||||||
import PublicReportCard from "@/components/PublicReportCard.vue";
|
import ResourceCard from "@/components/ResourceCard.vue";
|
||||||
import TimeRelative from "@/components/TimeRelative.vue";
|
import TimeRelative from "@/components/TimeRelative.vue";
|
||||||
import Map, { LngLatBounds } from "@/map/Map.vue";
|
import Map, { LngLatBounds } from "@/map/Map.vue";
|
||||||
import Layer from "@/map/Layer.vue";
|
import Layer from "@/map/Layer.vue";
|
||||||
|
|
|
||||||
|
|
@ -529,9 +529,27 @@ export class PublicReportWater extends PublicReport {
|
||||||
uri: "",
|
uri: "",
|
||||||
});
|
});
|
||||||
*/
|
*/
|
||||||
|
export interface ResourceStubDTO {
|
||||||
|
created: string;
|
||||||
|
type: string;
|
||||||
|
uri: string;
|
||||||
|
}
|
||||||
|
export class ResourceStub {
|
||||||
|
constructor(
|
||||||
|
public created: Date,
|
||||||
|
public type: string,
|
||||||
|
public uri: string,
|
||||||
|
) {}
|
||||||
|
static fromJSON(json: ResourceStubDTO): ResourceStub {
|
||||||
|
return new ResourceStub(new Date(json.created), json.type, json.uri);
|
||||||
|
}
|
||||||
|
}
|
||||||
export interface CommunicationDTO {
|
export interface CommunicationDTO {
|
||||||
created: string;
|
created: string;
|
||||||
id: string;
|
id: string;
|
||||||
|
log: LogEntryDTO[];
|
||||||
|
related: ResourceStubDTO[];
|
||||||
|
response: string;
|
||||||
source: string;
|
source: string;
|
||||||
status: string;
|
status: string;
|
||||||
type: string;
|
type: string;
|
||||||
|
|
@ -541,6 +559,9 @@ export class Communication {
|
||||||
constructor(
|
constructor(
|
||||||
public created: Date,
|
public created: Date,
|
||||||
public id: string,
|
public id: string,
|
||||||
|
public log: LogEntry[],
|
||||||
|
public related: ResourceStub[],
|
||||||
|
public response: string,
|
||||||
public source: string,
|
public source: string,
|
||||||
public status: string,
|
public status: string,
|
||||||
public type: string,
|
public type: string,
|
||||||
|
|
@ -550,6 +571,9 @@ export class Communication {
|
||||||
return new Communication(
|
return new Communication(
|
||||||
new Date(json.created),
|
new Date(json.created),
|
||||||
json.id,
|
json.id,
|
||||||
|
json.log.map((l) => LogEntry.fromJSON(l)),
|
||||||
|
json.related.map((r) => ResourceStub.fromJSON(r)),
|
||||||
|
json.response,
|
||||||
json.source,
|
json.source,
|
||||||
json.status,
|
json.status,
|
||||||
json.type,
|
json.type,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue