Browse Source

add image onto give claim, then display on feel (full round-trip, baby!)

photo-upload
Trent Larson 6 months ago
parent
commit
e4543457e2
  1. 12
      project.task.yaml
  2. 10
      src/libs/endorserServer.ts
  3. 1
      src/views/GiftedDetails.vue
  4. 4
      src/views/GiftedPhoto.vue
  5. 7
      src/views/HomeView.vue

12
project.task.yaml

@ -14,16 +14,10 @@ tasks :
- .2 list the "show more" contacts alphabetically - .2 list the "show more" contacts alphabetically
- 32 image on give : - 32 image on give :
- Show a camera to take a picture
- Scale the image to a reasonable size
- Upload to a public readable place
- check the rate limits
- use CID (hash?)
- put the image URL in the claim
- Rates - images erased?
- image not associated with JWT ULID since that's assigned later
- remove previous image
- send image type (eg. portrait, give, project) - send image type (eg. portrait, give, project)
- upload to a public readable place at correct hosting location
- remove previous image when editing
- on gift details, if project then show, otherwise mark "gift for you"
- ask to detect location & record it in settings - ask to detect location & record it in settings
- if personal location is set, show potential local affiliations - if personal location is set, show potential local affiliations

10
src/libs/endorserServer.ts

@ -67,6 +67,7 @@ export const BLANK_GENERIC_SERVER_RECORD: GenericServerRecord = {
issuer: "", issuer: "",
}; };
// a summary record; the VC is found the fullClaim field
export interface GiveServerRecord { export interface GiveServerRecord {
agentDid: string; agentDid: string;
amount: number; amount: number;
@ -81,6 +82,7 @@ export interface GiveServerRecord {
unit: string; unit: string;
} }
// a summary record; the VC is found the fullClaim field
export interface OfferServerRecord { export interface OfferServerRecord {
amount: number; amount: number;
amountGiven: number; amountGiven: number;
@ -98,13 +100,14 @@ export interface OfferServerRecord {
validThrough: string; validThrough: string;
} }
// a summary record; the VC is not currently part of this record
export interface PlanServerRecord { export interface PlanServerRecord {
agentDid?: string; // optional, if the issuer wants someone else to manage as well agentDid?: string; // optional, if the issuer wants someone else to manage as well
description: string; description: string;
endTime?: string; endTime?: string;
fulfillsPlanHandleId: string; fulfillsPlanHandleId: string;
issuerDid: string;
handleId: string; handleId: string;
issuerDid: string;
locLat?: number; locLat?: number;
locLon?: number; locLon?: number;
startTime?: string; startTime?: string;
@ -120,6 +123,7 @@ export interface GiveVerifiableCredential {
description?: string; description?: string;
fulfills?: { "@type": string; identifier?: string; lastClaimId?: string }[]; fulfills?: { "@type": string; identifier?: string; lastClaimId?: string }[];
identifier?: string; identifier?: string;
image?: string;
object?: { amountOfThisGood: number; unitCode: string }; object?: { amountOfThisGood: number; unitCode: string };
recipient?: { identifier: string }; recipient?: { identifier: string };
} }
@ -434,6 +438,7 @@ export async function createAndSubmitGive(
fulfillsProjectHandleId?: string, fulfillsProjectHandleId?: string,
fulfillsOfferHandleId?: string, fulfillsOfferHandleId?: string,
isTrade: boolean = false, isTrade: boolean = false,
imageUrl?: string,
): Promise<CreateAndSubmitClaimResult> { ): Promise<CreateAndSubmitClaimResult> {
const vcClaim: GiveVerifiableCredential = { const vcClaim: GiveVerifiableCredential = {
"@context": "https://schema.org", "@context": "https://schema.org",
@ -460,6 +465,9 @@ export async function createAndSubmitGive(
identifier: fulfillsOfferHandleId, identifier: fulfillsOfferHandleId,
}); });
} }
if (imageUrl) {
vcClaim.image = imageUrl;
}
return createAndSubmitClaim( return createAndSubmitClaim(
vcClaim as GenericServerRecord, vcClaim as GenericServerRecord,
identity, identity,

1
src/views/GiftedDetails.vue

@ -302,6 +302,7 @@ export default class GiftedDetails extends Vue {
this.projectId, this.projectId,
this.offerId, this.offerId,
this.isTrade, this.isTrade,
this.imageUrl,
); );
if ( if (

4
src/views/GiftedPhoto.vue

@ -25,8 +25,7 @@
<fa icon="spinner" class="fa-spin fa-3x text-center block" /> <fa icon="spinner" class="fa-spin fa-3x text-center block" />
</div> </div>
<div v-else-if="blob"> <div v-else-if="blob">
<img :src="URL.createObjectURL(blob)" class="w-full" /> <div class="flex justify-around">
<div class="flex justify-around mt-2">
<button <button
@click="uploadImage" @click="uploadImage"
class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-2 rounded-full" class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-2 rounded-full"
@ -40,6 +39,7 @@
<span>Retry</span> <span>Retry</span>
</button> </button>
</div> </div>
<img :src="URL.createObjectURL(blob)" class="mt-2 w-full" />
</div> </div>
<div v-else> <div v-else>
<!-- <!--

7
src/views/HomeView.vue

@ -225,6 +225,11 @@
</router-link> </router-link>
</span> </span>
</div> </div>
<div v-if="record.image" class="flex justify-center">
<a :href="record.image" target="_blank">
<img :src="record.image" class="h-24 mt-2 rounded-xl" />
</a>
</div>
</li> </li>
</ul> </ul>
</InfiniteScroll> </InfiniteScroll>
@ -267,6 +272,7 @@ interface GiveRecordWithContactInfo extends GiveServerRecord {
displayName: string; displayName: string;
known: boolean; known: boolean;
}; };
image: string;
receiver: { receiver: {
displayName: string; displayName: string;
known: boolean; known: boolean;
@ -427,6 +433,7 @@ export default class HomeView extends Vue {
contactForDid(giverDid, this.allContacts), contactForDid(giverDid, this.allContacts),
this.allMyDids, this.allMyDids,
), ),
image: claim.image,
receiver: didInfoForContact( receiver: didInfoForContact(
recipientDid, recipientDid,
this.activeDid, this.activeDid,

Loading…
Cancel
Save