|
|
@ -73,7 +73,6 @@ |
|
|
|
<script lang="ts"> |
|
|
|
import { AxiosError } from "axios"; |
|
|
|
import * as didJwt from "did-jwt"; |
|
|
|
import * as R from "ramda"; |
|
|
|
import { Component, Vue } from "vue-facing-decorator"; |
|
|
|
|
|
|
|
import { accountsDB, db } from "@/db"; |
|
|
@ -100,16 +99,26 @@ export default class NewEditProjectView extends Vue { |
|
|
|
projectName = ""; |
|
|
|
description = ""; |
|
|
|
errorMessage = ""; |
|
|
|
accounts: AccountsSchema; |
|
|
|
numAccounts = 0; |
|
|
|
|
|
|
|
async beforeCreate() { |
|
|
|
accountsDB.open(); |
|
|
|
this.accounts = accountsDB.accounts; |
|
|
|
this.numAccounts = await this.accounts.count(); |
|
|
|
} |
|
|
|
|
|
|
|
public async getIdentity(activeDid) { |
|
|
|
await accountsDB.open(); |
|
|
|
const accounts = await accountsDB.accounts.toArray(); |
|
|
|
const account = R.find((acc) => acc.did === activeDid, accounts); |
|
|
|
const account = await accountsDB.accounts |
|
|
|
.where("did") |
|
|
|
.equals(activeDid) |
|
|
|
.first(); |
|
|
|
const identity = JSON.parse(account?.identity || "null"); |
|
|
|
|
|
|
|
if (!identity) { |
|
|
|
throw new Error( |
|
|
|
"Attempted to load Give records with no identity available.", |
|
|
|
"Attempted to load project records with no identity available.", |
|
|
|
); |
|
|
|
} |
|
|
|
return identity; |
|
|
@ -135,14 +144,10 @@ export default class NewEditProjectView extends Vue { |
|
|
|
this.apiServer = settings?.apiServer || ""; |
|
|
|
|
|
|
|
if (this.projectId) { |
|
|
|
await accountsDB.open(); |
|
|
|
const num_accounts = await accountsDB.accounts.count(); |
|
|
|
if (num_accounts === 0) { |
|
|
|
if (this.numAccounts === 0) { |
|
|
|
console.error("Error: no account was found."); |
|
|
|
} else { |
|
|
|
const accounts = await accountsDB.accounts.toArray(); |
|
|
|
const account = R.find((acc) => acc.did === this.activeDid, accounts); |
|
|
|
const identity = JSON.parse(account?.identity || "null"); |
|
|
|
const identity = await this.getIdentity(this.activeDid); |
|
|
|
if (!identity) { |
|
|
|
throw new Error( |
|
|
|
"An ID is chosen but there are no keys for it so it cannot be used to talk with the service.", |
|
|
@ -272,19 +277,11 @@ export default class NewEditProjectView extends Vue { |
|
|
|
public async onSaveProjectClick() { |
|
|
|
this.isHiddenSave = true; |
|
|
|
this.isHiddenSpinner = false; |
|
|
|
await accountsDB.open(); |
|
|
|
const num_accounts = await accountsDB.accounts.count(); |
|
|
|
if (num_accounts === 0) { |
|
|
|
|
|
|
|
if (this.numAccounts === 0) { |
|
|
|
console.error("Error: there is no account."); |
|
|
|
} else { |
|
|
|
const accounts = await accountsDB.accounts.toArray(); |
|
|
|
const account = R.find((acc) => acc.did === this.activeDid, accounts); |
|
|
|
const identity = JSON.parse(account?.identity || "null"); |
|
|
|
if (!identity) { |
|
|
|
throw new Error( |
|
|
|
"An ID is chosen but there are no keys for it so it cannot be used to talk with the service.", |
|
|
|
); |
|
|
|
} |
|
|
|
const identity = await this.getIdentity(this.activeDid); |
|
|
|
this.SaveProject(identity); |
|
|
|
} |
|
|
|
} |
|
|
|