/* * BusMgr Control - Home scripts. */ (function (win, doc, undef) { "use strict"; let ch = sbc.controlHome = {}; let $pnl = ch.$pnl = {}, $dlg = ch.$dlg = {}, $frm = ch.$frm = {}; //-------------------------------------------------------------- ch.refreshApplicationStats = function (delay) { } ch.handleStatsResponse = function (response) { } //-------------------------------------------------------------- ch.refreshDbSchema = function (instance, delay) { if (sbc.awaitingLogin) return; if (!ch.awaitingSchemaResponse) { let $pnlSchema = $('.sbc-panel-results .sbc-panel-info.DbSchema.' + instance); var $items = $('.sbc-panel-item-list', $pnlSchema).fadeOut(200).empty(); var $msgs = $('.sbc-panel-messages', $pnlSchema).hide().empty().append($('
' + sbc.msg.dataQuerying + '
')).fadeIn(200); } $('.DatabaseInstance', $frm.dbSchema).val(instance); sbc.ajax.dbSchema = sbc.ajax.dbSchema || { url: sbc.url.base + 'System/Ajax/ValidateDatabaseSchema', formSel: $frm.dbSchema, $msgs: $msgs, callbackFn: ch.handleDbSchemaResponse, noWaitIcon: true }; sbc.doAjaxRequest(sbc.ajax.dbSchema, delay || 50); ch.awaitingSchemaResponse = true; } ch.handleDbSchemaResponse = function (response) { //sbc.debug('handleDbSchemaResponse', response); delete ch.awaitingSchemaResponse; let $pnlSchema = $('.sbc-panel-results .sbc-panel-info.DbSchema.' + response.instance); var $msgs = $('.sbc-panel-messages', $pnlSchema).hide().empty(); var $tablePanel = $('.sbc-panel-item-table', $pnlSchema).hide(); var $table = $('table.sbc-item-list', $tablePanel); $('tbody tr', $table).remove(); if (!response.success) return; if (response.instance == 'Control') ch.toSchema = setTimeout(function () { ch.refreshDbSchema('Template'); }, 250); if (response.instance == 'Template') ch.toSchema = setTimeout(function () { ch.refreshDbSchema('Demo'); }, 250); // Items. var items = response.items; if (!items.length) return $msgs.append($('
' + sbc.msg.dbSchemaValid + '
')).fadeIn(500); for (let itemIdx = 0; itemIdx < items.length; itemIdx++) $table.append(ch.populateDbSchemaItem(ch.getDbSchemaRowTemplate(), items[itemIdx])); $tablePanel.show(); } ch.getDbSchemaTableTemplate = function () { return $('.sbc-panel-results .sbc-panel-item-template .sbc-panel-item-table.DbSchema').clone().hide(); } ch.getDbSchemaRowTemplate = function () { return $('.sbc-panel-results .sbc-panel-item-template .sbc-row-item.DbSchemaItem').clone(); } ch.populateDbSchemaItem = function ($item, item) { if (!item) return; $item.prop('id', sbc.itemIdPrefix + item.id); $('.SchemaName', $item).text(item.schemaName); $('.TableName', $item).text(item.tableName); $('.IndexName', $item).text(item.indexName); $('.ColumnName', $item).text(item.columnName); $('.Comment', $item).text(item.comment); return $item; } //-------------------------------------------------------------- $(function () { $frm.dbSchema = $('#frmDatabaseSchema'); $pnl.dbSchemaControl = $('.sbc-panel-info.DbSchema.Control').append(ch.getDbSchemaTableTemplate()); $pnl.dbSchemaTemplate = $('.sbc-panel-info.DbSchema.Template'); $pnl.dbSchemaTemplate.append(ch.getDbSchemaTableTemplate()); $pnl.dbSchemaDemo = $('.sbc-panel-info.DbSchema.Demo').append(ch.getDbSchemaTableTemplate()); ch.toSchema = setTimeout(function () { ch.refreshDbSchema('Control'); }, 600); // NB Can only request one of the database schemas at a time as they share the same ajax config. }); //-------------------------------------------------------------- }(window, window.document)); /* The End */