Can now use pipeline as query
This commit is contained in:
1 parent
41552040cc
commit
e305aa8f2a
16 files changed
+323
-123
No files matched your search
@@ -26,10 +26,12 @@ getStatsUrl = (keyName, routeParams)->
|
||||
ret = "#/#{r.server}/#{r.database}/#{r.collection}/stats/#{ keyName }"
|
||||
if r.query
|
||||
ret = "#{ ret }/query/#{ r.query }"
|
||||
else if r.pipeline
|
||||
ret = "#{ret}/pipeline/#{r.pipeline}"
|
||||
return ret
|
||||
|
||||
directive = () ->
|
||||
directive =
|
||||
directive =
|
||||
templateUrl: "/partials/directives/key.html"
|
||||
replace: true,
|
||||
transclude: false,
|
||||
@@ -39,6 +41,7 @@ directive = () ->
|
||||
value: "="
|
||||
indexes: "="
|
||||
controller:["$scope", "$routeParams", ($scope, $routeParams) ->
|
||||
$scope.indexes = $scope.indexes or []
|
||||
$scope.canMakeHistogram = _.isNumber($scope.value)
|
||||
$scope.statsUrl = getStatsUrl($scope.keyName, $routeParams)
|
||||
$scope.hasIndexDesc = hasIndexDesc($scope.keyName, $scope.indexes)
|
||||
@@ -56,5 +59,5 @@ directive = () ->
|
||||
return "#{url}/geojson/#{$scope.keyName}"
|
||||
]
|
||||
return directive
|
||||
|
||||
|
||||
directives.directive( "vulKey", [directive])
|
||||
@@ -2,17 +2,17 @@
|
||||
mongoJsToMongoJSON = (queryString) ->
|
||||
ObjectId = (id) ->
|
||||
return {"$oid": id}
|
||||
|
||||
|
||||
DBRef = (name, id) ->
|
||||
return {"$ref": name, "$id": id}
|
||||
|
||||
|
||||
Timestamp = (t, i) ->
|
||||
return {"t": t, "i": i}
|
||||
NumberLong = (number) ->
|
||||
return { "$numberLong": String(number)}
|
||||
MaxKey = { "$maxKey": 1 }
|
||||
MinKey = { "$minKey": 1 }
|
||||
|
||||
|
||||
query = ""
|
||||
eval("query = " + queryString)
|
||||
fixQuery = (query) ->
|
||||
@@ -35,7 +35,7 @@ mongoJsToMongoJSON = (queryString) ->
|
||||
query[k] = fixQuery(v)
|
||||
return query
|
||||
return query
|
||||
|
||||
|
||||
return fixQuery(query)
|
||||
|
||||
testmongoJsToMongoJSON = () ->
|
||||
@@ -57,27 +57,29 @@ testmongoJsToMongoJSON = () ->
|
||||
]
|
||||
}"""
|
||||
assertEqual(mongoJsToMongoJSON(s), {a: [1,3, {reg: [{ "$regex":"allo", "$options": "mgi" }, {"$date": 1399585944320}]}]})
|
||||
|
||||
|
||||
|
||||
testmongoJsToMongoJSON()
|
||||
|
||||
directive = () ->
|
||||
directive =
|
||||
directive =
|
||||
templateUrl: "/partials/directives/searchBar.html"
|
||||
replace: true,
|
||||
transclude: false,
|
||||
restrict: 'E',
|
||||
scope:
|
||||
query: "@"
|
||||
callback: "="
|
||||
querycallback: "="
|
||||
pipelinecallback: "="
|
||||
controller:["$scope", "$routeParams", ($scope, $routeParams) ->
|
||||
$scope.bigInput = false
|
||||
$scope.newQuery = $scope.query or ""
|
||||
$scope.codeMirrorOptions =
|
||||
lineWrapping : true
|
||||
lineNumbers: true
|
||||
indentUnit: 4
|
||||
mode: 'text/typescript'
|
||||
|
||||
|
||||
$scope.parseQueryToJSON = (query) ->
|
||||
try
|
||||
query = mongoJsToMongoJSON(query)
|
||||
@@ -87,18 +89,29 @@ directive = () ->
|
||||
catch error
|
||||
$scope.error
|
||||
return ""
|
||||
|
||||
$scope.isValidEntry = ()->
|
||||
|
||||
$scope.isValidQueryEntry = ()->
|
||||
query = $scope.parseQueryToJSON($scope.newQuery)
|
||||
return query != ""
|
||||
|
||||
$scope.callCallback = () ->
|
||||
return query != "" and not _.isArray(JSON.parse(query))
|
||||
|
||||
$scope.isValidPipelineEntry = ()->
|
||||
query = $scope.parseQueryToJSON($scope.newQuery)
|
||||
if query != ""
|
||||
query != "" and _.isArray(JSON.parse(query))
|
||||
|
||||
$scope.queryCallback = () ->
|
||||
if $scope.isValidQueryEntry()
|
||||
query = $scope.parseQueryToJSON($scope.newQuery)
|
||||
f = () ->
|
||||
$scope.callback(query)
|
||||
$scope.querycallback(query)
|
||||
$scope.$eval(f)
|
||||
|
||||
$scope.pipelineCallback = () ->
|
||||
if $scope.isValidPipelineEntry()
|
||||
query = $scope.parseQueryToJSON($scope.newQuery)
|
||||
f = () ->
|
||||
$scope.pipelinecallback(query)
|
||||
$scope.$eval(f)
|
||||
]
|
||||
return directive
|
||||
|
||||
directives.directive( "vulSearchBar", [directive])
|
||||
|
||||
directives.directive( "vulSearchBar", [directive])
|
||||
@@ -30,7 +30,7 @@ directive = () ->
|
||||
return "#/#{rp.server}/#{rp.database}/#{rp.collection}/_id/#{s.docId}/field/#{s.key}"
|
||||
$scope.isObjectId = (val) ->
|
||||
objectIdRegexp = /^[01234567890abcdef]{24}$/
|
||||
return _.isString(val) and objectIdRegexp.test(val)
|
||||
_.isString(val) and objectIdRegexp.test(val)
|
||||
|
||||
$scope.getDateFromObjectId = (objectId) ->
|
||||
util.parseObjectId(objectId).date.toISOString()
|
||||
|
||||
Reference in new issue
Block a user