UNPKG

kui-shell

Version:

This is the monorepo for Kui, the hybrid command-line/GUI electron-based Kubernetes tool

48 lines 2.19 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const debug_1 = require("debug"); const table_1 = require("../views/table"); const debug = debug_1.default('webapp/views/diff'); exports.applyDiffTable = (diff, tab, tableDom, rows, prepareRows, option) => { if (diff.rowUpdate && diff.rowUpdate.length > 0) { debug('update rows', diff.rowUpdate); diff.rowUpdate.map(update => { const newRowView = table_1.formatOneRowResult(tab, option)(update.model); tableDom.replaceChild(newRowView, rows[update.updateIndex]); rows[update.updateIndex] = newRowView; prepareRows[update.updateIndex] = update.model; }); } if (diff.rowDeletion && diff.rowDeletion.length > 0) { debug('delete rows', diff.rowDeletion); diff.rowDeletion .filter(_ => _.model.name !== 'NAME') .map(rowDeletion => { rowDeletion.model.attributes.forEach(attr => { if (attr.key === 'STATUS') { attr.value = 'Offline'; attr.css = 'red-background'; } }); prepareRows[rowDeletion.deleteIndex] = rowDeletion.model; const status = rows[rowDeletion.deleteIndex].querySelector('.cell-inner[data-key="STATUS"]'); if (status) { status.className = 'cell-inner red-background'; status.innerText = 'Offline'; } const pulse = rows[rowDeletion.deleteIndex].querySelector('.repeating-pulse'); if (pulse) pulse.classList.remove('repeating-pulse'); }); } if (diff.rowInsertion && diff.rowInsertion.length > 0) { debug('insert rows', diff.rowInsertion); diff.rowInsertion.map(update => { const newRowView = table_1.formatOneRowResult(tab, option)(update.model); tableDom.insertBefore(newRowView, rows[update.insertBeforeIndex]); rows.splice(update.insertBeforeIndex, 0, newRowView); prepareRows.splice(update.insertBeforeIndex, 0, update.model); }); } }; //# sourceMappingURL=diffTable.js.map