Commit ffed01af by Vishal Kadam

Updated search result page according to new api change

parent 915b4ac6
......@@ -6,8 +6,7 @@ angular.module('dgc', ['ngCookies',
'ui.router',
'dgc.system',
'dgc.home',
'dgc.search',
'dgc.details'
'dgc.search'
]);
angular.module('dgc.system', ['dgc.system.notification']);
......
......@@ -17,7 +17,7 @@ angular.module('dgc.system.notification').service('NotificationService', ['$time
};
_.each(colorCoding, function(value, key) {
service[key] = function(message) {
service[key] = function(message, timeout) {
var notification = message;
if (_.isString(message)) {
notification = {
......@@ -28,7 +28,7 @@ angular.module('dgc.system.notification').service('NotificationService', ['$time
notification.message = notification.msg || notification.message;
delete notification.msg;
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);
if (notification.timeout) {
......
<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}}
</alert>
</div>
\ No newline at end of file
'use strict';
angular.module('dgc.search').controller('SearchController', ['$scope', '$state', '$stateParams', 'SearchResource', 'DetailsResource',
function($scope, $state, $stateParams, SearchResource, DetailsResource) {
angular.module('dgc.search').controller('SearchController', ['$scope', '$location', '$http', '$state', '$stateParams', 'SearchResource', 'NotificationService',
function($scope, $location, $http, $state, $stateParams, SearchResource, NotificationService) {
$scope.types = ['hive_table', 'hive_database'];
$scope.types = [];
$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.results = [];
NotificationService.reset();
SearchResource.search($location.search(query).$$search, function(response) {
$scope.results = response;
if ($scope.results.length < 1) {
NotificationService.error("No Result found", false);
}
$state.go('search.results', {}, {
location: false
});
});
};
$scope.query = $stateParams.query;
var urlParts = $location.$$url.split('?');
$scope.query = urlParts.length > 1 ? urlParts[1] : null;
if ($scope.query) {
$scope.search($stateParams.query);
$scope.search($scope.query);
}
}
]);
'use strict';
angular.module('dgc.search').factory('SearchResource', ['$resource', function($resource) {
return $resource('/api/metadata/entities/list/:query', {
'query': '@id'
return $resource('/api/metadata/discovery/search/fulltext', {}, {
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',
url: '/search',
templateUrl: '/modules/search/views/search.html'
}).state('search.results', {
url: '/:query',
url: '/?',
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 @@
<small class="small-txt">Search : hive_table, hive_database</small>
</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>
</form>
......
<h4>{{query}} results</h4>
<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>
<ng-include src="'/modules/search/views/'+result.type+'.html'"/>
</li>
</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