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