annotate web/light9-collector-client.html @ 2439:06da5db2fafe

rewrite ascoltami to use the graph for more playback data
author drewp@bigasterisk.com
date Thu, 30 May 2024 01:08:07 -0700
parents 4556eebe5d73
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1417
9db73555b129 split code out of live/
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
1 <link rel="import" href="/lib/polymer/polymer.html">
9db73555b129 split code out of live/
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
2 <link rel="import" href="/lib/iron-ajax/iron-ajax.html">
9db73555b129 split code out of live/
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
3
9db73555b129 split code out of live/
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
4 <dom-module id="light9-collector-client">
9db73555b129 split code out of live/
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
5 <template>
9db73555b129 split code out of live/
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
6 <iron-ajax url="/collector/attrs" method="PUT" id="put"></iron-ajax>
1659
16e0af42613f collector web client show call count in status display
drewp@bigasterisk.com
parents: 1489
diff changeset
7 <span>{{status}} ([[sent]] sent)</span>
1417
9db73555b129 split code out of live/
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
8 </template>
9db73555b129 split code out of live/
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
9 <script>
9db73555b129 split code out of live/
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
10 Polymer({
9db73555b129 split code out of live/
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
11 is: "light9-collector-client",
9db73555b129 split code out of live/
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
12 properties: {
9db73555b129 split code out of live/
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
13 status: {type: String, value: 'init'},
9db73555b129 split code out of live/
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
14 clientSession: {value: ""+Date.now()},
1659
16e0af42613f collector web client show call count in status display
drewp@bigasterisk.com
parents: 1489
diff changeset
15 self: {type: Object, notify: true},
16e0af42613f collector web client show call count in status display
drewp@bigasterisk.com
parents: 1489
diff changeset
16 sent: {type: Number, value: 0},
1417
9db73555b129 split code out of live/
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
17 },
9db73555b129 split code out of live/
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
18 ready: function() {
9db73555b129 split code out of live/
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
19 this.self = this;
9db73555b129 split code out of live/
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
20 var self = this;
1447
8a9a9b58a4e2 live page now knows that collector needs all settings on each request
drewp@bigasterisk.com
parents: 1417
diff changeset
21 this.lastSent = [];
1417
9db73555b129 split code out of live/
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
22
9db73555b129 split code out of live/
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
23 self.$.put.addEventListener(
9db73555b129 split code out of live/
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
24 'error', function() { self.status = 'err'; });
9db73555b129 split code out of live/
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
25 self.$.put.addEventListener(
9db73555b129 split code out of live/
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
26 'request', function() { self.status = 'send'; });
9db73555b129 split code out of live/
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
27 self.$.put.addEventListener(
9db73555b129 split code out of live/
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
28 'response', function() { self.status = 'ok'; });
9db73555b129 split code out of live/
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
29 // collector gives up on clients after 10sec
9db73555b129 split code out of live/
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
30 setInterval(self.ping.bind(self), 9000);
9db73555b129 split code out of live/
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
31 self.status = 'ready';
9db73555b129 split code out of live/
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
32 },
9db73555b129 split code out of live/
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
33 ping: function() {
1447
8a9a9b58a4e2 live page now knows that collector needs all settings on each request
drewp@bigasterisk.com
parents: 1417
diff changeset
34 this.send(this.lastSent);
1417
9db73555b129 split code out of live/
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
35 },
9db73555b129 split code out of live/
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
36 send: function(settings) {
9db73555b129 split code out of live/
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
37 this.$.put.body = JSON.stringify({
9db73555b129 split code out of live/
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
38 "settings": settings,
9db73555b129 split code out of live/
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
39 "client": window.location.href,
1489
31612b323436 pass packet creation time so collector can see how much lag there is
Drew Perttula <drewp@bigasterisk.com>
parents: 1447
diff changeset
40 "clientSession": this.clientSession,
31612b323436 pass packet creation time so collector can see how much lag there is
Drew Perttula <drewp@bigasterisk.com>
parents: 1447
diff changeset
41 "sendTime": Date.now() / 1000
31612b323436 pass packet creation time so collector can see how much lag there is
Drew Perttula <drewp@bigasterisk.com>
parents: 1447
diff changeset
42 });
1417
9db73555b129 split code out of live/
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
43 this.$.put.generateRequest();
1659
16e0af42613f collector web client show call count in status display
drewp@bigasterisk.com
parents: 1489
diff changeset
44 this.sent += 1;
1447
8a9a9b58a4e2 live page now knows that collector needs all settings on each request
drewp@bigasterisk.com
parents: 1417
diff changeset
45 this.lastSent = settings.slice();
1417
9db73555b129 split code out of live/
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
46 }
9db73555b129 split code out of live/
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
47 });
9db73555b129 split code out of live/
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
48 </script>
9db73555b129 split code out of live/
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
49 </dom-module>