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
8f64e6af
Commit
8f64e6af
authored
Jun 03, 2015
by
dileep bhimineni
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
changes for HDPDGI-41 and HDPDGI-40
parent
fe28c005
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
37 deletions
+44
-37
searchController.js
dashboard/v2/public/modules/search/searchController.js
+39
-32
search.html
dashboard/v2/public/modules/search/views/search.html
+5
-5
No files found.
dashboard/v2/public/modules/search/searchController.js
View file @
8f64e6af
...
...
@@ -29,12 +29,6 @@ angular.module('dgc.search').controller('SearchController', ['$scope', '$locatio
$scope
.
itemsPerPage
=
10
;
$scope
.
filteredResults
=
[];
$scope
.
resultRows
=
[];
$scope
.
$on
(
'$stateChangeStart'
,
function
(
event
,
toState
)
{
if
(
toState
.
resolve
)
{
$scope
.
loading
=
true
;
}
});
$scope
.
setPage
=
function
(
pageNo
)
{
$scope
.
currentPage
=
pageNo
;
};
...
...
@@ -48,43 +42,56 @@ angular.module('dgc.search').controller('SearchController', ['$scope', '$locatio
SearchResource
.
search
({
query
:
query
},
function
searchSuccess
(
response
)
{
$scope
.
querySuceess
=
true
;
$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
=
'loading results...'
;
$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
);
$scope
.
transformedResults
=
{};
$scope
.
dataTransitioned
=
false
;
if
(
response
.
results
.
dataType
.
typeName
.
indexOf
(
'__'
)
===
0
)
{
$scope
.
dataTransitioned
=
true
;
var
attrDef
=
response
.
results
.
dataType
.
attributeDefinitions
;
angular
.
forEach
(
attrDef
,
function
(
value
)
{
if
(
value
.
dataTypeName
===
'__IdType'
)
{
$scope
.
searchKey
=
value
.
name
;
}
});
$scope
.
transformedResults
=
$scope
.
filterResults
();
}
else
{
$scope
.
transformedResults
=
$scope
.
resultRows
;
}
if
(
$scope
.
results
.
rows
)
$scope
.
searchMessage
=
$scope
.
resultCount
+
' results matching your search query '
+
$scope
.
query
+
' were found'
;
else
$scope
.
searchMessage
=
'0 results matching your search query '
+
$scope
.
query
+
' were found'
;
$scope
.
$watch
(
'currentPage + itemsPerPage'
,
function
()
{
var
begin
=
((
$scope
.
currentPage
-
1
)
*
$scope
.
itemsPerPage
),
end
=
begin
+
$scope
.
itemsPerPage
;
$scope
.
filteredResults
=
$scope
.
transformedResults
.
slice
(
begin
,
end
);
$scope
.
pageCount
=
function
()
{
return
Math
.
ceil
(
$scope
.
resultCount
/
$scope
.
itemsPerPage
);
};
if
(
$scope
.
results
.
length
<
1
)
{
NotificationService
.
error
(
'No Result found'
,
false
);
}
});
},
function
searchError
(
err
)
{
NotificationService
.
error
(
'Error occurred during executing search query, error status code = '
+
err
.
status
+
', status text = '
+
err
.
statusText
,
false
);
});
$state
.
go
(
'search'
,
{
query
:
query
},
{
location
:
'replace'
});
};
$scope
.
typeAvailable
=
function
()
{
if
(
$scope
.
results
.
dataType
)
{
return
$scope
.
types
.
indexOf
(
$scope
.
results
.
dataType
.
typeName
&&
$scope
.
results
.
dataType
.
typeName
.
toLowerCase
())
>
-
1
;
}
$scope
.
filterResults
=
function
()
{
var
res
=
[];
angular
.
forEach
(
$scope
.
resultRows
,
function
(
value
,
key
)
{
res
.
push
(
value
[
$scope
.
searchKey
]
);
});
return
res
;
};
$scope
.
doToggle
=
function
(
$event
,
el
)
{
this
.
isCollapsed
=
!
el
;
...
...
@@ -93,19 +100,19 @@ angular.module('dgc.search').controller('SearchController', ['$scope', '$locatio
var
res
=
{};
var
count
=
0
;
angular
.
forEach
(
items
,
function
(
value
,
key
)
{
if
(
typeof
value
!==
'object'
)
{
if
(
typeof
value
!==
'object'
&&
(
key
.
indexOf
(
'$$'
)
<
0
)
)
{
res
[
key
]
=
value
;
count
++
;
}
});
$scope
.
keyLength
=
count
;
return
res
;
};
$scope
.
searchQuery
=
$location
.
search
();
$scope
.
query
=
(
$location
.
search
()).
query
;
if
(
$scope
.
query
)
{
$scope
.
search
(
$scope
.
query
);
}
}
}
]);
dashboard/v2/public/modules/search/views/search.html
View file @
8f64e6af
...
...
@@ -39,7 +39,7 @@
<div
data-ng-include=
"'/modules/navigation/views/navigation.html'"
></div>
<div
class=
"col-lg-9"
>
<div
class=
"col-lg-9"
ng-show=
'resultCount > 0'
>
<h4
ng-show=
"searchMessage"
>
{{searchMessage}}
</h4>
<ul
class=
"list-unstyled"
>
...
...
@@ -47,7 +47,7 @@
<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
ng-show=
"$index < 4
"
><b>
{{key}}:
</b>
{{value}} {{(($index+1 === limit) || $last )
? '' : ', '}}
</span>
</span>
<div
collapse=
"isCollapsed"
>
<span
ng-repeat=
"(key, value) in filterSearchResults(result)"
>
...
...
@@ -57,11 +57,11 @@
<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
data-ng-if=
"!searchTypesAvailable"
data-ng-include=
"'/modules/search/views/types/guid.html'"
></div>
<h5
ng-show=
"!dataTransitioned"
>
Tags :
<a
ng-repeat=
"(key, value) in result['$traits$']"
data-ui-sref=
"search
({query: key})"
>
{{key}}
</a>
</h5>
</li>
</ul>
<div
class=
"resultsPagination"
ng-show=
'
filteredResults.length
> 0'
>
<div
class=
"resultsPagination"
ng-show=
'
resultCount
> 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