@@ -196,6 +196,7 @@ export class ClsDashboard {
196
196
197
197
// 获取 dashboard 列表
198
198
async getList ( ) : Promise < Dashboard [ ] > {
199
+ console . log ( `Getting dashboard list}` ) ;
199
200
const res = await this . cls . clsClient . request ( {
200
201
method : 'GET' ,
201
202
path : '/dashboards' ,
@@ -208,7 +209,12 @@ export class ClsDashboard {
208
209
}
209
210
const dashboards = ( ( res . dashboards || [ ] ) as Raw . Dashboard [ ] ) . map (
210
211
( { CreateTime, DashboardName, DashboardId, data } : Raw . Dashboard ) => {
211
- const parseData = JSON . parse ( data ) ;
212
+ let parseData = [ ] ;
213
+ try {
214
+ parseData = JSON . parse ( data ) ;
215
+ } catch ( err ) {
216
+ console . log ( `Get list fail id: ${ DashboardId } , data: ${ data } ` ) ;
217
+ }
212
218
const dashboard : Dashboard = {
213
219
createTime : CreateTime ,
214
220
name : DashboardName ,
@@ -225,6 +231,7 @@ export class ClsDashboard {
225
231
226
232
// 获取 dashboard 详情
227
233
async getDetail ( { name, id } : { name ?: string ; id ?: string } ) : Promise < Dashboard | undefined > {
234
+ console . log ( `Getting dashboard id: ${ id } , name: ${ name } ` ) ;
228
235
if ( id ) {
229
236
const res = await this . cls . clsClient . request ( {
230
237
method : 'GET' ,
@@ -237,7 +244,12 @@ export class ClsDashboard {
237
244
return undefined ;
238
245
}
239
246
240
- const parseData = JSON . parse ( res . data ) ;
247
+ let parseData = [ ] ;
248
+ try {
249
+ parseData = JSON . parse ( res . data ) ;
250
+ } catch ( err ) {
251
+ console . log ( `get detail: ${ id } , data: ${ res . data } ` ) ;
252
+ }
241
253
const rawPanels : Raw . DashboardChart [ ] = parseData . panels ;
242
254
243
255
return {
@@ -272,6 +284,7 @@ export class ClsDashboard {
272
284
273
285
// 删除 dashboard
274
286
async remove ( { id, name } : RemoveDashboardInputs ) {
287
+ console . log ( `Removing dashboard id: ${ id } , name: ${ name } ` ) ;
275
288
if ( ! id && ! name ) {
276
289
throw new ApiError ( {
277
290
type : 'API_removeDashboard' ,
@@ -309,6 +322,7 @@ export class ClsDashboard {
309
322
310
323
// 创建 dashboard
311
324
async deploy ( inputs : DeployDashboardInputs , logsetConfig : LogsetConfig ) {
325
+ console . log ( `Deploy dashboard ${ inputs . name } ` ) ;
312
326
const { name, charts } = inputs ;
313
327
const data = JSON . stringify ( {
314
328
panels : charts . map ( ( v ) => {
0 commit comments