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