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
+37 -3

No files matched your search

+9 -2
View File
@@ -10,7 +10,7 @@ directive = () ->
docId: "=" docId: "="
key: "=" key: "="
expended: "=" expended: "="
controller:["$scope", "$routeParams", ($scope, $routeParams) -> controller:["$scope", "$routeParams", "util", ($scope, $routeParams, util) ->
$scope.isSmallString = (str)-> $scope.isSmallString = (str)->
if not _.isString(str) if not _.isString(str)
return false return false
@@ -28,10 +28,17 @@ directive = () ->
rp = $routeParams rp = $routeParams
s = $scope s = $scope
return "#/#{rp.server}/#{rp.database}/#{rp.collection}/_id/#{s.docId}/field/#{s.key}" 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.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.isNumber = _.isNumber($scope.value)
$scope.isObject = _.isObject($scope.value) $scope.isObject = _.isObject($scope.value)
$scope.isArray = _.isArray($scope.value) $scope.isArray = _.isArray($scope.value)
+8
View File
@@ -8,6 +8,14 @@ root.services.factory('util', ['$http', '$rootScope', ($http, $rootScope)->
finally( () -> finally( () ->
$rootScope.$broadcast("loadingFinished") $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 return service
+3 -1
View File
@@ -1,11 +1,13 @@
<span> <span>
<span ng-show="isObjectId">
<pre> {{value}} [ {{getDateFromObjectId(value)}} ]</pre>
</span>
<span ng-show="isString"> <span ng-show="isString">
<pre ng-show="isSmallString(value)"> {{value}} </pre> <pre ng-show="isSmallString(value)"> {{value}} </pre>
<a ng-hide="isSmallString(value)" ng-href="{{ url() }}"> <a ng-hide="isSmallString(value)" ng-href="{{ url() }}">
<pre> {{ getSmallPrefix(value) }} </pre> <pre> {{ getSmallPrefix(value) }} </pre>
</a> </a>
</span> </span>
<span ng-show="isNumber"> <span ng-show="isNumber">
{{value | number | replaceAllCommasBySpaces}} {{value | number | replaceAllCommasBySpaces}}
+17
View File
@@ -22,3 +22,20 @@ MongoServers:
- -
name: vulture example 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