|
1 | | -<!-- |
2 | | -@license |
3 | | -Copyright (c) 2016 The Polymer Project Authors. All rights reserved. |
4 | | -This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt |
5 | | -The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt |
6 | | -The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt |
7 | | -Code distributed by Google as part of the polymer project is also |
8 | | -subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt |
9 | | ---> |
10 | | - |
11 | 1 | <link rel="import" href="../bower_components/polymer/polymer-element.html"> |
| 2 | +<link rel="import" href="../bower_components/polymerfire/polymerfire.html"> |
| 3 | +<link rel="import" href="../bower_components/polymerfire/firebase-query.html"> |
12 | 4 | <link rel="import" href="shared-styles.html"> |
13 | 5 |
|
14 | 6 | <dom-module id="stats-page"> |
|
21 | 13 | } |
22 | 14 | </style> |
23 | 15 |
|
| 16 | + <!--<firebase-document |
| 17 | + id="doc2" |
| 18 | + app-name="puppyscheduler" |
| 19 | + path="/events" |
| 20 | + data="{{events}}"> |
| 21 | + </firebase-document> --> |
| 22 | + <firebase-query |
| 23 | + id="query" |
| 24 | + app-name="puppyscheduler" |
| 25 | + path="/events" |
| 26 | + data="{{events}}" |
| 27 | + </firebase-query> |
| 28 | + |
24 | 29 | <div class="card"> |
25 | | - <div class="circle">2</div> |
26 | | - <h1>View Two</h1> |
27 | | - <p>Ea duis bonorum nec, falli paulo aliquid ei eum.</p> |
28 | | - <p>Id nam odio natum malorum, tibique copiosae expetenda mel ea.Detracto suavitate repudiandae no eum. Id adhuc minim soluta nam.Id nam odio natum malorum, tibique copiosae expetenda mel ea.</p> |
| 30 | + Last time Peed: [[lastTimePeed]] |
29 | 31 | </div> |
30 | 32 | </template> |
31 | 33 |
|
32 | 34 | <script> |
33 | 35 | class StatsPage extends Polymer.Element { |
34 | 36 | static get is() { return 'stats-page'; } |
35 | | - } |
| 37 | + |
| 38 | + /*static get observers() { |
| 39 | + return [ |
| 40 | + 'dataChanged(events.*)' |
| 41 | + ] |
| 42 | + }*/ |
| 43 | + |
| 44 | + static get properties() { |
| 45 | + return { |
| 46 | + events: { |
| 47 | + type: Object, |
| 48 | + observer: 'dataChanged' |
| 49 | + }, |
| 50 | + lastTimePeed: String |
| 51 | + } |
| 52 | + } |
| 53 | + |
| 54 | + dataChanged(newData, oldData) { |
| 55 | + console.log('data changed'); |
| 56 | + console.log('newData is '); |
| 57 | + console.log(newData); |
| 58 | + console.log('oldData is '); |
| 59 | + console.log(oldData); |
| 60 | + this.lastTimePeed = this._findLastEvent("peed"); |
| 61 | + } |
| 62 | + |
| 63 | + _findLastEvent(eventName) { |
| 64 | + console.log('finding last event, events are...'); |
| 65 | + console.log(this.events); |
| 66 | + return 'abc'; |
| 67 | + } |
| 68 | + |
| 69 | + _formatDateReadable(ts) { |
| 70 | + // how long ago in ms |
| 71 | + var diff = Date.now() - ts; |
| 72 | + // convert to a readable time |
| 73 | + var secs = Math.floor(diff / 1000); |
| 74 | + var mins = Math.floor(secs / 60 ); |
| 75 | + var hours = Math.floor(mins / 60); |
| 76 | + |
| 77 | + if(hours >= 1) { |
| 78 | + return hours + ' hours ago'; |
| 79 | + } else if (mins >= 1){ |
| 80 | + return mins + ' minutes ago'; |
| 81 | + } else { |
| 82 | + return secs + ' seconds ago'; |
| 83 | + } |
| 84 | + } |
| 85 | + } |
| 86 | + |
36 | 87 |
|
37 | 88 | window.customElements.define(StatsPage.is, StatsPage); |
38 | 89 | </script> |
|
0 commit comments