Mercurial > code > home > repos > streamed-graph
annotate src/streamed-graph.ts @ 15:7ca4ff2088c3
managed to use a newer ts or something, so this includes a bunch of type fixes too
author | drewp@bigasterisk.com |
---|---|
date | Sun, 08 Dec 2019 23:32:12 -0800 |
parents | 26d3e4860adc |
children | e90d9021c6a0 |
rev | line source |
---|---|
3
a7ba8627a7b6
still trying to make imports work. add other files too
drewp@bigasterisk.com
parents:
diff
changeset
|
1 |
a7ba8627a7b6
still trying to make imports work. add other files too
drewp@bigasterisk.com
parents:
diff
changeset
|
2 // these are just for timebank- move them out |
a7ba8627a7b6
still trying to make imports work. add other files too
drewp@bigasterisk.com
parents:
diff
changeset
|
3 import '@polymer/polymer/lib/elements/dom-bind.js'; |
a7ba8627a7b6
still trying to make imports work. add other files too
drewp@bigasterisk.com
parents:
diff
changeset
|
4 |
a7ba8627a7b6
still trying to make imports work. add other files too
drewp@bigasterisk.com
parents:
diff
changeset
|
5 |
a7ba8627a7b6
still trying to make imports work. add other files too
drewp@bigasterisk.com
parents:
diff
changeset
|
6 import { PolymerElement, html } from '@polymer/polymer'; |
a7ba8627a7b6
still trying to make imports work. add other files too
drewp@bigasterisk.com
parents:
diff
changeset
|
7 import { customElement, property, computed } from '@polymer/decorators'; |
a7ba8627a7b6
still trying to make imports work. add other files too
drewp@bigasterisk.com
parents:
diff
changeset
|
8 import { render } from 'lit-html'; |
15
7ca4ff2088c3
managed to use a newer ts or something, so this includes a bunch of type fixes too
drewp@bigasterisk.com
parents:
9
diff
changeset
|
9 import { GraphView } from './graph_view'; |
9
26d3e4860adc
working on porting graph_view to n3.js. also working on making tests run
drewp@bigasterisk.com
parents:
8
diff
changeset
|
10 import { N3Store } from "n3" |
4
a668a774b162
back up, slowly turn on code again until ts breaks
drewp@bigasterisk.com
parents:
3
diff
changeset
|
11 |
3
a7ba8627a7b6
still trying to make imports work. add other files too
drewp@bigasterisk.com
parents:
diff
changeset
|
12 import { StreamedGraphClient } from './streamed_graph_client'; |
a7ba8627a7b6
still trying to make imports work. add other files too
drewp@bigasterisk.com
parents:
diff
changeset
|
13 |
a7ba8627a7b6
still trying to make imports work. add other files too
drewp@bigasterisk.com
parents:
diff
changeset
|
14 @customElement('streamed-graph') |
a7ba8627a7b6
still trying to make imports work. add other files too
drewp@bigasterisk.com
parents:
diff
changeset
|
15 class StreamedGraph extends PolymerElement { |
a7ba8627a7b6
still trying to make imports work. add other files too
drewp@bigasterisk.com
parents:
diff
changeset
|
16 @property({ type: String }) |
a7ba8627a7b6
still trying to make imports work. add other files too
drewp@bigasterisk.com
parents:
diff
changeset
|
17 url: string = ''; |
a7ba8627a7b6
still trying to make imports work. add other files too
drewp@bigasterisk.com
parents:
diff
changeset
|
18 |
15
7ca4ff2088c3
managed to use a newer ts or something, so this includes a bunch of type fixes too
drewp@bigasterisk.com
parents:
9
diff
changeset
|
19 // @property({ type: Object }) |
7ca4ff2088c3
managed to use a newer ts or something, so this includes a bunch of type fixes too
drewp@bigasterisk.com
parents:
9
diff
changeset
|
20 // graph: {version: number, store!: N3Store}; |
3
a7ba8627a7b6
still trying to make imports work. add other files too
drewp@bigasterisk.com
parents:
diff
changeset
|
21 |
15
7ca4ff2088c3
managed to use a newer ts or something, so this includes a bunch of type fixes too
drewp@bigasterisk.com
parents:
9
diff
changeset
|
22 // @property({ type: boolean }) |
7ca4ff2088c3
managed to use a newer ts or something, so this includes a bunch of type fixes too
drewp@bigasterisk.com
parents:
9
diff
changeset
|
23 // expanded: boolean = false; |
3
a7ba8627a7b6
still trying to make imports work. add other files too
drewp@bigasterisk.com
parents:
diff
changeset
|
24 |
15
7ca4ff2088c3
managed to use a newer ts or something, so this includes a bunch of type fixes too
drewp@bigasterisk.com
parents:
9
diff
changeset
|
25 // @computed('expanded') |
7ca4ff2088c3
managed to use a newer ts or something, so this includes a bunch of type fixes too
drewp@bigasterisk.com
parents:
9
diff
changeset
|
26 // expandAction(): string { |
7ca4ff2088c3
managed to use a newer ts or something, so this includes a bunch of type fixes too
drewp@bigasterisk.com
parents:
9
diff
changeset
|
27 // return this.expanded ? '-' : '+'; |
7ca4ff2088c3
managed to use a newer ts or something, so this includes a bunch of type fixes too
drewp@bigasterisk.com
parents:
9
diff
changeset
|
28 // } |
3
a7ba8627a7b6
still trying to make imports work. add other files too
drewp@bigasterisk.com
parents:
diff
changeset
|
29 |
15
7ca4ff2088c3
managed to use a newer ts or something, so this includes a bunch of type fixes too
drewp@bigasterisk.com
parents:
9
diff
changeset
|
30 // @property({ type: string }) |
7ca4ff2088c3
managed to use a newer ts or something, so this includes a bunch of type fixes too
drewp@bigasterisk.com
parents:
9
diff
changeset
|
31 // status: string = ''; |
3
a7ba8627a7b6
still trying to make imports work. add other files too
drewp@bigasterisk.com
parents:
diff
changeset
|
32 |
15
7ca4ff2088c3
managed to use a newer ts or something, so this includes a bunch of type fixes too
drewp@bigasterisk.com
parents:
9
diff
changeset
|
33 // sg: StreamedGraphClient; |
7ca4ff2088c3
managed to use a newer ts or something, so this includes a bunch of type fixes too
drewp@bigasterisk.com
parents:
9
diff
changeset
|
34 // graphView: Element; |
7ca4ff2088c3
managed to use a newer ts or something, so this includes a bunch of type fixes too
drewp@bigasterisk.com
parents:
9
diff
changeset
|
35 // graphViewDirty = true; |
3
a7ba8627a7b6
still trying to make imports work. add other files too
drewp@bigasterisk.com
parents:
diff
changeset
|
36 |
15
7ca4ff2088c3
managed to use a newer ts or something, so this includes a bunch of type fixes too
drewp@bigasterisk.com
parents:
9
diff
changeset
|
37 // static get template() { |
7ca4ff2088c3
managed to use a newer ts or something, so this includes a bunch of type fixes too
drewp@bigasterisk.com
parents:
9
diff
changeset
|
38 // return html` |
7ca4ff2088c3
managed to use a newer ts or something, so this includes a bunch of type fixes too
drewp@bigasterisk.com
parents:
9
diff
changeset
|
39 // <link rel="stylesheet" href="../src/streamed-graph.css"> |
7ca4ff2088c3
managed to use a newer ts or something, so this includes a bunch of type fixes too
drewp@bigasterisk.com
parents:
9
diff
changeset
|
40 // <div id="ui"> |
7ca4ff2088c3
managed to use a newer ts or something, so this includes a bunch of type fixes too
drewp@bigasterisk.com
parents:
9
diff
changeset
|
41 // <span class="expander"><button on-click="toggleExpand">{{expandAction}}</button></span> |
7ca4ff2088c3
managed to use a newer ts or something, so this includes a bunch of type fixes too
drewp@bigasterisk.com
parents:
9
diff
changeset
|
42 // StreamedGraph <a href="{{url}}">[source]</a>: |
7ca4ff2088c3
managed to use a newer ts or something, so this includes a bunch of type fixes too
drewp@bigasterisk.com
parents:
9
diff
changeset
|
43 // {{status}} |
7ca4ff2088c3
managed to use a newer ts or something, so this includes a bunch of type fixes too
drewp@bigasterisk.com
parents:
9
diff
changeset
|
44 // </div> |
7ca4ff2088c3
managed to use a newer ts or something, so this includes a bunch of type fixes too
drewp@bigasterisk.com
parents:
9
diff
changeset
|
45 // <div id="graphView"></div>`; |
7ca4ff2088c3
managed to use a newer ts or something, so this includes a bunch of type fixes too
drewp@bigasterisk.com
parents:
9
diff
changeset
|
46 // } |
3
a7ba8627a7b6
still trying to make imports work. add other files too
drewp@bigasterisk.com
parents:
diff
changeset
|
47 |
15
7ca4ff2088c3
managed to use a newer ts or something, so this includes a bunch of type fixes too
drewp@bigasterisk.com
parents:
9
diff
changeset
|
48 // ready() { |
7ca4ff2088c3
managed to use a newer ts or something, so this includes a bunch of type fixes too
drewp@bigasterisk.com
parents:
9
diff
changeset
|
49 // super.ready(); |
7ca4ff2088c3
managed to use a newer ts or something, so this includes a bunch of type fixes too
drewp@bigasterisk.com
parents:
9
diff
changeset
|
50 // this.graph = {version: -1, store: null}; |
7ca4ff2088c3
managed to use a newer ts or something, so this includes a bunch of type fixes too
drewp@bigasterisk.com
parents:
9
diff
changeset
|
51 // this.graphView = (this.shadowRoot as ShadowRoot).getElementById("graphView") as Element; |
8
6fefd287aff9
closer- element now holds a changing graph, but can't draw it yet
drewp@bigasterisk.com
parents:
6
diff
changeset
|
52 |
15
7ca4ff2088c3
managed to use a newer ts or something, so this includes a bunch of type fixes too
drewp@bigasterisk.com
parents:
9
diff
changeset
|
53 // this._onUrl(this.url); // todo: watch for changes and rebuild |
7ca4ff2088c3
managed to use a newer ts or something, so this includes a bunch of type fixes too
drewp@bigasterisk.com
parents:
9
diff
changeset
|
54 // } |
3
a7ba8627a7b6
still trying to make imports work. add other files too
drewp@bigasterisk.com
parents:
diff
changeset
|
55 |
15
7ca4ff2088c3
managed to use a newer ts or something, so this includes a bunch of type fixes too
drewp@bigasterisk.com
parents:
9
diff
changeset
|
56 // toggleExpand(ev) { |
7ca4ff2088c3
managed to use a newer ts or something, so this includes a bunch of type fixes too
drewp@bigasterisk.com
parents:
9
diff
changeset
|
57 // this.expanded = !this.expanded; |
7ca4ff2088c3
managed to use a newer ts or something, so this includes a bunch of type fixes too
drewp@bigasterisk.com
parents:
9
diff
changeset
|
58 // if (this.expanded) { |
7ca4ff2088c3
managed to use a newer ts or something, so this includes a bunch of type fixes too
drewp@bigasterisk.com
parents:
9
diff
changeset
|
59 // this.redrawGraph() |
7ca4ff2088c3
managed to use a newer ts or something, so this includes a bunch of type fixes too
drewp@bigasterisk.com
parents:
9
diff
changeset
|
60 // } else { |
7ca4ff2088c3
managed to use a newer ts or something, so this includes a bunch of type fixes too
drewp@bigasterisk.com
parents:
9
diff
changeset
|
61 // this.graphViewDirty = false; |
7ca4ff2088c3
managed to use a newer ts or something, so this includes a bunch of type fixes too
drewp@bigasterisk.com
parents:
9
diff
changeset
|
62 // render(null, this.graphView); |
7ca4ff2088c3
managed to use a newer ts or something, so this includes a bunch of type fixes too
drewp@bigasterisk.com
parents:
9
diff
changeset
|
63 // } |
7ca4ff2088c3
managed to use a newer ts or something, so this includes a bunch of type fixes too
drewp@bigasterisk.com
parents:
9
diff
changeset
|
64 // } |
3
a7ba8627a7b6
still trying to make imports work. add other files too
drewp@bigasterisk.com
parents:
diff
changeset
|
65 |
15
7ca4ff2088c3
managed to use a newer ts or something, so this includes a bunch of type fixes too
drewp@bigasterisk.com
parents:
9
diff
changeset
|
66 // redrawGraph() { |
7ca4ff2088c3
managed to use a newer ts or something, so this includes a bunch of type fixes too
drewp@bigasterisk.com
parents:
9
diff
changeset
|
67 // this.graphViewDirty = true; |
7ca4ff2088c3
managed to use a newer ts or something, so this includes a bunch of type fixes too
drewp@bigasterisk.com
parents:
9
diff
changeset
|
68 // requestAnimationFrame(this._redrawLater.bind(this)); |
7ca4ff2088c3
managed to use a newer ts or something, so this includes a bunch of type fixes too
drewp@bigasterisk.com
parents:
9
diff
changeset
|
69 // } |
3
a7ba8627a7b6
still trying to make imports work. add other files too
drewp@bigasterisk.com
parents:
diff
changeset
|
70 |
15
7ca4ff2088c3
managed to use a newer ts or something, so this includes a bunch of type fixes too
drewp@bigasterisk.com
parents:
9
diff
changeset
|
71 // _onUrl(url) { |
7ca4ff2088c3
managed to use a newer ts or something, so this includes a bunch of type fixes too
drewp@bigasterisk.com
parents:
9
diff
changeset
|
72 // if (this.sg) { this.sg.close(); } |
7ca4ff2088c3
managed to use a newer ts or something, so this includes a bunch of type fixes too
drewp@bigasterisk.com
parents:
9
diff
changeset
|
73 // this.sg = new StreamedGraphClient( |
7ca4ff2088c3
managed to use a newer ts or something, so this includes a bunch of type fixes too
drewp@bigasterisk.com
parents:
9
diff
changeset
|
74 // url, |
7ca4ff2088c3
managed to use a newer ts or something, so this includes a bunch of type fixes too
drewp@bigasterisk.com
parents:
9
diff
changeset
|
75 // this.onGraphChanged.bind(this), |
7ca4ff2088c3
managed to use a newer ts or something, so this includes a bunch of type fixes too
drewp@bigasterisk.com
parents:
9
diff
changeset
|
76 // this.set.bind(this, 'status'), |
7ca4ff2088c3
managed to use a newer ts or something, so this includes a bunch of type fixes too
drewp@bigasterisk.com
parents:
9
diff
changeset
|
77 // [],//window.NS, |
7ca4ff2088c3
managed to use a newer ts or something, so this includes a bunch of type fixes too
drewp@bigasterisk.com
parents:
9
diff
changeset
|
78 // [] |
7ca4ff2088c3
managed to use a newer ts or something, so this includes a bunch of type fixes too
drewp@bigasterisk.com
parents:
9
diff
changeset
|
79 // ); |
7ca4ff2088c3
managed to use a newer ts or something, so this includes a bunch of type fixes too
drewp@bigasterisk.com
parents:
9
diff
changeset
|
80 // } |
3
a7ba8627a7b6
still trying to make imports work. add other files too
drewp@bigasterisk.com
parents:
diff
changeset
|
81 |
15
7ca4ff2088c3
managed to use a newer ts or something, so this includes a bunch of type fixes too
drewp@bigasterisk.com
parents:
9
diff
changeset
|
82 // onGraphChanged() { |
7ca4ff2088c3
managed to use a newer ts or something, so this includes a bunch of type fixes too
drewp@bigasterisk.com
parents:
9
diff
changeset
|
83 // this.graph = { |
7ca4ff2088c3
managed to use a newer ts or something, so this includes a bunch of type fixes too
drewp@bigasterisk.com
parents:
9
diff
changeset
|
84 // version: this.graph.version + 1, |
7ca4ff2088c3
managed to use a newer ts or something, so this includes a bunch of type fixes too
drewp@bigasterisk.com
parents:
9
diff
changeset
|
85 // store: this.sg.store |
7ca4ff2088c3
managed to use a newer ts or something, so this includes a bunch of type fixes too
drewp@bigasterisk.com
parents:
9
diff
changeset
|
86 // }; |
7ca4ff2088c3
managed to use a newer ts or something, so this includes a bunch of type fixes too
drewp@bigasterisk.com
parents:
9
diff
changeset
|
87 // if (this.expanded) { |
7ca4ff2088c3
managed to use a newer ts or something, so this includes a bunch of type fixes too
drewp@bigasterisk.com
parents:
9
diff
changeset
|
88 // this.redrawGraph(); |
7ca4ff2088c3
managed to use a newer ts or something, so this includes a bunch of type fixes too
drewp@bigasterisk.com
parents:
9
diff
changeset
|
89 // } |
7ca4ff2088c3
managed to use a newer ts or something, so this includes a bunch of type fixes too
drewp@bigasterisk.com
parents:
9
diff
changeset
|
90 // } |
3
a7ba8627a7b6
still trying to make imports work. add other files too
drewp@bigasterisk.com
parents:
diff
changeset
|
91 |
15
7ca4ff2088c3
managed to use a newer ts or something, so this includes a bunch of type fixes too
drewp@bigasterisk.com
parents:
9
diff
changeset
|
92 // _redrawLater() { |
7ca4ff2088c3
managed to use a newer ts or something, so this includes a bunch of type fixes too
drewp@bigasterisk.com
parents:
9
diff
changeset
|
93 // if (!this.graphViewDirty) return; |
7ca4ff2088c3
managed to use a newer ts or something, so this includes a bunch of type fixes too
drewp@bigasterisk.com
parents:
9
diff
changeset
|
94 // render(new GraphView(this.url, this.graph.store).makeTemplate(), this.graphView); |
7ca4ff2088c3
managed to use a newer ts or something, so this includes a bunch of type fixes too
drewp@bigasterisk.com
parents:
9
diff
changeset
|
95 // this.graphViewDirty = false; |
7ca4ff2088c3
managed to use a newer ts or something, so this includes a bunch of type fixes too
drewp@bigasterisk.com
parents:
9
diff
changeset
|
96 // } |
3
a7ba8627a7b6
still trying to make imports work. add other files too
drewp@bigasterisk.com
parents:
diff
changeset
|
97 |
a7ba8627a7b6
still trying to make imports work. add other files too
drewp@bigasterisk.com
parents:
diff
changeset
|
98 |
a7ba8627a7b6
still trying to make imports work. add other files too
drewp@bigasterisk.com
parents:
diff
changeset
|
99 } |