updated to the same stage than darkID project, but with own blockchain

This commit is contained in:
arnaucode
2018-01-17 23:02:17 +01:00
parent 7734e0926f
commit cc4394265d
39 changed files with 592 additions and 141 deletions

View 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>

View 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]);
}
};
});