Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mmt-errorView
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Christian Maeder
mmt-errorView
Commits
8a919a46
Commit
8a919a46
authored
Feb 17, 2015
by
cmaeder
Browse files
Options
Downloads
Patches
Plain Diff
use fewer routes and search in all columns
parent
cd10ee01
No related branches found
No related tags found
1 merge request
!2
Search all fields and start with an overview by grouping identical short messages
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/main/resource/static/search.html
+2
-7
2 additions, 7 deletions
src/main/resource/static/search.html
src/main/resource/static/search.js
+8
-5
8 additions, 5 deletions
src/main/resource/static/search.js
src/main/scala/SearchDB.scala
+25
-15
25 additions, 15 deletions
src/main/scala/SearchDB.scala
with
35 additions
and
27 deletions
src/main/resource/static/search.html
+
2
−
7
View file @
8a919a46
...
@@ -19,12 +19,7 @@
...
@@ -19,12 +19,7 @@
<form
ng-submit=
"search()"
>
<form
ng-submit=
"search()"
>
<p>
restrict the number of displayed entries to support fast searches in
<p>
restrict the number of displayed entries to support fast searches in
every column
</p>
every column. Click "search" to reload choice (revealing undisplayed entries).
</p>
<input
type=
"text"
ng-model=
"searchText"
size=
"30"
placeholder=
"search"
/>
in:
<select
ng-model=
"field"
ng-init=
"columns[shortMsg].long"
ng-options=
"columns[key].long for key in colProps | filter : '!id'"
></select>
<input
class=
"btn-primary"
type=
"submit"
value=
"search"
/>
<input
class=
"btn-primary"
type=
"submit"
value=
"search"
/>
<span>
<span>
maximal entries:
maximal entries:
...
@@ -36,7 +31,7 @@
...
@@ -36,7 +31,7 @@
<br>
<br>
<table>
<table>
<thead>
<thead>
<tr
ng-if=
"results.length != 0"
>
<tr>
<th
ng-repeat=
"key in colProps"
ng-if=
"columns[key].x"
>
<th
ng-repeat=
"key in colProps"
ng-if=
"columns[key].x"
>
<span
ng-click=
"sort.col = key; sort.asc = !sort.asc"
<span
ng-click=
"sort.col = key; sort.asc = !sort.asc"
style=
"cursor:pointer"
>
style=
"cursor:pointer"
>
...
...
This diff is collapsed.
Click to expand it.
src/main/resource/static/search.js
+
8
−
5
View file @
8a919a46
...
@@ -18,18 +18,21 @@ angular.module('searchApp', []).controller('SearchController',
...
@@ -18,18 +18,21 @@ angular.module('searchApp', []).controller('SearchController',
$scope
.
number
=
0
;
$scope
.
number
=
0
;
$scope
.
maxNumber
=
100
;
$scope
.
maxNumber
=
100
;
$scope
.
searchText
=
''
;
$scope
.
searchText
=
''
;
$scope
.
query
=
function
()
{
return
'
/
'
+
$scope
.
field
+
$scope
.
query
=
function
()
{
'
?limit=
'
+
$scope
.
maxNumber
+
var
res
=
''
;
'
&text=
'
+
$scope
.
searchText
;
for
(
k
in
$scope
.
columns
)
{
res
=
res
+
'
&
'
+
k
+
"
=
"
+
$scope
.
columns
[
k
].
search
;
};
return
'
?limit=
'
+
$scope
.
maxNumber
+
res
;
};
};
$scope
.
search
=
function
()
{
$scope
.
search
=
function
()
{
$http
.
get
(
'
/sally/error/search
'
+
$scope
.
query
()).
success
(
function
(
data
)
{
$http
.
get
(
'
/sally/error/search
2
'
+
$scope
.
query
()).
success
(
function
(
data
)
{
$scope
.
results
=
data
;
$scope
.
results
=
data
;
});
});
$scope
.
count
();
$scope
.
count
();
};
};
$scope
.
count
=
function
()
{
$scope
.
count
=
function
()
{
$http
.
get
(
'
/sally/error/count
'
+
$scope
.
query
()).
success
(
function
(
data
)
{
$http
.
get
(
'
/sally/error/count
2
'
+
$scope
.
query
()).
success
(
function
(
data
)
{
$scope
.
number
=
data
[
0
].
count
;
$scope
.
number
=
data
[
0
].
count
;
});
});
};
};
...
...
This diff is collapsed.
Click to expand it.
src/main/scala/SearchDB.scala
+
25
−
15
View file @
8a919a46
...
@@ -9,12 +9,23 @@ import org.apache.camel.scala.dsl.builder.RouteBuilder
...
@@ -9,12 +9,23 @@ import org.apache.camel.scala.dsl.builder.RouteBuilder
import
org.apache.camel.util.jndi.JndiContext
import
org.apache.camel.util.jndi.JndiContext
import
org.eclipse.jetty.server.handler.ResourceHandler
import
org.eclipse.jetty.server.handler.ResourceHandler
import
scala.collection.JavaConverters._
class
SearchDB
(
inPrefix
:
String
,
addStaticRoute
:
Boolean
)
extends
RouteBuilder
{
class
SearchDB
(
inPrefix
:
String
,
addStaticRoute
:
Boolean
)
extends
RouteBuilder
{
def
query2HashMap
(
ex
:
Exchange
)
:
util.HashMap
[
String
,
String
]
=
{
def
query2HashMap
2
(
ex
:
Exchange
)
:
util.HashMap
[
String
,
String
]
=
{
val
hm
=
new
util
.
HashMap
[
String
,
String
]()
val
hm
=
new
util
.
HashMap
[
String
,
String
]()
hm
.
put
(
"text"
,
"%"
+
ex
.
getIn
.
getHeader
(
"text"
)
+
"%"
)
val
inMap
=
ex
.
getIn
.
getHeaders
.
asScala
hm
.
put
(
"limit"
,
ex
.
getIn
.
getHeader
(
"limit"
).
toString
)
Table
.
columns
map
{
col
=>
hm
.
put
(
col
,
inMap
.
get
(
col
)
match
{
case
Some
(
v
:
String
)
if
v
.
nonEmpty
=>
"%"
+
v
+
"%"
case
_
=>
"%"
})
}
hm
.
put
(
"limit"
,
inMap
.
get
(
"limit"
)
match
{
case
Some
(
v
)
=>
v
.
toString
case
_
=>
"100000"
})
hm
hm
}
}
...
@@ -25,15 +36,14 @@ class SearchDB(inPrefix: String, addStaticRoute: Boolean) extends RouteBuilder {
...
@@ -25,15 +36,14 @@ class SearchDB(inPrefix: String, addStaticRoute: Boolean) extends RouteBuilder {
(
"log:lll"
+
this
.
getClass
+
"?showHeaders=true"
)
(
"log:lll"
+
this
.
getClass
+
"?showHeaders=true"
)
prefix
=
inPrefix
+
"sally/error/"
prefix
=
inPrefix
+
"sally/error/"
}
}
Table
.
columns
.
map
{
col
=>
((
prefix
+
"search2"
)
transform
query2HashMap2
)
-->
((
prefix
+
"count/"
+
col
)
transform
(
"db:SELECT * FROM errors WHERE "
+
(
ex
=>
"%"
+
ex
.
getIn
.
getHeader
(
"text"
)
+
"%"
))
-->
Table
.
columns
.
map
(
col
=>
col
+
" LIKE :#"
+
col
).
mkString
(
" AND "
)
+
(
"db:SELECT COUNT(*) as count FROM errors WHERE "
+
col
+
" LIKE #"
)
marshal
" LIMIT :#limit"
)
marshal
new
DataFormatDefinition
(
new
JacksonDataFormat
())
((
prefix
+
"count2"
)
transform
query2HashMap2
)
-->
(
"db:SELECT COUNT(*) as count FROM errors WHERE "
+
Table
.
columns
.
map
(
col
=>
col
+
" LIKE :#"
+
col
).
mkString
(
" AND "
))
marshal
new
DataFormatDefinition
(
new
JacksonDataFormat
())
new
DataFormatDefinition
(
new
JacksonDataFormat
())
((
prefix
+
"search/"
+
col
)
transform
query2HashMap
)
-->
(
"db:SELECT * FROM errors WHERE "
+
col
+
" LIKE :#text LIMIT :#limit"
)
marshal
new
DataFormatDefinition
(
new
JacksonDataFormat
())
}
}
}
object
SearchDB
{
object
SearchDB
{
...
@@ -42,9 +52,9 @@ object SearchDB {
...
@@ -42,9 +52,9 @@ object SearchDB {
val
(
context
,
_
)
=
Table
.
initArgs
(
args
)
val
(
context
,
_
)
=
Table
.
initArgs
(
args
)
val
resHandler
=
new
ResourceHandler
()
val
resHandler
=
new
ResourceHandler
()
resHandler
.
setResourceBase
(
"src/main/resource"
)
resHandler
.
setResourceBase
(
"src/main/resource"
)
val
j
dni
=
new
JndiContext
()
val
j
ndiContext
=
new
JndiContext
()
j
dni
.
bind
(
"staticHandler"
,
resHandler
)
j
ndiContext
.
bind
(
"staticHandler"
,
resHandler
)
context
.
setJndiContext
(
j
dni
)
context
.
setJndiContext
(
j
ndiContext
)
context
.
addRoutes
(
new
SearchDB
(
"jetty:http://localhost:8383/"
,
true
))
context
.
addRoutes
(
new
SearchDB
(
"jetty:http://localhost:8383/"
,
true
))
context
.
start
()
context
.
start
()
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment