import Ember from 'ember'; var skipNodeTitles = ['id', 'source', 'target', 'sourceLinks', 'targetLinks', 'urn']; var rotation = false; var ZOOM_DURATION = 2000; function setupSearch() { $("#nodeInfoSplitter").tabs({active: 0}); // var width = $(window).width() * 0.99 + 10; // var height = ($(window).height() * 0.99) - 82; // $('#mainSplitter').height(height); // $('#graphSplitter').height(height * 0.6); // $('#nodeInfoSplitter').height(height * 0.4); // $("#mainSplitter").splitter({ // type: "h", // dock: "bottom", // dockSpeed: 200, // dockKey: 'W', // accessKey: 'W', // sizeTop: true // }); refreshLineageData(); $('#rotationgraphbtn').click(function (e) { if (g_currentData) { var type = $('#lineageType').val(); rotation = !rotation; setupDagreGraph(g_currentData, rotation, type); } }); $("#uplevelbtn").click(function () { g_upLevel++; refreshLineageData(); }); $("#downlevelbtn").click(function () { g_downLevel++; refreshLineageData(); }); } function refreshLineageData(type, id) { var type = $('#lineageType').val(); var id = $('#lineageID').val(); var application = $('#application').val(); if (application) { application = application.replace(/\./g, " "); } var project = $('#project').val(); var flow = $('#flow').val(); var url = ''; if (type == 'chains') { url = 'api/v1/lineage/chains'; $("#chainComboBox").on('change', function (event) { var items = $("#chainComboBox").jqxComboBox('getSelectedItems'); var names = ''; $.each(items, function (index) { names = names + this.label; if (items.length - 1 != index) { names += ","; } }); if (names) { var dataUrl = 'api/v1/lineage/appworxflow/' + names; $("#loading").show(); $.get(dataUrl, function (data) { if (data && data.status == "ok") { $("#loading").hide(); renderTables(data.data); g_currentData = data.data; setupDagreGraph(data.data, rotation, type); $('#nodeInfoTab a:first').tab("show"); } }); } }); $("#loading").show(); $.get(url, function (data) { if (data && data.status == "ok") { $("#chainComboBox").jqxComboBox({source: data.chains, multiSelect: true, width: 450, height: 25}); $("#chainComboBox").jqxComboBox('selectItem', 'TAGG_PV_PAGE_STATS'); } $("#loading").hide(); }); } else if (type == 'dataset') { url = '/api/v1/lineage/dataset/' + id + '?upLevel=' + g_upLevel + '&downLevel=' + g_downLevel; $("#loading").show(); $.get(url, function (data) { if (data && data.status == "ok") { $("#loading").hide(); var titleObj = $('#title'); if (titleObj && data.data && data.data.urn) { titleObj.text("Lineage for: " + data.data.urn); } renderTables(data.data); g_currentData = data.data; setupDagreGraph(data.data, rotation, type); $('#nodeInfoTab a:first').tab("show"); } }); } else if (type == 'metric') { url = '/api/v1/lineage/metric/' + id + '?upLevel=' + g_upLevel + '&downLevel=' + g_downLevel; ; $("#loading").show(); $.get(url, function (data) { if (data && data.status == "ok") { $("#loading").hide(); renderTables(data.data); g_currentData = data.data; setupDagreGraph(data.data, rotation, type); $('#nodeInfoTab a:first').tab("show"); } }); } else if (type == 'azkaban') { url = '/api/v1/lineage/flow/' + application + '/' + project + '/' + flow; $("#loading").show(); $.get(url, function (data) { if (data && data.status == "ok") { $("#loading").hide(); var titleObj = $('#title'); if (titleObj && data.data && data.data.flowName) { titleObj.text("Lineage for: " + application + '/' + project + '/' + data.data.flowName); } renderTables(data.data); g_currentData = data.data; setupDagreGraph(data.data, rotation, type); $('#nodeInfoTab a:first').tab("show"); } }); } else if (type == 'appworx') { url = '/api/v1/lineage/flow/' + application + '/' + project + '/' + flow; $("#loading").show(); $.get(url, function (data) { if (data && data.status == "ok") { $("#loading").hide(); var titleObj = $('#title'); if (titleObj && data.data && data.data.flowName) { titleObj.text("Lineage for: " + application + '/' + project + '/' + data.data.flowName); } renderTables(data.data); g_currentData = data.data; setupDagreGraph(data.data, rotation, type); $('#nodeInfoTab a:first').tab("show"); } }); } } function renderTables(data) { var dataTable = $('#lineagedatatable'); var jobTable = $('#lineagejobtable'); dataTable.html(''); jobTable.html(''); var firstDataNode = false; var firstJobNode = false; if (dataTable && data) { var nodes = data.nodes; if (nodes) { var dataHeader = ''; var dataBody = ''; var jobHeader = ''; var jobBody = ''; dataHeader += ''; jobHeader += ''; var dataHeaderNames = []; var jobHeaderNames = []; for (var i = 0; i < nodes.length; i++) { dataBody += ''; jobBody += ''; if (nodes[i].node_type == 'data') { if (!firstDataNode) { if (nodes[i]["_sort_list"]) { $.each(nodes[i]["_sort_list"], function (k, v) { dataHeader += '' + v + ''; dataHeaderNames.push(v); if (nodes[i][v]) { dataBody += '' + nodes[i][v] + ''; } else { dataBody += '' + ''; } }); } firstDataNode = true; } else { for (var j = 0; j < dataHeaderNames.length; j++) { if (nodes[i][dataHeaderNames[j]]) { dataBody += '' + nodes[i][dataHeaderNames[j]] + ''; } else { dataBody += '' + ''; } } } } else if (nodes[i].node_type == 'script') { if (!firstJobNode) { if (nodes[i]['_sort_list']) { $.each(nodes[i]['_sort_list'], function (k, v) { jobHeader += '' + v + ''; jobHeaderNames.push(v); if (nodes[i][v]) { jobBody += '' + nodes[i][v] + ''; } else { jobBody += '' + ''; } }); } firstJobNode = true; } else { for (var j = 0; j < jobHeaderNames.length; j++) { if (nodes[i][jobHeaderNames[j]]) { jobBody += '' + nodes[i][jobHeaderNames[j]] + ''; } else { jobBody += '' + ''; } } } } dataBody += ''; jobBody += ''; } dataBody += ''; jobBody += ''; dataHeader += ''; dataHeader += ''; jobHeader += ''; jobHeader += ''; dataTable.append(dataHeader); dataTable.append(dataBody); jobTable.append(jobHeader); jobTable.append(jobBody); } } } function setViewport(scale, translation, duration) { if (!duration || duration < 0) { duration = 0; } d3.select('.graph-attach g') .transition() .duration(duration) .attr("transform", "translate(" + translation[0] + "," + translation[1] + ") scale(" + 1 + ")"); //renderer.setOriginalScale(1); //minimapZoom(translation, 1); } function zoomTo(scale, focus, duration) { var width = $('#svg-canvas').width(); var height = $('#svg-canvas').height(); var translation = [ -((focus[0] * scale) - (width / 2)), -((focus[1] * scale) - (height / 2)) ]; return setViewport(scale, translation, duration); } function setupDagreGraph(data, rotation, type) { d3.select("svg") .remove(); $('#canvas').html(''); var width = $(window).width() * 0.99; $('#svg-canvas').width(width); $('#svg-canvas').height((($(window).height() * 0.99) - 82) * 0.6 - 40); this.$container = $('#controls'); $field = this.$container.find('.search-field'); this.$submit = this.$container.find('.search-submit'); this.$clear = this.$container.find('.search-clear'); $results = $('