http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/a9d61e1b/dashboard/v3/js/1stmaycontrollers.js ---------------------------------------------------------------------- diff --git a/dashboard/v3/js/1stmaycontrollers.js b/dashboard/v3/js/1stmaycontrollers.js new file mode 100755 index 0000000..59d7572 --- /dev/null +++ b/dashboard/v3/js/1stmaycontrollers.js @@ -0,0 +1,1250 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +var DgcControllers = angular.module("DgcControllers", []); + + DgcControllers.service('sharedProperties', function () { + var property=""; + var Query=""; + + return { + getProperty: function () { + return property; + }, + setProperty: function(value) { + property = value; + }, + getQuery: function () { + return Query; + },setQuery: function(value) { + Query = value; + } + }; +}); + + + +DgcControllers.controller("headerController", ['$scope', '$window', '$location', '$stateParams', function($scope, $window, $location,$stateParams) + { + $scope.executeSearch=function executeSearch() { + $window.location.href = "#Search/" + $scope.query; + + + } + $scope.query=$stateParams.searchid; + }] +); + +DgcControllers.controller("footerController", ['$scope','$http', function($scope, $http) + { + $http.get('/api/metadata/admin/version') + .success(function (data) { + $scope.iserror1=false; + $scope.apiVersion=data.Version; + + }) + .error(function (e) { + $scope.iserror1=true; + $scope.error1=e; + }); + + }] +); + + +DgcControllers.controller("NavController", ['$scope','$http', '$filter', 'sharedProperties', function($scope, $http, $filter, sharedProperties) +{ + + $http.get('/api/metadata/types/traits/list') + .success(function (data) { + $scope.iserror1=false; + $scope.leftnav=angular.fromJson(data.results); + + }) + .error(function (e) { + $scope.iserror1=true; + $scope.error1=e; + }); + //Nav to textbox + + $scope.updateVar = function (event) { + $scope.$$prevSibling.query = angular.element(event.target).text(); + + }; + + +}] +); + + +DgcControllers.controller("ListController", ['$scope','$http', '$filter','$stateParams', 'sharedProperties', function($scope, $http, $filter, $stateParams, sharedProperties) + { + + + $scope.isUndefined = function (strval) { + + return (typeof strval === "undefined"); + } + + $scope.StoreJson = function (strval) { + sharedProperties.setProperty(strval); + } + + $scope.Showpaging = function(itemlength) + { + + return (itemlength > 1); + } + + $scope.isString=function isString(value){ + return typeof value === 'string'; + } + + $scope.isObject=function isObject(value){ + + return typeof value === 'object'; + } + $scope.Storeqry=function Storeqry(value){ + + return typeof value === 'object'; + } + + + + $scope.executeSearchForleftNav = function executeSearchForleftNav(strSearch){ + $scope.query=strSearch; + sharedProperties.setQuery(strSearch); + //$scope.executeSearch(); + } + + console.log($stateParams.searchid); + $scope.SearchQuery=$stateParams.searchid; + $scope.reverse = false; + $scope.filteredItems = []; + $scope.groupedItems = []; + $scope.itemsPerPage = 10; + $scope.pagedItems = []; + $scope.currentPage = 0; + $scope.itemlength=0; + $scope.configdata=[]; + $scope.results=[]; + $scope.datatype=""; + $http.get('js/config.json').success(function(data){ + $scope.configdata=data.Search; + + }); + + + $http.get('/api/metadata/discovery/search?query='+$scope.SearchQuery) + .success(function (data) { + $scope.iserror=false; + $scope.entities=angular.fromJson(data.results.rows); + if(!$scope.isUndefined($scope.entities)){ + $scope.itemlength=$scope.entities.length; + $scope.datatype=data.results.dataType.typeName; + + var i=0; + angular.forEach($scope.configdata, function(values, key) { + if (key === data.results.dataType.typeName) { + i=1; + } + }); + if(i===0){ + var tempdataType="__tempQueryResultStruct"; + //console.log(tempdataType); + var datatype1=$scope.datatype.substring(0,tempdataType.length); + // console.log(datatype1); + if(datatype1===tempdataType){ + $scope.datatype=tempdataType; + } + + } + + sharedProperties.setProperty($scope.datatype); + } + + // console.log($scope.entities); + + + // to get value based on config but not use (used in view directly) + /* angular.forEach($scope.configdata, function(values, key) { + if(key===data.results.dataType.typeName) + { + $scope.entities.forEach(function(k,v){ + angular.forEach(values, function(value, key1) { + var obj = {}; + obj[value] = k[value]; + $scope.results.push(obj); + }); + }); + } + }); + */ + + $scope.currentPage = 0; + // now group by pages + $scope.groupToPages(); + + + }); + // .error(function (e) { + // alert("failed"); + // $scope.iserror=true; + // $scope.error=e; + + + // }); + +//click value to textbox + + $scope.updateVars = function (event) { + var appElement = document.querySelector('[ng-model=query]'); + var $scope = angular.element(appElement).scope(); + $scope.query = angular.element(event.target).text(); + // $scope.$apply(function() { + // $scope.query = angular.element(event.target).text(); + // }); + + + console.log("test"); + console.log(angular.element(event.target).text()); + console.log("testingFact"); + }; + //click value to textbox + $scope.getGuidName=function getGuidName(val){ + $http.get('/api/metadata/entities/definition/'+val) + .success(function (data) { + $scope.iserror1=false; + if(!$scope.isUndefined(data.results)){ + $scope.gname=angular.fromJson(data.results); + console.log(angular.fromJson(data.results)); + // $scope.gname=data.results.name; + } + + }) + .error(function (e) { + $scope.iserror1=true; + $scope.error1=e; + }); + //return $scope.gname; + } + + + // calculate page in place + $scope.groupToPages = function () { + $scope.pagedItems = []; + + for (var i = 0; i < $scope.itemlength; i++) { + if (i % $scope.itemsPerPage === 0) { + $scope.pagedItems[Math.floor(i / $scope.itemsPerPage)] = [ $scope.entities[i] ]; + } else { + $scope.pagedItems[Math.floor(i / $scope.itemsPerPage)].push($scope.entities[i]); + } + } + + }; + + $scope.range = function (start, end) { + var ret = []; + if (!end) { + end = start; + start = 0; + } + for (var i = start; i < end; i++) { + ret.push(i); + } + return ret; + }; + + $scope.prevPage = function () { + if ($scope.currentPage > 0) { + $scope.currentPage--; + } + }; + + $scope.nextPage = function () { + if ($scope.currentPage < $scope.pagedItems.length - 1) { + $scope.currentPage++; + } + }; + + + $scope.firstPage = function () { + if ($scope.currentPage > 0) { + $scope.currentPage = 0; + } + }; + + $scope.lastPage = function () { + if ($scope.currentPage < $scope.pagedItems.length - 1) { + $scope.currentPage = $scope.pagedItems.length-1; + } + }; + $scope.setPage = function () { + $scope.currentPage = this.n; + }; + + }] +); + + +DgcControllers.controller("DefinitionController", ['$scope','$http', '$stateParams', 'sharedProperties','$q', function($scope, $http, $stateParams, sharedProperties, $q) + { + + $scope.guidName=""; + $scope.ids=[]; + $scope.isUndefined = function (strval) { + return (typeof strval === "undefined"); + } + + $scope.isString=function isString(value){ + return typeof value === 'string' || getType(value)==='[object Number]'; + } + + var getType = function (elem) { + return Object.prototype.toString.call(elem); + }; + + $scope.isObject=function isObject(value){ + return typeof value === 'object'; + } +//onclick to textbox + + $scope.updateDetailsVariable = function (event) { + var appElement = document.querySelector('[ng-model=query]'); + var $scope = angular.element(appElement).scope(); + $scope.query = angular.element(event.target).text(); + // $scope.$apply(function() { + // $scope.query = angular.element(event.target).text(); + // }); + + + console.log("test"); + console.log(angular.element(event.target).text()); + console.log("testing"); + }; +//onclick to textbox + $scope.getGuidName=function getGuidName(val){ + $http.get('/api/metadata/entities/definition/'+val) + .success(function (data) { + $scope.iserror1=false; + if(!$scope.isUndefined(data.results)){ + $scope.gname=angular.fromJson(data.results); + //console.log(angular.fromJson(data.results)); + // $scope.gname=data.results.name; + } + + }) + .error(function (e) { + $scope.iserror1=true; + $scope.error1=e; + }); + return true; + } + + $scope.Name=$stateParams.Id; + $scope.searchqry=sharedProperties.getQuery(); + $scope.datatype1=sharedProperties.getProperty(); + + $http.get('/api/metadata/entities/definition/'+$stateParams.Id) + .success(function (data) { + $scope.iserror1=false; + $scope.details= angular.fromJson(data.results); + if(!$scope.isUndefined( $scope.details)) { + // console.log($scope.details['name']); + $scope.datatype1=$scope.details["$typeName$"]; + $scope.getSchema($scope.details['name']); + $scope.getLinegae($scope.details['name']); + $scope.getLinegaeforinput($scope.details['name']); + } + }) + .error(function (e) { + $scope.iserror1=true; + $scope.error1=e; + }); + + + $scope.getSchema= function (tableName) { + + $http.get('/api/metadata/lineage/hive/schema/'+tableName) + .success(function (data) { + $scope.iserror1=false; + $scope.schema= angular.fromJson(data.results.rows); + // console.log(tableName); + + + }) + .error(function (e) { + $scope.iserror1=true; + $scope.error1=e; + }); + } + +$scope.getLinegae= function (tableName) { + +// $scope.width = 900; +// $scope.height = 900; + var arr=[]; + var arrmyalias=[]; + var datatypes=[]; + var tags=[]; + $http.get('/api/metadata/lineage/hive/outputs/'+tableName) + .success(function (data) { + $scope.iserror1=false; + $scope.lineage= angular.fromJson(data.results.rows); + + $scope.vts = []; + $scope.edges1 = []; + $scope.listguid = []; + angular.forEach($scope.lineage, function(lineage1){ + var level = 0; + angular.forEach(lineage1.path, function(item, index){ + // if ($scope.listguid.indexOf(index) == -1) { + // $scope.listguid.push(index); + + $scope.vts.push({"Name": item.guid,"Id" :index,"hasChild":"True","type":item.typeName}); + $scope.edges1.push({source: index, target: (index+1)}); + + // } + }); + + }); + + + var newarr = []; + var unique = {}; + + angular.forEach($scope.edges1, function(item) { + if (!unique[item.source]) { + newarr.push(item); + unique[item.source] = item; + //console.log(newarr); + } + }); + + var newarrvts = []; + var uniquevts = {}; + + angular.forEach($scope.vts, function(item) { + if (!uniquevts[item.Name]) { + newarrvts.push(item); + uniquevts[item.Name] = item; + + var url="/api/metadata/entities/definition/"+item.Name; + arr.push($http.get(url)); + } + }); + + + $q.all(arr).then(function(ret){ + //console.log("Result guid list length="+ret.length); + for(var i=0;i<ret.length;i++){ + var f=angular.fromJson(ret[i].data.results); + //console.log(i+"Their Names="+angular.toJson(f)); + //console.log(i+"Their Names="+f.name); + arrmyalias[i]=f.name; + + datatypes[i]=f['$typeName$']; + + if(f['$typeName$']==="Table") + { + angular.forEach(f['$traits$'], function(key, value) { + tags[i]=value; + + }); + } + else{ + tags[i]=f.queryText; + } + + + } +if(arrmyalias.length>1){ + doMakeStaticJson(arrmyalias); + } + else{ + $scope.errornodata=""; + } +// loadjsonRealv2(arrmyalias); + // doMakeStaticJson(arrmyalias); + + }); + + }) + .error(function (e) { + $scope.iserror1=true; + $scope.error1=e; + }); + + function doMakeStaticJson(arrmyalias){ + + var toparr=[]; + console.log(arrmyalias.length); + var rootobj=new Object(); + rootobj.name=arrmyalias[0]; + rootobj.alias=arrmyalias[0]; + rootobj.query=tags[0]; + rootobj.datatype=datatypes[0]; + rootobj.parent="null"; + + toparr[0]=rootobj; + +//start first object + var child1obj=new Object(); + child1obj.alias=arrmyalias[1]; + child1obj.name=arrmyalias[1]; + child1obj.query=tags[1]; + child1obj.datatype=datatypes[1]; + child1obj.parent=arrmyalias[0]; + + //start + var childsub1obj=new Object(); + childsub1obj.name=arrmyalias[2]; + childsub1obj.alias=arrmyalias[2]; + childsub1obj.query=tags[2]; + childsub1obj.datatype=datatypes[2]; + childsub1obj.parent=arrmyalias[1]; + if(arrmyalias.length>2){ + var arraychildren1=[]; + arraychildren1.push(childsub1obj); + child1obj.children=arraychildren1; + } + //start + var childsub2obj=new Object(); + childsub2obj.name=arrmyalias[3]; + childsub2obj.alias=arrmyalias[3]; + childsub2obj.query=tags[3]; + childsub2obj.datatype=datatypes[3]; + childsub2obj.parent=arrmyalias[2]; + if(arrmyalias.length>3){ + var arraychildren2=[]; + arraychildren2.push(childsub2obj); + childsub1obj.children=arraychildren2; + } + + //start + var childsub3obj=new Object(); + childsub3obj.name=arrmyalias[4]; + childsub3obj.alias=arrmyalias[4]; + childsub3obj.query=tags[4]; + childsub3obj.datatype=datatypes[4]; + childsub3obj.parent=arrmyalias[3]; + if(arrmyalias.length>4){ + var arraychildren3=[]; + arraychildren3.push(childsub3obj); + childsub2obj.children=arraychildren3; + } + +///end first objects + + + + /*var arraychildren2=[]; + arraychildren2.push(child1obj2); +// arraychildren2.push(childsub2obj2); + + + child1obj2.children=arraychildren2; + + + //end second objects + */ + + var array1=[]; + array1[0]=child1obj; +// array1[1]=child1obj2; + + + rootobj.children=array1; + + + //console.info("MITH SEE THIS="+angular.toJson(toparr)); + + root = toparr[0]; + console.log(root); + update(root); + } + + + //Width and height + var width = 700, + height = 500, + root; +//image intitializer + var mitharr=["img/tableicon.png","img/process.png","img/tableicon.png","img/process.png","img/tableicon.png"]; + + + + var force = d3.layout.force() + .gravity(0) + .friction(0.7) + .charge(-90) + .linkDistance(120) + .size([width, height]) + .on("tick", tick); + + var svg = d3.select("svg") +// .attr("transform", "translate(" + (width/2) + +// "," + (height/2) + ")") + + .attr('transform-origin', '-419 -530') + .attr("viewBox", "10 -300 1000 1000") + .attr("preserveAspectRatio", "xMidYMid meet"); +// .append("g") +// .attr("transform", "translate(" + d.x + "," + d.y +") rotate(180) scale(-1, -1)"); + + +// .attr("preserveAspectRatio", "xMidYMid slice"); + + var link = svg.selectAll(".link"), + node = svg.selectAll(".node"); + + var tip = d3.tip() + .attr('class', 'd3-tip') + .offset([-10, 0]) + .html(function(d) { + return "<pre class='alert alert-success' style='max-width:400px;'>" + d.query + "</pre>"; + }); + svg.call(tip); + + function update(source) { + var nodes = flatten(root), + links = d3.layout.tree().links(nodes); + + // Restart the force layout. + force + .nodes(nodes) + .links(links) + + .start(); + + // Update links. + link = link.data(links, function(d) { return d.target.id; }); + + link.exit().remove(); + + link.enter().insert("line", ".node") + .attr("class", "link"); + + // Update nodes. + node = node.data(nodes, function(d) { return d.id; }); + + node.exit().remove(); + + svg.append("svg:pattern").attr("id","processICO").attr("width",1).attr("height",1) + .append("svg:image").attr("xlink:href","./img/process.png").attr("x",-5.5).attr("y",-4).attr("width",42).attr("height",42); + svg.append("svg:pattern").attr("id","textICO").attr("width",1).attr("height",1) + .append("svg:image").attr("xlink:href","./img/tableicon.png").attr("x",2).attr("y",2).attr("width",25).attr("height",25); + + +//arrow + svg.append("svg:defs").append("svg:marker").attr("id", "arrow").attr("viewBox", "0 0 10 10").attr("refX", 36).attr("refY", 5).attr("markerUnits", "strokeWidth").attr("markerWidth", 8).attr("markerHeight", 8).attr("orient", "auto").append("svg:path").attr("d", "M 0 0 L 10 5 L 0 10 z"); +//arrow + var nodeEnter = node.enter().append("g") + .attr("class", "nodeTrans") + .on("mouseover", tip.show) + .on("mouseout", tip.hide) + .call(force.drag); + + + + + nodeEnter.append("circle") + .attr("r", function(d) { return 15; }); + + link.attr("marker-end", "url(#arrow)"); //also added attribute for arrow at end + + nodeEnter.append("text") + .style("text-anchor", "middle") + + + .attr("dy", "-1em") + + .attr("text-anchor", function(d) { + return d.children || d._children ? "end" : "start"; }) + .text(function(d) { + return d.alias; + //return d.name; + }) + + .style("fill-opacity", 1); + + +// nodeEnter.select("circle") +// .attr("xlink:href", function(d) { +// //return d.icon; +// return mitharr[d.depth]; +// }) +// .attr("x", "-12px") +// .attr("y", "-12px") +// .attr("width", "24px") +// .attr("height", "24px"); + + + node.select("circle") +// .attr("xlink:href", function(d) { +// //return d.icon; +// return mitharr[d.depth]; +// }) + .style("fill", function(d, i) { + if(d.datatype==="Table"){ + return "url('#textICO')"; + + }else{ + return "url('#processICO')"; + } + return colors(i); + }); +//force.stop(); +//force.resume(); + +} + +//force.stop(); +function tick() { + link.attr("x1", function(d) { return d.source.x; }) + .attr("y1", function(d) { return d.source.y; }) + .attr("x2", function(d) { return d.target.x; }) + .attr("y2", function(d) { return d.target.y; }); + + + node.attr("transform", function(d) { return "translate(" + d.x + "," + d.y + ") " }); + +} + +//node[0].x = width / 2; +// node[1].y = height / 2; +d3.select(window).on('resize', update); + +function color(d) { + return d._children ? "#3182bd" // collapsed package + : d.children ? "#c6dbef" // expanded package + : "#fd8d3c"; // leaf node +} + +// Toggle children on click. +function click(d) { + if (d3.event.defaultPrevented) return; // ignore drag + if (d.children) { + d._children = d.children; + d.children = null; + } else { + d.children = d._children; + d._children = null; + } + update(); + +} + +// Returns a list of all nodes the root. +function flatten(root) { + var nodes = [], i = 0; + + function recurse(node) { + if (node.children) node.children.forEach(recurse); + if (!node.id) node.id = ++i; + nodes.push(node); + } + + recurse(root); + return nodes; + +} + + +// +// }) +// .error(function (e) { +// $scope.iserror1=true; +// $scope.error1=e; +// }); + + + } + + + + + +$scope.getLinegaeforinput= function (tableName) { + +// $scope.width = 900; +// $scope.height = 900; + var arr=[]; + var arrmyalias=[]; + var datatypes=[]; + var tags=[]; + $http.get('/api/metadata/lineage/hive/inputs/'+tableName) + .success(function (data) { + $scope.iserror1=false; + $scope.lineage= angular.fromJson(data.results.rows); + + $scope.vts = []; + $scope.edges1 = []; + $scope.listguid = []; + angular.forEach($scope.lineage, function(lineage1){ + var level = 0; + angular.forEach(lineage1.path, function(item, index){ + // if ($scope.listguid.indexOf(index) == -1) { + // $scope.listguid.push(index); + + $scope.vts.push({"Name": item.guid,"Id" :index,"hasChild":"True","type":item.typeName}); + $scope.edges1.push({source: index, target: (index+1)}); + + // } + }); + + }); + + var newarr = []; + var unique = {}; + + angular.forEach($scope.edges1, function(item) { + if (!unique[item.source]) { + newarr.push(item); + unique[item.source] = item; + //console.log(newarr); + } + }); + + var newarrvts = []; + var uniquevts = {}; + + angular.forEach($scope.vts, function(item) { + if (!uniquevts[item.Name]) { + newarrvts.push(item); + uniquevts[item.Name] = item; + + var url="/api/metadata/entities/definition/"+item.Name; + arr.push($http.get(url)); + + //getLienageGuidName(item.Name); + + } + }); + console.log(item.Name); + + $q.all(arr).then(function(ret){ + //console.log("Result guid list length="+ret.length); + for(var i=0;i<ret.length;i++){ + var f=angular.fromJson(ret[i].data.results); + //console.log(i+"Their Names="+angular.toJson(f)); + //console.log(i+"Their Names="+f.name); + arrmyalias[i]=f.name; + + datatypes[i]=f['$typeName$']; + + if(f['$typeName$']==="Table") + { + angular.forEach(f['$traits$'], function(key, value) { + tags[i]=value; + console.log(value); + }); + } + else{ + tags[i]=f.queryText; + console.log(f.queryText); + } + + + } + console.log(arrmyalias); + +if(arrmyalias.length>1){ + doMakeStaticJson(arrmyalias); + } + else{ + $scope.errornodata1=""; + } +// loadjsonRealv2(arrmyalias); + // doMakeStaticJson(arrmyalias); + + }); + + }) + .error(function (e) { + $scope.iserror1=true; + $scope.error1=e; + }); + + function doMakeStaticJson(arrmyalias){ + + var toparr=[]; + + var rootobj=new Object(); + rootobj.name=arrmyalias[0]; + rootobj.alias=arrmyalias[0]; + rootobj.query=tags[0]; + rootobj.datatype=datatypes[0]; + rootobj.parent="null"; + + toparr[0]=rootobj; + +//start first object + var child1obj=new Object(); + child1obj.alias=arrmyalias[1]; + child1obj.name=arrmyalias[1]; + child1obj.query=tags[1]; + child1obj.datatype=datatypes[1]; + child1obj.parent=arrmyalias[0]; + + //start + var childsub1obj=new Object(); + childsub1obj.name=arrmyalias[2]; + childsub1obj.alias=arrmyalias[2]; + childsub1obj.query=tags[2]; + childsub1obj.datatype=datatypes[2]; + childsub1obj.parent=arrmyalias[1]; + + if(arrmyalias.length>2){ + var arraychildren1=[]; + arraychildren1.push(childsub1obj); + child1obj.children=arraychildren1; + } + //start + var childsub2obj=new Object(); + childsub2obj.name=arrmyalias[3]; + childsub2obj.alias=arrmyalias[3]; + childsub2obj.query=tags[3]; + childsub2obj.datatype=datatypes[3]; + childsub2obj.parent=arrmyalias[2]; + if(arrmyalias.length>3){ + var arraychildren2=[]; + arraychildren2.push(childsub2obj); + childsub1obj.children=arraychildren2; + } + + //start + var childsub3obj=new Object(); + childsub3obj.name=arrmyalias[4]; + childsub3obj.alias=arrmyalias[4]; + childsub3obj.query=tags[4]; + childsub3obj.datatype=datatypes[4]; + childsub3obj.parent=arrmyalias[3]; + + if(arrmyalias.length>4){ + var arraychildren3=[]; + arraychildren3.push(childsub3obj); + childsub2obj.children=arraychildren3; + } + + +///end first objects + + + + /*var arraychildren2=[]; + arraychildren2.push(child1obj2); +// arraychildren2.push(childsub2obj2); + + + child1obj2.children=arraychildren2; + + + //end second objects + */ + + var array1=[]; + array1[0]=child1obj; +// array1[1]=child1obj2; + + + rootobj.children=array1; + + + //console.info("MITH SEE THIS="+angular.toJson(toparr)); + + root = toparr[0]; + console.log("test input"); + console.log(root); + update(root); + } + + + //Width and height + var width = 700, + height = 500, + root; +//image intitializer + var mitharr=["img/tableicon.png","img/process.png","img/tableicon.png","img/process.png","img/tableicon.png"]; + + + + var force = d3.layout.force() + .gravity(0) + .friction(0.7) + .charge(-90) + .linkDistance(120) + .size([width, height]) + .on("tick", tick); + + var svg = d3.select("svg1").append("svg") +// .attr("transform", "translate(" + (width/2) + +// "," + (height/2) + ")") + + .attr('transform-origin', '-419 -530') + .attr("viewBox", "10 -300 1000 1000") + .attr("preserveAspectRatio", "xMidYMid meet"); +// .append("g") +// .attr("transform", "translate(" + d.x + "," + d.y +") rotate(180) scale(-1, -1)"); + + +// .attr("preserveAspectRatio", "xMidYMid slice"); + + var link = svg.selectAll(".link"), + node = svg.selectAll(".node"); + + var tip = d3.tip() + .attr('class', 'd3-tip') + .offset([-10, 0]) + .html(function(d) { + return "<pre class='alert alert-success' style='max-width:400px;'>" + d.query + "</pre>"; + }); + + if(svg){ + svg.call(tip); + } + + + function update(source) { + var nodes = flatten(root), + links = d3.layout.tree().links(nodes); + + // Restart the force layout. + force + .nodes(nodes) + .links(links) + + .start(); + + // Update links. + link = link.data(links, function(d) { return d.target.id; }); + + link.exit().remove(); + + link.enter().insert("line", ".node") + .attr("class", "link"); + + // Update nodes. + node = node.data(nodes, function(d) { return d.id; }); + + node.exit().remove(); + + svg.append("svg:pattern").attr("id","processICO1").attr("width",1).attr("height",1) + .append("svg:image").attr("xlink:href","./img/process.png").attr("x",-5.5).attr("y",-4).attr("width",42).attr("height",42); + svg.append("svg:pattern").attr("id","textICO1").attr("width",1).attr("height",1) + .append("svg:image").attr("xlink:href","./img/tableicon.png").attr("x",2).attr("y",2).attr("width",25).attr("height",25); + + +//arrow + svg.append("svg:defs").append("svg:marker").attr("id", "arrow1").attr("viewBox", "0 0 10 10").attr("refX", 60).attr("refY", 5).attr("markerUnits", "strokeWidth").attr("markerWidth", 8).attr("markerHeight", 8).attr("orient", "auto").append("svg:path").attr("d", "M 0 0 L 10 5 L 0 10 z"); +//arrow + var nodeEnter = node.enter().append("g") + .attr("class", "nodeTrans") + .on("mouseover", tip.show) + .on("mouseout", tip.hide) + .call(force.drag); + + + + + nodeEnter.append("circle") + .attr("r", function(d) { return 15; }); + + link.attr("marker-end", "url(#arrow1)"); //also added attribute for arrow at end + + nodeEnter.append("text") + .style("text-anchor", "middle") + + + .attr("dy", "-1em") + + .attr("text-anchor", function(d) { + return d.children || d._children ? "end" : "start"; }) + .text(function(d) { + return d.alias; + //return d.name; + }) + + .style("fill-opacity", 1); + + +// nodeEnter.select("circle") +// .attr("xlink:href", function(d) { +// //return d.icon; +// return mitharr[d.depth]; +// }) +// .attr("x", "-12px") +// .attr("y", "-12px") +// .attr("width", "24px") +// .attr("height", "24px"); + + + node.select("circle") +// .attr("xlink:href", function(d) { +// //return d.icon; +// return mitharr[d.depth]; +// }) + .style("fill", function(d) { + if(d.datatype==="Table"){ + return "url('#textICO1')"; + + }else{ + return "url('#processICO1')"; + } + return colors(i); + }); +//force.stop(); +//force.resume(); + +} + +//force.stop(); +function tick() { + link.attr("x1", function(d) { return d.source.x; }) + .attr("y1", function(d) { return d.source.y; }) + .attr("x2", function(d) { return d.target.x; }) + .attr("y2", function(d) { return d.target.y; }); + + + node.attr("transform", function(d) { return "translate(" + d.x + "," + d.y + ") " }); + +} + +//node[0].x = width / 2; +// node[1].y = height / 2; +d3.select(window).on('resize', update); + +function color(d) { + return d._children ? "#3182bd" // collapsed package + : d.children ? "#c6dbef" // expanded package + : "#fd8d3c"; // leaf node +} + +// Toggle children on click. +function click(d) { + if (d3.event.defaultPrevented) return; // ignore drag + if (d.children) { + d._children = d.children; + d.children = null; + } else { + d.children = d._children; + d._children = null; + } + update(); + +} + +// Returns a list of all nodes the root. +function flatten(root) { + var nodes = [], i = 0; + + function recurse(node) { + if (node.children) node.children.forEach(recurse); + if (!node.id) node.id = ++i; + nodes.push(node); + } + + recurse(root); + return nodes; + +} + + +// +// }) +// .error(function (e) { +// $scope.iserror1=true; +// $scope.error1=e; +// }); + + + } + + + + // console.log( $scope.vts); + + $scope.reverse = function(array) { + var copy = [].concat(array); + return copy.reverse(); + } + + // function back() + // { + // $window.history.back(); + // myModule.run(function ($rootScope, $location) { + + // var history = []; + + // $rootScope.$on('$routeChangeSuccess', function() { + // history.push($location.$$path); + // }); + + // $rootScope.back = function () { + // var prevUrl = history.length > 1 ? history.splice(-2)[0] : "/"; + // $location.path(prevUrl); + // }; + + // }); + // } + + + + + }] +); + + +DgcControllers.controller("GuidController", ['$scope','$http', '$filter','$stateParams', 'sharedProperties', function($scope, $http, $filter, $stateParams, sharedProperties) + { + + + +$scope.getGuidName=function getGuidName(val){ + + $scope.gnew=[]; + $http.get('/api/metadata/entities/definition/'+val) + .success(function (data) { + $scope.iserror1=false; + if(!$scope.isUndefined(data.results)){ + + $scope.gname=angular.fromJson(data.results); + var data1=angular.fromJson(data.results); + //$scope.gnew({"id" : val,"name" : data1['name']}); + + $scope.gnew= $scope.gname.name; + // $scope.$watch($scope.gnew, true); + +} + //dddd + + + }) + .error(function (e) { + $scope.iserror1=true; + $scope.error1=e; + }); + + //return $scope.gnew; + } + + + }] +); +
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/a9d61e1b/dashboard/v3/js/app.js ---------------------------------------------------------------------- diff --git a/dashboard/v3/js/app.js b/dashboard/v3/js/app.js new file mode 100755 index 0000000..0adb15b --- /dev/null +++ b/dashboard/v3/js/app.js @@ -0,0 +1,63 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +var DgcApp = angular.module('DgcApp', [ + 'ui.router', + 'DgcControllers', + 'ui.bootstrap' +]); + +DgcApp.config(['$urlRouterProvider','$stateProvider', function($urlRouterProvider, $stateProvider) { + $urlRouterProvider.otherwise('Home'); + $stateProvider + .state('Home', { + url: 'Home', + views: { + 'content': { + templateUrl: 'partials/search.html', + controller: 'ListController' + } + } + }) + .state('Search', { + url: '/Search/:searchid', + views: { + 'content': { + templateUrl: 'partials/search.html', + controller: 'ListController' + } + } + }) + .state('details', { + url: 'details/:Id', + views: { + 'content': { + templateUrl: 'partials/wiki.html', + controller: 'DefinitionController' + } + } + }); +}]); + +DgcApp.run(['$window', '$rootScope', +function ($window , $rootScope) { + $rootScope.goBack = function(){ + $window.history.back(); + return false; + } +}]); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/a9d61e1b/dashboard/v3/js/config.json ---------------------------------------------------------------------- diff --git a/dashboard/v3/js/config.json b/dashboard/v3/js/config.json new file mode 100755 index 0000000..4530ee0 --- /dev/null +++ b/dashboard/v3/js/config.json @@ -0,0 +1,54 @@ +{ "Search": { + "Table": [ + { "$id$":["id"] }, + "name", + { "description": ["description"] }, + "owner", + "createTime", + { "$traits$":[""]} + ], + "DB": [ + { "$id$":["id"] }, + "name", + { "description": ["description"] }, + "locationUri", + "owner", + { "$traits$":[""]} + ], + "Column": [ + { "$id$":["id"] }, + "name", + "dataType", + "comment", + "table", + { "$traits$":[""]} + ], + "__tempQueryResultStruct": [ + { "instanceInfo": ["guid","typeName"] } + ], + "StorageDesc": [ + { "$id$":["id"] }, + "compressed", + "outputFormat", + "location", + "inputFormat", + { "$traits$":[""]} + ], + "LoadProcess": [ + { "$id$":["id"] }, +{ "inputTables":["id"] }, + "name", + "queryText", + "startTime", + "endTime", + { "$traits$":[""]} + ], + "View": [ + { "$id$":["id"] }, + "inputTables", + "name", + { "$traits$":[""]} + ] + + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/a9d61e1b/dashboard/v3/js/controllers.js ---------------------------------------------------------------------- diff --git a/dashboard/v3/js/controllers.js b/dashboard/v3/js/controllers.js new file mode 100755 index 0000000..c707a6d --- /dev/null +++ b/dashboard/v3/js/controllers.js @@ -0,0 +1,1247 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +var DgcControllers = angular.module("DgcControllers", []); + + DgcControllers.service('sharedProperties', function () { + var property=""; + var Query=""; + + return { + getProperty: function () { + return property; + }, + setProperty: function(value) { + property = value; + }, + getQuery: function () { + return Query; + },setQuery: function(value) { + Query = value; + } + }; +}); + + + +DgcControllers.controller("headerController", ['$scope', '$window', '$location', '$stateParams', function($scope, $window, $location,$stateParams) + { + $scope.executeSearch=function executeSearch() { + $window.location.href = "#Search/" + $scope.query; + + + } + $scope.query=$stateParams.searchid; + }] +); + +DgcControllers.controller("footerController", ['$scope','$http', function($scope, $http) + { + $http.get('/api/metadata/admin/version') + .success(function (data) { + $scope.iserror1=false; + $scope.apiVersion=data.Version; + + }) + .error(function (e) { + $scope.iserror1=true; + $scope.error1=e; + }); + + }] +); + + +DgcControllers.controller("NavController", ['$scope','$http', '$filter', 'sharedProperties', function($scope, $http, $filter, sharedProperties) +{ + + $http.get('/api/metadata/types/traits/list') + .success(function (data) { + $scope.iserror1=false; + $scope.leftnav=angular.fromJson(data.results); + + }) + .error(function (e) { + $scope.iserror1=true; + $scope.error1=e; + }); + //Nav to textbox + + $scope.updateVar = function (event) { + $scope.$$prevSibling.query = angular.element(event.target).text(); + + }; + + +}] +); + + +DgcControllers.controller("ListController", ['$scope','$http', '$filter','$stateParams', 'sharedProperties', function($scope, $http, $filter, $stateParams, sharedProperties) + { + + + $scope.isUndefined = function (strval) { + + return (typeof strval === "undefined"); + } + + $scope.StoreJson = function (strval) { + sharedProperties.setProperty(strval); + } + + $scope.Showpaging = function(itemlength) + { + + return (itemlength > 1); + } + + $scope.isString=function isString(value){ + return typeof value === 'string'; + } + + $scope.isObject=function isObject(value){ + + return typeof value === 'object'; + } + $scope.Storeqry=function Storeqry(value){ + + return typeof value === 'object'; + } + + + + $scope.executeSearchForleftNav = function executeSearchForleftNav(strSearch){ + $scope.query=strSearch; + sharedProperties.setQuery(strSearch); + //$scope.executeSearch(); + } + + console.log($stateParams.searchid); + $scope.SearchQuery=$stateParams.searchid; + $scope.reverse = false; + $scope.filteredItems = []; + $scope.groupedItems = []; + $scope.itemsPerPage = 10; + $scope.pagedItems = []; + $scope.currentPage = 0; + $scope.itemlength=0; + $scope.configdata=[]; + $scope.results=[]; + $scope.datatype=""; + $http.get('js/config.json').success(function(data){ + $scope.configdata=data.Search; + + }); + + + $http.get('/api/metadata/discovery/search?query='+$scope.SearchQuery) + .success(function (data) { + $scope.iserror=false; + $scope.entities=angular.fromJson(data.results.rows); + if(!$scope.isUndefined($scope.entities)){ + $scope.itemlength=$scope.entities.length; + $scope.datatype=data.results.dataType.typeName; + + var i=0; + angular.forEach($scope.configdata, function(values, key) { + if (key === data.results.dataType.typeName) { + i=1; + } + }); + if(i===0){ + var tempdataType="__tempQueryResultStruct"; + //console.log(tempdataType); + var datatype1=$scope.datatype.substring(0,tempdataType.length); + // console.log(datatype1); + if(datatype1===tempdataType){ + $scope.datatype=tempdataType; + } + + } + + sharedProperties.setProperty($scope.datatype); + } + + // console.log($scope.entities); + + + // to get value based on config but not use (used in view directly) + /* angular.forEach($scope.configdata, function(values, key) { + if(key===data.results.dataType.typeName) + { + $scope.entities.forEach(function(k,v){ + angular.forEach(values, function(value, key1) { + var obj = {}; + obj[value] = k[value]; + $scope.results.push(obj); + }); + }); + } + }); + */ + + $scope.currentPage = 0; + // now group by pages + $scope.groupToPages(); + + + }); + // .error(function (e) { + // alert("failed"); + // $scope.iserror=true; + // $scope.error=e; + + + // }); + +//click value to textbox + + $scope.updateVars = function (event) { + var appElement = document.querySelector('[ng-model=query]'); + var $scope = angular.element(appElement).scope(); + $scope.query = angular.element(event.target).text(); + // $scope.$apply(function() { + // $scope.query = angular.element(event.target).text(); + // }); + + + console.log("test"); + console.log(angular.element(event.target).text()); + console.log("testingFact"); + }; + //click value to textbox + $scope.getGuidName=function getGuidName(val){ + $http.get('/api/metadata/entities/definition/'+val) + .success(function (data) { + $scope.iserror1=false; + if(!$scope.isUndefined(data.results)){ + $scope.gname=angular.fromJson(data.results); + console.log(angular.fromJson(data.results)); + // $scope.gname=data.results.name; + } + + }) + .error(function (e) { + $scope.iserror1=true; + $scope.error1=e; + }); + //return $scope.gname; + } + + + // calculate page in place + $scope.groupToPages = function () { + $scope.pagedItems = []; + + for (var i = 0; i < $scope.itemlength; i++) { + if (i % $scope.itemsPerPage === 0) { + $scope.pagedItems[Math.floor(i / $scope.itemsPerPage)] = [ $scope.entities[i] ]; + } else { + $scope.pagedItems[Math.floor(i / $scope.itemsPerPage)].push($scope.entities[i]); + } + } + + }; + + $scope.range = function (start, end) { + var ret = []; + if (!end) { + end = start; + start = 0; + } + for (var i = start; i < end; i++) { + ret.push(i); + } + return ret; + }; + + $scope.prevPage = function () { + if ($scope.currentPage > 0) { + $scope.currentPage--; + } + }; + + $scope.nextPage = function () { + if ($scope.currentPage < $scope.pagedItems.length - 1) { + $scope.currentPage++; + } + }; + + + $scope.firstPage = function () { + if ($scope.currentPage > 0) { + $scope.currentPage = 0; + } + }; + + $scope.lastPage = function () { + if ($scope.currentPage < $scope.pagedItems.length - 1) { + $scope.currentPage = $scope.pagedItems.length-1; + } + }; + $scope.setPage = function () { + $scope.currentPage = this.n; + }; + + }] +); + + +DgcControllers.controller("DefinitionController", ['$scope','$http', '$stateParams', 'sharedProperties','$q', function($scope, $http, $stateParams, sharedProperties, $q) + { + + $scope.guidName=""; + $scope.ids=[]; + $scope.isUndefined = function (strval) { + return (typeof strval === "undefined"); + } + + $scope.isString=function isString(value){ + return typeof value === 'string' || getType(value)==='[object Number]'; + } + + var getType = function (elem) { + return Object.prototype.toString.call(elem); + }; + + $scope.isObject=function isObject(value){ + return typeof value === 'object'; + } +//onclick to textbox + + $scope.updateDetailsVariable = function (event) { + var appElement = document.querySelector('[ng-model=query]'); + var $scope = angular.element(appElement).scope(); + $scope.query = angular.element(event.target).text(); + // $scope.$apply(function() { + // $scope.query = angular.element(event.target).text(); + // }); + + + console.log("test"); + console.log(angular.element(event.target).text()); + console.log("testing"); + }; +//onclick to textbox + $scope.getGuidName=function getGuidName(val){ + $http.get('/api/metadata/entities/definition/'+val) + .success(function (data) { + $scope.iserror1=false; + if(!$scope.isUndefined(data.results)){ + $scope.gname=angular.fromJson(data.results); + //console.log(angular.fromJson(data.results)); + // $scope.gname=data.results.name; + } + + }) + .error(function (e) { + $scope.iserror1=true; + $scope.error1=e; + }); + return true; + } + + $scope.Name=$stateParams.Id; + $scope.searchqry=sharedProperties.getQuery(); + $scope.datatype1=sharedProperties.getProperty(); + + $http.get('/api/metadata/entities/definition/'+$stateParams.Id) + .success(function (data) { + $scope.iserror1=false; + $scope.details= angular.fromJson(data.results); + if(!$scope.isUndefined( $scope.details)) { + // console.log($scope.details['name']); + $scope.datatype1=$scope.details["$typeName$"]; + $scope.getSchema($scope.details['name']); + $scope.getLinegae($scope.details['name']); + $scope.getLinegaeforinput($scope.details['name']); + } + }) + .error(function (e) { + $scope.iserror1=true; + $scope.error1=e; + }); + + + $scope.getSchema= function (tableName) { + + $http.get('/api/metadata/lineage/hive/schema/'+tableName) + .success(function (data) { + $scope.iserror1=false; + $scope.schema= angular.fromJson(data.results.rows); + // console.log(tableName); + + + }) + .error(function (e) { + $scope.iserror1=true; + $scope.error1=e; + }); + } + +$scope.getLinegae= function (tableName) { + +// $scope.width = 900; +// $scope.height = 900; + var arr=[]; + var arrmyalias=[]; + var datatypes=[]; + var tags=[]; + $http.get('/api/metadata/lineage/hive/outputs/'+tableName) + .success(function (data) { + $scope.iserror1=false; + $scope.lineage= angular.fromJson(data.results.rows); + + $scope.vts = []; + $scope.edges1 = []; + $scope.listguid = []; + angular.forEach($scope.lineage, function(lineage1){ + var level = 0; + angular.forEach(lineage1.path, function(item, index){ + // if ($scope.listguid.indexOf(index) == -1) { + // $scope.listguid.push(index); + + $scope.vts.push({"Name": item.guid,"Id" :index,"hasChild":"True","type":item.typeName}); + $scope.edges1.push({source: index, target: (index+1)}); + + // } + }); + + }); + + + var newarr = []; + var unique = {}; + + angular.forEach($scope.edges1, function(item) { + if (!unique[item.source]) { + newarr.push(item); + unique[item.source] = item; + //console.log(newarr); + } + }); + + var newarrvts = []; + var uniquevts = {}; + + angular.forEach($scope.vts, function(item) { + if (!uniquevts[item.Name]) { + newarrvts.push(item); + uniquevts[item.Name] = item; + + var url="/api/metadata/entities/definition/"+item.Name; + arr.push($http.get(url)); + } + }); + + + $q.all(arr).then(function(ret){ + //console.log("Result guid list length="+ret.length); + for(var i=0;i<ret.length;i++){ + var f=angular.fromJson(ret[i].data.results); + //console.log(i+"Their Names="+angular.toJson(f)); + //console.log(i+"Their Names="+f.name); + arrmyalias[i]=f.name; + + datatypes[i]=f['$typeName$']; + + if(f['$typeName$']==="Table") + { + angular.forEach(f['$traits$'], function(key, value) { + tags[i]=value; + + }); + } + else{ + tags[i]=f.queryText; + } + + + } +if(arrmyalias.length>1){ + doMakeStaticJson(arrmyalias); + } + else{ + $scope.errornodata=""; + } +// loadjsonRealv2(arrmyalias); + // doMakeStaticJson(arrmyalias); + + }); + + }) + .error(function (e) { + $scope.iserror1=true; + $scope.error1=e; + }); + + function doMakeStaticJson(arrmyalias){ + + var toparr=[]; + console.log(arrmyalias.length); + var rootobj=new Object(); + rootobj.name=arrmyalias[0]; + rootobj.alias=arrmyalias[0]; + rootobj.query=tags[0]; + rootobj.datatype=datatypes[0]; + rootobj.parent="null"; + + toparr[0]=rootobj; + +//start first object + var child1obj=new Object(); + child1obj.alias=arrmyalias[1]; + child1obj.name=arrmyalias[1]; + child1obj.query=tags[1]; + child1obj.datatype=datatypes[1]; + child1obj.parent=arrmyalias[0]; + + //start + var childsub1obj=new Object(); + childsub1obj.name=arrmyalias[2]; + childsub1obj.alias=arrmyalias[2]; + childsub1obj.query=tags[2]; + childsub1obj.datatype=datatypes[2]; + childsub1obj.parent=arrmyalias[1]; + if(arrmyalias.length>2){ + var arraychildren1=[]; + arraychildren1.push(childsub1obj); + child1obj.children=arraychildren1; + } + //start + var childsub2obj=new Object(); + childsub2obj.name=arrmyalias[3]; + childsub2obj.alias=arrmyalias[3]; + childsub2obj.query=tags[3]; + childsub2obj.datatype=datatypes[3]; + childsub2obj.parent=arrmyalias[2]; + if(arrmyalias.length>3){ + var arraychildren2=[]; + arraychildren2.push(childsub2obj); + childsub1obj.children=arraychildren2; + } + + //start + var childsub3obj=new Object(); + childsub3obj.name=arrmyalias[4]; + childsub3obj.alias=arrmyalias[4]; + childsub3obj.query=tags[4]; + childsub3obj.datatype=datatypes[4]; + childsub3obj.parent=arrmyalias[3]; + if(arrmyalias.length>4){ + var arraychildren3=[]; + arraychildren3.push(childsub3obj); + childsub2obj.children=arraychildren3; + } + +///end first objects + + + + /*var arraychildren2=[]; + arraychildren2.push(child1obj2); +// arraychildren2.push(childsub2obj2); + + + child1obj2.children=arraychildren2; + + + //end second objects + */ + + var array1=[]; + array1[0]=child1obj; +// array1[1]=child1obj2; + + + rootobj.children=array1; + + + //console.info("MITH SEE THIS="+angular.toJson(toparr)); + + root = toparr[0]; + console.log(root); + update(root); + } + + + //Width and height + var width = 700, + height = 500, + root; +//image intitializer + var mitharr=["img/tableicon.png","img/process.png","img/tableicon.png","img/process.png","img/tableicon.png"]; + + + + var force = d3.layout.force() + .gravity(0) + .friction(0.7) + .charge(-90) + .linkDistance(120) + .size([width, height]) + .on("tick", tick); + + var svg = d3.select("svg") +// .attr("transform", "translate(" + (width/2) + +// "," + (height/2) + ")") + + .attr('transform-origin', '-419 -530') + .attr("viewBox", "10 -300 1000 1000") + .attr("preserveAspectRatio", "xMidYMid meet"); +// .append("g") +// .attr("transform", "translate(" + d.x + "," + d.y +") rotate(180) scale(-1, -1)"); + + +// .attr("preserveAspectRatio", "xMidYMid slice"); + + var link = svg.selectAll(".link"), + node = svg.selectAll(".node"); + + var tip = d3.tip() + .attr('class', 'd3-tip') + .offset([-10, 0]) + .html(function(d) { + return "<pre class='alert alert-success' style='max-width:400px;'>" + d.query + "</pre>"; + }); + svg.call(tip); + + function update(source) { + var nodes = flatten(root), + links = d3.layout.tree().links(nodes); + + // Restart the force layout. + force + .nodes(nodes) + .links(links) + + .start(); + + // Update links. + link = link.data(links, function(d) { return d.target.id; }); + + link.exit().remove(); + + link.enter().insert("line", ".node") + .attr("class", "link"); + + // Update nodes. + node = node.data(nodes, function(d) { return d.id; }); + + node.exit().remove(); + + svg.append("svg:pattern").attr("id","processICO").attr("width",1).attr("height",1) + .append("svg:image").attr("xlink:href","./img/process.png").attr("x",-5.5).attr("y",-4).attr("width",42).attr("height",42); + svg.append("svg:pattern").attr("id","textICO").attr("width",1).attr("height",1) + .append("svg:image").attr("xlink:href","./img/tableicon.png").attr("x",2).attr("y",2).attr("width",25).attr("height",25); + + +//arrow + svg.append("svg:defs").append("svg:marker").attr("id", "arrow").attr("viewBox", "0 0 10 10").attr("refX", 36).attr("refY", 5).attr("markerUnits", "strokeWidth").attr("markerWidth", 8).attr("markerHeight", 8).attr("orient", "auto").append("svg:path").attr("d", "M 0 0 L 10 5 L 0 10 z"); +//arrow + var nodeEnter = node.enter().append("g") + .attr("class", "nodeTrans") + .on("mouseover", tip.show) + .on("mouseout", tip.hide) + .call(force.drag); + + + + + nodeEnter.append("circle") + .attr("r", function(d) { return 15; }); + + link.attr("marker-end", "url(#arrow)"); //also added attribute for arrow at end + + nodeEnter.append("text") + .style("text-anchor", "middle") + + + .attr("dy", "-1em") + + .attr("text-anchor", function(d) { + return d.children || d._children ? "end" : "start"; }) + .text(function(d) { + return d.alias; + //return d.name; + }) + + .style("fill-opacity", 1); + + +// nodeEnter.select("circle") +// .attr("xlink:href", function(d) { +// //return d.icon; +// return mitharr[d.depth]; +// }) +// .attr("x", "-12px") +// .attr("y", "-12px") +// .attr("width", "24px") +// .attr("height", "24px"); + + + node.select("circle") +// .attr("xlink:href", function(d) { +// //return d.icon; +// return mitharr[d.depth]; +// }) + .style("fill", function(d, i) { + if(d.datatype==="Table"){ + return "url('#textICO')"; + + }else{ + return "url('#processICO')"; + } + return colors(i); + }); +//force.stop(); +//force.resume(); + +} + +//force.stop(); +function tick() { + link.attr("x1", function(d) { return d.source.x; }) + .attr("y1", function(d) { return d.source.y; }) + .attr("x2", function(d) { return d.target.x; }) + .attr("y2", function(d) { return d.target.y; }); + + + node.attr("transform", function(d) { return "translate(" + d.x + "," + d.y + ") " }); + +} + +//node[0].x = width / 2; +// node[1].y = height / 2; +d3.select(window).on('resize', update); + +function color(d) { + return d._children ? "#3182bd" // collapsed package + : d.children ? "#c6dbef" // expanded package + : "#fd8d3c"; // leaf node +} + +// Toggle children on click. +function click(d) { + if (d3.event.defaultPrevented) return; // ignore drag + if (d.children) { + d._children = d.children; + d.children = null; + } else { + d.children = d._children; + d._children = null; + } + update(); + +} + +// Returns a list of all nodes the root. +function flatten(root) { + var nodes = [], i = 0; + + function recurse(node) { + if (node.children) node.children.forEach(recurse); + if (!node.id) node.id = ++i; + nodes.push(node); + } + + recurse(root); + return nodes; + +} + + +// +// }) +// .error(function (e) { +// $scope.iserror1=true; +// $scope.error1=e; +// }); + + + } + + + + + +$scope.getLinegaeforinput= function (tableName) { + +// $scope.width = 900; +// $scope.height = 900; + var arr=[]; + var arrmyalias=[]; + var datatypes=[]; + var tags=[]; + $http.get('/api/metadata/lineage/hive/inputs/'+tableName) + .success(function (data) { + $scope.iserror1=false; + $scope.lineage= angular.fromJson(data.results.rows); + + $scope.vts = []; + $scope.edges1 = []; + $scope.listguid = []; + angular.forEach($scope.lineage, function(lineage1){ + var level = 0; + angular.forEach(lineage1.path, function(item, index){ + // if ($scope.listguid.indexOf(index) == -1) { + // $scope.listguid.push(index); + + $scope.vts.push({"Name": item.guid,"Id" :index,"hasChild":"True","type":item.typeName}); + $scope.edges1.push({source: index, target: (index+1)}); + + // } + }); + + }); + + var newarr = []; + var unique = {}; + + angular.forEach($scope.edges1, function(item) { + if (!unique[item.source]) { + newarr.push(item); + unique[item.source] = item; + //console.log(newarr); + } + }); + + var newarrvts = []; + var uniquevts = {}; + + angular.forEach($scope.vts, function(item) { + if (!uniquevts[item.Name]) { + newarrvts.push(item); + uniquevts[item.Name] = item; + + var url="/api/metadata/entities/definition/"+item.Name; + arr.push($http.get(url)); + + //getLienageGuidName(item.Name); + + } + }); + + + $q.all(arr).then(function(ret){ + //console.log("Result guid list length="+ret.length); + for(var i=0;i<ret.length;i++){ + var f=angular.fromJson(ret[i].data.results); + //console.log(i+"Their Names="+angular.toJson(f)); + //console.log(i+"Their Names="+f.name); + arrmyalias[i]=f.name; + + datatypes[i]=f['$typeName$']; + + if(f['$typeName$']==="Table") + { + angular.forEach(f['$traits$'], function(key, value) { + tags[i]=value; + console.log(value); + }); + } + else{ + tags[i]=f.queryText; + console.log(f.queryText); + } + + + } +if(arrmyalias.length>1){ + doMakeStaticJson(arrmyalias); + } + else{ + $scope.errornodata1=""; + } +// loadjsonRealv2(arrmyalias); + // doMakeStaticJson(arrmyalias); + + }); + + }) + .error(function (e) { + $scope.iserror1=true; + $scope.error1=e; + }); + + function doMakeStaticJson(arrmyalias){ + + var toparr=[]; + + var rootobj=new Object(); + rootobj.name=arrmyalias[0]; + rootobj.alias=arrmyalias[0]; + rootobj.query=tags[0]; + rootobj.datatype=datatypes[0]; + rootobj.parent="null"; + + toparr[0]=rootobj; + +//start first object + var child1obj=new Object(); + child1obj.alias=arrmyalias[1]; + child1obj.name=arrmyalias[1]; + child1obj.query=tags[1]; + child1obj.datatype=datatypes[1]; + child1obj.parent=arrmyalias[0]; + + //start + var childsub1obj=new Object(); + childsub1obj.name=arrmyalias[2]; + childsub1obj.alias=arrmyalias[2]; + childsub1obj.query=tags[2]; + childsub1obj.datatype=datatypes[2]; + childsub1obj.parent=arrmyalias[1]; + + if(arrmyalias.length>2){ + var arraychildren1=[]; + arraychildren1.push(childsub1obj); + child1obj.children=arraychildren1; + } + //start + var childsub2obj=new Object(); + childsub2obj.name=arrmyalias[3]; + childsub2obj.alias=arrmyalias[3]; + childsub2obj.query=tags[3]; + childsub2obj.datatype=datatypes[3]; + childsub2obj.parent=arrmyalias[2]; + if(arrmyalias.length>3){ + var arraychildren2=[]; + arraychildren2.push(childsub2obj); + childsub1obj.children=arraychildren2; + } + + //start + var childsub3obj=new Object(); + childsub3obj.name=arrmyalias[4]; + childsub3obj.alias=arrmyalias[4]; + childsub3obj.query=tags[4]; + childsub3obj.datatype=datatypes[4]; + childsub3obj.parent=arrmyalias[3]; + + if(arrmyalias.length>4){ + var arraychildren3=[]; + arraychildren3.push(childsub3obj); + childsub2obj.children=arraychildren3; + } + + +///end first objects + + + + /*var arraychildren2=[]; + arraychildren2.push(child1obj2); +// arraychildren2.push(childsub2obj2); + + + child1obj2.children=arraychildren2; + + + //end second objects + */ + + var array1=[]; + array1[0]=child1obj; +// array1[1]=child1obj2; + + + rootobj.children=array1; + + + //console.info("MITH SEE THIS="+angular.toJson(toparr)); + + root = toparr[0]; + + update(root); + } + + + //Width and height + var width = 700, + height = 500, + root; +//image intitializer + var mitharr=["img/tableicon.png","img/process.png","img/tableicon.png","img/process.png","img/tableicon.png"]; + + + + var force = d3.layout.force() + .gravity(0) + .friction(0.7) + .charge(-90) + .linkDistance(120) + .size([width, height]) + .on("tick", tick); + + var svg = d3.select("svg1").append("svg") +// .attr("transform", "translate(" + (width/2) + +// "," + (height/2) + ")") + + .attr('transform-origin', '-419 -530') + .attr("viewBox", "10 -300 1000 1000") + .attr("preserveAspectRatio", "xMidYMid meet"); +// .append("g") +// .attr("transform", "translate(" + d.x + "," + d.y +") rotate(180) scale(-1, -1)"); + + +// .attr("preserveAspectRatio", "xMidYMid slice"); + + var link = svg.selectAll(".link"), + node = svg.selectAll(".node"); + + var tip = d3.tip() + .attr('class', 'd3-tip') + .offset([-10, 0]) + .html(function(d) { + return "<pre class='alert alert-success' style='max-width:400px;'>" + d.query + "</pre>"; + }); + + if(svg){ + svg.call(tip); + } + + + function update(source) { + var nodes = flatten(root), + links = d3.layout.tree().links(nodes); + + // Restart the force layout. + force + .nodes(nodes) + .links(links) + + .start(); + + // Update links. + link = link.data(links, function(d) { return d.target.id; }); + + link.exit().remove(); + + link.enter().insert("line", ".node") + .attr("class", "link"); + + // Update nodes. + node = node.data(nodes, function(d) { return d.id; }); + + node.exit().remove(); + + svg.append("svg:pattern").attr("id","processICO1").attr("width",1).attr("height",1) + .append("svg:image").attr("xlink:href","./img/process.png").attr("x",-5.5).attr("y",-4).attr("width",42).attr("height",42); + svg.append("svg:pattern").attr("id","textICO1").attr("width",1).attr("height",1) + .append("svg:image").attr("xlink:href","./img/tableicon.png").attr("x",2).attr("y",2).attr("width",25).attr("height",25); + + +//arrow + svg.append("svg:defs").append("svg:marker").attr("id", "arrow1").attr("viewBox", "0 0 10 10").attr("refX", 60).attr("refY", 5).attr("markerUnits", "strokeWidth").attr("markerWidth", 8).attr("markerHeight", 8).attr("orient", "auto").append("svg:path").attr("d", "M 0 0 L 10 5 L 0 10 z"); +//arrow + var nodeEnter = node.enter().append("g") + .attr("class", "nodeTrans") + .on("mouseover", tip.show) + .on("mouseout", tip.hide) + .call(force.drag); + + + + + nodeEnter.append("circle") + .attr("r", function(d) { return 15; }); + + link.attr("marker-end", "url(#arrow1)"); //also added attribute for arrow at end + + nodeEnter.append("text") + .style("text-anchor", "middle") + + + .attr("dy", "-1em") + + .attr("text-anchor", function(d) { + return d.children || d._children ? "end" : "start"; }) + .text(function(d) { + return d.alias; + //return d.name; + }) + + .style("fill-opacity", 1); + + +// nodeEnter.select("circle") +// .attr("xlink:href", function(d) { +// //return d.icon; +// return mitharr[d.depth]; +// }) +// .attr("x", "-12px") +// .attr("y", "-12px") +// .attr("width", "24px") +// .attr("height", "24px"); + + + node.select("circle") +// .attr("xlink:href", function(d) { +// //return d.icon; +// return mitharr[d.depth]; +// }) + .style("fill", function(d) { + if(d.datatype==="Table"){ + return "url('#textICO1')"; + + }else{ + return "url('#processICO1')"; + } + return colors(i); + }); +//force.stop(); +//force.resume(); + +} + +//force.stop(); +function tick() { + link.attr("x1", function(d) { return d.source.x; }) + .attr("y1", function(d) { return d.source.y; }) + .attr("x2", function(d) { return d.target.x; }) + .attr("y2", function(d) { return d.target.y; }); + + + node.attr("transform", function(d) { return "translate(" + d.x + "," + d.y + ") " }); + +} + +//node[0].x = width / 2; +// node[1].y = height / 2; +d3.select(window).on('resize', update); + +function color(d) { + return d._children ? "#3182bd" // collapsed package + : d.children ? "#c6dbef" // expanded package + : "#fd8d3c"; // leaf node +} + +// Toggle children on click. +function click(d) { + if (d3.event.defaultPrevented) return; // ignore drag + if (d.children) { + d._children = d.children; + d.children = null; + } else { + d.children = d._children; + d._children = null; + } + update(); + +} + +// Returns a list of all nodes the root. +function flatten(root) { + var nodes = [], i = 0; + + function recurse(node) { + if (node.children) node.children.forEach(recurse); + if (!node.id) node.id = ++i; + nodes.push(node); + } + + recurse(root); + return nodes; + +} + + +// +// }) +// .error(function (e) { +// $scope.iserror1=true; +// $scope.error1=e; +// }); + + + } + + + + // console.log( $scope.vts); + + $scope.reverse = function(array) { + var copy = [].concat(array); + return copy.reverse(); + } + + // function back() + // { + // $window.history.back(); + // myModule.run(function ($rootScope, $location) { + + // var history = []; + + // $rootScope.$on('$routeChangeSuccess', function() { + // history.push($location.$$path); + // }); + + // $rootScope.back = function () { + // var prevUrl = history.length > 1 ? history.splice(-2)[0] : "/"; + // $location.path(prevUrl); + // }; + + // }); + // } + + + + + }] +); + + +DgcControllers.controller("GuidController", ['$scope','$http', '$filter','$stateParams', 'sharedProperties', function($scope, $http, $filter, $stateParams, sharedProperties) + { + + + +$scope.getGuidName=function getGuidName(val){ + + $scope.gnew=[]; + $http.get('/api/metadata/entities/definition/'+val) + .success(function (data) { + $scope.iserror1=false; + if(!$scope.isUndefined(data.results)){ + + $scope.gname=angular.fromJson(data.results); + var data1=angular.fromJson(data.results); + //$scope.gnew({"id" : val,"name" : data1['name']}); + + $scope.gnew= $scope.gname.name; + // $scope.$watch($scope.gnew, true); + +} + //dddd + + + }) + .error(function (e) { + $scope.iserror1=true; + $scope.error1=e; + }); + + //return $scope.gnew; + } + + + }] +); + http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/a9d61e1b/dashboard/v3/js/ie-emulation-modes-warning.js ---------------------------------------------------------------------- diff --git a/dashboard/v3/js/ie-emulation-modes-warning.js b/dashboard/v3/js/ie-emulation-modes-warning.js new file mode 100755 index 0000000..896ed62 --- /dev/null +++ b/dashboard/v3/js/ie-emulation-modes-warning.js @@ -0,0 +1,51 @@ +// NOTICE!! DO NOT USE ANY OF THIS JAVASCRIPT +// IT'S JUST JUNK FOR OUR DOCS! +// ++++++++++++++++++++++++++++++++++++++++++ +/*! + * Copyright 2014 Twitter, Inc. + * + * Licensed under the Creative Commons Attribution 3.0 Unported License. For + * details, see http://creativecommons.org/licenses/by/3.0/. + */ +// Intended to prevent false-positive bug reports about Bootstrap not working properly in old versions of IE due to folks testing using IE's unreliable emulation modes. +(function () { + 'use strict'; + + function emulatedIEMajorVersion() { + var groups = /MSIE ([0-9.]+)/.exec(window.navigator.userAgent) + if (groups === null) { + return null + } + var ieVersionNum = parseInt(groups[1], 10) + var ieMajorVersion = Math.floor(ieVersionNum) + return ieMajorVersion + } + + function actualNonEmulatedIEMajorVersion() { + // Detects the actual version of IE in use, even if it's in an older-IE emulation mode. + // IE JavaScript conditional compilation docs: http://msdn.microsoft.com/en-us/library/ie/121hztk3(v=vs.94).aspx + // @cc_on docs: http://msdn.microsoft.com/en-us/library/ie/8ka90k2e(v=vs.94).aspx + var jscriptVersion = new Function('/*@cc_on return @_jscript_version; @*/')() // jshint ignore:line + if (jscriptVersion === undefined) { + return 11 // IE11+ not in emulation mode + } + if (jscriptVersion < 9) { + return 8 // IE8 (or lower; haven't tested on IE<8) + } + return jscriptVersion // IE9 or IE10 in any mode, or IE11 in non-IE11 mode + } + + var ua = window.navigator.userAgent + if (ua.indexOf('Opera') > -1 || ua.indexOf('Presto') > -1) { + return // Opera, which might pretend to be IE + } + var emulated = emulatedIEMajorVersion() + if (emulated === null) { + return // Not IE + } + var nonEmulated = actualNonEmulatedIEMajorVersion() + + if (emulated !== nonEmulated) { + window.alert('WARNING: You appear to be using IE' + nonEmulated + ' in IE' + emulated + ' emulation mode.\nIE emulation modes can behave significantly differently from ACTUAL older versions of IE.\nPLEASE DON\'T FILE BOOTSTRAP BUGS based on testing in IE emulation modes!') + } +})();
