forked from jsnbuchanan/crowd-funder-for-time-pwa
Add AlertMessage component
This commit is contained in:
@@ -107,18 +107,22 @@
|
|||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</InfiniteScroll>
|
</InfiniteScroll>
|
||||||
|
<AlertMessage
|
||||||
|
:alertTitle="alertTitle"
|
||||||
|
:alertMessage="alertMessage"
|
||||||
|
></AlertMessage>
|
||||||
</section>
|
</section>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import * as R from "ramda";
|
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";
|
||||||
import { MASTER_SETTINGS_KEY } from "@/db/tables/settings";
|
import { MASTER_SETTINGS_KEY } from "@/db/tables/settings";
|
||||||
import { accessToken } from "@/libs/crypto";
|
import { accessToken } from "@/libs/crypto";
|
||||||
import { IIdentifier } from "@veramo/core";
|
import { IIdentifier } from "@veramo/core";
|
||||||
import InfiniteScroll from "@/components/InfiniteScroll";
|
import InfiniteScroll from "@/components/InfiniteScroll";
|
||||||
|
import AlertMessage from "@/components/AlertMessage";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents data about a project
|
* Represents data about a project
|
||||||
@@ -143,13 +147,15 @@ interface ProjectData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
components: { InfiniteScroll },
|
components: { InfiniteScroll, AlertMessage },
|
||||||
})
|
})
|
||||||
export default class ProjectsView extends Vue {
|
export default class ProjectsView extends Vue {
|
||||||
apiServer = "";
|
apiServer = "";
|
||||||
projects: ProjectData[] = [];
|
projects: ProjectData[] = [];
|
||||||
current: IIdentifier;
|
current: IIdentifier;
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
|
alertTitle = "";
|
||||||
|
alertMessage = "";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Core project data loader
|
* Core project data loader
|
||||||
@@ -171,9 +177,13 @@ export default class ProjectsView extends Vue {
|
|||||||
const { name, description, handleId = plan.fullIri, rowid } = plan;
|
const { name, description, handleId = plan.fullIri, rowid } = plan;
|
||||||
this.projects.push({ name, description, handleId, rowid });
|
this.projects.push({ name, description, handleId, rowid });
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
console.log(resp.status);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Got error loading projects:", error);
|
console.error("Got error loading projects:", error.message);
|
||||||
|
this.alertTitle = "Error";
|
||||||
|
this.alertMessage = "Got an error loading projects:" + error.message;
|
||||||
} finally {
|
} finally {
|
||||||
this.isLoading = false;
|
this.isLoading = false;
|
||||||
}
|
}
|
||||||
@@ -218,24 +228,32 @@ export default class ProjectsView extends Vue {
|
|||||||
* 'created' hook runs when the Vue instance is first created
|
* 'created' hook runs when the Vue instance is first created
|
||||||
**/
|
**/
|
||||||
async created() {
|
async created() {
|
||||||
await db.open();
|
try {
|
||||||
const settings = await db.settings.get(MASTER_SETTINGS_KEY);
|
await db.open();
|
||||||
const activeDid = settings?.activeDid || "";
|
const settings = await db.settings.get(MASTER_SETTINGS_KEY);
|
||||||
this.apiServer = settings?.apiServer || "";
|
const activeDid = settings?.activeDid || "";
|
||||||
|
this.apiServer = settings?.apiServer || "";
|
||||||
|
|
||||||
await accountsDB.open();
|
await accountsDB.open();
|
||||||
const num_accounts = await accountsDB.accounts.count();
|
const num_accounts = await accountsDB.accounts.count();
|
||||||
if (num_accounts === 0) {
|
if (num_accounts === 0) {
|
||||||
console.error("Problem! Should have a profile!");
|
console.error("Problem! You need a profile!");
|
||||||
} else {
|
this.alertTitle = "Error!";
|
||||||
const accounts = await accountsDB.accounts.toArray();
|
this.alertMessage = "Problem! You need a profile!";
|
||||||
const account = R.find((acc) => acc.did === activeDid, accounts);
|
} else {
|
||||||
const identity = JSON.parse(account?.identity || "null");
|
const accounts = await accountsDB.accounts.toArray();
|
||||||
if (!identity) {
|
const account = R.find((acc) => acc.did === activeDid, accounts);
|
||||||
throw new Error("No identity found.");
|
const identity = JSON.parse(account?.identity || "null");
|
||||||
|
if (!identity) {
|
||||||
|
throw new Error("No identity found.");
|
||||||
|
}
|
||||||
|
this.current = identity;
|
||||||
|
this.LoadProjects(identity);
|
||||||
}
|
}
|
||||||
this.current = identity;
|
} catch (err) {
|
||||||
this.LoadProjects(identity);
|
console.log(err);
|
||||||
|
this.alertTitle = "Error!";
|
||||||
|
this.alertMessage = "Problem! You need a profile!";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user