Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions gui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"@fortawesome/free-solid-svg-icons": "^5.12.0",
"@fortawesome/vue-fontawesome": "^0.1.8",
"core-js": "^3.7.0",
"file-saver": "^2.0.5",
"node-sass": "^5.0.0",
"sass-loader": "^11.0.1",
"signals": "^1.0.0",
Expand Down
29 changes: 24 additions & 5 deletions gui/src/dashboard/Graph.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
:class="{ controlActive: live }"
@click="live = !live"
/>
<FlatButton
icon="record-vinyl"
:class="{ controlActive: record }"
@click="saveFile()"
/>
</div>
</template>
<div ref="chart-container" class="chart-container">
Expand All @@ -30,7 +35,8 @@ import Panel from "../components/Panel.vue";
import FlatButton from "../components/FlatButton.vue";
import NumberField from "../components/NumberField.vue";
import { NamespaceQuery, Variable } from "telegraph";
import TimeChart from 'timechart'
import TimeChart from 'timechart';
import { saveAs } from 'file-saver';


export default {
Expand All @@ -50,6 +56,7 @@ export default {
timespan: 20,
useTimespan: true,
live: true,
record: true,

width: 0,
height: 0,
Expand Down Expand Up @@ -102,25 +109,37 @@ export default {
},
updateVariable(v) {
},
saveFile() {
var FileSaver = require('file-saver');
var strArr = [];
for (var pt of this.history) {
var str = JSON.stringify(pt, null, 2);
strArr.push(str);
}
var blob = new Blob(strArr, {type: "text/plain;charset=utf-8"});
FileSaver.saveAs(blob, "graph_data.txt");
},
},
watch: {
nodeQuery(n, o) {
// if (o) o.unregister(this.updateVariable);
// n.updated.register(this.updateVariable);
if (o) o.unregister(this.updateVariable);
n.updated.register(this.updateVariable);
},
},
created() {
// callback for adding data
setInterval(() => {
// Every 100 miliseconds, graphs a point (x, y)
this.interval = setInterval(() => {
const time = performance.now();
this.history.push({x: time, y: Math.sin(time * 0.002)});
this.chart.update();
}, 100);
this.nodeQuery.register(this.updateVariable);
this.graphData();
},
destroyed() {
if (this.sub) this.sub.cancel();
},

};
</script>

Expand Down
6 changes: 5 additions & 1 deletion gui/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import {
faSatelliteDish,
faCircle,
faSquare,
faRedo,
faRecordVinyl,
} from "@fortawesome/free-solid-svg-icons";
import { faTrashAlt } from "@fortawesome/free-regular-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
Expand Down Expand Up @@ -56,7 +58,9 @@ library.add(
faCircle,
faSquare,
faPlay,
faClock
faClock,
faRedo,
faRecordVinyl,
);

Vue.component("font-awesome-icon", FontAwesomeIcon);
Expand Down
5 changes: 5 additions & 0 deletions gui/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4038,6 +4038,11 @@ file-loader@^4.2.0:
loader-utils "^1.2.3"
schema-utils "^2.5.0"

file-saver@^2.0.5:
version "2.0.5"
resolved "https://registry.yarnpkg.com/file-saver/-/file-saver-2.0.5.tgz#d61cfe2ce059f414d899e9dd6d4107ee25670c38"
integrity sha512-P9bmyZ3h/PRG+Nzga+rbdI4OEpNDzAVyy74uVO9ATgzLK6VtAsYybF/+TOCvrc0MO793d6+42lLyZTw7/ArVzA==

file-uri-to-path@1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz#553a7b8446ff6f684359c445f1e37a05dacc33dd"
Expand Down
Loading