mirror of
https://github.com/arnaucube/blockchainIDsystem.git
synced 2026-02-07 11:06:41 +01:00
updated to the same stage than darkID project, but with own blockchain
This commit is contained in:
56
clientApp/GUI/views/id/id.html
Normal file
56
clientApp/GUI/views/id/id.html
Normal file
@@ -0,0 +1,56 @@
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-sm-2">
|
||||
|
||||
</div>
|
||||
<div class="col-sm-8">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h4>ID: {{id.id}}</h4>
|
||||
|
||||
<span class="pull-right">{{id.date | date: "dd.MM.y, HH:mm:ss"}}h</span>
|
||||
|
||||
<span class="badge c_o_red300" ng-show="!id.verified">Not verified</span>
|
||||
<span class="badge c_o_green300" ng-show="id.verified">Verified</span>
|
||||
<span class="badge c_o_orange300" ng-show="!id.unblindedsig">Not signed</span>
|
||||
<span class="badge c_o_blue300" ng-show="id.unblindedsig">Signed</span>
|
||||
<span class="badge c_o_deepPurple300" ng-show="id.blockchainref">in Blockchain</span>
|
||||
<div class="row">
|
||||
<textarea style="color:#000000;width:100%;" rows="4"
|
||||
ng-model="decryptData.c"
|
||||
placeholder="Enter here the proof-of-decrypt..."
|
||||
></textarea>
|
||||
</div>
|
||||
<h5 ng-show="decryptData.m">PoD:</h5>
|
||||
{{decryptData.m}}
|
||||
<div ng-click="decrypt()" ng-show="id.blockchainref" class="btn btn-raised pull-right c_o_pink300">
|
||||
Proof of decrypt
|
||||
</div>
|
||||
|
||||
<br><br><br><br><br>
|
||||
<hr>
|
||||
<h5>Testing only:</h5>
|
||||
<div class="row">
|
||||
<textarea style="color:#000000;width:100%;" rows="4"
|
||||
ng-model="encryptData.m"
|
||||
placeholder="Enter here the unencrypted..."
|
||||
></textarea>
|
||||
</div>
|
||||
<div class="row">
|
||||
<textarea style="backgroud:grey;color:#000000;width:100%;" rows="4"
|
||||
ng-model="encryptData.c"
|
||||
placeholder="Encrypted data..."
|
||||
></textarea>
|
||||
</div>
|
||||
<div ng-click="encrypt()" ng-show="id.blockchainref" class="btn btn-raised pull-right c_o_orange300">
|
||||
Encrypt
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-2">
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
76
clientApp/GUI/views/id/id.js
Normal file
76
clientApp/GUI/views/id/id.js
Normal file
@@ -0,0 +1,76 @@
|
||||
'use strict';
|
||||
|
||||
angular.module('app.id', ['ngRoute'])
|
||||
|
||||
.config(['$routeProvider', function($routeProvider) {
|
||||
$routeProvider.when('/id/:keyid', {
|
||||
templateUrl: 'views/id/id.html',
|
||||
controller: 'IdCtrl'
|
||||
});
|
||||
}])
|
||||
|
||||
.controller('IdCtrl', function($scope, $rootScope, $http, $routeParams) {
|
||||
$scope.keyid = $routeParams.keyid;
|
||||
$scope.decryptData = {
|
||||
m:"",
|
||||
c:""
|
||||
};
|
||||
$scope.encryptData = {
|
||||
m:"",
|
||||
c:""
|
||||
};
|
||||
|
||||
$rootScope.server = JSON.parse(localStorage.getItem("old_darkID_server"));
|
||||
|
||||
$scope.id = {};
|
||||
$scope.clientApp = function(route, param) {
|
||||
$http.get(clientapi + route + '/' + param)
|
||||
.then(function(data) {
|
||||
console.log('data success');
|
||||
console.log(data);
|
||||
$scope.id = data.data;
|
||||
|
||||
}, function(data) {
|
||||
console.log('data error');
|
||||
});
|
||||
};
|
||||
$scope.clientApp('id', $routeParams.keyid);
|
||||
|
||||
|
||||
$scope.decrypt = function() {
|
||||
$http({
|
||||
url: clientapi + 'decrypt/' + $routeParams.keyid,
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": undefined
|
||||
},
|
||||
data: $scope.decryptData
|
||||
})
|
||||
.then(function(data) {
|
||||
console.log("data: ");
|
||||
console.log(data.data);
|
||||
$scope.decryptData = data.data;
|
||||
},
|
||||
function(data) {
|
||||
console.log(data);
|
||||
});
|
||||
};
|
||||
$scope.encrypt = function() {
|
||||
$http({
|
||||
url: clientapi + 'encrypt/' + $routeParams.keyid,
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": undefined
|
||||
},
|
||||
data: $scope.encryptData
|
||||
})
|
||||
.then(function(data) {
|
||||
console.log("data: ");
|
||||
console.log(data.data);
|
||||
$scope.encryptData = data.data;
|
||||
},
|
||||
function(data) {
|
||||
console.log(data);
|
||||
});
|
||||
};
|
||||
});
|
||||
@@ -1,20 +1,20 @@
|
||||
<div class="container" style="margin-top: -80px;">
|
||||
<div class="container" style="margin-top: -60px;">
|
||||
<div class="row">
|
||||
<div class="col-sm-3">
|
||||
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<div class="card">
|
||||
<img src="img/blockchainIDsystem-logo01.png" class="img-responsive" />
|
||||
<img src="img/darkID-logo01.png" class="img-responsive" />
|
||||
<div class="card-body">
|
||||
<h4 class="card-title">
|
||||
blockchainIDsystem
|
||||
darkID
|
||||
</h4>
|
||||
<input ng-model="user.email" class="form-control" placeholder="Email" type="text">
|
||||
<input ng-model="user.password" class="form-control" placeholder="Password" type="password">
|
||||
<div class="row">
|
||||
<div class="col-sm-6">
|
||||
<div href="#!/signup" class="btn btn-raised btn-block c_o_pink300">Signup</div>
|
||||
<a href="#!/signup" class="btn btn-raised btn-block c_o_pink300">Signup</a>
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<div ng-click="login()" class="btn btn-raised btn-block c_o_cyan300 pull-right">Login</div>
|
||||
|
||||
@@ -9,13 +9,32 @@ angular.module('app.login', ['ngRoute'])
|
||||
});
|
||||
}])
|
||||
|
||||
.controller('LoginCtrl', function($scope, $http, $routeParams, toastr) {
|
||||
.controller('LoginCtrl', function($scope, $rootScope, $http, $routeParams, toastr) {
|
||||
$rootScope.server = "";
|
||||
$scope.user = {};
|
||||
//set server in goclient
|
||||
$http.get(clientapi + 'getserver')
|
||||
.then(function(data) {
|
||||
console.log("data server: ");
|
||||
console.log(data.data + "/");
|
||||
$rootScope.server = "http://" + data.data.replace("\n", "") + "/";
|
||||
console.log($rootScope.server + "/");
|
||||
localStorage.setItem("old_darkID_server", JSON.stringify($rootScope.server));
|
||||
console.log("server", $rootScope.server + "/");
|
||||
}, function(data) {
|
||||
console.log('data error');
|
||||
});
|
||||
|
||||
$scope.login = function() {
|
||||
|
||||
console.log('Doing login', $scope.user);
|
||||
console.log(urlapi + "login");
|
||||
console.log($rootScope.server + "/login");
|
||||
|
||||
|
||||
|
||||
//
|
||||
$http({
|
||||
url: urlapi + 'login',
|
||||
url: $rootScope.server + 'login',
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": undefined
|
||||
@@ -26,12 +45,12 @@ angular.module('app.login', ['ngRoute'])
|
||||
console.log("data: ");
|
||||
console.log(data.data);
|
||||
if (data.data.token) {
|
||||
localStorage.setItem("blid_token", data.data.token);
|
||||
localStorage.setItem("blid_user", JSON.stringify(data.data));
|
||||
localStorage.setItem("old_darkID_token", data.data.token);
|
||||
localStorage.setItem("old_darkID_user", JSON.stringify(data.data));
|
||||
window.location.reload();
|
||||
} else {
|
||||
console.log("login failed");
|
||||
toastr.error('Login failed');
|
||||
toastr.error('Login failed, ' + data.data);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -4,39 +4,48 @@
|
||||
|
||||
</div>
|
||||
<div class="col-sm-8">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div ng-click="newID()" class="btn btn-raised c_o_pink300">Create new ID</div>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="card-body">
|
||||
<h4 class="card-title">
|
||||
<div ng-click="newID()" class="btn btn-raised pull-right c_o_pink300">Create new ID</div>
|
||||
<h4 class="card-title">
|
||||
My IDs
|
||||
</h4>
|
||||
<div class="row" style="height:200px;" ng-repeat="id in ids">
|
||||
<div class="card" ng-repeat="id in ids" style="overflow-x:hidden;">
|
||||
<div class="card-body">
|
||||
<h4>{{id.pubK}}</h4>
|
||||
<span class="pull-right">{{id.date | date: "dd.MM.y, HH:mm:ss"}}h</span>
|
||||
|
||||
<span class="badge c_o_red300" ng-show="!id.verified">Not verified</span>
|
||||
<span class="badge c_o_green300" ng-show="id.verified">Verified</span>
|
||||
<span class="badge c_o_orange300" ng-show="!id.unblindedsig">Not signed</span>
|
||||
<span class="badge c_o_blue300" ng-show="id.unblindedsig">Signed</span>
|
||||
<span class="badge c_o_deepPurple300" ng-show="id.blockchainref">in Blockchain</span>
|
||||
<div class="row">
|
||||
<div class="col-sm-6">
|
||||
Public Key: {{id.pubK}}
|
||||
<!--<br> Private Key: {{id.privK}}-->
|
||||
<br> Date of creation: {{id.date}}
|
||||
<!--<br> {{id.pubKSigned}}-->
|
||||
<br>
|
||||
<br><br>
|
||||
<div ng-click="clientApp('blindandsendtosign', id.pubK)" ng-show="!id.unblindedsig" class="btn btn-raised btn-sm c_o_cyan300">
|
||||
Send to serverIDsigner
|
||||
</div>
|
||||
<div ng-click="clientApp('addtoblockchain', id.pubK)" ng-show="id.unblindedsig && !id.blockchainref" class="btn btn-raised btn-sm c_o_deepPurple300">
|
||||
<i title="" class="fa fa-chain"></i> Add to blockchain
|
||||
</div>
|
||||
<a ng-href="#!/id/{{id.pubK}}" ng-show="id.blockchainref" class="btn btn-raised btn-sm c_o_green300">
|
||||
Use ID
|
||||
</a>
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<div class="pull-right">
|
||||
<span class="badge c_o_red300" ng-show="!id.verified">Not verified</span>
|
||||
<span class="badge c_o_green300" ng-show="id.verified">Verified</span>
|
||||
</div>
|
||||
<div class="pull-right">
|
||||
<span class="badge c_o_orange300" ng-show="!id.pubKSigned">Not signed</span>
|
||||
<span class="badge c_o_green300" ng-show="id.pubKSigned">Signed</span>
|
||||
</div>
|
||||
<div ng-click="blindAndSendToSign(id.pubK)" ng-show="!id.pubKSigned" class="btn btn-sm btn-raised c_o_cyan300 pull-right">Send to serverIDsigner</div>
|
||||
<!--<div ng-click="verify(id.pubK)" ng-show="!id.verified"class="btn btn-sm btn-raised c_o_deepPurple300 pull-right">Verify</div>-->
|
||||
|
||||
<div ng-click="clientApp('delete', id.pubK)" class="btn btn-raised pull-right btn-sm c_o_red300">
|
||||
<i title="Delete" class="fa fa-trash fa-1x"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="progress progress-striped" ng-show="generatingID">
|
||||
<div class="progress-bar progress-bar-success active" style="width: 100%"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-2">
|
||||
|
||||
|
||||
@@ -9,7 +9,11 @@ angular.module('app.main', ['ngRoute'])
|
||||
});
|
||||
}])
|
||||
|
||||
.controller('MainCtrl', function($scope, $http) {
|
||||
.controller('MainCtrl', function($scope, $rootScope, $http) {
|
||||
|
||||
$rootScope.server = JSON.parse(localStorage.getItem("old_darkID_server"));
|
||||
|
||||
$scope.generatingID = false;
|
||||
$scope.ids = [];
|
||||
$http.get(clientapi + 'ids')
|
||||
.then(function(data) {
|
||||
@@ -22,19 +26,21 @@ angular.module('app.main', ['ngRoute'])
|
||||
});
|
||||
|
||||
$scope.newID = function() {
|
||||
$scope.generatingID = true;
|
||||
$http.get(clientapi + 'newid')
|
||||
.then(function(data) {
|
||||
console.log('data success');
|
||||
console.log(data);
|
||||
$scope.ids = data.data;
|
||||
$scope.generatingID = false;
|
||||
|
||||
}, function(data) {
|
||||
console.log('data error');
|
||||
});
|
||||
};
|
||||
|
||||
$scope.blindAndSendToSign = function(pubK) {
|
||||
$http.get(clientapi + 'blindandsendtosign/' + pubK)
|
||||
$scope.blindAndSendToSign = function(id) {
|
||||
$http.get(clientapi + 'blindandsendtosign/' + id)
|
||||
.then(function(data) {
|
||||
console.log('data success');
|
||||
console.log(data);
|
||||
@@ -44,8 +50,19 @@ angular.module('app.main', ['ngRoute'])
|
||||
console.log('data error');
|
||||
});
|
||||
};
|
||||
$scope.verify = function(pubK) {
|
||||
$http.get(clientapi + 'verify/' + pubK)
|
||||
$scope.verify = function(id) {
|
||||
$http.get(clientapi + 'verify/' + id)
|
||||
.then(function(data) {
|
||||
console.log('data success');
|
||||
console.log(data);
|
||||
$scope.ids = data.data;
|
||||
|
||||
}, function(data) {
|
||||
console.log('data error');
|
||||
});
|
||||
};
|
||||
$scope.clientApp = function(route, param) {
|
||||
$http.get(clientapi + route + '/' + param)
|
||||
.then(function(data) {
|
||||
console.log('data success');
|
||||
console.log(data);
|
||||
|
||||
@@ -7,12 +7,29 @@
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<a class="navbar-brand" href="/" title="blockchainIDsystem">
|
||||
<img src="img/blockchainIDsystem-logo-white.png" style="width:30px;height:30px;display:inline;" alt=""> <b>blockchainIDsystem</b>
|
||||
<a class="navbar-brand" href="#!/" title="darkID">
|
||||
<img src="img/darkID-logo-white.png" style="width:30px;height:30px;display:inline;" alt=""> darkID
|
||||
</a>
|
||||
</div>
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav">
|
||||
<li>
|
||||
<a href="#!/stats" title="Stats">
|
||||
<i title="Server" class="fa fa-bar-chart fa-1x"></i> Stats
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="http://127.0.0.1:3080" target="_blank" title="Blockchain Explorer">
|
||||
<i title="Server" class="fa fa-link fa-1x"></i> Blockchain Explorer
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li>
|
||||
<a title="serverIDsigner">
|
||||
<i title="Server" class="fa fa-server fa-1x"></i> {{server}}
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="">
|
||||
<i title="User" class="fa fa-user fa-1x"></i> {{user.email}}
|
||||
|
||||
@@ -9,13 +9,15 @@ angular.module('app.navbar', ['ngRoute'])
|
||||
});
|
||||
}])
|
||||
|
||||
.controller('NavbarCtrl', function($scope, $http, $routeParams, $location) {
|
||||
.controller('NavbarCtrl', function($scope, $rootScope, $http, $routeParams, $location) {
|
||||
$rootScope.server = JSON.parse(localStorage.getItem("old_darkID_server"));
|
||||
|
||||
$scope.user = JSON.parse(localStorage.getItem("blid_user"));
|
||||
$scope.user = JSON.parse(localStorage.getItem("old_darkID_user"));
|
||||
|
||||
$scope.logout = function() {
|
||||
localStorage.removeItem("blid_token");
|
||||
localStorage.removeItem("blid_user");
|
||||
localStorage.removeItem("old_darkID_token");
|
||||
localStorage.removeItem("old_darkID_user");
|
||||
localStorage.removeItem("old_darkID_server");
|
||||
window.location.reload();
|
||||
};
|
||||
|
||||
|
||||
@@ -1,40 +1,32 @@
|
||||
<div class="container">
|
||||
<div class="container" style="margin-top: -80px;">
|
||||
<div class="row">
|
||||
<div class="col-sm-4">
|
||||
<div class="col-sm-3">
|
||||
|
||||
</div>
|
||||
<div class="col-sm-4">
|
||||
<div class="panel">
|
||||
<div class="panel-heading c_deepPurpleG500to300">
|
||||
<h3 class="panel-title">Signup</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div class="form-group label-floating">
|
||||
<input ng-model="user.username" abmFormControl class="form-control" id="inputUsername" placeholder="Username" type="text">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input ng-model="user.password" abmFormControl class="form-control" id="inputPassword" placeholder="Password" type="password">
|
||||
</div>
|
||||
<div class="form-group label-floating">
|
||||
<input ng-model="user.email" abmFormControl class="form-control" id="inputEmail" placeholder="Email" type="text">
|
||||
</div>
|
||||
<div class="form-group label-floating">
|
||||
<input ng-model="user.phone" abmFormControl class="form-control" id="inputPhone" placeholder="Phone" type="text">
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label for="staticEmail" class="col-sm-1 col-form-label">@</label>
|
||||
<div class="col-sm-10">
|
||||
<input ng-model="user.telegram" abmFormControl class="form-control" id="inputTelegram" placeholder="Telegram" type="text">
|
||||
<div class="col-sm-6">
|
||||
<div class="card">
|
||||
<img src="img/darkID-logo01.png" class="img-responsive" />
|
||||
<div class="card-body">
|
||||
<h4 class="card-title">
|
||||
darkID
|
||||
</h4>
|
||||
<input ng-model="user.email" class="form-control" placeholder="Email" type="text">
|
||||
<input ng-model="user.password" class="form-control" placeholder="Password" type="password">
|
||||
<input ng-model="user.phone" class="form-control" placeholder="Phone" type="text">
|
||||
<div class="row">
|
||||
<div class="col-sm-6">
|
||||
<a href="#!/login" class="btn btn-raised btn-block c_o_blue300">Cancel</a>
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<div ng-click="signup()" class="btn btn-raised btn-block c_o_pink300 pull-right">Signup</div>
|
||||
</div>
|
||||
</div>
|
||||
<a ng-href="#!/login" class="btn btn-raised c_grey500">Back</a>
|
||||
<div ng-click="doSignup()" class="btn btn-raised c_deepPurple300 pull-right">Signup</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="col-sm-4">
|
||||
<div class="col-sm-3">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -9,35 +9,27 @@ angular.module('app.signup', ['ngRoute'])
|
||||
});
|
||||
}])
|
||||
|
||||
.controller('SignupCtrl', function($scope, $http, $routeParams) {
|
||||
.controller('SignupCtrl', function($scope, $http, $routeParams, $rootScope) {
|
||||
$scope.user = {};
|
||||
$scope.doSignup = function() {
|
||||
console.log('Doing login', $scope.user);
|
||||
|
||||
$scope.signup = function() {
|
||||
console.log('Doing signup', $scope.user);
|
||||
$http({
|
||||
url: urlapi + 'signup',
|
||||
method: "POST",
|
||||
data: $scope.user
|
||||
})
|
||||
.then(function(response) {
|
||||
console.log("response: ");
|
||||
console.log(response.data);
|
||||
if (response.data.success == true)
|
||||
{
|
||||
localStorage.setItem("cr_webapp_token", response.data.token);
|
||||
localStorage.setItem("cr_webapp_userdata", JSON.stringify(response.data.user));
|
||||
window.location.reload();
|
||||
}else{
|
||||
console.log("signup failed");
|
||||
toastr.error('Signup failed');
|
||||
}
|
||||
url: $rootScope.server + 'signup',
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": undefined
|
||||
},
|
||||
data: $scope.user
|
||||
})
|
||||
.then(function(data) {
|
||||
console.log("data: ");
|
||||
console.log(data.data);
|
||||
window.location="/";
|
||||
|
||||
|
||||
},
|
||||
function(response) { // optional
|
||||
// failed
|
||||
console.log(response);
|
||||
});
|
||||
},
|
||||
function(data) {
|
||||
console.log(data);
|
||||
});
|
||||
|
||||
};
|
||||
});
|
||||
|
||||
39
clientApp/GUI/views/stats/stats.html
Normal file
39
clientApp/GUI/views/stats/stats.html
Normal file
@@ -0,0 +1,39 @@
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-sm-2">
|
||||
|
||||
</div>
|
||||
<div class="col-sm-8">
|
||||
<h4 class="card-title">
|
||||
Stats
|
||||
</h4>
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
<canvas id="line" class="chart chart-line" chart-data="chart1.data"
|
||||
chart-labels="chart1.labels"
|
||||
chart-colors="chart1.colours">
|
||||
</canvas>
|
||||
</div>
|
||||
<div class="row">
|
||||
<canvas id="line" class="chart chart-pie" chart-data="chart2.data"
|
||||
chart-labels="chart2.labels"
|
||||
chart-colors="chart2.colours">
|
||||
</canvas>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="progress progress-striped" ng-show="generatingID">
|
||||
<div class="progress-bar progress-bar-success active" style="width: 100%"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-2">
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
136
clientApp/GUI/views/stats/stats.js
Normal file
136
clientApp/GUI/views/stats/stats.js
Normal file
@@ -0,0 +1,136 @@
|
||||
'use strict';
|
||||
|
||||
angular.module('app.stats', ['ngRoute'])
|
||||
|
||||
.config(['$routeProvider', function($routeProvider) {
|
||||
$routeProvider.when('/stats', {
|
||||
templateUrl: 'views/stats/stats.html',
|
||||
controller: 'StatsCtrl'
|
||||
});
|
||||
}])
|
||||
|
||||
.controller('StatsCtrl', function($scope, $rootScope, $http, $filter) {
|
||||
|
||||
$rootScope.server = JSON.parse(localStorage.getItem("old_darkID_server"));
|
||||
|
||||
$scope.generatingID = false;
|
||||
$scope.ids = [];
|
||||
$http.get(clientapi + 'ids')
|
||||
.then(function(data) {
|
||||
console.log('data success');
|
||||
console.log(data);
|
||||
$scope.ids = data.data;
|
||||
$scope.idsToChart();
|
||||
}, function(data) {
|
||||
console.log('data error');
|
||||
});
|
||||
|
||||
$scope.newID = function() {
|
||||
$scope.generatingID = true;
|
||||
$http.get(clientapi + 'newid')
|
||||
.then(function(data) {
|
||||
console.log('data success');
|
||||
console.log(data);
|
||||
$scope.ids = data.data;
|
||||
$scope.generatingID = false;
|
||||
|
||||
}, function(data) {
|
||||
console.log('data error');
|
||||
});
|
||||
};
|
||||
|
||||
$scope.blindAndSendToSign = function(id) {
|
||||
$http.get(clientapi + 'blindandsendtosign/' + id)
|
||||
.then(function(data) {
|
||||
console.log('data success');
|
||||
console.log(data);
|
||||
$scope.ids = data.data;
|
||||
|
||||
}, function(data) {
|
||||
console.log('data error');
|
||||
});
|
||||
};
|
||||
$scope.verify = function(id) {
|
||||
$http.get(clientapi + 'verify/' + id)
|
||||
.then(function(data) {
|
||||
console.log('data success');
|
||||
console.log(data);
|
||||
$scope.ids = data.data;
|
||||
|
||||
}, function(data) {
|
||||
console.log('data error');
|
||||
});
|
||||
};
|
||||
$scope.clientApp = function(route, param) {
|
||||
$http.get(clientapi + route + '/' + param)
|
||||
.then(function(data) {
|
||||
console.log('data success');
|
||||
console.log(data);
|
||||
$scope.ids = data.data;
|
||||
|
||||
}, function(data) {
|
||||
console.log('data error');
|
||||
});
|
||||
};
|
||||
|
||||
//chartjs
|
||||
$scope.chart1 = {
|
||||
colours: ['#4DD0E1', '#9575CD', '#F06292', '#FFF176'],
|
||||
labels: [],
|
||||
data: []
|
||||
};
|
||||
$scope.chart2 = {
|
||||
colours: ['#4DD0E1', '#9575CD', '#F06292', '#FFF176'],
|
||||
labels: [],
|
||||
data: []
|
||||
};
|
||||
$scope.idsToChart = function() {
|
||||
//chart1
|
||||
var dictionary = {};
|
||||
var ids = $scope.ids;
|
||||
for(var i=0; i<ids.length; i++) {
|
||||
var day = $filter('date')(ids[i].date, 'dd.MM.y, HH:mm');
|
||||
if(dictionary[day]==undefined) {
|
||||
dictionary[day] = 1
|
||||
} else {
|
||||
dictionary[day]++;
|
||||
}
|
||||
}
|
||||
console.log(dictionary);
|
||||
for(var key in dictionary) {
|
||||
$scope.chart1.labels.push(key);
|
||||
$scope.chart1.data.push(dictionary[key]);
|
||||
}
|
||||
|
||||
|
||||
//chart2
|
||||
var dictionary = {};
|
||||
for(var i=0; i<ids.length; i++) {
|
||||
if(ids[i].blockchainref) {
|
||||
if(dictionary['in blockchain']==undefined) {
|
||||
dictionary['in blockchain'] = 1
|
||||
} else {
|
||||
dictionary['in blockchain']++;
|
||||
}
|
||||
} else if(ids[i].unblindedsig) {
|
||||
if(dictionary['signed']==undefined) {
|
||||
dictionary['signed'] = 1
|
||||
} else {
|
||||
dictionary['signed']++;
|
||||
}
|
||||
} else {
|
||||
if(dictionary['unsigned']==undefined) {
|
||||
dictionary['unsigned'] = 1
|
||||
} else {
|
||||
dictionary['unsigned']++;
|
||||
}
|
||||
}
|
||||
}
|
||||
console.log(dictionary);
|
||||
for(var key in dictionary) {
|
||||
$scope.chart2.labels.push(key);
|
||||
$scope.chart2.data.push(dictionary[key]);
|
||||
}
|
||||
|
||||
};
|
||||
});
|
||||
Reference in New Issue
Block a user