forked from trent_larson/crowd-funder-for-time-pwa
allow viewing of a project without an ID (and other refactors)
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
|
||||
tasks:
|
||||
- .5 audit all console.log calls
|
||||
- 01 design ideas for simple gives on the Home page
|
||||
- 01 add list of 'give' records for a project on ProjectView UI
|
||||
- 02 Discover page - display results (currently in console.log), spin when searching
|
||||
- 02 Discover page - display results (currently in console.log) & link, spin when searching
|
||||
- 08 search by location, endpoint, etc assignee:trent
|
||||
- 01 add a location for a project via map pin :
|
||||
- give attribute to use assignee:trent
|
||||
- 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)
|
||||
|
||||
- 08 Scan QR code to import into contacts.
|
||||
@@ -69,9 +69,10 @@ tasks:
|
||||
- pull, w/ scheduled runs
|
||||
|
||||
- linking between projects or plans :
|
||||
- terminology:
|
||||
- for subtasks: fulfills (is it really the same?), feeds, contributes to, supplies, boosts, advances
|
||||
- for blocking: blocks, precedes, comes before, is sought by -- vs follows, seeks, builds on ("contributes to" isn't specific enough, "succeeds" has different, possibly confusing meaning)
|
||||
- show total time given to & from a project
|
||||
- terminology:
|
||||
- for subtasks: fulfills (is it really the same?), feeds, contributes to, supplies, boosts, advances
|
||||
- for blocking: blocks, precedes, comes before, is sought by -- vs follows, seeks, builds on ("contributes to" isn't specific enough, "succeeds" has different, possibly confusing meaning)
|
||||
|
||||
- Stats :
|
||||
- 01 point out user's location on the world
|
||||
|
||||
@@ -279,6 +279,7 @@ import { useClipboard } from "@vueuse/core";
|
||||
|
||||
import { AppString } from "@/constants/app";
|
||||
import { db, accountsDB } from "@/db";
|
||||
import { AccountsSchema } from "@/db/tables/accounts";
|
||||
import { MASTER_SETTINGS_KEY } from "@/db/tables/settings";
|
||||
import { accessToken } from "@/libs/crypto";
|
||||
import { AxiosError } from "axios/index";
|
||||
|
||||
@@ -121,6 +121,7 @@ import * as R from "ramda";
|
||||
|
||||
import { Component, Vue } from "vue-facing-decorator";
|
||||
import { accountsDB, db } from "@/db";
|
||||
import { AccountsSchema } from "@/db/tables/accounts";
|
||||
import { Contact } from "@/db/tables/contacts";
|
||||
import { MASTER_SETTINGS_KEY } from "@/db/tables/settings";
|
||||
import { accessToken, SimpleSigner } from "@/libs/crypto";
|
||||
|
||||
@@ -58,7 +58,14 @@
|
||||
<!-- Results List -->
|
||||
<ul class="">
|
||||
<li class="border-b border-slate-300">
|
||||
<a href="project-view.html" class="block py-4 flex gap-4">
|
||||
<a
|
||||
@click="
|
||||
onClickLoadProject(
|
||||
'https://endorser.ch/entity/01H3HER4DTNCR6ZC4VXA3VPWVQ',
|
||||
)
|
||||
"
|
||||
class="block py-4 flex gap-4"
|
||||
>
|
||||
<div class="w-12">
|
||||
<img
|
||||
src="https://picsum.photos/200/200?random=1"
|
||||
@@ -76,7 +83,14 @@
|
||||
</li>
|
||||
|
||||
<li class="border-b border-slate-300">
|
||||
<a href="project-view.html" class="block py-4 flex gap-4">
|
||||
<a
|
||||
@click="
|
||||
onClickLoadProject(
|
||||
'https://endorser.ch/entity/01H3HER4DTNCR6ZC4VXA3VPWVQ',
|
||||
)
|
||||
"
|
||||
class="block py-4 flex gap-4"
|
||||
>
|
||||
<div class="w-12">
|
||||
<img
|
||||
src="https://picsum.photos/200/200?random=2"
|
||||
@@ -94,7 +108,14 @@
|
||||
</li>
|
||||
|
||||
<li class="border-b border-slate-300">
|
||||
<a href="project-view.html" class="block py-4 flex gap-4">
|
||||
<a
|
||||
@click="
|
||||
onClickLoadProject(
|
||||
'https://endorser.ch/entity/01H3HER4DTNCR6ZC4VXA3VPWVQ',
|
||||
)
|
||||
"
|
||||
class="block py-4 flex gap-4"
|
||||
>
|
||||
<div class="w-12">
|
||||
<img
|
||||
src="https://picsum.photos/200/200?random=3"
|
||||
@@ -240,5 +261,17 @@ export default class DiscoverView extends Vue {
|
||||
this.alertTitle = "Error";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle clicking on a project entry found in the list
|
||||
* @param id of the project
|
||||
**/
|
||||
onClickLoadProject(id: string) {
|
||||
localStorage.setItem("projectId", id);
|
||||
const route = {
|
||||
name: "project",
|
||||
};
|
||||
this.$router.push(route);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -73,6 +73,7 @@
|
||||
import { Component, Vue } from "vue-facing-decorator";
|
||||
import GiftedDialog from "@/components/GiftedDialog.vue";
|
||||
import { db, accountsDB } from "@/db";
|
||||
import { AccountsSchema } from "@/db/tables/accounts";
|
||||
import { MASTER_SETTINGS_KEY } from "@/db/tables/settings";
|
||||
import { accessToken } from "@/libs/crypto";
|
||||
import { createAndSubmitGive, didInfo } from "@/libs/endorserServer";
|
||||
|
||||
@@ -76,6 +76,7 @@ import * as didJwt from "did-jwt";
|
||||
import { Component, Vue } from "vue-facing-decorator";
|
||||
|
||||
import { accountsDB, db } from "@/db";
|
||||
import { AccountsSchema } from "@/db/tables/accounts";
|
||||
import { MASTER_SETTINGS_KEY } from "@/db/tables/settings";
|
||||
import { accessToken, SimpleSigner } from "@/libs/crypto";
|
||||
import { useAppStore } from "@/store/app";
|
||||
|
||||
@@ -66,28 +66,40 @@
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<button
|
||||
@click="openDialog({ name: 'you', did: activeDid })"
|
||||
class="text-center text-lg font-bold uppercase bg-blue-600 text-white px-2 py-3 rounded-md"
|
||||
>
|
||||
I gave...
|
||||
</button>
|
||||
... or choose a contact who gave:
|
||||
<div v-if="activeDid">
|
||||
<button
|
||||
@click="openDialog({ name: 'you', did: activeDid })"
|
||||
class="text-center text-lg font-bold uppercase bg-blue-600 text-white px-2 py-3 rounded-md"
|
||||
>
|
||||
I gave...
|
||||
</button>
|
||||
― or:
|
||||
</div>
|
||||
<!-- similar contact selection code is in multiple places -->
|
||||
<button
|
||||
v-for="contact in allContacts"
|
||||
:key="contact.did"
|
||||
@click="openDialog(contact)"
|
||||
class="text-blue-500"
|
||||
>
|
||||
{{ contact.name }},
|
||||
</button>
|
||||
Record a gift from
|
||||
<span v-for="contact in allContacts" :key="contact.did">
|
||||
<button @click="openDialog(contact)" class="text-blue-500">
|
||||
{{ contact.name }}</button
|
||||
>,
|
||||
</span>
|
||||
<span v-if="allContacts.length > 0"> or </span>
|
||||
<button @click="openDialog()" class="text-blue-500">
|
||||
someone not specified
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Gifts to & from this -->
|
||||
<!--
|
||||
<div class="mt-8 flex justify-around">
|
||||
<div>
|
||||
<h1 class="text-xl">Given to this Project</h1>
|
||||
</div>
|
||||
<div>
|
||||
<h1 class="text-xl">... and from this Project</h1>
|
||||
</div>
|
||||
</div>
|
||||
-->
|
||||
|
||||
<GiftedDialog
|
||||
ref="customDialog"
|
||||
@dialog-result="handleDialogResult"
|
||||
@@ -108,6 +120,7 @@ import { Component, Vue } from "vue-facing-decorator";
|
||||
|
||||
import GiftedDialog from "@/components/GiftedDialog.vue";
|
||||
import { accountsDB, db } from "@/db";
|
||||
import { AccountsSchema } from "@/db/tables/accounts";
|
||||
import { Contact } from "@/db/tables/contacts";
|
||||
import { MASTER_SETTINGS_KEY } from "@/db/tables/settings";
|
||||
import { createAndSubmitGive } from "@/libs/endorserServer";
|
||||
@@ -120,26 +133,42 @@ import QuickNav from "@/components/QuickNav";
|
||||
components: { GiftedDialog, AlertMessage, QuickNav },
|
||||
})
|
||||
export default class ProjectViewView extends Vue {
|
||||
accounts: AccountsSchema;
|
||||
activeDid = "";
|
||||
allContacts: Array<Contact> = [];
|
||||
apiServer = "";
|
||||
expanded = false;
|
||||
name = "";
|
||||
description = "";
|
||||
truncatedDesc = "";
|
||||
truncateLength = 40;
|
||||
timeSince = "";
|
||||
projectId = localStorage.getItem("projectId") || ""; // handle ID
|
||||
errorMessage = "";
|
||||
alertMessage = "";
|
||||
alertTitle = "";
|
||||
accounts: AccountsSchema;
|
||||
allContacts: Array<Contact> = [];
|
||||
apiServer = "";
|
||||
description = "";
|
||||
errorMessage = "";
|
||||
expanded = false;
|
||||
givesToThis: Array<any> = [];
|
||||
givesFromThis: Array<any> = [];
|
||||
name = "";
|
||||
numAccounts = 0;
|
||||
projectId = localStorage.getItem("projectId") || ""; // handle ID
|
||||
timeSince = "";
|
||||
truncatedDesc = "";
|
||||
truncateLength = 40;
|
||||
|
||||
async beforeCreate() {
|
||||
accountsDB.open();
|
||||
this.accounts = accountsDB.accounts;
|
||||
this.numAccounts = await this.accounts.count();
|
||||
this.numAccounts = (await this.accounts?.count()) || 0;
|
||||
}
|
||||
|
||||
async created() {
|
||||
await db.open();
|
||||
const settings = await db.settings.get(MASTER_SETTINGS_KEY);
|
||||
this.activeDid = settings?.activeDid || "";
|
||||
this.apiServer = settings?.apiServer || "";
|
||||
this.allContacts = await db.contacts.toArray();
|
||||
|
||||
this.accounts = accountsDB.accounts;
|
||||
const accountsArr = await this.accounts?.toArray();
|
||||
const account = accountsArr.find((acc) => acc.did === this.activeDid);
|
||||
const identity = JSON.parse(account?.identity || "null");
|
||||
this.LoadProject(identity);
|
||||
}
|
||||
|
||||
public async getIdentity(activeDid) {
|
||||
@@ -188,11 +217,13 @@ export default class ProjectViewView extends Vue {
|
||||
this.apiServer +
|
||||
"/api/claim/byHandle/" +
|
||||
encodeURIComponent(this.projectId);
|
||||
const token = await accessToken(identity);
|
||||
const headers = {
|
||||
"Content-Type": "application/json",
|
||||
Authorization: "Bearer " + token,
|
||||
};
|
||||
if (identity) {
|
||||
const token = await accessToken(identity);
|
||||
headers["Authorization"] = "Bearer " + token;
|
||||
}
|
||||
|
||||
try {
|
||||
const resp = await this.axios.get(url, { headers });
|
||||
@@ -202,7 +233,6 @@ export default class ProjectViewView extends Vue {
|
||||
const eventDate = new Date(startTime);
|
||||
const now = moment.now();
|
||||
this.timeSince = moment.utc(now).to(eventDate);
|
||||
errorMessage;
|
||||
}
|
||||
this.name = resp.data.claim?.name || "(no name)";
|
||||
this.description = resp.data.claim?.description || "(no description)";
|
||||
@@ -224,28 +254,6 @@ export default class ProjectViewView extends Vue {
|
||||
}
|
||||
}
|
||||
|
||||
async created() {
|
||||
await db.open();
|
||||
const settings = await db.settings.get(MASTER_SETTINGS_KEY);
|
||||
this.activeDid = settings?.activeDid || "";
|
||||
this.apiServer = settings?.apiServer || "";
|
||||
this.allContacts = await db.contacts.toArray();
|
||||
|
||||
if (this.numAccounts === 0) {
|
||||
console.error("Problem! Should have a profile!");
|
||||
} else {
|
||||
const accounts = await accountsDB.accounts.toArray();
|
||||
const account = accounts.find((acc) => acc.did === this.activeDid);
|
||||
const identity = JSON.parse(account?.identity || "null");
|
||||
if (!identity) {
|
||||
throw new Error(
|
||||
"An ID is chosen but there are no keys for it so it cannot be used to talk with the service.",
|
||||
);
|
||||
}
|
||||
this.LoadProject(identity);
|
||||
}
|
||||
}
|
||||
|
||||
openDialog(contact) {
|
||||
this.$refs.customDialog.open(contact);
|
||||
}
|
||||
|
||||
@@ -75,6 +75,7 @@
|
||||
<script lang="ts">
|
||||
import { Component, Vue } from "vue-facing-decorator";
|
||||
import { accountsDB, db } from "@/db";
|
||||
import { AccountsSchema } from "@/db/tables/accounts";
|
||||
import { MASTER_SETTINGS_KEY } from "@/db/tables/settings";
|
||||
import { accessToken } from "@/libs/crypto";
|
||||
import { IIdentifier } from "@veramo/core";
|
||||
@@ -137,14 +138,15 @@ export default class ProjectsView extends Vue {
|
||||
try {
|
||||
this.isLoading = true;
|
||||
const resp = await this.axios.get(url, { headers });
|
||||
if (resp.status === 200) {
|
||||
if (resp.status === 200 || !resp.data.data) {
|
||||
const plans: ProjectData[] = resp.data.data;
|
||||
for (const plan of plans) {
|
||||
const { name, description, handleId = plan.fullIri, rowid } = plan;
|
||||
this.projects.push({ name, description, handleId, rowid });
|
||||
}
|
||||
} else {
|
||||
console.log(resp.status);
|
||||
console.log("Bad server response & data:", resp.status, resp.data);
|
||||
throw Error("Failed to get projects from the server.");
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Got error loading projects:", error.message);
|
||||
@@ -217,19 +219,18 @@ export default class ProjectsView extends Vue {
|
||||
this.apiServer = settings?.apiServer || "";
|
||||
|
||||
if (this.numAccounts === 0) {
|
||||
console.error("Problem! You need a profile!");
|
||||
this.alertTitle = "Error!";
|
||||
this.alertMessage = "Problem! You need a profile!";
|
||||
console.error("No accounts found.");
|
||||
this.alertTitle = "Error";
|
||||
this.alertMessage = "You need an identity to load your projects.";
|
||||
} else {
|
||||
const identity = await this.getIdentity(activeDid);
|
||||
console.log(identity);
|
||||
this.current = identity;
|
||||
this.LoadProjects(identity);
|
||||
}
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
this.alertTitle = "Error!";
|
||||
this.alertMessage = "Problem! You need a profile!";
|
||||
console.log("Error initializing:", err);
|
||||
this.alertTitle = "Error";
|
||||
this.alertMessage = "Something went wrong loading your projects.";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user