Browse Source

add choice of a start date for a project

Trent Larson 7 months ago
parent
commit
79b14355d9
  1. 8
      src/views/ContactQRScanShowView.vue
  2. 50
      src/views/NewEditProjectView.vue
  3. 17
      src/views/ProjectViewView.vue

8
src/views/ContactQRScanShowView.vue

@ -82,12 +82,7 @@ import { useClipboard } from "@vueuse/core";
import { NotificationIface } from "@/constants/app"; import { NotificationIface } from "@/constants/app";
import { accountsDB, db } from "@/db/index"; import { accountsDB, db } from "@/db/index";
import { MASTER_SETTINGS_KEY } from "@/db/tables/settings"; import { MASTER_SETTINGS_KEY } from "@/db/tables/settings";
import { import { deriveAddress, nextDerivationPath, SimpleSigner } from "@/libs/crypto";
deriveAddress,
getContactPayloadFromJwtUrl,
nextDerivationPath,
SimpleSigner,
} from "@/libs/crypto";
import QuickNav from "@/components/QuickNav.vue"; import QuickNav from "@/components/QuickNav.vue";
import { Account } from "@/db/tables/accounts"; import { Account } from "@/db/tables/accounts";
import { import {
@ -187,7 +182,6 @@ export default class ContactQRScanShow extends Vue {
const url = content[0]?.rawValue; const url = content[0]?.rawValue;
if (url) { if (url) {
try { try {
const fullData = getContactPayloadFromJwtUrl(url);
localStorage.setItem("contactEndorserUrl", url); localStorage.setItem("contactEndorserUrl", url);
this.$router.push({ name: "contacts" }); this.$router.push({ name: "contacts" });
} catch (e) { } catch (e) {

50
src/views/NewEditProjectView.vue

@ -64,6 +64,23 @@
class="block w-full rounded border border-slate-400 mb-4 px-3 py-2" class="block w-full rounded border border-slate-400 mb-4 px-3 py-2"
/> />
<div class="flex mb-4 columns-3 w-full">
<input
v-model="startDateInput"
placeholder="Start Date"
type="date"
class="col-span-1 w-full rounded border border-slate-400 px-3 py-2"
/>
<input
:disabled="!startDateInput"
v-model="startTimeInput"
placeholder="Start Time"
type="time"
class="col-span-1 w-full rounded border border-slate-400 ml-2 px-3 py-2"
/>
<span class="col-span-1 w-full flex justify-center">{{ zoneName }}</span>
</div>
<div class="flex items-center mb-4"> <div class="flex items-center mb-4">
<input <input
type="checkbox" type="checkbox"
@ -137,6 +154,7 @@
import "leaflet/dist/leaflet.css"; import "leaflet/dist/leaflet.css";
import { AxiosError } from "axios"; import { AxiosError } from "axios";
import * as didJwt from "did-jwt"; import * as didJwt from "did-jwt";
import { DateTime } from "luxon";
import { Component, Vue } from "vue-facing-decorator"; import { Component, Vue } from "vue-facing-decorator";
import { LMap, LMarker, LTileLayer } from "@vue-leaflet/vue-leaflet"; import { LMap, LMarker, LTileLayer } from "@vue-leaflet/vue-leaflet";
@ -174,6 +192,9 @@ export default class NewEditProjectView extends Vue {
numAccounts = 0; numAccounts = 0;
projectId = localStorage.getItem("projectId") || ""; projectId = localStorage.getItem("projectId") || "";
projectIssuerDid = ""; projectIssuerDid = "";
startDateInput?: string;
startTimeInput?: string;
zoneName = DateTime.local().zoneName;
zoom = 2; zoom = 2;
async beforeCreate() { async beforeCreate() {
@ -252,6 +273,13 @@ export default class NewEditProjectView extends Vue {
if (this.fullClaim?.agent?.identifier) { if (this.fullClaim?.agent?.identifier) {
this.agentDid = this.fullClaim.agent.identifier; this.agentDid = this.fullClaim.agent.identifier;
} }
if (this.fullClaim.startTime) {
const localDateTime = DateTime.fromISO(
this.fullClaim.startTime as string,
).toLocal();
this.startDateInput = localDateTime.toFormat("yyyy-MM-dd");
this.startTimeInput = localDateTime.toFormat("HH:mm");
}
} }
} catch (error) { } catch (error) {
console.error("Got error retrieving that project", error); console.error("Got error retrieving that project", error);
@ -282,6 +310,28 @@ export default class NewEditProjectView extends Vue {
} else { } else {
delete vcClaim.location; delete vcClaim.location;
} }
if (this.startDateInput) {
try {
const startTimeFull = this.startTimeInput || "00:00:00";
const fullTimeString = this.startDateInput + " " + startTimeFull;
// throw an error on an invalid date or time string
vcClaim.startTime = new Date(fullTimeString).toISOString(); // ensure timezone is part of it
} catch {
// it's not a valid date so erase it and tell the user
delete vcClaim.startTime;
this.$notify(
{
group: "alert",
type: "danger",
title: "Error",
text: "The date was invalid so it was not set.",
},
5000,
);
}
} else {
delete vcClaim.startTime;
}
// Make a payload for the claim // Make a payload for the claim
const vcPayload = { const vcPayload = {
vc: { vc: {

17
src/views/ProjectViewView.vue

@ -53,9 +53,9 @@
<span v-show="showDidCopy">Copied DID</span> <span v-show="showDidCopy">Copied DID</span>
</span> </span>
</div> </div>
<div v-if="timeSince"> <div v-if="startTime">
<fa icon="calendar" class="fa-fw text-slate-400"></fa> <fa icon="calendar" class="fa-fw text-slate-400"></fa>
{{ timeSince }} {{ startTime }}
</div> </div>
<div v-if="latitude || longitude"> <div v-if="latitude || longitude">
<fa icon="location-dot" class="fa-fw text-slate-400"></fa> <fa icon="location-dot" class="fa-fw text-slate-400"></fa>
@ -339,7 +339,6 @@
<script lang="ts"> <script lang="ts">
import { AxiosError, RawAxiosRequestHeaders } from "axios"; import { AxiosError, RawAxiosRequestHeaders } from "axios";
import * as moment from "moment";
import { IIdentifier } from "@veramo/core"; import { IIdentifier } from "@veramo/core";
import { Component, Vue } from "vue-facing-decorator"; import { Component, Vue } from "vue-facing-decorator";
@ -396,7 +395,7 @@ export default class ProjectViewView extends Vue {
offersToThis: Array<OfferSummaryRecord> = []; offersToThis: Array<OfferSummaryRecord> = [];
projectId = localStorage.getItem("projectId") || ""; // handle ID projectId = localStorage.getItem("projectId") || ""; // handle ID
showDidCopy = false; showDidCopy = false;
timeSince = ""; startTime = "";
truncatedDesc = ""; truncatedDesc = "";
truncateLength = 40; truncateLength = 40;
url = ""; url = "";
@ -468,11 +467,13 @@ 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) {
const startTime = resp.data.startTime; const startTime = resp.data.claim?.startTime;
if (startTime != null) { if (startTime != null) {
const eventDate = new Date(startTime); const startDateTime = new Date(startTime);
const now = moment.now(); this.startTime =
this.timeSince = moment.utc(now).to(eventDate); startDateTime.toLocaleDateString() +
" " +
startDateTime.toLocaleTimeString();
} }
this.agentDid = resp.data.claim?.agent?.identifier; this.agentDid = resp.data.claim?.agent?.identifier;
this.issuer = resp.data.issuer; this.issuer = resp.data.issuer;

Loading…
Cancel
Save