|
|
@ -422,6 +422,7 @@ import * as libsUtil from "@/libs/util"; |
|
|
|
import { |
|
|
|
BLANK_GENERIC_SERVER_RECORD, |
|
|
|
GenericCredWrapper, |
|
|
|
getHeaders, |
|
|
|
GiverReceiverInputInfo, |
|
|
|
GiveSummaryRecord, |
|
|
|
OfferSummaryRecord, |
|
|
@ -484,14 +485,12 @@ export default class ProjectViewView extends Vue { |
|
|
|
const accounts = accountsDB.accounts; |
|
|
|
const accountsArr: Account[] = await accounts?.toArray(); |
|
|
|
this.allMyDids = accountsArr.map((acc) => acc.did); |
|
|
|
const account = accountsArr.find((acc) => acc.did === this.activeDid); |
|
|
|
const identity = JSON.parse((account?.identity as string) || "null"); |
|
|
|
|
|
|
|
const pathParam = window.location.pathname.substring("/project/".length); |
|
|
|
if (pathParam) { |
|
|
|
this.projectId = decodeURIComponent(pathParam); |
|
|
|
} |
|
|
|
this.loadProject(this.projectId, identity); |
|
|
|
this.loadProject(this.projectId, this.activeDid); |
|
|
|
} |
|
|
|
|
|
|
|
public async getIdentity(activeDid: string) { |
|
|
@ -521,18 +520,12 @@ export default class ProjectViewView extends Vue { |
|
|
|
this.expanded = false; |
|
|
|
} |
|
|
|
|
|
|
|
async loadProject(projectId: string, identity: IIdentifier) { |
|
|
|
async loadProject(projectId: string, userDid: string) { |
|
|
|
this.projectId = projectId; |
|
|
|
|
|
|
|
const url = |
|
|
|
this.apiServer + "/api/claim/byHandle/" + encodeURIComponent(projectId); |
|
|
|
const headers: RawAxiosRequestHeaders = { |
|
|
|
"Content-Type": "application/json", |
|
|
|
}; |
|
|
|
if (identity) { |
|
|
|
const token = await accessToken(identity); |
|
|
|
headers["Authorization"] = "Bearer " + token; |
|
|
|
} |
|
|
|
const headers = await getHeaders(userDid); |
|
|
|
|
|
|
|
try { |
|
|
|
const resp = await this.axios.get(url, { headers }); |
|
|
@ -602,8 +595,8 @@ export default class ProjectViewView extends Vue { |
|
|
|
this.loadPlanFulfillersTo(); |
|
|
|
|
|
|
|
// now load fulfilled-by, a single project |
|
|
|
if (identity) { |
|
|
|
const token = await accessToken(identity); |
|
|
|
if (this.activeDid) { |
|
|
|
const token = await accessToken(this.activeDid); |
|
|
|
headers["Authorization"] = "Bearer " + token; |
|
|
|
} |
|
|
|
const fulfilledByUrl = |
|
|
@ -655,15 +648,7 @@ export default class ProjectViewView extends Vue { |
|
|
|
} |
|
|
|
const givesInUrl = givesUrl + postfix; |
|
|
|
|
|
|
|
const headers: RawAxiosRequestHeaders = { |
|
|
|
"Content-Type": "application/json", |
|
|
|
}; |
|
|
|
const identity = await this.getIdentity(this.activeDid); |
|
|
|
if (identity) { |
|
|
|
const token = await accessToken(identity); |
|
|
|
headers["Authorization"] = "Bearer " + token; |
|
|
|
} |
|
|
|
|
|
|
|
const headers = await getHeaders(this.activeDid); |
|
|
|
try { |
|
|
|
const resp = await this.axios.get(givesInUrl, { headers }); |
|
|
|
if (resp.status === 200 && resp.data.data) { |
|
|
@ -710,15 +695,7 @@ export default class ProjectViewView extends Vue { |
|
|
|
} |
|
|
|
const offersInUrl = offersUrl + postfix; |
|
|
|
|
|
|
|
const headers: RawAxiosRequestHeaders = { |
|
|
|
"Content-Type": "application/json", |
|
|
|
}; |
|
|
|
const identity = await this.getIdentity(this.activeDid); |
|
|
|
if (identity) { |
|
|
|
const token = await accessToken(identity); |
|
|
|
headers["Authorization"] = "Bearer " + token; |
|
|
|
} |
|
|
|
|
|
|
|
const headers = await getHeaders(this.activeDid); |
|
|
|
try { |
|
|
|
const resp = await this.axios.get(offersInUrl, { headers }); |
|
|
|
if (resp.status === 200 && resp.data.data) { |
|
|
@ -766,15 +743,7 @@ export default class ProjectViewView extends Vue { |
|
|
|
} |
|
|
|
const fulfillsInUrl = fulfillsUrl + postfix; |
|
|
|
|
|
|
|
const headers: RawAxiosRequestHeaders = { |
|
|
|
"Content-Type": "application/json", |
|
|
|
}; |
|
|
|
const identity = await this.getIdentity(this.activeDid); |
|
|
|
if (identity) { |
|
|
|
const token = await accessToken(identity); |
|
|
|
headers["Authorization"] = "Bearer " + token; |
|
|
|
} |
|
|
|
|
|
|
|
const headers = await getHeaders(this.activeDid); |
|
|
|
try { |
|
|
|
const resp = await this.axios.get(fulfillsInUrl, { headers }); |
|
|
|
if (resp.status === 200) { |
|
|
@ -822,15 +791,7 @@ export default class ProjectViewView extends Vue { |
|
|
|
} |
|
|
|
const providedByFullUrl = providedByUrl + postfix; |
|
|
|
|
|
|
|
const headers: RawAxiosRequestHeaders = { |
|
|
|
"Content-Type": "application/json", |
|
|
|
}; |
|
|
|
const identity = await this.getIdentity(this.activeDid); |
|
|
|
if (identity) { |
|
|
|
const token = await accessToken(identity); |
|
|
|
headers["Authorization"] = "Bearer " + token; |
|
|
|
} |
|
|
|
|
|
|
|
const headers = await getHeaders(this.activeDid); |
|
|
|
try { |
|
|
|
const resp = await this.axios.get(providedByFullUrl, { headers }); |
|
|
|
if (resp.status === 200) { |
|
|
@ -877,7 +838,7 @@ export default class ProjectViewView extends Vue { |
|
|
|
path: "/project/" + encodeURIComponent(projectId), |
|
|
|
}; |
|
|
|
this.$router.push(route); |
|
|
|
this.loadProject(projectId, await this.getIdentity(this.activeDid)); |
|
|
|
this.loadProject(projectId, this.activeDid); |
|
|
|
} |
|
|
|
|
|
|
|
getOpenStreetMapUrl() { |
|
|
|