|
|
@ -126,16 +126,47 @@ |
|
|
|
|
|
|
|
<script lang="ts"> |
|
|
|
import { Options, Vue } from "vue-class-component"; |
|
|
|
import { useAppStore } from "@/store/app"; |
|
|
|
import { accessToken } from "@/libs/crypto"; |
|
|
|
import { db } from "../db"; |
|
|
|
import { IIdentifier } from "@veramo/core"; |
|
|
|
import { AppString } from "@/constants/app"; |
|
|
|
|
|
|
|
@Options({ |
|
|
|
components: {}, |
|
|
|
}) |
|
|
|
export default class ProjectViewView extends Vue { |
|
|
|
projectId = ""; |
|
|
|
created(): void { |
|
|
|
this.projectId = useAppStore().projectId; |
|
|
|
console.log(this.projectId); |
|
|
|
projectId = |
|
|
|
localStorage.getItem("projectId") === null |
|
|
|
? "" |
|
|
|
: localStorage.getItem("projectId"); |
|
|
|
async LoadProject(identity: IIdentifier) { |
|
|
|
console.log("LoadProject", this.projectId); |
|
|
|
const endorserApiServer = AppString.DEFAULT_ENDORSER_API_SERVER; |
|
|
|
const url = endorserApiServer + "/api/claim/" + this.projectId; |
|
|
|
const token = await accessToken(identity); |
|
|
|
const headers = { |
|
|
|
"Content-Type": "application/json", |
|
|
|
Authorization: "Bearer " + token, |
|
|
|
}; |
|
|
|
|
|
|
|
try { |
|
|
|
const resp = await this.axios.get(url, { headers }); |
|
|
|
console.log(resp.status, resp.data); |
|
|
|
} catch (error) { |
|
|
|
console.log(error); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
async created() { |
|
|
|
await db.open(); |
|
|
|
const num_accounts = await db.accounts.count(); |
|
|
|
if (num_accounts === 0) { |
|
|
|
console.log("Problem! Should have a profile!"); |
|
|
|
} else { |
|
|
|
const accounts = await db.accounts.toArray(); |
|
|
|
const identity = JSON.parse(accounts[0].identity); |
|
|
|
this.LoadProject(identity); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
</script> |
|
|
|