added objectid timestamp to the user interface

the logic is done on the client.
This commit is contained in:
didier amyot committed 2015-04-10 08:16:46 -07:00
1 parent 100b7e1839
commit 41552040cc
4 files changed
+47 -13

No files matched your search

+13 -6
View File
@@ -1,6 +1,6 @@
directive = () ->
directive =
directive =
templateUrl: "/partials/directives/value.html"
replace: true,
transclude: false,
@@ -10,13 +10,13 @@ directive = () ->
docId: "="
key: "="
expended: "="
controller:["$scope", "$routeParams", ($scope, $routeParams) ->
controller:["$scope", "$routeParams", "util", ($scope, $routeParams, util) ->
$scope.isSmallString = (str)->
if not _.isString(str)
return false
rgx = str.match(/\n/g) or []
return str.length < 1000 and rgx.length < 20
$scope.isSmallObject = (obj) ->
return $scope.isSmallString(JSON.stringify(obj, null, 4))
@@ -28,15 +28,22 @@ directive = () ->
rp = $routeParams
s = $scope
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)
$scope.getDateFromObjectId = (objectId) ->
util.parseObjectId(objectId).date.toISOString()
$scope.valueLength = if _.isObject($scope.value) then _.keys($scope.value).length else $scope.value.length
$scope.isString = _.isString($scope.value)
$scope.isObjectId = $scope.isObjectId($scope.value)
$scope.isString = not $scope.isObjectId and _.isString($scope.value)
$scope.isNumber = _.isNumber($scope.value)
$scope.isObject = _.isObject($scope.value)
$scope.isArray = _.isArray($scope.value)
$scope.isBoolean = _.isBoolean($scope.value)
]
return directive
directives.directive( "vulValue", [directive])
+11 -3
View File
@@ -1,14 +1,22 @@
root = this
root.services.factory('util', ['$http', '$rootScope', ($http, $rootScope)->
service =
service =
get: (params...) ->
$rootScope.$broadcast("loading")
return $http.get(params...).
finally( () ->
$rootScope.$broadcast("loadingFinished")
)
parseObjectId: (objectIdAsString) ->
if objectIdAsString.length != 24
throw new Error("object id string must be of length 24")
ret =
date: new Date(parseInt(objectIdAsString.substr(0, 8), 16) * 1000)
machine: parseInt(objectIdAsString.substr(8, 14), 16)
process: parseInt(objectIdAsString.substr(14, 18), 16)
counter: parseInt(objectIdAsString.substr(18, 24), 16)
return service
]);
]);
+5 -3
View File
@@ -1,11 +1,13 @@
<span>
<span ng-show="isObjectId">
<pre> {{value}} [ {{getDateFromObjectId(value)}} ]</pre>
</span>
<span ng-show="isString">
<pre ng-show="isSmallString(value)"> {{value}} </pre>
<a ng-hide="isSmallString(value)" ng-href="{{ url() }}">
<pre> {{ getSmallPrefix(value) }} </pre>
</a>
</span>
<span ng-show="isNumber">
{{value | number | replaceAllCommasBySpaces}}
@@ -20,4 +22,4 @@
<pre ng-show="value" >true</pre>
<pre ng-show="!value" >false</pre>
</span>
</span>
</span>
+18 -1
View File
@@ -21,4 +21,21 @@ MongoServers:
-
name: vulture example
url: mongodb://vulture:vulture_example@ds047800.mongolab.com:47800/vulture_example
url: mongodb://vulture:vulture_example@ds047800.mongolab.com:47800/vulture_example
-
name: mioau
url: localhost:9999
-
name: kilink
url: 192.168.82.105:27017
-
name: brandindex demo
url: vdev-bix.paix.yougov.local
-
name: brandindex prod
url: vbixmgo.paix.yougov.local