|
|
|
<template>
|
|
|
|
<QuickNav selected="Discover"></QuickNav>
|
|
|
|
|
|
|
|
<!-- CONTENT -->
|
|
|
|
<section id="Content" class="p-6 pb-24">
|
|
|
|
<!-- Heading -->
|
|
|
|
<h1 id="ViewHeading" class="text-4xl text-center font-light pt-4 mb-8">
|
|
|
|
Discover
|
|
|
|
</h1>
|
|
|
|
|
|
|
|
<!-- Quick Search -->
|
|
|
|
<div id="QuickSearch" class="mb-4 flex" v-on:keyup.enter="search()">
|
|
|
|
<input
|
|
|
|
type="text"
|
|
|
|
v-model="searchTerms"
|
|
|
|
placeholder="Search…"
|
|
|
|
class="block w-full rounded-l border border-r-0 border-slate-400 px-3 py-2"
|
|
|
|
/>
|
|
|
|
<button
|
|
|
|
@click="search()"
|
|
|
|
class="px-4 rounded-r bg-slate-200 border border-l-0 border-slate-400"
|
|
|
|
>
|
|
|
|
<fa icon="magnifying-glass" class="fa-fw"></fa>
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<!-- Result Tabs -->
|
|
|
|
<div class="text-center text-slate-500 border-b border-slate-300">
|
|
|
|
<ul class="flex flex-wrap justify-center gap-4 -mb-px">
|
|
|
|
<li>
|
|
|
|
<a
|
|
|
|
href="#"
|
|
|
|
class="inline-block py-3 rounded-t-lg border-b-2 active text-blue-600 border-blue-600 font-semibold"
|
|
|
|
>
|
|
|
|
Nearby
|
|
|
|
<span
|
|
|
|
class="font-semibold text-sm bg-slate-200 px-1.5 py-0.5 rounded-md"
|
|
|
|
>20+</span
|
|
|
|
>
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<a
|
|
|
|
href="#"
|
|
|
|
class="inline-block py-3 rounded-t-lg border-b-2 border-transparent hover:text-slate-600 hover:border-slate-300"
|
|
|
|
>
|
|
|
|
Remote
|
|
|
|
<span
|
|
|
|
class="font-semibold text-sm bg-slate-200 px-1.5 py-0.5 rounded-md"
|
|
|
|
>13</span
|
|
|
|
>
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<!-- Results List -->
|
|
|
|
<ul class="">
|
|
|
|
<li class="border-b border-slate-300">
|
|
|
|
<a href="project-view.html" class="block py-4 flex gap-4">
|
|
|
|
<div class="w-12">
|
|
|
|
<img
|
|
|
|
src="https://picsum.photos/200/200?random=1"
|
|
|
|
class="w-full rounded"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="grow">
|
|
|
|
<h2 class="text-base font-semibold">Canyon cleanup</h2>
|
|
|
|
<div class="text-sm">
|
|
|
|
<fa icon="user" class="fa-fw text-slate-400"></fa> Rotary
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
|
|
<li class="border-b border-slate-300">
|
|
|
|
<a href="project-view.html" class="block py-4 flex gap-4">
|
|
|
|
<div class="w-12">
|
|
|
|
<img
|
|
|
|
src="https://picsum.photos/200/200?random=2"
|
|
|
|
class="w-full rounded"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="grow">
|
|
|
|
<h2 class="text-base font-semibold">Potluck with neighbors</h2>
|
|
|
|
<div class="text-sm">
|
|
|
|
<fa icon="user" class="fa-fw text-slate-400"></fa> Andrew A.
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
|
|
<li class="border-b border-slate-300">
|
|
|
|
<a href="project-view.html" class="block py-4 flex gap-4">
|
|
|
|
<div class="w-12">
|
|
|
|
<img
|
|
|
|
src="https://picsum.photos/200/200?random=3"
|
|
|
|
class="w-full rounded"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="grow">
|
|
|
|
<h2 class="text-base font-semibold">Historical site</h2>
|
|
|
|
<div class="text-sm">
|
|
|
|
<fa icon="user" class="fa-fw text-slate-400 mr-1"></fa>
|
|
|
|
<em>Unknown</em>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
<AlertMessage
|
|
|
|
:alertTitle="alertTitle"
|
|
|
|
:alertMessage="alertMessage"
|
|
|
|
></AlertMessage>
|
|
|
|
</section>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import { Component, Vue } from "vue-facing-decorator";
|
|
|
|
|
|
|
|
import { accountsDB, db } from "@/db";
|
|
|
|
import { MASTER_SETTINGS_KEY } from "@/db/tables/settings";
|
|
|
|
import * as R from "ramda";
|
|
|
|
import { accessToken } from "@/libs/crypto";
|
|
|
|
import AlertMessage from "@/components/AlertMessage";
|
|
|
|
import QuickNav from "@/components/QuickNav";
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
components: { AlertMessage, QuickNav },
|
|
|
|
})
|
|
|
|
export default class DiscoverView extends Vue {
|
|
|
|
activeDid = "";
|
|
|
|
apiServer = "";
|
|
|
|
searchTerms = "";
|
|
|
|
|
|
|
|
async mounted() {
|
|
|
|
await db.open();
|
|
|
|
const settings = await db.settings.get(MASTER_SETTINGS_KEY);
|
|
|
|
this.activeDid = settings?.activeDid || "";
|
|
|
|
this.apiServer = settings?.apiServer || "";
|
|
|
|
}
|
|
|
|
|
|
|
|
public async search() {
|
|
|
|
const headers = { "Content-Type": "application/json" };
|
|
|
|
if (this.activeDid) {
|
|
|
|
await accountsDB.open();
|
|
|
|
const allAccounts = await accountsDB.accounts.toArray();
|
|
|
|
const account = R.find((acc) => acc.did === this.activeDid, allAccounts);
|
|
|
|
//console.log("about to parse from", this.activeDid, account?.identity);
|
|
|
|
const identity = JSON.parse(account?.identity || "null");
|
|
|
|
if (!identity) {
|
|
|
|
throw new Error("No identity found.");
|
|
|
|
}
|
|
|
|
const token = await accessToken(identity);
|
|
|
|
headers["Authorization"] = "Bearer " + token;
|
|
|
|
} else {
|
|
|
|
// it's OK without auth... we just won't get any identifiers
|
|
|
|
}
|
|
|
|
const claimContents =
|
|
|
|
"claimContents=" + encodeURIComponent(this.searchTerms);
|
|
|
|
const claimType = "claimType=PlanAction";
|
|
|
|
const queryParams = [claimContents, claimType].join("&");
|
|
|
|
return fetch(this.apiServer + "/api/v2/report/claims?" + queryParams, {
|
|
|
|
method: "GET",
|
|
|
|
headers: headers,
|
|
|
|
})
|
|
|
|
.then(async (response) => {
|
|
|
|
if (response.status !== 200) {
|
|
|
|
const details = await response.text();
|
|
|
|
throw details;
|
|
|
|
}
|
|
|
|
return response.json();
|
|
|
|
})
|
|
|
|
.then((results) => {
|
|
|
|
if (results.data) {
|
|
|
|
console.log(results.data);
|
|
|
|
} else {
|
|
|
|
throw JSON.stringify(results);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.catch((e) => {
|
|
|
|
console.log("Error with feed load:", e);
|
|
|
|
this.alertMessage =
|
|
|
|
e.userMessage || "There was an error retrieving projects.";
|
|
|
|
this.alertTitle = "Error";
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
alertMessage = "";
|
|
|
|
alertTitle = "";
|
|
|
|
}
|
|
|
|
</script>
|