Skip to content
Snippets Groups Projects
Commit c7c39c4a authored by Benoit Lavenier's avatar Benoit Lavenier
Browse files

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	www/js/app.js
parents 4bd0e34f c1cdc28a
No related branches found
No related tags found
No related merge requests found
...@@ -12,14 +12,8 @@ ...@@ -12,14 +12,8 @@
/www/css/ionic.app.css /www/css/ionic.app.css
/www/css/ionic.app.min.css /www/css/ionic.app.min.css
/www/lib/angular /www/lib/*
/www/lib/angular-animate !/www/lib/ionic
/www/lib/angular-messages
/www/lib/angular-sanitize
/www/lib/angular-ui-router
/www/lib/angular-moment
/www/lib/moment
/www/lib/waves
/www/js/config.js /www/js/config.js
/www/dist /www/dist
/hooks/playstore-config.json /hooks/playstore-config.json
......
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
<script src="js/vendor/socket-io.js"></script> <script src="js/vendor/socket-io.js"></script>
<script src="js/vendor/underscore.js"></script> <script src="js/vendor/underscore.js"></script>
<script src="js/vendor/qrcode.min.js"></script> <script src="js/vendor/qrcode.min.js"></script>
<!--<script src="lib/leaflet/dist/leaflet.js"></script>-->
<!--removeIf(ubuntu)--> <!-- FIXME: issue #463 --> <!--removeIf(ubuntu)--> <!-- FIXME: issue #463 -->
<script src="js/vendor/Chart.js"></script> <script src="js/vendor/Chart.js"></script>
<!--endRemoveIf(ubuntu)--> <!--endRemoveIf(ubuntu)-->
...@@ -53,6 +54,11 @@ ...@@ -53,6 +54,11 @@
<script src="lib/ionic/js/angular/angular-image-crop.js"></script> <script src="lib/ionic/js/angular/angular-image-crop.js"></script>
<script src="lib/ionic/js/angular/angular-file-saver.bundle.js"></script> <script src="lib/ionic/js/angular/angular-file-saver.bundle.js"></script>
<script src="lib/ionic/js/angular/angular-idle.js"></script> <script src="lib/ionic/js/angular/angular-idle.js"></script>
<!-- Need to leaflet
<script src="lib/angular-simple-logger/dist/angular-simple-logger.js"></script>
<script src="lib/ui-leaflet/dist/ui-leaflet.js"></script>-->
<!--removeIf(ubuntu)--> <!-- FIXME: issue #463 --> <!--removeIf(ubuntu)--> <!-- FIXME: issue #463 -->
<script src="lib/ionic/js/angular/angular-chart.min.js"></script> <script src="lib/ionic/js/angular/angular-chart.min.js"></script>
<!--endRemoveIf(ubuntu)--> <!--endRemoveIf(ubuntu)-->
...@@ -182,9 +188,10 @@ ...@@ -182,9 +188,10 @@
<!--<script src="dist/dist_js/plugins/rml9/plugin-01-add_button.js"></script>--> <!--<script src="dist/dist_js/plugins/rml9/plugin-01-add_button.js"></script>-->
<!--<script src="dist/dist_js/plugins/rml9/plugin-02-add_view.js"></script>--> <!--<script src="dist/dist_js/plugins/rml9/plugin-02-add_view.js"></script>-->
<!--<script src="dist/dist_js/plugins/rml9/plugin-03-file_export.js"></script>--> <!--<script src="dist/dist_js/plugins/rml9/plugin-03-file_export.js"></script>-->
<!--script src="dist/dist_js/plugins/rml9/plugin-04-chart.js"></script--> <!--<script src="dist/dist_js/plugins/rml9/plugin-04-chart.js"></script>-->
<!--<script src="dist/dist_js/plugins/rml9/plugin-05-service_api.js"></script>--> <!--<script src="dist/dist_js/plugins/rml9/plugin-05-service_api.js"></script>-->
<!--<script src="dist/dist_js/plugins/rml9/plugin-06-settings.js"></script>--> <!--<script src="dist/dist_js/plugins/rml9/plugin-06-settings.js"></script>-->
<!--<script src="dist/dist_js/plugins/rml9/plugin-07-add_map.js"></script>-->
<!--<script src="dist/dist_js/plugins/rml9/plugin-final.js"></script>--> <!--<script src="dist/dist_js/plugins/rml9/plugin-final.js"></script>-->
<!--endRemoveIf(no-plugin)--> <!--endRemoveIf(no-plugin)-->
......
...@@ -72,7 +72,7 @@ angular.module('cesium.bma.services', ['ngApi', 'cesium.http.services', 'cesium. ...@@ -72,7 +72,7 @@ angular.module('cesium.bma.services', ['ngApi', 'cesium.http.services', 'cesium.
that.cache = _emptyCache(); that.cache = _emptyCache();
// Allow to force SSL connection with port different from 443 // Allow to force SSL connection with port different from 443
var forceUseSsl = (csConfig.httpsMode === true || csConfig.httpsMode == 'true' ||csConfig.httpsMode === 'force') || var forceUseSsl = (csConfig.httpsMode == true || csConfig.httpsMode === 'force') ||
($window.location && $window.location.protocol === 'https:') ? true : false; ($window.location && $window.location.protocol === 'https:') ? true : false;
if (forceUseSsl) { if (forceUseSsl) {
console.debug('[BMA] Enable SSL (forced by config or detected in URL)'); console.debug('[BMA] Enable SSL (forced by config or detected in URL)');
......
...@@ -87,17 +87,17 @@ angular.module('cesium.rml9.plugin', ['chart.js', 'cesium.graph.services', 'cesi ...@@ -87,17 +87,17 @@ angular.module('cesium.rml9.plugin', ['chart.js', 'cesium.graph.services', 'cesi
_.forEach(txArray, function (tx) { _.forEach(txArray, function (tx) {
sumByPubkeys[tx.pubkey] = sumByPubkeys[tx.pubkey] || { sumByPubkeys[tx.pubkey] = sumByPubkeys[tx.pubkey] || {
label: tx.uid || tx.pubkey, label: tx.uid || tx.pubkey,
sum: 0 amount: 0
}; };
sumByPubkeys[tx.pubkey].sum += tx.amount; sumByPubkeys[tx.pubkey].amount += tx.amount;
}); });
// Get values (from the map), then sort (desc) on sum // Get values (from the map), then sort (desc) on sum
var sumItems = _.sortBy(_.values(sumByPubkeys), 'sum').reverse(); var sumItems = _.sortBy(_.values(sumByPubkeys), 'amount').reverse();
// Return arrays expected by angular-chart // Return arrays expected by angular-chart
return { return {
data: _.pluck(sumItems, 'sum'), data: _.pluck(sumItems, 'amount'),
labels: _.pluck(sumItems, 'label'), labels: _.pluck(sumItems, 'label'),
colors: gpColor.scale.custom(sumItems.length) colors: gpColor.scale.custom(sumItems.length)
}; };
......
angular.module('cesium.rml9.plugin', ['cesium.services'])
.config(function($stateProvider, PluginServiceProvider, csConfig) {
'ngInject';
var enable = csConfig.plugins && csConfig.plugins.rml9;
if (enable) {
PluginServiceProvider
// Extension de la vue d'une identité: ajout d'un bouton
.extendState('app.wot_identity', {
points: {
'buttons': {
templateUrl: "plugins/rml9/templates/07-button.html"
}
}
})
// Extension de 'Mes opérations' : insertion d'un bouton
.extendState('app.view_wallet_tx', {
points: {
'buttons': {
templateUrl: "plugins/rml9/templates/07-button.html"
}
}
});
// [NEW] Ajout d'une nouvelle page #/app/rml9
$stateProvider
.state('app.rml9', {
url: "/rml9/:pubkey",
views: {
'menuContent': {
templateUrl: "plugins/rml9/templates/07-view.html",
controller: 'Rml9ViewCtrl'
}
}
});
}
})
// [NEW] Manage events from the page #/app/rml9
.controller('Rml9ViewCtrl', function($scope) {
'ngInject';
$scope.map = {
center: {
lat: 37.26,
lng: 138.86,
zoom: 4
},
defaults: {
scrollWheelZoom: false
}
};
var data = {
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [125.6, 10.1]
},
"properties": {
"name": "Dinagat Islands"
}
};
$scope.map.geojson ={
data: data,
style: {
fillColor: "green",
weight: 2,
opacity: 1,
color: 'white',
dashArray: '3',
fillOpacity: 0.7
}
};
// [NEW] When opening the view
$scope.$on('$ionicView.enter', function(e, state) {
console.log("[RML9] Opening the view...");
});
});
...@@ -31,7 +31,7 @@ angular.module('cesium.rml9.plugin', ['cesium.services']) ...@@ -31,7 +31,7 @@ angular.module('cesium.rml9.plugin', ['cesium.services'])
.extendState('app.settings', { .extendState('app.settings', {
points: { points: {
'plugins': { 'plugins': {
templateUrl: "plugins/rml9/templates/04-settings_item.html" templateUrl: "plugins/rml9/templates/06-settings_item.html"
} }
} }
}); });
...@@ -42,7 +42,7 @@ angular.module('cesium.rml9.plugin', ['cesium.services']) ...@@ -42,7 +42,7 @@ angular.module('cesium.rml9.plugin', ['cesium.services'])
url: "/rml9/:pubkey", url: "/rml9/:pubkey",
views: { views: {
'menuContent': { 'menuContent': {
templateUrl: "plugins/rml9/templates/03-view_with_button.html", templateUrl: "plugins/rml9/templates/final-view.html",
controller: 'Rml9ViewCtrl' controller: 'Rml9ViewCtrl'
} }
} }
...@@ -52,9 +52,7 @@ angular.module('cesium.rml9.plugin', ['cesium.services']) ...@@ -52,9 +52,7 @@ angular.module('cesium.rml9.plugin', ['cesium.services'])
}) })
// [NEW] Manage events from the page #/app/rml9 // [NEW] Manage events from the page #/app/rml9
.controller('Rml9ViewCtrl', function($scope, csTx, .controller('Rml9ViewCtrl', function($scope, csTx, FileSaver, gpColor) {
// [NEW] declare an AngularJS plugin, useful to create file
FileSaver) {
'ngInject'; 'ngInject';
// When opening the view // When opening the view
...@@ -71,7 +69,14 @@ angular.module('cesium.rml9.plugin', ['cesium.services']) ...@@ -71,7 +69,14 @@ angular.module('cesium.rml9.plugin', ['cesium.services'])
console.log(result); // Allow to discover data structure console.log(result); // Allow to discover data structure
if (result && result.tx && result.tx.history) { if (result && result.tx && result.tx.history) {
$scope.items = result.tx.history; $scope.items = result.tx.history;
$scope.items = result && result.tx && result.tx.history || [];
// Charts data
$scope.inputChart = $scope.computeChartData(_.filter(result.tx.history, function(tx) {
return tx.amount > 0;
}));
$scope.outputChart = $scope.computeChartData(_.filter(result.tx.history, function(tx) {
return tx.amount < 0;
}));
} }
// [NEW] store the account balance // [NEW] store the account balance
...@@ -90,19 +95,46 @@ angular.module('cesium.rml9.plugin', ['cesium.services']) ...@@ -90,19 +95,46 @@ angular.module('cesium.rml9.plugin', ['cesium.services'])
if (!result || !result.tx || !result.tx.history) return; // no TX if (!result || !result.tx || !result.tx.history) return; // no TX
// TODO: replace this ! var headers = ['time', 'issuer', 'amount', 'comment'];
// You can choose any format (CSV, TXT, JSON, ...) and test it ! var content = result.tx.history.reduce(function(res, tx){
var content = [ return res.concat([
"Hello Libre World !\n", tx.time,
"Cesium rock's !\n" tx.pubkey,
]; (''+tx.amount/100).replace('.',','),
tx.comment
].join(';') + '\n');
}, [headers.join(';') + '\n']);
var file = new Blob(content, {type: 'text/plain; charset=utf-8'}); var file = new Blob(content, {type: 'text/plain; charset=utf-8'});
var filename = $scope.pubkey+'-history.txt'; var filename = $scope.pubkey+'-history.csv';
FileSaver.saveAs(file, filename); FileSaver.saveAs(file, filename);
}); });
}; };
// Load chart data: received amount by pubkey
$scope.computeChartData = function(txArray) {
// Sum TX amount, with a group by pubkey
var sumByPubkeys = {};
_.forEach(txArray, function (tx) {
sumByPubkeys[tx.pubkey] = sumByPubkeys[tx.pubkey] || {
label: tx.uid || tx.pubkey,
sum: 0
};
sumByPubkeys[tx.pubkey].sum += tx.amount;
});
// Get values (from the map), then sort (desc) on sum
var sumItems = _.sortBy(_.values(sumByPubkeys), 'sum').reverse();
// Return arrays expected by angular-chart
return {
data: _.pluck(sumItems, 'sum'),
labels: _.pluck(sumItems, 'label'),
colors: gpColor.scale.custom(sumItems.length)
};
};
}); });
<!-- [NEW] Display only if plugin is enable --> <!-- [NEW] Display only if plugin is enable -->
<ng-if ng-if="enable">
<!-- Button: call a method from the state controller --> <!-- Button: call a method from the state controller -->
<button class="button button-balanced button-small-padding icon ion-android-archive" <button ng-if="enable" class="button button-balanced button-small-padding icon ion-android-archive"
ng-click="onButtonClick()" ng-click="onButtonClick()"
title="{{'RML9.BTN_SWOW_TX' | translate}}"> title="{{'RML9.BTN_SWOW_TX' | translate}}">
</button> </button>
</ng-if>
<!-- Button: Open a view, using `ui-sref` attribute -->
<button class="button button-balanced button-small-padding icon ion-android-archive"
ui-sref="app.rml9({pubkey: formData.pubkey})"
title="{{'RML9.BTN_SWOW_TX' | translate}}">
</button>
<leaflet id="map-geojson" center="map.center" geojson="map.geojson"></leaflet>
<!-- Button: Open a view, using `ui-sref` attribute -->
<button ng-if class="button button-balanced button-small-padding icon ion-android-archive"
ui-sref="app.rml9({pubkey: formData.pubkey})"
title="{{'RML9.BTN_SWOW_TX' | translate}}">
</button>
<ion-view left-buttons="leftButtons">
<ion-nav-title>
{{'RML9.VIEW.TITLE' | translate}}
</ion-nav-title>
<ion-content>
<div class="list">
<!-- buttons bar -->
<div class="center padding">
<div class="buttons">
<button class="button button-balanced icon-left icon ion-archive"
ng-click="onExportButtonClick()">{{'RML9.BTN_EXPORT' | translate}}
</button>
</div>
</div>
<!-- the pubkey -->
<div class="item">
{{'COMMON.PUBKEY'|translate}}
<div class="badge">{{pubkey|formatPubkey}}</div>
</div>
<!-- the balance -->
<div class="item">
{{'RML9.VIEW.BALANCE'|translate}}
<div class="badge badge-calm">
{{balance|formatAmount}} <span ng-bind-html="$root.currency.name|currencySymbol"></span>
</div>
</div>
<!-- a text divider-->
<div class="item item-divider">{{'RML9.VIEW.DIVIDER'|translate:{pubkey: pubkey} }}</div>
<!-- iterate on each TX -->
<div class="row">
<div class="col col-75">
<div class="item item-text-wrap" ng-repeat="item in items">
<h3>
{{item.time|formatDate}}
<span ng-if="item.comment" class="gray"> | {{item.comment}}</span>
</h3>
<h4 ng-if="item.uid" class="positive"><i class="icon ion-person"></i> {{item.name||item.uid}}</h4>
<h4 ng-if="!item.uid" class="gray"><i class="icon ion-key"></i> {{item.pubkey|formatPubkey}}</h4>
<div class="badge"
ng-class="{'badge-balanced': item.amount > 0}">
{{item.amount|formatAmount}} <span ng-bind-html="$root.currency.name|currencySymbol"></span>
</div>
</div>
</div>
<div class="col col-25">
<!-- [NEW] TX input chart -->
<p class="gray" translate>RML9.CHART.INPUT_CHART_TITLE</p>
<canvas id="chart-received-pie" class="chart-pie"
chart-data="inputChart.data"
chart-labels="inputChart.labels">
</canvas>
<!-- [NEW] TX input chart -->
<p class="gray" translate>RML9.CHART.OUTPUT_CHART_TITLE</p>
<canvas id="chart-sent-pie" class="chart-pie"
chart-data="outputChart.data"
chart-labels="outputChart.labels">
</canvas>
</div>
</div>
</div>
</ion-content>
</ion-view>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment