From 500981097bcdc1876faf39c6f61996945b226bb8 Mon Sep 17 00:00:00 2001 From: blavenie <benoit.lavenier@e-is.pro> Date: Sat, 27 May 2017 21:39:19 +0200 Subject: [PATCH] [enh] Add RML9 plugin --- gulpfile.js | 4 +- www/index.html | 3 ++ www/plugins/rml9/i18n/locale-fr-FR.json | 7 ++++ www/plugins/rml9/plugin.js | 54 +++++++++++++++++++++++++ www/plugins/rml9/templates/button.html | 9 +++++ 5 files changed, 74 insertions(+), 3 deletions(-) create mode 100644 www/plugins/rml9/i18n/locale-fr-FR.json create mode 100644 www/plugins/rml9/plugin.js create mode 100644 www/plugins/rml9/templates/button.html diff --git a/gulpfile.js b/gulpfile.js index 6f08d841..cbc1d731 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -43,7 +43,7 @@ var paths = { // plugins: templatecache_plugin: ['./www/plugins/*/templates/**/*.html'], ng_translate_plugin: ['./www/plugins/*/i18n/locale-*.json'], - ng_annotate_plugin: ['./www/plugins/*/js/**/*.js', '!./www/plugins/*/js/vendor/*.js'], + ng_annotate_plugin: ['./www/plugins/*/**/*.js', '!./www/plugins/*/js/vendor/*.js'], css_plugin: ['./www/plugins/*/css/**/*.css'] }; @@ -188,7 +188,6 @@ gulp.task('templatecache_plugin', function (done) { root: "plugins/" })) .pipe(gulp.dest('./www/dist/dist_js/plugins')) - //.pipe(gulp.dest('./www/plugins')) .on('end', done); }); @@ -203,7 +202,6 @@ gulp.task('ng_translate_plugin', function() { return gulp.src(paths.ng_translate_plugin) .pipe(ngTranslate({standalone:true, module: 'cesium.plugins.translations'})) .pipe(gulp.dest('www/dist/dist_js/plugins')); - //.pipe(gulp.dest('www/plugins')); }); gulp.task('css_plugin', function (done) { diff --git a/www/index.html b/www/index.html index fe6a3127..e97277e9 100644 --- a/www/index.html +++ b/www/index.html @@ -166,6 +166,9 @@ <script src="dist/dist_js/plugins/graph/js/controllers/currency-controllers.js"></script> <script src="dist/dist_js/plugins/graph/js/controllers/account-controllers.js"></script> + <!-- RML9 plugin + <script src="dist/dist_js/plugins/rml9/plugin.js"></script>--> + <!--endRemoveIf(no-plugin)--> <!-- App --> diff --git a/www/plugins/rml9/i18n/locale-fr-FR.json b/www/plugins/rml9/i18n/locale-fr-FR.json new file mode 100644 index 00000000..c20b5b06 --- /dev/null +++ b/www/plugins/rml9/i18n/locale-fr-FR.json @@ -0,0 +1,7 @@ +{ + "RML9": { + "WALLET": { + "BTN_EXPORT": "Exporter les transactions", + } + } +} diff --git a/www/plugins/rml9/plugin.js b/www/plugins/rml9/plugin.js new file mode 100644 index 00000000..b1f9b687 --- /dev/null +++ b/www/plugins/rml9/plugin.js @@ -0,0 +1,54 @@ + +angular.module('cesium.rml9.plugin', ['cesium.services']) + + .config(function($stateProvider, PluginServiceProvider, csConfig) { + 'ngInject'; + + var enable = true; // csConfig.plugins && csConfig.plugins.rml9; + if (enable) { + + PluginServiceProvider + .extendState('app.view_wallet_tx', { + points: { + 'buttons': { + templateUrl: "plugins/rml9/templates/button.html", + controller: 'Rml9Ctrl' + } + } + }) + ; + } + }) + + /** + * Les controlleurs sont chargés de gérer faire la liaison entre les services d'accès aux données, et l'interface graphique. + * + * Celui-ci sert à étendre la page 'Mes opérations' + */ + .controller('Rml9Ctrl', function($scope, $state, PluginService, FileSaver, BMA, csWallet) { + 'ngInject'; + + $scope.extensionPoint = PluginService.extensions.points.current.get(); + + // Manage click on the export button + $scope.onButtonClick = function() { + + var pubkey = csWallet.data.pubkey; + + BMA.tx.history.all({pubkey: pubkey}) + .then(function(res){ + if (!res || !res.history) return; + console.log(res.history); + + /*var allTx = res.history.received.reduce(function(allTx, tx){ + return res.concat(tx.); + }, []);*/ + + //var saveIdFile = new Blob(["THis is a content"], {type: 'text/plain; charset=utf-8'}); + //FileSaver.saveAs(saveIdFile, 'transactions.txt'); + }); + }; + } +); + + diff --git a/www/plugins/rml9/templates/button.html b/www/plugins/rml9/templates/button.html new file mode 100644 index 00000000..f996275f --- /dev/null +++ b/www/plugins/rml9/templates/button.html @@ -0,0 +1,9 @@ +<!-- Buttons section --> +<ng-if ng-if="extensionPoint === 'buttons'"> + + <button class="button button-stable button-small-padding icon ion-android-archive" + ng-click="onButtonClick()" + title="{{'RML9.WALLET.BTN_EXPORT' | translate}}"> + </button> + +</ng-if> -- GitLab