Browse Source

list the gives to a plan and gives to which this plan contributed

pull/37/head
Trent Larson 1 year ago
parent
commit
0b7a35c9b8
  1. 1
      project.task.yaml
  2. 2
      src/main.ts
  3. 106
      src/views/ProjectViewView.vue

1
project.task.yaml

@ -7,6 +7,7 @@ tasks:
- 08 search by location, endpoint, etc assignee:trent - 08 search by location, endpoint, etc assignee:trent
- 01 add a location for a project via map pin (see API by clicking on "Nearby") - 01 add a location for a project via map pin (see API by clicking on "Nearby")
- 01 remove all the "form" fields (or at least investigate to see if that page refresh is desired) - 01 remove all the "form" fields (or at least investigate to see if that page refresh is desired)
- .2 change "errorMessage" to "alertMessage" on ProjectViewView.vue
- 08 Scan QR code to import into contacts. - 08 Scan QR code to import into contacts.

2
src/main.ts

@ -19,6 +19,7 @@ import {
faCircleUser, faCircleUser,
faClock, faClock,
faCoins, faCoins,
faComment,
faCopy, faCopy,
faEllipsisVertical, faEllipsisVertical,
faEye, faEye,
@ -58,6 +59,7 @@ library.add(
faCircleUser, faCircleUser,
faClock, faClock,
faCoins, faCoins,
faComment,
faCopy, faCopy,
faEllipsisVertical, faEllipsisVertical,
faEye, faEye,

106
src/views/ProjectViewView.vue

@ -23,7 +23,7 @@
</h1> </h1>
</div> </div>
<div> <div class="text-red-500">
{{ errorMessage }} {{ errorMessage }}
</div> </div>
@ -89,7 +89,6 @@
</div> </div>
<!-- Gifts to & from this --> <!-- Gifts to & from this -->
<!--
<div class="mt-8 flex justify-around"> <div class="mt-8 flex justify-around">
<div> <div>
<h1 class="text-xl">Given to this Project</h1> <h1 class="text-xl">Given to this Project</h1>
@ -98,8 +97,52 @@
<h1 class="text-xl">... and from this Project</h1> <h1 class="text-xl">... and from this Project</h1>
</div> </div>
</div> </div>
--> <div class="flex justify-around">
<div class="w-1/2">
<div v-for="give in givesToThis" :key="give.id">
<div class="flex justify-between">
<div class="flex gap-3">
<div class="flex gap-2">
<fa icon="user" class="fa-fw text-slate-400"></fa>
<span>{{
didInfo(give.agentDid, activeDid, accounts, allContacts)
}}</span>
</div>
<div class="flex gap-2" v-if="give.amount">
<fa icon="coins" class="fa-fw text-slate-400"></fa>
<span>{{ give.amount }}</span>
</div>
<div class="flex gap-2" v-if="give.description">
<fa icon="comment" class="fa-fw text-slate-400"></fa>
<span>{{ give.description }}</span>
</div>
</div>
</div>
</div>
</div>
<div class="w-1/2">
<div v-for="give in givesByThis" :key="give.id">
<div class="flex justify-between">
<div class="flex gap-3">
<div class="flex gap-2">
<fa icon="user" class="fa-fw text-slate-400"></fa>
<span>{{
didInfo(give.agentDid, activeDid, accounts, allContacts)
}}</span>
</div>
<div class="flex gap-2" v-if="give.amount">
<fa icon="coins" class="fa-fw text-slate-400"></fa>
<span>{{ give.amount }}</span>
</div>
<div class="flex gap-2">
<fa icon="comment" class="fa-fw text-slate-400"></fa>
<span>{{ give.description }}</span>
</div>
</div>
</div>
</div>
</div>
</div>
<GiftedDialog <GiftedDialog
ref="customDialog" ref="customDialog"
@dialog-result="handleDialogResult" @dialog-result="handleDialogResult"
@ -116,6 +159,7 @@
<script lang="ts"> <script lang="ts">
import { AxiosError } from "axios"; import { AxiosError } from "axios";
import * as moment from "moment"; import * as moment from "moment";
import { IIdentifier } from "@veramo/core";
import { Component, Vue } from "vue-facing-decorator"; import { Component, Vue } from "vue-facing-decorator";
import GiftedDialog from "@/components/GiftedDialog.vue"; import GiftedDialog from "@/components/GiftedDialog.vue";
@ -123,9 +167,12 @@ import { accountsDB, db } from "@/db";
import { AccountsSchema } from "@/db/tables/accounts"; import { AccountsSchema } from "@/db/tables/accounts";
import { Contact } from "@/db/tables/contacts"; import { Contact } from "@/db/tables/contacts";
import { MASTER_SETTINGS_KEY } from "@/db/tables/settings"; import { MASTER_SETTINGS_KEY } from "@/db/tables/settings";
import { createAndSubmitGive } from "@/libs/endorserServer";
import { accessToken } from "@/libs/crypto"; import { accessToken } from "@/libs/crypto";
import { IIdentifier } from "@veramo/core"; import {
createAndSubmitGive,
didInfo,
GiveServerRecord,
} from "@/libs/endorserServer";
import AlertMessage from "@/components/AlertMessage"; import AlertMessage from "@/components/AlertMessage";
import QuickNav from "@/components/QuickNav"; import QuickNav from "@/components/QuickNav";
@ -142,8 +189,8 @@ export default class ProjectViewView extends Vue {
description = ""; description = "";
errorMessage = ""; errorMessage = "";
expanded = false; expanded = false;
givesToThis: Array<any> = []; givesToThis: Array<GiveServerRecord> = [];
givesFromThis: Array<any> = []; givesByThis: Array<GiveServerRecord> = [];
name = ""; name = "";
numAccounts = 0; numAccounts = 0;
projectId = localStorage.getItem("projectId") || ""; // handle ID projectId = localStorage.getItem("projectId") || ""; // handle ID
@ -204,6 +251,11 @@ export default class ProjectViewView extends Vue {
this.$router.push(route); this.$router.push(route);
} }
// Isn't there a better way to make this available to the template?
didInfo(did, activeDid, identities, contacts) {
return didInfo(did, activeDid, identities, contacts);
}
expandText() { expandText() {
this.expanded = true; this.expanded = true;
} }
@ -228,6 +280,8 @@ export default class ProjectViewView extends Vue {
try { try {
const resp = await this.axios.get(url, { headers }); const resp = await this.axios.get(url, { headers });
if (resp.status === 200) { if (resp.status === 200) {
// feel free to remove this; I haven't yet because it's helpful
console.log('Loaded project: ', resp.data);
const startTime = resp.data.startTime; const startTime = resp.data.startTime;
if (startTime != null) { if (startTime != null) {
const eventDate = new Date(startTime); const eventDate = new Date(startTime);
@ -252,6 +306,42 @@ export default class ProjectViewView extends Vue {
console.error("Error retrieving project:", error); console.error("Error retrieving project:", error);
} }
} }
const givesInUrl =
this.apiServer +
"/api/v2/report/givesForPlans?planIds=" +
encodeURIComponent(JSON.stringify([this.projectId]));
try {
const resp = await this.axios.get(givesInUrl, { headers });
if (resp.status === 200 && resp.data.data) {
this.givesToThis = resp.data.data;
} else {
this.errorMessage = "Failed to retrieve gives to this project.";
}
} catch (error: unknown) {
console.error("Error retrieving gives to this project:", error);
const serverError = error as AxiosError;
this.errorMessage =
"Something went wrong retrieving gives to this project.";
}
const givesOutUrl =
this.apiServer +
"/api/v2/report/givesProvidedBy?providerId=" +
encodeURIComponent(this.projectId);
try {
const resp = await this.axios.get(givesOutUrl, { headers });
if (resp.status === 200 && resp.data.data) {
this.givesByThis = resp.data.data;
} else {
this.errorMessage = "Failed to retrieve gives by this project.";
}
} catch (error: unknown) {
console.error("Error retrieving gives by this project:", error);
const serverError = error as AxiosError;
this.errorMessage =
"Something went wrong retrieving gives by project.";
}
} }
openDialog(contact) { openDialog(contact) {

Loading…
Cancel
Save