Compare commits
8 Commits
c076ce5b44
...
bd27d8a10f
Author | SHA1 | Date |
---|---|---|
Jose Olarte III | bd27d8a10f | 2 months ago |
Trent Larson | a7b89f4bb6 | 3 months ago |
Trent Larson | e9c5bd8e99 | 3 months ago |
Trent Larson | 5d47eab6d8 | 3 months ago |
Trent Larson | e24cd06e3d | 3 months ago |
Trent Larson | 767d33c0a0 | 3 months ago |
Trent Larson | 22c3d28405 | 3 months ago |
Trent Larson | 7a25892472 | 3 months ago |
23 changed files with 551 additions and 123 deletions
@ -0,0 +1,96 @@ |
|||
<template> |
|||
<div v-if="visible" class="dialog-overlay"> |
|||
<div class="dialog"> |
|||
<h1 class="text-xl font-bold text-center mb-4">Set Your Name</h1> |
|||
|
|||
Note that this is not sent to servers. It is only shared with people when |
|||
you choose to send it to them. |
|||
<input |
|||
type="text" |
|||
placeholder="Name" |
|||
class="block w-full rounded border border-slate-400 mb-4 px-3 py-2" |
|||
v-model="givenName" |
|||
/> |
|||
|
|||
<div class="mt-8"> |
|||
<div class="grid grid-cols-1 sm:grid-cols-2 gap-2"> |
|||
<button |
|||
type="button" |
|||
class="block w-full text-center text-lg font-bold uppercase bg-gradient-to-b from-blue-400 to-blue-700 shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.5)] text-white px-2 py-3 rounded-md mb-2" |
|||
@click="onClickSaveChanges()" |
|||
> |
|||
Save |
|||
</button> |
|||
<!-- SHOW ME instead while processing saving changes --> |
|||
<button |
|||
type="button" |
|||
class="block w-full text-center text-md uppercase bg-gradient-to-b from-slate-400 to-slate-700 shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.5)] text-white px-2 py-3 rounded-md mb-2" |
|||
@click="onClickCancel()" |
|||
> |
|||
Cancel |
|||
</button> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</template> |
|||
|
|||
<script lang="ts"> |
|||
import { Vue, Component } from "vue-facing-decorator"; |
|||
|
|||
import { NotificationIface } from "@/constants/app"; |
|||
import { db } from "@/db/index"; |
|||
import { MASTER_SETTINGS_KEY, Settings } from "@/db/tables/settings"; |
|||
|
|||
@Component |
|||
export default class UserNameDialog extends Vue { |
|||
$notify!: (notification: NotificationIface, timeout?: number) => void; |
|||
|
|||
callback: (string?) => void = () => {}; |
|||
givenName = ""; |
|||
visible = false; |
|||
|
|||
async open(aCallback?: (name?: string) => void) { |
|||
this.callback = aCallback || this.callback; |
|||
await db.open(); |
|||
const settings = (await db.settings.get(MASTER_SETTINGS_KEY)) as Settings; |
|||
this.givenName = settings?.firstName || ""; |
|||
this.visible = true; |
|||
} |
|||
|
|||
async onClickSaveChanges() { |
|||
await db.settings.update(MASTER_SETTINGS_KEY, { |
|||
firstName: this.givenName, |
|||
}); |
|||
this.visible = false; |
|||
this.callback(this.givenName); |
|||
} |
|||
|
|||
onClickCancel() { |
|||
this.visible = false; |
|||
} |
|||
} |
|||
</script> |
|||
|
|||
<style> |
|||
.dialog-overlay { |
|||
position: fixed; |
|||
top: 0; |
|||
left: 0; |
|||
right: 0; |
|||
bottom: 0; |
|||
background-color: rgba(0, 0, 0, 0.5); |
|||
display: flex; |
|||
justify-content: center; |
|||
align-items: center; |
|||
padding: 1.5rem; |
|||
} |
|||
|
|||
.dialog { |
|||
background-color: white; |
|||
padding: 1rem; |
|||
border-radius: 0.5rem; |
|||
width: 100%; |
|||
max-width: 500px; |
|||
} |
|||
</style> |
@ -0,0 +1,123 @@ |
|||
<template> |
|||
<QuickNav /> |
|||
<TopMessage /> |
|||
|
|||
<!-- CONTENT --> |
|||
<section id="Content" class="p-2 pb-24 max-w-3xl mx-auto"> |
|||
<!-- Breadcrumb --> |
|||
<div> |
|||
<!-- Back --> |
|||
<div class="text-lg text-center font-light relative px-7"> |
|||
<h1 |
|||
class="text-lg text-center px-2 py-1 absolute -left-2 -top-1" |
|||
@click="$router.back()" |
|||
> |
|||
<fa icon="chevron-left" class="fa-fw" /> |
|||
</h1> |
|||
</div> |
|||
|
|||
<!-- Heading --> |
|||
<h1 id="ViewHeading" class="text-4xl text-center font-light"> |
|||
Share Your Contact Info |
|||
</h1> |
|||
</div> |
|||
|
|||
<div class="flex justify-center mt-8"> |
|||
<button |
|||
class="block w-fit text-center text-lg font-bold bg-gradient-to-b from-blue-400 to-blue-700 shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.5)] text-white px-2 py-3 rounded-md" |
|||
@click="onClickShare()" |
|||
> |
|||
Copy to Clipboard |
|||
</button> |
|||
</div> |
|||
<div class="ml-12"> |
|||
<div class="mt-8">Click to copy your info, then send it to them.</div> |
|||
<div> |
|||
They will paste it in the input box on the Contacts |
|||
<fa icon="users" /> screen. |
|||
</div> |
|||
</div> |
|||
</section> |
|||
</template> |
|||
|
|||
<script lang="ts"> |
|||
import * as R from "ramda"; |
|||
import { Component, Vue } from "vue-facing-decorator"; |
|||
import { Router } from "vue-router"; |
|||
import { useClipboard } from "@vueuse/core"; |
|||
|
|||
import QuickNav from "@/components/QuickNav.vue"; |
|||
import TopMessage from "@/components/TopMessage.vue"; |
|||
import { NotificationIface } from "@/constants/app"; |
|||
import { accountsDB, db } from "@/db/index"; |
|||
import { MASTER_SETTINGS_KEY, Settings } from "@/db/tables/settings"; |
|||
import { generateEndorserJwtForAccount } from "@/libs/endorserServer"; |
|||
|
|||
@Component({ |
|||
components: { QuickNav, TopMessage }, |
|||
}) |
|||
export default class ShareMyContactInfoView extends Vue { |
|||
$notify!: (notification: NotificationIface, timeout?: number) => void; |
|||
|
|||
async onClickShare() { |
|||
await db.open(); |
|||
const settings = (await db.settings.get(MASTER_SETTINGS_KEY)) as Settings; |
|||
const activeDid = settings?.activeDid || ""; |
|||
const givenName = settings?.firstName || ""; |
|||
const isRegistered = !!settings?.isRegistered; |
|||
const profileImageUrl = settings?.profileImageUrl || ""; |
|||
|
|||
await accountsDB.open(); |
|||
const accounts = await accountsDB.accounts.toArray(); |
|||
const account = R.find((acc) => acc.did === activeDid, accounts); |
|||
|
|||
const numContacts = await db.contacts.count(); |
|||
|
|||
if (account) { |
|||
const message = await generateEndorserJwtForAccount( |
|||
account, |
|||
isRegistered, |
|||
givenName, |
|||
profileImageUrl, |
|||
); |
|||
useClipboard() |
|||
.copy(message) |
|||
.then(() => { |
|||
this.$notify( |
|||
{ |
|||
group: "alert", |
|||
type: "info", |
|||
title: "Copied", |
|||
text: "Your contact info was copied to the clipboard. Have them paste it in the box on their 'Contacts' screen.", |
|||
}, |
|||
5000, |
|||
); |
|||
if (numContacts > 0) { |
|||
setTimeout(() => { |
|||
this.$notify( |
|||
{ |
|||
group: "alert", |
|||
type: "success", |
|||
title: "Share Other Contacts", |
|||
text: "You may want to share some of your contacts with them. Select them below to copy and send.", |
|||
}, |
|||
10000, |
|||
); |
|||
}, 3000); |
|||
} |
|||
}); |
|||
(this.$router as Router).push({ name: "contacts" }); |
|||
} else { |
|||
this.$notify( |
|||
{ |
|||
group: "alert", |
|||
type: "error", |
|||
title: "Error", |
|||
text: "No account was found for the active DID.", |
|||
}, |
|||
5000, |
|||
); |
|||
} |
|||
} |
|||
} |
|||
</script> |
Loading…
Reference in new issue