Commit ffed01af by Vishal Kadam

Updated search result page according to new api change

parent 915b4ac6
...@@ -6,8 +6,7 @@ angular.module('dgc', ['ngCookies', ...@@ -6,8 +6,7 @@ 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']);
......
...@@ -17,7 +17,7 @@ angular.module('dgc.system.notification').service('NotificationService', ['$time ...@@ -17,7 +17,7 @@ angular.module('dgc.system.notification').service('NotificationService', ['$time
}; };
_.each(colorCoding, function(value, key) { _.each(colorCoding, function(value, key) {
service[key] = function(message) { service[key] = function(message, timeout) {
var notification = message; var notification = message;
if (_.isString(message)) { if (_.isString(message)) {
notification = { notification = {
...@@ -28,7 +28,7 @@ angular.module('dgc.system.notification').service('NotificationService', ['$time ...@@ -28,7 +28,7 @@ angular.module('dgc.system.notification').service('NotificationService', ['$time
notification.message = notification.msg || notification.message; notification.message = notification.msg || notification.message;
delete notification.msg; delete notification.msg;
notification.type = value; notification.type = value;
notification.timeout = _.isUndefined(notification.timeout) ? true : notification.timeout; notification.timeout = _.isUndefined(timeout) ? (_.isUndefined(notification.timeout) ? true : notification.timeout) : timeout;
notifications.push(notification); notifications.push(notification);
if (notification.timeout) { if (notification.timeout) {
......
<div data-ng-controller="NotificationController"> <div data-ng-controller="NotificationController">
<alert data-ng-repeat="notification in getNotifications()" type="notification.type" close="close(notification)"> <alert data-ng-repeat="notification in getNotifications()" data-type="{{notification.type}}" data-close="close(notification)">
{{notification.message}} {{notification.message}}
</alert> </alert>
</div> </div>
\ No newline at end of file
'use strict'; 'use strict';
angular.module('dgc.search').controller('SearchController', ['$scope', '$state', '$stateParams', 'SearchResource', 'DetailsResource', angular.module('dgc.search').controller('SearchController', ['$scope', '$location', '$http', '$state', '$stateParams', 'SearchResource', 'NotificationService',
function($scope, $state, $stateParams, SearchResource, DetailsResource) { function($scope, $location, $http, $state, $stateParams, SearchResource, NotificationService) {
$scope.types = ['hive_table', 'hive_database']; $scope.types = [];
$scope.results = []; $scope.results = [];
$scope.search = function(query) { $scope.search = function(query) {
SearchResource.get({ $scope.results = [];
query: query NotificationService.reset();
}, function(response) { SearchResource.search($location.search(query).$$search, function(response) {
$scope.results = []; $scope.results = response;
angular.forEach(response.list, function(typeId) { if ($scope.results.length < 1) {
DetailsResource.get({ NotificationService.error("No Result found", false);
id: typeId }
}, function(definition) { $state.go('search.results', {}, {
$scope.results.push(definition); location: false
});
});
$state.go('search.results', {
query: query
}); });
}); });
}; };
$scope.query = $stateParams.query; var urlParts = $location.$$url.split('?');
$scope.query = urlParts.length > 1 ? urlParts[1] : null;
if ($scope.query) { if ($scope.query) {
$scope.search($stateParams.query); $scope.search($scope.query);
} }
} }
]); ]);
'use strict'; 'use strict';
angular.module('dgc.search').factory('SearchResource', ['$resource', function($resource) { angular.module('dgc.search').factory('SearchResource', ['$resource', function($resource) {
return $resource('/api/metadata/entities/list/:query', { return $resource('/api/metadata/discovery/search/fulltext', {}, {
'query': '@id' search: {
'method': 'GET',
'responseType': 'json',
'isArray': true,
'transformResponse': function(data) {
var results = [];
angular.forEach(data && data.vertices, function(val) {
results.push(val);
});
return results;
}
}
}); });
}]); }]);
...@@ -9,7 +9,7 @@ angular.module('dgc.search').config(['$stateProvider', ...@@ -9,7 +9,7 @@ angular.module('dgc.search').config(['$stateProvider',
url: '/search', url: '/search',
templateUrl: '/modules/search/views/search.html' templateUrl: '/modules/search/views/search.html'
}).state('search.results', { }).state('search.results', {
url: '/:query', url: '/?',
templateUrl: '/modules/search/views/searchResult.html' templateUrl: '/modules/search/views/searchResult.html'
}); });
} }
......
<a data-ui-sref="details({id:result.guid})">{{result.guid}}</a>
\ No newline at end of file
<a data-ui-sref="details({id:result.guid})">{{result["hive_table.name"]}}</a>
\ No newline at end of file
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
<small class="small-txt">Search : hive_table, hive_database</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="row">
<div class="col-sm-offset-1 col-lg-11" data-ui-view=""></div> <div class="col-sm-offset-1 col-lg-11" data-ui-view=""></div>
</div> </div>
</form> </form>
......
<h4>{{query}} results</h4> <h4>"{{query}}" results</h4>
<ul class="list-unstyled"> <ul class="list-unstyled">
<li ng-repeat="result in results"> <li ng-repeat="result in results">
<a data-ui-sref="details({id:result.$id$.id})">{{result.description}}</a> <ng-include src="'/modules/search/views/'+result.type+'.html'"/>
</li> </li>
</ul> </ul>
\ No newline at end of file
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