|
|
@ -103,9 +103,46 @@ export default class ProjectsView extends Vue { |
|
|
|
isLoading = false; |
|
|
|
numAccounts = 0; |
|
|
|
|
|
|
|
async beforeCreate() { |
|
|
|
await accountsDB.open(); |
|
|
|
this.numAccounts = await accountsDB.accounts.count(); |
|
|
|
/** |
|
|
|
* 'created' hook runs when the Vue instance is first created |
|
|
|
**/ |
|
|
|
async created() { |
|
|
|
try { |
|
|
|
await db.open(); |
|
|
|
const settings = await db.settings.get(MASTER_SETTINGS_KEY); |
|
|
|
const activeDid = settings?.activeDid || ""; |
|
|
|
this.apiServer = settings?.apiServer || ""; |
|
|
|
|
|
|
|
await accountsDB.open(); |
|
|
|
this.numAccounts = await accountsDB.accounts.count(); |
|
|
|
if (this.numAccounts === 0) { |
|
|
|
console.error("No accounts found."); |
|
|
|
this.$notify( |
|
|
|
{ |
|
|
|
group: "alert", |
|
|
|
type: "danger", |
|
|
|
title: "Error", |
|
|
|
text: "You need an identifier to load your projects.", |
|
|
|
}, |
|
|
|
-1, |
|
|
|
); |
|
|
|
} else { |
|
|
|
const identity = await this.getIdentity(activeDid); |
|
|
|
this.current = identity; |
|
|
|
this.loadProjects(identity); |
|
|
|
} |
|
|
|
} catch (err) { |
|
|
|
console.log("Error initializing:", err); |
|
|
|
this.$notify( |
|
|
|
{ |
|
|
|
group: "alert", |
|
|
|
type: "danger", |
|
|
|
title: "Error", |
|
|
|
text: "Something went wrong loading your projects.", |
|
|
|
}, |
|
|
|
-1, |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -186,7 +223,7 @@ export default class ProjectsView extends Vue { |
|
|
|
* Load projects initially |
|
|
|
* @param identity of the user |
|
|
|
**/ |
|
|
|
async LoadProjects(identity: IIdentifier) { |
|
|
|
async loadProjects(identity: IIdentifier) { |
|
|
|
const url = `${this.apiServer}/api/v2/report/plansByIssuer`; |
|
|
|
const token: string = await accessToken(identity); |
|
|
|
await this.dataLoader(url, token); |
|
|
@ -208,46 +245,6 @@ export default class ProjectsView extends Vue { |
|
|
|
return identity; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 'created' hook runs when the Vue instance is first created |
|
|
|
**/ |
|
|
|
async created() { |
|
|
|
try { |
|
|
|
await db.open(); |
|
|
|
const settings = await db.settings.get(MASTER_SETTINGS_KEY); |
|
|
|
const activeDid = settings?.activeDid || ""; |
|
|
|
this.apiServer = settings?.apiServer || ""; |
|
|
|
|
|
|
|
if (this.numAccounts === 0) { |
|
|
|
console.error("No accounts found."); |
|
|
|
this.$notify( |
|
|
|
{ |
|
|
|
group: "alert", |
|
|
|
type: "danger", |
|
|
|
title: "Error", |
|
|
|
text: "You need an identifier to load your projects.", |
|
|
|
}, |
|
|
|
-1, |
|
|
|
); |
|
|
|
} else { |
|
|
|
const identity = await this.getIdentity(activeDid); |
|
|
|
this.current = identity; |
|
|
|
this.LoadProjects(identity); |
|
|
|
} |
|
|
|
} catch (err) { |
|
|
|
console.log("Error initializing:", err); |
|
|
|
this.$notify( |
|
|
|
{ |
|
|
|
group: "alert", |
|
|
|
type: "danger", |
|
|
|
title: "Error", |
|
|
|
text: "Something went wrong loading your projects.", |
|
|
|
}, |
|
|
|
-1, |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Handling clicking on the new project button |
|
|
|
**/ |
|
|
|