Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
atlas
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
dataplatform
atlas
Commits
6b9acc52
Commit
6b9acc52
authored
May 30, 2015
by
dileep bhimineni
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
changes for search results and paginations
parent
5b415fe0
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
59 additions
and
28 deletions
+59
-28
searchController.js
dashboard/v2/public/modules/search/searchController.js
+42
-13
searchRoutes.js
dashboard/v2/public/modules/search/searchRoutes.js
+1
-1
search.html
dashboard/v2/public/modules/search/views/search.html
+1
-1
searchResult.html
dashboard/v2/public/modules/search/views/searchResult.html
+15
-13
No files found.
dashboard/v2/public/modules/search/searchController.js
View file @
6b9acc52
...
...
@@ -26,35 +26,57 @@ angular.module('dgc.search').controller('SearchController', ['$scope', '$locatio
$scope
.
resultCount
=
0
;
$scope
.
isCollapsed
=
true
;
$scope
.
currentPage
=
1
;
$scope
.
numPerPage
=
10
;
$scope
.
itemsPerPage
=
2
;
$scope
.
maxSize
=
5
;
$scope
.
$watch
(
"currentPage + numPerPage"
,
function
()
{
var
begin
=
((
$scope
.
currentPage
-
1
)
*
$scope
.
numPerPage
);
var
end
=
begin
+
$scope
.
numPerPage
;
$scope
.
filteredResults
=
$scope
.
results
.
slice
(
begin
,
end
);
});
$scope
.
itemsPerPage
=
10
$scope
.
totalItems
=
40
;
$scope
.
setPage
=
function
(
pageNo
)
{
$scope
.
currentPage
=
pageNo
;
};
$scope
.
search
=
function
(
query
)
{
$scope
.
results
=
[];
NotificationService
.
reset
();
$scope
.
limit
=
4
;
SearchResource
.
search
({
query
:
query
},
function
searchSuccess
(
response
)
{
$scope
.
results
=
response
.
results
;
$scope
.
resultCount
=
response
.
count
;
$scope
.
results
=
response
.
results
;
$scope
.
resultRows
=
$scope
.
results
.
rows
;
$scope
.
totalItems
=
$scope
.
resultCount
;
$scope
.
$watch
(
'currentPage + itemsPerPage'
,
function
()
{
var
begin
=
((
$scope
.
currentPage
-
1
)
*
$scope
.
itemsPerPage
),
end
=
begin
+
$scope
.
itemsPerPage
;
$scope
.
searchTypesAvailable
=
$scope
.
typeAvailable
();
if
(
$scope
.
searchTypesAvailable
)
{
$scope
.
searchMessage
=
'searching...'
;
$scope
.
filteredResults
=
$scope
.
resultRows
.
slice
(
begin
,
end
);
$scope
.
pageCount
=
function
()
{
return
Math
.
ceil
(
$scope
.
resultCount
/
$scope
.
itemsPerPage
);
};
if
(
$scope
.
results
.
rows
)
$scope
.
searchMessage
=
$scope
.
results
.
rows
.
length
+
' results matching your search query '
+
$scope
.
query
+
' were found'
;
else
$scope
.
searchMessage
=
'0 results matching your search query '
+
$scope
.
query
+
' were found'
;
if
(
$scope
.
results
.
length
<
1
)
{
NotificationService
.
error
(
'No Result found'
,
false
);
}
}
else
{
$scope
.
searchMessage
=
'0 results matching your search query '
+
$scope
.
query
+
' were found'
;
}
$state
.
go
(
'search.results'
,
{
query
:
query
},
{
location
:
'replace'
});
});
},
function
searchError
(
err
)
{
NotificationService
.
error
(
'Error occurred during executing search query, error status code = '
+
err
.
status
+
', status text = '
+
err
.
statusText
,
false
);
});
};
$scope
.
typeAvailable
=
function
()
{
return
$scope
.
types
.
indexOf
(
this
.
results
.
dataType
.
typeName
&&
this
.
results
.
dataType
.
typeName
.
toLowerCase
())
>
-
1
;
console
.
log
(
$scope
.
results
.
dataType
);
if
(
$scope
.
results
.
dataType
)
{
return
$scope
.
types
.
indexOf
(
$scope
.
results
.
dataType
.
typeName
&&
$scope
.
results
.
dataType
.
typeName
.
toLowerCase
())
>
-
1
;
}
};
$scope
.
doToggle
=
function
(
$event
,
el
)
{
...
...
@@ -62,14 +84,21 @@ angular.module('dgc.search').controller('SearchController', ['$scope', '$locatio
};
$scope
.
filterSearchResults
=
function
(
items
)
{
var
res
=
{};
var
count
=
0
;
angular
.
forEach
(
items
,
function
(
value
,
key
)
{
if
(
typeof
value
!==
'object'
)
if
(
typeof
value
!==
'object'
)
{
res
[
key
]
=
value
;
count
++
;
}
});
$scope
.
keyLength
=
count
;
return
res
;
};
$scope
.
query
=
$stateParams
.
query
;
$scope
.
searchQuery
=
$location
.
search
();
$scope
.
query
=
(
$location
.
search
()).
query
;
if
(
$scope
.
query
)
{
$scope
.
searchMessage
=
'searching...'
;
$scope
.
search
(
$scope
.
query
);
}
}
...
...
dashboard/v2/public/modules/search/searchRoutes.js
View file @
6b9acc52
...
...
@@ -28,7 +28,7 @@ angular.module('dgc.search').config(['$stateProvider',
templateUrl
:
'/modules/search/views/search.html'
,
controller
:
'SearchController'
}).
state
(
'search.results'
,
{
url
:
'
/:
query'
,
url
:
'
?
query'
,
templateUrl
:
'/modules/search/views/searchResult.html'
,
controller
:
'SearchController'
});
...
...
dashboard/v2/public/modules/search/views/search.html
View file @
6b9acc52
...
...
@@ -39,7 +39,7 @@
<div
data-ng-include=
"'/modules/navigation/views/navigation.html'"
></div>
<div
class=
"col-lg-9"
data-ui-view=
""
></div>
<div
class=
"col-lg-9"
data-ui-view=
""
style=
"min-height: 1350px;"
></div>
</div>
</div>
</div>
dashboard/v2/public/modules/search/views/searchResult.html
View file @
6b9acc52
...
...
@@ -15,32 +15,34 @@
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<!--
<h4 ng-show='results.rows.length > 0'>{{results.rows.length}} results matching your search query "{{query}}" were found</h4>
<h4 ng-show='results.rows.length == "0"'>searching .....</h4>
<h4 ng-show='!(results.rows)'>0 results matching your search query "{{query}}" were found</h4>-->
<h4
ng-show=
'resultCount > 0'
>
{{resultCount}} results matching your search query "{{query}}" were found
</h4>
<h4
ng-show=
'resultCount == "0"'
>
searching .....
</h4>
<h4
ng-show=
"searchMessage"
>
{{searchMessage}}
</h4>
<ul
class=
"list-unstyled"
>
<li
ng-repeat=
"result in results.rows"
class=
"searchresults"
>
<div
data-ng-if=
"typeAvailable()"
>
<li
ng-repeat=
"result in filteredResults"
class=
"searchresults"
>
<h4><a
data-ui-sref=
"details({id:result['$id$'].id})"
>
{{result.name}}
</a></h4>
<p>
{{result.description}}
</p>
<span
ng-repeat=
"(key, value) in filterSearchResults(result)"
>
<span
ng-show=
"$index < 4"
><b>
{{key}}:
</b>
{{value}}{{$index+1 === limit ? '' : ', '}}
</span>
</span>
<div
collapse=
"isCollapsed"
>
<span
class=
"well well-lg"
><span
ng-repeat=
"(key, value) in filterSearchResults(result)"
>
<span
ng-repeat=
"(key, value) in filterSearchResults(result)"
>
<span
ng-show=
"$index > 4"
><b>
{{key}}:
</b>
{{value}}{{$last ? '' : ', '}}
</span>
</span>
</span>
</span>
</div>
<a
href
=
"javascript: void(0);"
ng-show=
"isCollapsed
"
ng-click=
"doToggle($event,isCollapsed)"
>
..show more
</a>
<a
href
=
"javascript: void(0);"
ng-show=
"!isCollapsed"
ng-click=
"doToggle($event,isCollapsed)"
>
..show less
</a>
<a
href
ng-show=
"isCollapsed && (keyLength > 4)
"
ng-click=
"doToggle($event,isCollapsed)"
>
..show more
</a>
<a
href
ng-show=
"!isCollapsed"
ng-click=
"doToggle($event,isCollapsed)"
>
..show less
</a>
<h5>
Tags :
<a
ng-repeat=
"(key, value) in result['$traits$']"
data-ui-sref=
"search.results({query: key})"
>
{{key}}
</a>
</h5>
</div>
<div
data-ng-if=
"!typeAvailable()"
data-ng-include=
"'/modules/search/views/types/guid.html'"
></div>
<div
data-ng-if=
"!searchTypesAvailable"
data-ng-include=
"'/modules/search/views/types/guid.html'"
></div>
</li>
</ul>
<div
ng-show=
'resultCount > 0'
><pagination
total-items=
"totalItems"
ng-model=
"currentPage"
ng-change=
"pageChanged()"
></pagination></div>
<div
ng-show=
'results.rows.length > 0'
>
<pagination
total-items=
"totalItems"
items-per-page=
"itemsPerPage"
ng-model=
"currentPage"
ng-change=
"pageChanged()"
></pagination>
<p>
</div>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment