added objectid timestamp to the user interface
the logic is done on the client.
This commit is contained in:
1 parent
100b7e1839
commit
41552040cc
4 files changed
+47
-13
No files matched your search
@@ -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])
|
||||
@@ -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
|
||||
|
||||
]);
|
||||
]);
|
||||
Reference in new issue
Block a user