From c696de33f3d6cd7a4ec39c55b82778cfa79ca94d Mon Sep 17 00:00:00 2001 From: Trent Larson Date: Fri, 23 Feb 2024 19:02:10 -0700 Subject: [PATCH 01/19] add page to take a picture and upload to an image server --- package-lock.json | 6 +++ package.json | 1 + project.task.yaml | 3 +- src/components/GiftedDialog.vue | 12 ++++- src/main.ts | 4 ++ src/router/index.ts | 6 +++ src/views/GiftedPhoto.vue | 89 +++++++++++++++++++++++++++++++++ 7 files changed, 118 insertions(+), 3 deletions(-) create mode 100644 src/views/GiftedPhoto.vue diff --git a/package-lock.json b/package-lock.json index 2ab5803db..213d10b34 100644 --- a/package-lock.json +++ b/package-lock.json @@ -53,6 +53,7 @@ "readable-stream": "^4.4.2", "reflect-metadata": "^0.1.13", "register-service-worker": "^1.7.2", + "simple-vue-camera": "^1.1.3", "three": "^0.156.1", "ua-parser-js": "^1.0.37", "util": "^0.12.5", @@ -25432,6 +25433,11 @@ "node": ">= 5.10.0" } }, + "node_modules/simple-vue-camera": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/simple-vue-camera/-/simple-vue-camera-1.1.3.tgz", + "integrity": "sha512-GVAYq1BMI9cHt+h24tu2dfIFFvhjVQ1M8IkK5LmrKcYoBA8FZlLNlhrHC2NnTPbMAXIvJn1Bqx8X6Q31+Y2+jA==" + }, "node_modules/sirv": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/sirv/-/sirv-2.0.3.tgz", diff --git a/package.json b/package.json index cfab56ec9..80b5bb21a 100644 --- a/package.json +++ b/package.json @@ -53,6 +53,7 @@ "readable-stream": "^4.4.2", "reflect-metadata": "^0.1.13", "register-service-worker": "^1.7.2", + "simple-vue-camera": "^1.1.3", "three": "^0.156.1", "ua-parser-js": "^1.0.37", "util": "^0.12.5", diff --git a/project.task.yaml b/project.task.yaml index a63e09b73..489b84e97 100644 --- a/project.task.yaml +++ b/project.task.yaml @@ -20,7 +20,7 @@ tasks : - 32 image on give : - Show a camera to take a picture - Scale the image to a reasonable size - - Upload to a public readable place + - Upload to a public readable place - restrict size, catch all errors, multiple file types - check the rate limits - use CID (hash?) - put the image URL in the claim @@ -40,6 +40,7 @@ tasks : - show previous on "Your" screen - checkboxes - randomize vs show in order, show non-person-oriented messages, show only contacts, show only projects +- .5 add a notice on the front page if their notifications are off - 08 allow user to add a time when they want their daily notification - .5 prompt for the name directly when they visit the QR scan page diff --git a/src/components/GiftedDialog.vue b/src/components/GiftedDialog.vue index 3edb081cd..fbc103d9e 100644 --- a/src/components/GiftedDialog.vue +++ b/src/components/GiftedDialog.vue @@ -36,8 +36,16 @@ -
- +
+ + + + + + diff --git a/src/main.ts b/src/main.ts index c97e44dd8..ca8cf213b 100644 --- a/src/main.ts +++ b/src/main.ts @@ -18,6 +18,7 @@ import { faBitcoinSign, faBurst, faCalendar, + faCamera, faChevronLeft, faChevronRight, faCircle, @@ -76,6 +77,7 @@ library.add( faBitcoinSign, faBurst, faCalendar, + faCamera, faChevronLeft, faChevronRight, faCircle, @@ -127,9 +129,11 @@ library.add( ); import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome"; +import Camera from "simple-vue-camera"; createApp(App) .component("fa", FontAwesomeIcon) + .component("camera", Camera) .use(createPinia()) .use(VueAxios, axios) .use(router) diff --git a/src/router/index.ts b/src/router/index.ts index 68da028fc..9830eb37d 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -84,6 +84,12 @@ const routes: Array = [ component: () => import(/* webpackChunkName: "discover" */ "../views/DiscoverView.vue"), }, + { + path: "/gifted-photo", + name: "gifted-photo", + component: () => + import(/* webpackChunkName: "gifted-photo" */ "../views/GiftedPhoto.vue"), + }, { path: "/help", name: "help", diff --git a/src/views/GiftedPhoto.vue b/src/views/GiftedPhoto.vue new file mode 100644 index 000000000..6af183ba9 --- /dev/null +++ b/src/views/GiftedPhoto.vue @@ -0,0 +1,89 @@ + + + From ca9044770009914f96b455ecb49898ee598e2ebc Mon Sep 17 00:00:00 2001 From: Trent Larson Date: Sat, 2 Mar 2024 16:15:03 -0700 Subject: [PATCH 02/19] fix different "environment" variables for prod & dev --- .env.development | 4 ++++ .env.production | 3 +++ CHANGELOG.md | 9 ++++++--- README.md | 8 ++++---- package.json | 1 + src/constants/app.ts | 4 +++- src/libs/endorserServer.ts | 4 ++-- 7 files changed, 23 insertions(+), 10 deletions(-) create mode 100644 .env.development create mode 100644 .env.production diff --git a/.env.development b/.env.development new file mode 100644 index 000000000..9e5c00605 --- /dev/null +++ b/.env.development @@ -0,0 +1,4 @@ +# Only the variables that start with VUE_APP_ are seen in the application process.env in Vue. + +# this won't resolve as a URL on production; it's a URN only found in the test system +VUE_APP_BVC_MEETUPS_PROJECT_CLAIM_ID=https://endorser.ch/entity/01HNTZYJJXTGT0EZS3VEJGX7AK diff --git a/.env.production b/.env.production new file mode 100644 index 000000000..d34380077 --- /dev/null +++ b/.env.production @@ -0,0 +1,3 @@ +# Only the variables that start with VUE_APP_ are seen in the application process.env in Vue. +VUE_APP_BVC_MEETUPS_PROJECT_CLAIM_ID=https://endorser.ch/entity/01GXYPFF7FA03NXKPYY142PY4H +VUE_APP_DEFAULT_ENDORSER_API_SERVER=https://api.endorser.ch diff --git a/CHANGELOG.md b/CHANGELOG.md index 96e74adbb..bab2bbc75 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,11 +6,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] -### Changed in DB -- ? +### Fixed +- Environment variable for BVC meetings project +### Changed in DB or environment +- Test that a new browser session will get the right default API +- Test that a new browser session will send the right BVC meetings project -## [0.2.17] - 2024.03.01- 3612ea42240c5e1b7d7eff29a39ff18f1b869b36 +## [0.2.17] - 2024.03.01 - 3612ea42240c5e1b7d7eff29a39ff18f1b869b36 ### Added - Shortcut page for Bountiful Voluntaryist Community ### Changed diff --git a/README.md b/README.md index be28ce065..04286a077 100644 --- a/README.md +++ b/README.md @@ -34,9 +34,9 @@ npm run lint * Update the project.task.yaml & CHANGELOG.md & the version in package.json, run `npm install`. -* If production: change src/constants/app.ts DEFAULT_*_SERVER to be "PROD" and package.json to remove "_Test". Also record what version is on production. +* If production: change package.json to remove "_Test". Also record what version is on production. -* `npm run build` +* `npm run build-dev` for test servers or `npm run build` for production. * Get on the server and back up the time-safari folder. @@ -44,9 +44,9 @@ npm run lint * Revert src/constants/app.ts and package.json (if that was prod). -* Commit changes. Record the new hash in the changelog. Edit package.json to increment version & add "-beta", `npm install`, and commit. Tag if you didn't before. Also record what version is on production. +* Commit changes. Record the new hash in the changelog. Edit package.json to increment version & add "-beta", `npm install`, and commit. Also record what version is on production. -* [Tag wth the new version.](https://gitea.anomalistdesign.com/trent_larson/crowd-funder-for-time-pwa/releases) +* [Tag with the new version.](https://gitea.anomalistdesign.com/trent_larson/crowd-funder-for-time-pwa/releases) diff --git a/package.json b/package.json index 584468096..07cae38b3 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "scripts": { "serve": "vue-cli-service serve", "build": "vue-cli-service build", + "build-dev": "vue-cli-service build --mode development", "lint": "vue-cli-service lint" }, "dependencies": { diff --git a/src/constants/app.ts b/src/constants/app.ts index 4e94d01ff..929610762 100644 --- a/src/constants/app.ts +++ b/src/constants/app.ts @@ -15,7 +15,9 @@ export enum AppString { NO_CONTACT_NAME = "(no name)", } -export const DEFAULT_ENDORSER_API_SERVER = AppString.TEST_ENDORSER_API_SERVER; +export const DEFAULT_ENDORSER_API_SERVER = + process.env.VUE_APP_DEFAULT_ENDORSER_API_SERVER || + AppString.TEST_ENDORSER_API_SERVER; export const DEFAULT_PUSH_SERVER = window.location.protocol + "//" + window.location.host; diff --git a/src/libs/endorserServer.ts b/src/libs/endorserServer.ts index 48856114b..ad508c096 100644 --- a/src/libs/endorserServer.ts +++ b/src/libs/endorserServer.ts @@ -780,8 +780,8 @@ export const claimSpecialDescription = ( }; export const BVC_MEETUPS_PROJECT_CLAIM_ID = - //"https://endorser.ch/entity/01GXYPFF7FA03NXKPYY142PY4H"; - "https://endorser.ch/entity/01HNTZYJJXTGT0EZS3VEJGX7AK"; + process.env.VUE_APP_BVC_MEETUPS_PROJECT_CLAIM_ID || + "https://endorser.ch/entity/01HNTZYJJXTGT0EZS3VEJGX7AK"; // this won't resolve as a URL on production; it's a URN only found in the test system export const bvcMeetingJoinClaim = (did: string, startTime: string) => { return { From 92b924643eb7a4961b18d6d13bec0908cf44217a Mon Sep 17 00:00:00 2001 From: Trent Larson Date: Tue, 5 Mar 2024 20:20:54 -0700 Subject: [PATCH 03/19] fix camera resolution, parameterize image API server --- project.task.yaml | 3 +++ src/constants/app.ts | 5 +++++ src/views/GiftedPhoto.vue | 19 ++++++++----------- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/project.task.yaml b/project.task.yaml index 489b84e97..4ed2a306f 100644 --- a/project.task.yaml +++ b/project.task.yaml @@ -1,6 +1,9 @@ tasks : +- .1 on feed, don't show "to someone anonymous" if it's to a project +- .1 on ideas, put an "x" to close it + - .2 fix give dialog from "more contacts" off home page to allow giving to this user - 01 in the feed, group by project or contact or topic or time/$ (via BC) - .2 anchor hash into BTC diff --git a/src/constants/app.ts b/src/constants/app.ts index 4e94d01ff..6c1951925 100644 --- a/src/constants/app.ts +++ b/src/constants/app.ts @@ -12,10 +12,15 @@ export enum AppString { TEST1_PUSH_SERVER = "https://test.timesafari.app", TEST2_PUSH_SERVER = "https://timesafari-pwa.anomalistlabs.com", + PROD_IMAGE_API_SERVER = "https://image-api.timesafari.app", + TEST_IMAGE_API_SERVER = "https://test-image-api.timesafari.app", + LOCAL_IMAGE_API_SERVER = "http://localhost:3001", + NO_CONTACT_NAME = "(no name)", } export const DEFAULT_ENDORSER_API_SERVER = AppString.TEST_ENDORSER_API_SERVER; +export const DEFAULT_IMAGE_API_SERVER = AppString.LOCAL_IMAGE_API_SERVER; export const DEFAULT_PUSH_SERVER = window.location.protocol + "//" + window.location.host; diff --git a/src/views/GiftedPhoto.vue b/src/views/GiftedPhoto.vue index 6af183ba9..c52fdac2f 100644 --- a/src/views/GiftedPhoto.vue +++ b/src/views/GiftedPhoto.vue @@ -22,12 +22,11 @@ Dude, you got an image! Dude, you got an image!
- + --> +
@@ -39,6 +38,8 @@ import axios from "axios"; import Camera from "simple-vue-camera"; import { Component, Vue } from "vue-facing-decorator"; +import { DEFAULT_IMAGE_API_SERVER } from "@/constants/app"; + interface Notification { group: string; type: string; @@ -68,19 +69,15 @@ export default class GiftedPhoto extends Vue { return; } - //this.localImageUrl = URL.createObjectURL(blob); - - console.log("Got an image:", blob?.size); - const formData = new FormData(); formData.append("image", blob, "snapshot.jpg"); try { const response = await axios.post( - "http://localhost:3000/image", + DEFAULT_IMAGE_API_SERVER + "/image", formData, ); - console.log("Upload successful", response.data); + console.log("Sent. Response:", response.data); } catch (error) { console.error("Error uploading the image", error); } From 0eb64ed7162b1c925c9065446ecbc76f77406b02 Mon Sep 17 00:00:00 2001 From: Trent Larson Date: Wed, 6 Mar 2024 06:12:41 -0700 Subject: [PATCH 04/19] add authentication token for image server, change default image server to localhost --- .env.development | 1 + src/views/GiftedPhoto.vue | 31 +++++++++++++++++++++++++++++++ src/views/ProjectViewView.vue | 9 --------- 3 files changed, 32 insertions(+), 9 deletions(-) diff --git a/.env.development b/.env.development index 9e5c00605..9f3db1671 100644 --- a/.env.development +++ b/.env.development @@ -2,3 +2,4 @@ # this won't resolve as a URL on production; it's a URN only found in the test system VUE_APP_BVC_MEETUPS_PROJECT_CLAIM_ID=https://endorser.ch/entity/01HNTZYJJXTGT0EZS3VEJGX7AK +VUE_APP_DEFAULT_IMAGE_API_SERVER=http://localhost:3001 diff --git a/src/views/GiftedPhoto.vue b/src/views/GiftedPhoto.vue index c52fdac2f..15462c99b 100644 --- a/src/views/GiftedPhoto.vue +++ b/src/views/GiftedPhoto.vue @@ -39,6 +39,10 @@ import Camera from "simple-vue-camera"; import { Component, Vue } from "vue-facing-decorator"; import { DEFAULT_IMAGE_API_SERVER } from "@/constants/app"; +import { getIdentity } from "@/libs/util"; +import { db } from "@/db/index"; +import { MASTER_SETTINGS_KEY, Settings } from "@/db/tables/settings"; +import { accessToken } from "@/libs/crypto"; interface Notification { group: string; @@ -51,8 +55,29 @@ interface Notification { export default class GiftedPhoto extends Vue { $notify!: (notification: Notification, timeout?: number) => void; + activeDid = ""; localImageUrl: string | null = null; + async mounted() { + try { + await db.open(); + const settings = (await db.settings.get(MASTER_SETTINGS_KEY)) as Settings; + this.activeDid = settings?.activeDid || ""; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + } catch (err: any) { + console.error("Error retrieving settings from database:", err); + this.$notify( + { + group: "alert", + type: "danger", + title: "Error", + text: err.message || "There was an error retrieving your settings.", + }, + -1, + ); + } + } + async storeImage(/* payload: MouseEvent */) { const cameraComponent = this.$refs.camera as InstanceType; const blob = await cameraComponent?.snapshot(); @@ -69,12 +94,18 @@ export default class GiftedPhoto extends Vue { return; } + const identifier = await getIdentity(this.activeDid); + const token = await accessToken(identifier); + const headers = { + Authorization: "Bearer " + token, + }; const formData = new FormData(); formData.append("image", blob, "snapshot.jpg"); try { const response = await axios.post( DEFAULT_IMAGE_API_SERVER + "/image", formData, + { headers }, ); console.log("Sent. Response:", response.data); diff --git a/src/views/ProjectViewView.vue b/src/views/ProjectViewView.vue index 10dc4722a..9b559f7ff 100644 --- a/src/views/ProjectViewView.vue +++ b/src/views/ProjectViewView.vue @@ -437,15 +437,6 @@ export default class ProjectViewView extends Vue { return identity; } - public async getHeaders(identity: IIdentifier) { - const token = await accessToken(identity); - const headers = { - "Content-Type": "application/json", - Authorization: "Bearer " + token, - }; - return headers; - } - onEditClick() { localStorage.setItem("projectId", this.projectId as string); const route = { From cae2bbc4ff46f8e42d0b5f72d990e894e539d347 Mon Sep 17 00:00:00 2001 From: Trent Larson Date: Thu, 7 Mar 2024 09:09:51 -0700 Subject: [PATCH 05/19] make styled button to take picture --- project.task.yaml | 3 +++ src/views/GiftedPhoto.vue | 17 +++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/project.task.yaml b/project.task.yaml index 4bb16bd81..e83526702 100644 --- a/project.task.yaml +++ b/project.task.yaml @@ -21,6 +21,9 @@ tasks : - Rates - images erased? - image not associated with JWT ULID since that's assigned later +- ask to detect location & record it in settings +- if personal location is set, show potential local affiliations + - 24 compelling UI for credential presentations - discover who in my network has activity on a project diff --git a/src/views/GiftedPhoto.vue b/src/views/GiftedPhoto.vue index 15462c99b..88fd6f67c 100644 --- a/src/views/GiftedPhoto.vue +++ b/src/views/GiftedPhoto.vue @@ -26,8 +26,21 @@ Camera "resolution" doesn't change how it shows on screen but rather stretches the result, eg the following which just stretches it vertically: :resolution="{ width: 375, height: 812 }" --> - - + +
+ + +
From acee761906ecafb0839c356b368dea680965a24f Mon Sep 17 00:00:00 2001 From: Trent Larson Date: Fri, 8 Mar 2024 01:10:17 -0700 Subject: [PATCH 06/19] add page for extended details of gifts including pic (not fully tested) --- src/components/GiftedDialog.vue | 30 +-- src/router/index.ts | 8 + src/views/GiftedDetails.vue | 313 ++++++++++++++++++++++++++++++++ 3 files changed, 338 insertions(+), 13 deletions(-) create mode 100644 src/views/GiftedDetails.vue diff --git a/src/components/GiftedDialog.vue b/src/components/GiftedDialog.vue index 8583dd5df..678a6fe69 100644 --- a/src/components/GiftedDialog.vue +++ b/src/components/GiftedDialog.vue @@ -36,23 +36,27 @@ -
+
- + More Options - - - - - - - -

Sign & Send to publish to the world @@ -101,9 +105,9 @@ export default class GiftedDialog extends Vue { apiServer = ""; amountInput = "0"; - giver?: GiverInputInfo; // undefined means no identified giver agent description = ""; givenToUser = false; + giver?: GiverInputInfo; // undefined means no identified giver agent isTrade = false; offerId = ""; unitCode = "HUR"; diff --git a/src/router/index.ts b/src/router/index.ts index da913d24a..c81751613 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -84,6 +84,14 @@ const routes: Array = [ component: () => import(/* webpackChunkName: "discover" */ "../views/DiscoverView.vue"), }, + { + path: "/gifted-details", + name: "gifted-details", + component: () => + import( + /* webpackChunkName: "gifted-details" */ "../views/GiftedDetails.vue" + ), + }, { path: "/gifted-photo", name: "gifted-photo", diff --git a/src/views/GiftedDetails.vue b/src/views/GiftedDetails.vue new file mode 100644 index 000000000..dc54954ab --- /dev/null +++ b/src/views/GiftedDetails.vue @@ -0,0 +1,313 @@ +