Browse Source

Type fixes

search-bbox
Matthew Aaron Raymer 1 year ago
parent
commit
b514d64068
  1. 35
      src/views/ProjectViewView.vue
  2. 11
      src/views/SeedBackupView.vue
  3. 36
      src/views/StatisticsView.vue

35
src/views/ProjectViewView.vue

@ -223,17 +223,14 @@ import {
didInfo, didInfo,
GiveServerRecord, GiveServerRecord,
} from "@/libs/endorserServer"; } from "@/libs/endorserServer";
import AlertMessage from "@/components/AlertMessage";
import QuickNav from "@/components/QuickNav"; import QuickNav from "@/components/QuickNav";
import EntityIcon from "@/components/EntityIcon"; import EntityIcon from "@/components/EntityIcon";
@Component({ @Component({
components: { GiftedDialog, AlertMessage, QuickNav, EntityIcon }, components: { GiftedDialog, QuickNav, EntityIcon },
}) })
export default class ProjectViewView extends Vue { export default class ProjectViewView extends Vue {
activeDid = ""; activeDid = "";
alertMessage = "";
alertTitle = "";
allMyDids: Array<string> = []; allMyDids: Array<string> = [];
allContacts: Array<Contact> = []; allContacts: Array<Contact> = [];
apiServer = ""; apiServer = "";
@ -342,7 +339,7 @@ export default class ProjectViewView extends Vue {
this.longitude = resp.data.claim?.location?.geo?.longitude || 0; this.longitude = resp.data.claim?.location?.geo?.longitude || 0;
} else if (resp.status === 404) { } else if (resp.status === 404) {
// actually, axios throws an error so we never get here // actually, axios throws an error so we never get here
this.$notify( (this as any).$notify(
{ {
group: "alert", group: "alert",
type: "danger", type: "danger",
@ -355,7 +352,7 @@ export default class ProjectViewView extends Vue {
} catch (error: unknown) { } catch (error: unknown) {
const serverError = error as AxiosError; const serverError = error as AxiosError;
if (serverError.response?.status === 404) { if (serverError.response?.status === 404) {
this.$notify( (this as any).$notify(
{ {
group: "alert", group: "alert",
type: "danger", type: "danger",
@ -365,7 +362,7 @@ export default class ProjectViewView extends Vue {
-1, -1,
); );
} else { } else {
this.$notify( (this as any).$notify(
{ {
group: "alert", group: "alert",
type: "danger", type: "danger",
@ -387,7 +384,7 @@ export default class ProjectViewView extends Vue {
if (resp.status === 200 && resp.data.data) { if (resp.status === 200 && resp.data.data) {
this.givesToThis = resp.data.data; this.givesToThis = resp.data.data;
} else { } else {
this.$notify( (this as any).$notify(
{ {
group: "alert", group: "alert",
type: "danger", type: "danger",
@ -399,7 +396,7 @@ export default class ProjectViewView extends Vue {
} }
} catch (error: unknown) { } catch (error: unknown) {
const serverError = error as AxiosError; const serverError = error as AxiosError;
this.$notify( (this as any).$notify(
{ {
group: "alert", group: "alert",
type: "danger", type: "danger",
@ -423,7 +420,7 @@ export default class ProjectViewView extends Vue {
if (resp.status === 200 && resp.data.data) { if (resp.status === 200 && resp.data.data) {
this.givesByThis = resp.data.data; this.givesByThis = resp.data.data;
} else { } else {
this.$notify( (this as any).$notify(
{ {
group: "alert", group: "alert",
type: "danger", type: "danger",
@ -435,7 +432,7 @@ export default class ProjectViewView extends Vue {
} }
} catch (error: unknown) { } catch (error: unknown) {
const serverError = error as AxiosError; const serverError = error as AxiosError;
this.$notify( (this as any).$notify(
{ {
group: "alert", group: "alert",
type: "danger", type: "danger",
@ -486,9 +483,9 @@ export default class ProjectViewView extends Vue {
* @param description may be an empty string * @param description may be an empty string
* @param hours may be 0 * @param hours may be 0
*/ */
async recordGive(giverDid, description, hours) { async recordGive(giverDid, description: string, hours: number) {
if (!this.activeDid) { if (!this.activeDid) {
this.$notify( (this as any).$notify(
{ {
group: "alert", group: "alert",
type: "danger", type: "danger",
@ -501,7 +498,7 @@ export default class ProjectViewView extends Vue {
} }
if (!description && !hours) { if (!description && !hours) {
this.$notify( (this as any).$notify(
{ {
group: "alert", group: "alert",
type: "danger", type: "danger",
@ -528,7 +525,7 @@ export default class ProjectViewView extends Vue {
if (result.status !== 201 || result.data?.error) { if (result.status !== 201 || result.data?.error) {
console.log("Error with give result:", result); console.log("Error with give result:", result);
this.$notify( (this as any).$notify(
{ {
group: "alert", group: "alert",
type: "danger", type: "danger",
@ -540,7 +537,7 @@ export default class ProjectViewView extends Vue {
-1, -1,
); );
} else { } else {
this.$notify( (this as any).$notify(
{ {
group: "alert", group: "alert",
type: "success", type: "success",
@ -552,14 +549,14 @@ export default class ProjectViewView extends Vue {
} }
} catch (e) { } catch (e) {
console.log("Error with give caught:", e); console.log("Error with give caught:", e);
this.$notify( (this as any).$notify(
{ {
group: "alert", group: "alert",
type: "danger", type: "danger",
title: "Error", title: "Error",
text: text:
e.userMessage || e?.userMessage ||
e.response?.data?.error?.message || e?.response?.data?.error?.message ||
"There was an error recording the give.", "There was an error recording the give.",
}, },
-1, -1,

11
src/views/SeedBackupView.vue

@ -62,16 +62,13 @@ import { Component, Vue } from "vue-facing-decorator";
import { accountsDB, db } from "@/db"; import { accountsDB, db } from "@/db";
import * as R from "ramda"; import * as R from "ramda";
import { MASTER_SETTINGS_KEY } from "@/db/tables/settings"; import { MASTER_SETTINGS_KEY } from "@/db/tables/settings";
import AlertMessage from "@/components/AlertMessage"; import QuickNav from "@/components/QuickNav.vue";
import QuickNav from "@/components/QuickNav";
@Component({ components: { AlertMessage, QuickNav } }) @Component({ components: { QuickNav } })
export default class SeedBackupView extends Vue { export default class SeedBackupView extends Vue {
activeAccount = null; activeAccount = null;
numAccounts = 0; numAccounts = 0;
showSeed = false; showSeed = false;
alertMessage = "";
alertTitle = "";
// 'created' hook runs when the Vue instance is first created // 'created' hook runs when the Vue instance is first created
async created() { async created() {
@ -84,9 +81,9 @@ export default class SeedBackupView extends Vue {
const accounts = await accountsDB.accounts.toArray(); const accounts = await accountsDB.accounts.toArray();
this.numAccounts = accounts.length; this.numAccounts = accounts.length;
this.activeAccount = R.find((acc) => acc.did === activeDid, accounts); this.activeAccount = R.find((acc) => acc.did === activeDid, accounts);
} catch (err) { } catch (err: unknown) {
console.error("Got an error loading an identity:", err); console.error("Got an error loading an identity:", err);
this.$notify( (this as any).$notify(
{ {
group: "alert", group: "alert",
type: "danger", type: "danger",

36
src/views/StatisticsView.vue

@ -34,25 +34,26 @@
</div> </div>
<button class="float-right" @click="captureGraphics()">Screenshot</button> <button class="float-right" @click="captureGraphics()">Screenshot</button>
<div id="scene-container" class="h-screen"></div> <div id="scene-container" class="h-screen"></div>
<AlertMessage
:alertTitle="alertTitle"
:alertMessage="alertMessage"
></AlertMessage>
</section> </section>
</template> </template>
<script lang="ts"> <script lang="ts">
import { SVGRenderer } from "three/addons/renderers/SVGRenderer.js"; import { SVGRenderer } from "three/addons/renderers/SVGRenderer.js";
import { Component, Vue } from "vue-facing-decorator"; import { Component, Vue } from "vue-facing-decorator";
import { World } from "@/components/World/World.js"; import { World } from "components/World/World.js";
import AlertMessage from "@/components/AlertMessage"; import QuickNav from "@/components/QuickNav.vue";
import QuickNav from "@/components/QuickNav";
@Component({ components: { AlertMessage, World, QuickNav } }) interface RendererSVGType {
domElement: Element;
}
interface Dictionary<T> {
[key: string]: T;
}
@Component({ components: { World, QuickNav } })
export default class StatisticsView extends Vue { export default class StatisticsView extends Vue {
world: World; world: World;
worldProperties: WorldProperties = {}; worldProperties: Dictionary<number> = {};
alertTitle = "";
alertMessage = "";
mounted() { mounted() {
try { try {
@ -60,14 +61,14 @@ export default class StatisticsView extends Vue {
const newWorld = new World(container, this); const newWorld = new World(container, this);
newWorld.start(); newWorld.start();
this.world = newWorld; this.world = newWorld;
} catch (err) { } catch (err : unknown) {
console.log(err); const error = err as Error;
this.$notify( (this as any).$notify(
{ {
group: "alert", group: "alert",
type: "danger", type: "danger",
title: "Mounting Error", title: "Mounting Error",
text: err.message, text: error.message,
}, },
-1, -1,
); );
@ -85,12 +86,13 @@ export default class StatisticsView extends Vue {
ExportToSVG(rendererSVG, "test.svg"); ExportToSVG(rendererSVG, "test.svg");
} }
public setWorldProperty(propertyName, propertyValue) { public setWorldProperty(propertyName: string, propertyValue: number) {
this.worldProperties[propertyName] = propertyValue; this.worldProperties[propertyName] = propertyValue;
} }
} }
function ExportToSVG(rendererSVG, filename) {
function ExportToSVG(rendererSVG: RendererSVGType, filename: string) {
const XMLS = new XMLSerializer(); const XMLS = new XMLSerializer();
const svgfile = XMLS.serializeToString(rendererSVG.domElement); const svgfile = XMLS.serializeToString(rendererSVG.domElement);
const svgData = svgfile; const svgData = svgfile;

Loading…
Cancel
Save