63
63
</div >
64
64
<div >
65
65
<LargeMessage
66
- v-if =" !loading && (!data || !data.hits || !data.hits.total )"
66
+ v-if =" !loading && (!data || !data.data || !data.data.length )"
67
67
heading =" No API logs yet"
68
68
img =" undraw_software_engineer_lvl5.svg"
69
69
text =" We couldn't find any API logs for this API key yet, go ahead and make some requests first"
81
81
</tr >
82
82
</thead >
83
83
<tbody >
84
- <tr v-for =" (log, i) in data.hits.hits" :key =" `l${log._id}${i}`" >
85
- <td ><TimeAgo :date =" log._source.date" /></td >
86
- <td >{{ log._source.method }}</td >
84
+ <tr v-for =" (log, i) in data.data" :key =" `l${log._id}${i}`" >
85
+ <td v-if =" log._source && log._source.date" >
86
+ <TimeAgo :date =" log._source.date" />
87
+ </td >
88
+ <td v-if =" log._source && log._source.method" >
89
+ {{ log._source.method }}
90
+ </td >
87
91
<td >
88
92
<code >{{ log._source.url.split("?")[0] }}</code >
89
93
</td >
90
- <td ><HTTPStatus :status =" log._source.statusCode" /></td >
91
- <td >
94
+ <td v-if =" log._source && log._source.statusCode" >
95
+ <HTTPStatus :status =" log._source.statusCode" />
96
+ </td >
97
+ <td
98
+ v-if ="
99
+ log._source &&
100
+ log._source.completedDate &&
101
+ log._source.date
102
+ "
103
+ >
92
104
{{
93
105
new Date(log._source.completedDate).getTime() -
94
106
new Date(log._source.date).getTime()
112
124
</tr >
113
125
</tbody >
114
126
</table >
127
+ <div class =" pagination text text--align-center" >
128
+ <button
129
+ v-if =" data && data.hasMore"
130
+ class =" button"
131
+ :disabled =" loadingMore"
132
+ @click =" loadMore"
133
+ >
134
+ <span >Load more logs</span >
135
+ <font-awesome-icon
136
+ v-if =" !loadingMore"
137
+ class =" icon"
138
+ icon =" arrow-down"
139
+ />
140
+ <font-awesome-icon
141
+ v-else
142
+ class =" icon icon--ml-2 icon--color-light"
143
+ icon =" sync"
144
+ spin
145
+ />
146
+ </button >
147
+ </div >
115
148
</div >
116
149
</div >
117
150
</div >
@@ -169,11 +202,12 @@ export default class ManageSettings extends Vue {
169
202
loading = " " ;
170
203
newScopes = " orgRead" ;
171
204
scopes = scopes ;
172
- loggedInMembership = 3 ;
173
205
activeApiKey = 0 ;
174
206
apiKeyOptions: any = {};
175
207
timeFilter = " 24h" ;
208
+ from = 0 ;
176
209
timeOptions = {
210
+ " 10s" : " Last 10 seconds" ,
177
211
" 60s" : " Last 60 seconds" ,
178
212
" 10m" : " Last 10 minutes" ,
179
213
" 24h" : " Last 24 hours" ,
@@ -185,9 +219,12 @@ export default class ManageSettings extends Vue {
185
219
this .apiKeys = {
186
220
... this .$store .getters [" manage/apiKeys" ](this .$route .params .team )
187
221
};
188
- this .loggedInMembership = parseInt (
189
- this .$store .getters [" manage/loggedInMembership" ](this .$route .params .team )
190
- );
222
+ this .data = {
223
+ ... this .$store .getters [" manage/apiKeyLogs" ](
224
+ this .$route .params .team ,
225
+ this .activeApiKey
226
+ )
227
+ };
191
228
}
192
229
193
230
private load() {
@@ -219,12 +256,15 @@ export default class ManageSettings extends Vue {
219
256
}
220
257
221
258
private loadData() {
259
+ this .from = 0 ;
222
260
if (! this .activeApiKey ) return ;
223
261
this .loading = " Loading your API logs" ;
224
262
this .$store
225
263
.dispatch (" manage/getApiKeyLogs" , {
226
264
team: this .$route .params .team ,
227
- id: this .activeApiKey
265
+ id: this .activeApiKey ,
266
+ range: this .timeFilter ,
267
+ from: this .from
228
268
})
229
269
.then (data => {
230
270
this .data = data ;
@@ -236,15 +276,24 @@ export default class ManageSettings extends Vue {
236
276
}
237
277
238
278
private loadMore() {
279
+ const data = { ... this .data };
280
+ if (data && data .data ) {
281
+ this .from = data .data .length ;
282
+ }
239
283
this .loadingMore = true ;
240
284
this .$store
241
- .dispatch (" manage/getApiKeys " , {
285
+ .dispatch (" manage/getApiKeyLogs " , {
242
286
team: this .$route .params .team ,
243
- start: this .$store .state .manage .apiKeys [this .$route .params .team ].next
287
+ id: this .activeApiKey ,
288
+ range: this .timeFilter ,
289
+ from: this .from
244
290
})
245
291
.then (() => {
246
- this .apiKeys = {
247
- ... this .$store .getters [" manage/apiKeys" ](this .$route .params .team )
292
+ this .data = {
293
+ ... this .$store .getters [" manage/apiKeyLogs" ](
294
+ this .$route .params .team ,
295
+ this .activeApiKey
296
+ )
248
297
};
249
298
})
250
299
.catch (error => {
0 commit comments