diff options
author | 2018-09-06 12:46:04 +0530 | |
---|---|---|
committer | 2018-09-12 13:10:46 +0000 | |
commit | 43d4b00848ebd0567b020fe219f07d4f7049ff0b (patch) | |
tree | f5c09d0006348c82a94693605349e79db4889b71 /configbackuprestore/vnfconfigbackupservice/src/main/webapp/node_modules/angular-object-diff/demo.js | |
parent | 4e2db0d6e56bc19425e6afa3efc7011820942e9e (diff) |
Epic-231:versioning, and backup the configuration
Merging the sdnc jira stories- 255,256
Change-Id: Iacb9274dae93f534f1331c4eb7d0669896d379d4
Issue-ID: SDNC-256
Signed-off-by: DushyantSinghThakur <dt00503496@techmahindra.com>
Former-commit-id: 94d8b3d82b82dedfd5949da2e5d1ed348ab066e2
Diffstat (limited to 'configbackuprestore/vnfconfigbackupservice/src/main/webapp/node_modules/angular-object-diff/demo.js')
-rw-r--r-- | configbackuprestore/vnfconfigbackupservice/src/main/webapp/node_modules/angular-object-diff/demo.js | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/configbackuprestore/vnfconfigbackupservice/src/main/webapp/node_modules/angular-object-diff/demo.js b/configbackuprestore/vnfconfigbackupservice/src/main/webapp/node_modules/angular-object-diff/demo.js new file mode 100644 index 00000000..3613fcca --- /dev/null +++ b/configbackuprestore/vnfconfigbackupservice/src/main/webapp/node_modules/angular-object-diff/demo.js @@ -0,0 +1,68 @@ +// Angular JS code +(function () { + 'use-strict'; + + angular.module('demoApp', ['ds.objectDiff']) + .config([ + '$interpolateProvider', + function ($interpolateProvider) { + return $interpolateProvider.startSymbol('{(').endSymbol(')}'); + } + ]) + .controller('DemoController', DemoController); + + DemoController.$inject = ['$scope', 'ObjectDiff']; + + function DemoController($scope, ObjectDiff) { + $scope.objectOne = "{\n" + + " a: {\n" + + " b: 1,\n" + + " c: [1, 2]\n" + + " },\n" + + " \"2b\": {\n" + + " foo: 'bar'\n" + + " }\n" + + " }"; + $scope.objectTwo = "{\n" + + " a: { \n" + + " b: 2,\n" + + " c: [1, 2, 3]\n" + + " },\n" + + " x: 1\n" + + " }"; + + + function makeDiff() { + var objectOne, objectTwo, diff; + try { + $scope.errorA = false; + objectOne = eval('(' + $scope.objectOne + ')'); //JSON.parse($scope.objectOne); + } catch (err) { + $scope.errorA = true; + } + try { + $scope.errorB = false; + objectTwo = eval('(' + $scope.objectTwo + ')'); //JSON.parse($scope.objectTwo); + } catch (err) { + $scope.errorB = true; + } + + // you can directly diff your objects if they are not string + diff = ObjectDiff.diffOwnProperties(objectOne, objectTwo); + + $scope.diffValue = ObjectDiff.toJsonView(diff); + $scope.diffValueChanges = ObjectDiff.toJsonDiffView(diff); + + $scope.yourObjectOne = objectOne; + $scope.yourObjectTwo = objectTwo; + } + + $scope.$watch('objectOne', function (newValue, oldValue) { + makeDiff(); + }); + $scope.$watch('objectTwo', function (newValue, oldValue) { + makeDiff(); + }); + } + +})(); |