Browse Source

Looks like GiftedDialog works? A little cleanup.

quicknav-component
Matthew Raymer 1 year ago
parent
commit
cf54096326
  1. 7
      src/components/GiftedDialog.vue
  2. 2
      src/libs/endorserServer.ts
  3. 66
      src/views/StatisticsView.vue

7
src/components/GiftedDialog.vue

@ -41,7 +41,7 @@
</template> </template>
<script lang="ts"> <script lang="ts">
import {Vue, Component, Prop, Emit} from "vue-facing-decorator"; import { Vue, Component, Prop, Emit } from "vue-facing-decorator";
@Component @Component
export default class GiftedDialog extends Vue { export default class GiftedDialog extends Vue {
@ -72,7 +72,7 @@ export default class GiftedDialog extends Vue {
@Emit("dialog-result") @Emit("dialog-result")
confirm() { confirm() {
result = { const result = {
action: "confirm", action: "confirm",
giver: this.giver, giver: this.giver,
hours: parseFloat(this.hours), hours: parseFloat(this.hours),
@ -88,11 +88,10 @@ export default class GiftedDialog extends Vue {
@Emit("dialog-result") @Emit("dialog-result")
cancel() { cancel() {
result = { action: "cancel" }; const result = { action: "cancel" };
this.close(); this.close();
return result; return result;
} }
} }
</script> </script>

2
src/libs/endorserServer.ts

@ -90,7 +90,7 @@ export function didInfo(did, identifiers, contacts) {
if (contact) { if (contact) {
return contact.name || "Someone Unnamed in Contacts"; return contact.name || "Someone Unnamed in Contacts";
} else if (!did) { } else if (!did) {
return "Unpecified Person"; return "Unspecified Person";
} else if (isHiddenDid(did)) { } else if (isHiddenDid(did)) {
return "Someone Not In Network"; return "Someone Not In Network";
} else { } else {

66
src/views/StatisticsView.vue

@ -103,6 +103,8 @@ interface WorldProperties {
export default class StatisticsView extends Vue { export default class StatisticsView extends Vue {
world: World; world: World;
worldProperties: WorldProperties = {}; worldProperties: WorldProperties = {};
alertTitle = "";
alertMessage = "";
// 'mounted' hook runs after initial render // 'mounted' hook runs after initial render
mounted() { mounted() {
@ -114,68 +116,12 @@ export default class StatisticsView extends Vue {
this.world = newWorld; this.world = newWorld;
} catch (err) { } catch (err) {
console.log(err); console.log(err);
this.alertTitle = "Mounting error";
this.alertMessage = err.message;
} }
} }
public captureGraphics() { public captureGraphics() {
/**
// from https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob#examples
// Adds a blank image
const dataBlob = document
.querySelector("#scene-container")
.firstChild.toBlob((blob) => {
const newImg = document.createElement("img");
const url = URL.createObjectURL(blob);
newImg.onload = () => {
// no longer need to read the blob so it's revoked
URL.revokeObjectURL(url);
};
newImg.src = url;
document.body.appendChild(newImg);
});
**/
/**
// Yields a blank page with the iframe below
const dataUrl = document
.querySelector("#scene-container")
.firstChild.toDataURL("image/png");
**/
/**
// Yields a blank page with the iframe below
const dataUrl = this.world.renderer.domElement.toDataURL("image/png");
**/
/**
// Show the image in a new tab
const iframe = `
<iframe
src="${dataUrl}"
frameborder="0"
style="border:0; top:0px; left:0px; bottom:0px; right:0px; width:100%; height:100%;"
allowfullscreen>
</iframe>`;
const win = window.open();
win.document.open();
win.document.write(iframe);
win.document.close();
**/
// from https://stackoverflow.com/a/17407392/845494
// This yields a file with funny formatting.
//const image = const dataUrl.replace("image/png", "image/octet-stream");
/**
// Yields a blank image at the bottom of the page
// from https://discourse.threejs.org/t/save-screenshot-on-server/39900/3
const img = new Image();
img.src = this.world.renderer.domElement.toDataURL();
document.body.appendChild(img);
**/
/** /**
* This yields an SVG that only shows white and black highlights * This yields an SVG that only shows white and black highlights
// from https://stackoverflow.com/questions/27632621/exporting-from-three-js-scene-to-svg-or-other-vector-format // from https://stackoverflow.com/questions/27632621/exporting-from-three-js-scene-to-svg-or-other-vector-format
@ -183,16 +129,12 @@ export default class StatisticsView extends Vue {
const rendererSVG = new SVGRenderer(); const rendererSVG = new SVGRenderer();
rendererSVG.setSize(window.innerWidth, window.innerHeight); rendererSVG.setSize(window.innerWidth, window.innerHeight);
rendererSVG.render(this.world.scene, this.world.camera); rendererSVG.render(this.world.scene, this.world.camera);
//document.body.appendChild(rendererSVG.domElement);
ExportToSVG(rendererSVG, "test.svg"); ExportToSVG(rendererSVG, "test.svg");
} }
public setWorldProperty(propertyName, propertyValue) { public setWorldProperty(propertyName, propertyValue) {
this.worldProperties[propertyName] = propertyValue; this.worldProperties[propertyName] = propertyValue;
} }
alertTitle = "";
alertMessage = "";
} }
function ExportToSVG(rendererSVG, filename) { function ExportToSVG(rendererSVG, filename) {

Loading…
Cancel
Save