|
32 | 32 | <span class="tag is-medium is-primary">Start</span> |
33 | 33 | </header> |
34 | 34 |
|
35 | | - <div class="timeline-item is-primary" v-for="(queries, key) in dataList"> |
| 35 | + <div class="timeline-item is-primary" v-for="key in dataListKey"> |
36 | 36 | <div class="timeline-marker is-icon button is-info"> |
37 | 37 | <span v-on:click="toggleQueryGroup(key)" class="material-icons" title="expand"> |
38 | 38 | <template v-if="!showQueryGroup(key)">expand_more</template> |
39 | 39 | <template v-if="showQueryGroup(key)">expand_less</template> |
40 | 40 | </span> |
41 | 41 | </div> |
42 | 42 | <div class="timeline-content"> |
43 | | - <p class="heading">{{groupTitle(key)}} ({{queries.length}}) |
| 43 | + <p class="heading">{{groupTitle(key)}} ({{dataList[key].length}}) |
44 | 44 |
|
45 | 45 | </p> |
46 | 46 | <div> |
47 | 47 | <div class="columns is-multiline" v-if="showQueryGroup(key)"> |
48 | | - <div class="column" v-for="(query) in queries" > |
| 48 | + <div class="column" v-for="query in dataList[key]" > |
49 | 49 | <query-block |
50 | 50 | :query="query" |
51 | 51 | > |
|
62 | 62 | </div> |
63 | 63 | </main> |
64 | 64 | </div> |
65 | | - <side-panel /> |
| 65 | + <side-panel :sort-field.sync="sortKey"/> |
66 | 66 | <page-footer /> |
67 | 67 | <notification /> |
68 | 68 | </div> |
|
87 | 87 |
|
88 | 88 | data() { |
89 | 89 | return { |
| 90 | + sortKey: 'time', |
| 91 | + sortDirection: 1, |
90 | 92 | listType: 'time', |
91 | 93 | cachedKeys: {}, |
92 | 94 | showTime: [] |
|
102 | 104 | return this.groupValuesByKey(this.listType); |
103 | 105 | }, |
104 | 106 |
|
| 107 | + dataListKey() { |
| 108 | + let list = this.dataList; |
| 109 | +
|
| 110 | + return Object.keys(list).sort((a, b) => { |
| 111 | + if (list[a][0][this.sortKey] === list[b][0][this.sortKey]) { |
| 112 | + return 0; |
| 113 | + } else if(list[a][0][this.sortKey] > list[b][0][this.sortKey]) { |
| 114 | + return -1 * this.sortDirection |
| 115 | + } |
| 116 | + return this.sortDirection; |
| 117 | + }); |
| 118 | + }, |
| 119 | +
|
105 | 120 | flattenedCachedKeys() { |
106 | 121 | return Object.values(this.cachedKeys).flat(); |
107 | 122 | }, |
|
184 | 199 | groupValuesByKey(key) { |
185 | 200 | let data = {}; |
186 | 201 | this.getUniqueValuesByKey(key).forEach((uniqueValue) => { |
187 | | - data[uniqueValue] = this.flattenedCachedKeys.filter(row => row[key] === uniqueValue); |
| 202 | + data[uniqueValue] = this.flattenedCachedKeys.filter(row => row[key] === uniqueValue).sort((a, b) => { |
| 203 | + if (a[this.sortKey] === b[this.sortKey]) { |
| 204 | + return 0; |
| 205 | + } else if(a[this.sortKey] > b[this.sortKey]) { |
| 206 | + return -1 * this.sortDirection |
| 207 | + } |
| 208 | + return this.sortDirection; |
| 209 | + }); |
188 | 210 | }); |
189 | 211 | return data; |
190 | 212 | } |
|
0 commit comments