Mercurial > code > home > repos > light9
annotate web/light9-collector-client.html @ 2450:a4052905ca7d default tip
notes about how rdfdb syncs, or should sync
author | drewp@bigasterisk.com |
---|---|
date | Mon, 03 Jun 2024 23:01:54 -0700 |
parents | 4556eebe5d73 |
children |
rev | line source |
---|---|
1417 | 1 <link rel="import" href="/lib/polymer/polymer.html"> |
2 <link rel="import" href="/lib/iron-ajax/iron-ajax.html"> | |
3 | |
4 <dom-module id="light9-collector-client"> | |
5 <template> | |
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 | 8 </template> |
9 <script> | |
10 Polymer({ | |
11 is: "light9-collector-client", | |
12 properties: { | |
13 status: {type: String, value: 'init'}, | |
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 | 17 }, |
18 ready: function() { | |
19 this.self = this; | |
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 | 22 |
23 self.$.put.addEventListener( | |
24 'error', function() { self.status = 'err'; }); | |
25 self.$.put.addEventListener( | |
26 'request', function() { self.status = 'send'; }); | |
27 self.$.put.addEventListener( | |
28 'response', function() { self.status = 'ok'; }); | |
29 // collector gives up on clients after 10sec | |
30 setInterval(self.ping.bind(self), 9000); | |
31 self.status = 'ready'; | |
32 }, | |
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 | 35 }, |
36 send: function(settings) { | |
37 this.$.put.body = JSON.stringify({ | |
38 "settings": settings, | |
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 | 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 | 46 } |
47 }); | |
48 </script> | |
49 </dom-module> |