From e420bee2ab4fd63f9628825eae30a70d06452e16 Mon Sep 17 00:00:00 2001 From: slqgsm Date: Thu, 28 Jul 2016 21:44:07 +0000 Subject: [PATCH] First commit for this branch, to allow removing of columns in table transformation --- .../app/plugins/panel/table/transformers.ts | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/public/app/plugins/panel/table/transformers.ts b/public/app/plugins/panel/table/transformers.ts index b1cc644790e..12e1b528422 100644 --- a/public/app/plugins/panel/table/transformers.ts +++ b/public/app/plugins/panel/table/transformers.ts @@ -152,8 +152,27 @@ transformers['table'] = { throw {message: 'Query result is not in table format, try using another transform.'}; } - model.columns = data[0].columns; - model.rows = data[0].rows; + var i,j,k, entry; + + if (panel.columns.length === 0) { + for (i = 0; i < data[0].columns.length; i++) { + panel.columns.push({ text: data[0].columns[i].text, value : data[0].columns[i].text}); + } + } + var indices = []; + for (i = 0; i < panel.columns.length; i++) { + var column = _.findWhere(data[0].columns, { "text" : panel.columns[i].text }); + indices.push(_.indexOf(data[0].columns, column)); + model.columns.push(column); + } + + for (i = 0; i < data[0].rows.length; i++) { + entry = []; + for (j = 0; j < indices.length; j++) { + entry.push(data[0].rows[i][indices[j]]); + } + model.rows.push(entry); + } } };