Skip to content
Snippets Groups Projects
Commit 6cf344f9 authored by ArnaudCerisier's avatar ArnaudCerisier
Browse files

fix RML9 plugin final version

parent eb589eee
No related branches found
No related tags found
No related merge requests found
......@@ -6,6 +6,7 @@
// 'starter.controllers' is found in controllers.js
angular.module('cesium', ['ionic', 'ionic-material', 'ngMessages', 'pascalprecht.translate',
'ngApi', 'angular-cache', 'angular.screenmatch', 'angular.bind.notifier','ImageCropper', 'ngFileSaver',
//'ui-leaflet',
// removeIf(no-device)
'ngCordova',
// endRemoveIf(no-device)
......@@ -394,7 +395,7 @@ angular.module('cesium', ['ionic', 'ionic-material', 'ngMessages', 'pascalprecht
// removeIf(firefoxos)
// Automatic redirection to large state (if define) (keep this code for platforms web and ubuntu build)
$rootScope.$on('$stateChangeStart', function (event, next, nextParams, fromState) {
if (next.data.large && !UIUtils.screen.isSmall()) {
if (next.data && next.data.large && !UIUtils.screen.isSmall()) {
var redirect = !$rootScope.tour && !event.currentScope.tour; // disabled for help tour
if (redirect) {
event.preventDefault();
......@@ -408,7 +409,7 @@ angular.module('cesium', ['ionic', 'ionic-material', 'ngMessages', 'pascalprecht
// removeIf(device)
// Automatic redirection to HTTPS
if ((csConfig.httpsMode === true || csConfig.httpsMode == 'true' ||csConfig.httpsMode === 'force') &&
if ((csConfig.httpsMode == true || csConfig.httpsMode === 'force') &&
$window.location.protocol != 'https:') {
$rootScope.$on('$stateChangeStart', function (event, next, nextParams, fromState) {
var path = 'https' + $rootScope.rootPath.substr(4) + $state.href(next, nextParams);
......
......@@ -72,7 +72,7 @@ angular.module('cesium.bma.services', ['ngResource', 'ngApi', 'cesium.http.servi
that.cache = _emptyCache();
// 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;
if (forceUseSsl) {
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
_.forEach(txArray, function (tx) {
sumByPubkeys[tx.pubkey] = sumByPubkeys[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
var sumItems = _.sortBy(_.values(sumByPubkeys), 'sum').reverse();
var sumItems = _.sortBy(_.values(sumByPubkeys), 'amount').reverse();
// Return arrays expected by angular-chart
return {
data: _.pluck(sumItems, 'sum'),
data: _.pluck(sumItems, 'amount'),
labels: _.pluck(sumItems, 'label'),
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) {
// Extension de la vue d'une identité: ajout d'un bouton
PluginServiceProvider
.extendState('app.wot_identity', {
points: {
'buttons': {
templateUrl: "plugins/rml9/templates/01-button.html",
controller: 'Rml9ButtonCtrl'
}
}
});
// Extension de 'Mes opérations' : insertion d'un bouton
PluginServiceProvider.extendState('app.view_wallet_tx', {
points: {
'buttons': {
templateUrl: "plugins/rml9/templates/01-button.html",
controller: 'Rml9ButtonCtrl'
}
}
});
// [NEW] Ajout d'une nouvelle page #/app/rml9
$stateProvider
.state('app.rml9', {
url: "/rml9/:pubkey",
views: {
'menuContent': {
templateUrl: "plugins/rml9/templates/02-view.html",
controller: 'Rml9ViewCtrl'
}
}
});
}
})
// Manage events from the plugin button
.controller('Rml9ButtonCtrl', function($scope, $state) {
'ngInject';
// Manage click event, on the plugin button
$scope.onButtonClick = function() {
// [Get the public key, from the page context ($scope.formData)
var pubkey = $scope.formData.pubkey;
if (!pubkey) return;
console.debug("[RML9] call method onButtonClick() on pubkey: " + pubkey);
// [NEW] Open the RML9 view (#/app/rml9)
$state.go('app.rml9', {pubkey: pubkey});
};
})
// [NEW] Manage events from the page #/app/rml9
.controller('Rml9ViewCtrl', function($scope, csTx) {
'ngInject';
// [NEW] When opening the view
$scope.$on('$ionicView.enter', function(e, state) {
console.log("[RML9] Opening the view...");
// [NEW] Get the pubkey (from URL params) and store it in the page context ($scope)
$scope.pubkey = (state && state.stateParams && state.stateParams.pubkey);
if (!$scope.pubkey) return;
// [NEW] Create some data to display
// Load account TX data
csTx.load($scope.pubkey) // <- appel au service csTx
.then(function(result) {
console.log(result); // Allow to discover data structure
if (result && result.tx && result.tx.history) {
$scope.items = result.tx.history;
}
});
});
});
<!-- [NEW] Display only if plugin is enable -->
<ng-if ng-if="enable">
<!-- 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()"
title="{{'RML9.BTN_SWOW_TX' | translate}}">
</button>
</ng-if>
<!-- [NEW] Display only if plugin is enable -->
<!-- Button: call a method from the state controller -->
<button ng-if="enable" class="button button-balanced button-small-padding icon ion-android-archive"
ng-click="onButtonClick()"
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">
<!-- the pubkey -->
<div class="item">
{{'COMMON.PUBKEY'|translate}}
<div class="badge">{{pubkey|formatPubkey}}</div>
</div>
<!-- a text divider-->
<div class="item item-divider">{{'RML9.VIEW.DIVIDER'|translate:{pubkey: pubkey} }}</div>
<!-- iterate on each TX -->
<div class="item" ng-repeat="item in items">
<h3>{{item.time|formatDate}}</h3>
<h4>{{item.pubkey|formatPubkey}}</h4>
<div class="badge">{{item.amount|formatAmount}}</div>
</div>
</div>
</ion-content>
</ion-view>
<!-- 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.
Finish editing this message first!
Please register or to comment