Commit 915b4ac6 by Vishal Kadam

Vishal: Added details page

parent 15f61140
...@@ -3,11 +3,11 @@ ...@@ -3,11 +3,11 @@
"description": "DGC Metadata", "description": "DGC Metadata",
"version": "1.0.0-SNAPSHOT", "version": "1.0.0-SNAPSHOT",
"dependencies": { "dependencies": {
"angular": "1.2.15", "angular": "~1.2.15",
"angular-resource": "1.2.15", "angular-resource": "~1.2.15",
"angular-cookies": "1.2.15", "angular-cookies": "~1.2.15",
"angular-route": "1.2.15", "angular-route": "~1.2.15",
"angular-sanitize": "1.2.15", "angular-sanitize": "~1.2.15",
"bootstrap": "~3.1.1", "bootstrap": "~3.1.1",
"angular-bootstrap": "~0.12.0", "angular-bootstrap": "~0.12.0",
"angular-ui-router": "~0.2.13", "angular-ui-router": "~0.2.13",
......
...@@ -83,7 +83,7 @@ module.exports = function(grunt) { ...@@ -83,7 +83,7 @@ module.exports = function(grunt) {
require('load-grunt-tasks')(grunt); require('load-grunt-tasks')(grunt);
//Default task(s). //Default task(s).
grunt.registerTask('default', ['bower', 'jsbeautifier:default']); grunt.registerTask('default', ['bower', 'jshint', 'jsbeautifier:default']);
// Server task // Server task
grunt.registerTask('server', ['bower', 'jshint', 'concurrent']); grunt.registerTask('server', ['bower', 'jshint', 'concurrent']);
......
...@@ -6,7 +6,8 @@ angular.module('dgc', ['ngCookies', ...@@ -6,7 +6,8 @@ angular.module('dgc', ['ngCookies',
'ui.router', 'ui.router',
'dgc.system', 'dgc.system',
'dgc.home', 'dgc.home',
'dgc.search' 'dgc.search',
'dgc.details'
]); ]);
angular.module('dgc.system', ['dgc.system.notification']); angular.module('dgc.system', ['dgc.system.notification']);
......
'use strict'; 'use strict';
//Setting up route //Setting up route
angular.module('dgc').config(['$locationProvider', '$urlRouterProvider', function($locationProvider, $urlRouterProvider) { angular.module('dgc').config(['$locationProvider', '$urlRouterProvider',
function($locationProvider, $urlRouterProvider) {
$locationProvider.hashPrefix('!'); $locationProvider.hashPrefix('!');
// For unmatched routes: // For unmatched routes:
$urlRouterProvider.otherwise('/'); $urlRouterProvider.otherwise('/search');
$urlRouterProvider.when('/', '/search'); }
}]); ]);
\ No newline at end of file
'use strict';
angular.module('dgc.details').controller('DetailsController', ['$scope', '$stateParams', 'DetailsResource',
function($scope, $stateParams, DetailsResource) {
$scope.details = DetailsResource.get({
id: $stateParams.id
});
$scope.isString = angular.isString;
}
]);
'use strict';
angular.module('dgc.details', []);
'use strict';
angular.module('dgc.details').factory('DetailsResource', ['$resource', function($resource) {
return $resource('/api/metadata/entities/definition/:id', {}, {
get: {
method: 'GET',
transformResponse: function(data) {
if (data) {
return angular.fromJson(data.definition);
}
},
responseType: 'json'
}
});
}]);
'use strict';
angular.module('dgc.details').config(['$stateProvider',
function($stateProvider) {
// states for my app
$stateProvider.state('details', {
url: '/details/:id',
templateUrl: '/modules/details/views/details.html'
});
}
]);
<h4>{{key}}:</h4>
<p>{{value}}</p>
\ No newline at end of file
<div class="container" data-ng-controller="DetailsController">
<div class="col-lg-12">
<tabset>
<tab data-heading="Wiki">
<div data-ng-repeat="(key,value) in details" data-ng-if="isString(value)" ng-include="'/modules/details/views/attribute.html'"></div>
</tab>
<tab data-heading="Raw">
<pre>{{details | json}}</pre>
</tab>
<tab data-heading="Lineage">Graph will be here soon...</tab>
</tabset>
</div>
</div>
\ No newline at end of file
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
angular.module('dgc.home').controller('HeaderController', ['$scope', function($scope) { angular.module('dgc.home').controller('HeaderController', ['$scope', function($scope) {
$scope.menu = [{'state': 'search', 'title': 'Search'}]; $scope.menu = [];
$scope.isCollapsed = true; $scope.isCollapsed = true;
$scope.isLoggedIn = function() { $scope.isLoggedIn = function() {
......
...@@ -20,7 +20,9 @@ angular.module('dgc.system.notification').service('NotificationService', ['$time ...@@ -20,7 +20,9 @@ angular.module('dgc.system.notification').service('NotificationService', ['$time
service[key] = function(message) { service[key] = function(message) {
var notification = message; var notification = message;
if (_.isString(message)) { if (_.isString(message)) {
notification = {message: message}; notification = {
message: message
};
} }
notification.message = notification.msg || notification.message; notification.message = notification.msg || notification.message;
......
'use strict'; 'use strict';
angular.module('dgc.search').controller('SearchController', ['$scope', function($scope) { angular.module('dgc.search').controller('SearchController', ['$scope', '$state', '$stateParams', 'SearchResource', 'DetailsResource',
function($scope, $state, $stateParams, SearchResource, DetailsResource) {
$scope.types = []; $scope.types = ['hive_table', 'hive_database'];
$scope.results = [];
$scope.search = function(query) {
SearchResource.get({
query: query
}, function(response) {
$scope.results = [];
angular.forEach(response.list, function(typeId) {
DetailsResource.get({
id: typeId
}, function(definition) {
$scope.results.push(definition);
});
});
$state.go('search.results', {
query: query
});
});
};
}]); $scope.query = $stateParams.query;
if ($scope.query) {
$scope.search($stateParams.query);
}
}
]);
'use strict'; 'use strict';
angular.module('dgc.search', ['dgc.search.routes']); angular.module('dgc.search', ['dgc.details']);
\ No newline at end of file
'use strict';
angular.module('dgc.search').factory('SearchResource', ['$resource', function($resource) {
return $resource('/api/metadata/entities/list/:query', {
'query': '@id'
});
}]);
'use strict'; 'use strict';
//Setting up route //Setting up route
angular.module('dgc.search.routes', []).config(['$stateProvider', angular.module('dgc.search').config(['$stateProvider',
function($stateProvider) { function($stateProvider) {
// states for my app // states for my app
$stateProvider.state('search', { $stateProvider.state('search', {
url: '/search', url: '/search',
templateUrl: '/modules/search/views/search.html' templateUrl: '/modules/search/views/search.html'
}).state('search.results', {
url: '/:query',
templateUrl: '/modules/search/views/searchResult.html'
}); });
} }
]); ]);
<div class="container" data-ng-controller="SearchController"> <div class="container" data-ng-controller="SearchController">
<form name="form" novalidate>
<div class="row"> <div class="row">
<div class="col-sm-offset-1 col-lg-5"> <div class="col-sm-offset-1 col-lg-5">
<div class="input-group"> <div class="input-group">
<input type="text" class="form-control" placeholder="Search"> <input type="text" class="form-control" placeholder="Search" data-ng-model="query" data-typeahead="type for type in types" required/>
<span class="input-group-btn"> <span class="input-group-btn">
<button class="btn btn-default" type="submit"><i class="glyphicon glyphicon-search white "></i></button> <button class="btn btn-default" type="submit" data-ng-disabled="form.$invalid" data-ng-click="search(query)"><i class="glyphicon glyphicon-search white "></i></button>
</span> </span>
</div> </div>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-sm-offset-1 col-lg-6"> <div class="col-sm-offset-1 col-lg-6">
<small class="small-txt">Search : Hive,Table,xxxx</small> <small class="small-txt">Search : hive_table, hive_database</small>
</div> </div>
</div> </div>
<div class="row" data-ng-show="results.length > 0">
<div class="col-sm-offset-1 col-lg-11" data-ui-view=""></div>
</div>
</form>
</div> </div>
\ No newline at end of file
<h4>{{query}} results</h4>
<ul class="list-unstyled">
<li ng-repeat="result in results">
<a data-ui-sref="details({id:result.$id$.id})">{{result.description}}</a>
</li>
</ul>
\ No newline at end of file
...@@ -28,8 +28,15 @@ ...@@ -28,8 +28,15 @@
<!-- Search Module --> <!-- Search Module -->
<script type="text/javascript" src="/modules/search/searchModule.js"></script> <script type="text/javascript" src="/modules/search/searchModule.js"></script>
<script type="text/javascript" src="/modules/search/searchRoutes.js"></script> <script type="text/javascript" src="/modules/search/searchRoutes.js"></script>
<script type="text/javascript" src="/modules/search/searchResource.js"></script>
<script type="text/javascript" src="/modules/search/searchController.js"></script> <script type="text/javascript" src="/modules/search/searchController.js"></script>
<!-- Details Module -->
<script type="text/javascript" src="/modules/details/detailsModule.js"></script>
<script type="text/javascript" src="/modules/details/detailsRoutes.js"></script>
<script type="text/javascript" src="/modules/details/detailsResource.js"></script>
<script type="text/javascript" src="/modules/details/detailsController.js"></script>
<!-- Initialize the application --> <!-- Initialize the application -->
<script type="text/javascript" src="js/init.js"></script> <script type="text/javascript" src="js/init.js"></script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment