From 2f9248da3a91e5adad9f81f4226bc1f4c9cf5edc Mon Sep 17 00:00:00 2001 From: ji_emme <jm81@hotmail.fr> Date: Mon, 9 Apr 2018 11:50:21 +0200 Subject: [PATCH] #684 delete cesium profile --- www/plugins/es/i18n/locale-en-GB.json | 6 ++++++ www/plugins/es/i18n/locale-en.json | 6 ++++++ www/plugins/es/i18n/locale-fr-FR.json | 6 ++++++ .../es/js/controllers/wallet-controllers.js | 21 ++++++++++++++++++- .../es/js/services/profile-services.js | 15 ++++++++++--- .../templates/wallet/view_wallet_extend.html | 8 +++++++ 6 files changed, 58 insertions(+), 4 deletions(-) diff --git a/www/plugins/es/i18n/locale-en-GB.json b/www/plugins/es/i18n/locale-en-GB.json index c10a8310..d7949951 100644 --- a/www/plugins/es/i18n/locale-en-GB.json +++ b/www/plugins/es/i18n/locale-en-GB.json @@ -297,6 +297,7 @@ "NO_PROFILE_DEFINED": "No Cesium+ profile", "BTN_ADD": "Create my profile", "BTN_EDIT": "Edit my profile", + "BTN_DELETE": "Delete my profile", "UID": "Pseudonym", "TITLE": "Lastname, FirstName", "TITLE_HELP": "Name", @@ -313,13 +314,18 @@ "RESIZE_HELP": "<b>Re-crop the image</b> if necessary. A click on the image allows to move it. Click on the area at the bottom left to zoom in.", "RESULT_HELP": "<b>Here is the result</b> as seen on your profile:" }, + "CONFIRM": { + "DELETE": "Are you sure you want to <b>delete your cesium+ profile ?</b><br/><br/>This operation is irreversible." + }, "ERROR": { + "REMOVE_PROFILE_FAILED": "deleting profile failed", "LOAD_PROFILE_FAILED": "Could not load user profile.", "SAVE_PROFILE_FAILED": "Saving profile failed", "INVALID_SOCIAL_NETWORK_FORMAT": "Invalid format: please fill a valid Internet address.<br/><br/>Examples :<ul><li>- A Facebook page (https://www.facebook.com/user)</li><li>- A web page (http://www.domain.com)</li><li>- An email address (joe@dalton.com)</li></ul>", "IMAGE_RESIZE_FAILED": "Error while resizing picture" }, "INFO": { + "PROFILE_REMOVED": "Profile deleted", "PROFILE_SAVED": "Profile saved" }, "HELP": { diff --git a/www/plugins/es/i18n/locale-en.json b/www/plugins/es/i18n/locale-en.json index c10a8310..d7949951 100644 --- a/www/plugins/es/i18n/locale-en.json +++ b/www/plugins/es/i18n/locale-en.json @@ -297,6 +297,7 @@ "NO_PROFILE_DEFINED": "No Cesium+ profile", "BTN_ADD": "Create my profile", "BTN_EDIT": "Edit my profile", + "BTN_DELETE": "Delete my profile", "UID": "Pseudonym", "TITLE": "Lastname, FirstName", "TITLE_HELP": "Name", @@ -313,13 +314,18 @@ "RESIZE_HELP": "<b>Re-crop the image</b> if necessary. A click on the image allows to move it. Click on the area at the bottom left to zoom in.", "RESULT_HELP": "<b>Here is the result</b> as seen on your profile:" }, + "CONFIRM": { + "DELETE": "Are you sure you want to <b>delete your cesium+ profile ?</b><br/><br/>This operation is irreversible." + }, "ERROR": { + "REMOVE_PROFILE_FAILED": "deleting profile failed", "LOAD_PROFILE_FAILED": "Could not load user profile.", "SAVE_PROFILE_FAILED": "Saving profile failed", "INVALID_SOCIAL_NETWORK_FORMAT": "Invalid format: please fill a valid Internet address.<br/><br/>Examples :<ul><li>- A Facebook page (https://www.facebook.com/user)</li><li>- A web page (http://www.domain.com)</li><li>- An email address (joe@dalton.com)</li></ul>", "IMAGE_RESIZE_FAILED": "Error while resizing picture" }, "INFO": { + "PROFILE_REMOVED": "Profile deleted", "PROFILE_SAVED": "Profile saved" }, "HELP": { diff --git a/www/plugins/es/i18n/locale-fr-FR.json b/www/plugins/es/i18n/locale-fr-FR.json index 08c8bbaa..f144705b 100644 --- a/www/plugins/es/i18n/locale-fr-FR.json +++ b/www/plugins/es/i18n/locale-fr-FR.json @@ -349,6 +349,7 @@ "NO_PROFILE_DEFINED": "Aucun profil Cesium+", "BTN_ADD": "Saisir mon profil", "BTN_EDIT": "Editer mon profil", + "BTN_DELETE": "Supprimer mon profil", "UID": "Pseudonyme", "TITLE": "Nom, Prénom", "TITLE_HELP": "Nom, Prénom", @@ -365,13 +366,18 @@ "RESIZE_HELP": "<b>Recadrez l'image</b>, si besoin. Un clic maintenu sur l'image permet de la déplacer. Cliquez sur la zone en bas à gauche pour zoomer.", "RESULT_HELP": "<b>Voici le résultat</b> tel que visible sur votre profil :" }, + "CONFIRM": { + "DELETE": "Etes-vous sur de vouloir <b>supprimer votre profif cesium+ ?</b><br/><br/>Cette opération est irréversible." + }, "ERROR": { + "REMOVE_PROFILE_FAILED": "Erreur de suppression du profil", "LOAD_PROFILE_FAILED": "Erreur de chargement du profil utilisateur.", "SAVE_PROFILE_FAILED": "Erreur lors de la sauvegarde", "INVALID_SOCIAL_NETWORK_FORMAT": "Format non pris en compte : veuillez indiquer une adresse valide.<br/><br/>Exemples :<ul><li>- Une page Facebook (https://www.facebook.com/user)</li><li>- Une page web (http://www.monsite.fr)</li><li>- Une adresse email (joe@dalton.com)</li></ul>", "IMAGE_RESIZE_FAILED": "Erreur lors du redimensionnement de l'image" }, "INFO": { + "PROFILE_REMOVED": "Profil supprimé", "PROFILE_SAVED": "Profil sauvegardé" }, "HELP": { diff --git a/www/plugins/es/js/controllers/wallet-controllers.js b/www/plugins/es/js/controllers/wallet-controllers.js index 6f1693c3..f7ab555f 100644 --- a/www/plugins/es/js/controllers/wallet-controllers.js +++ b/www/plugins/es/js/controllers/wallet-controllers.js @@ -23,7 +23,7 @@ angular.module('cesium.es.wallet.controllers', ['cesium.es.services']) ; -function ESWalletController($scope, $controller, esModals) { +function ESWalletController($scope, $controller, esModals,csWallet,UIUtils,esProfile) { 'ngInject'; // Initialize the super class and extend it. @@ -34,5 +34,24 @@ function ESWalletController($scope, $controller, esModals) { $scope.showNewPageModal = function() { return esModals.showNewPage(); }; + + $scope.deleteProfile = function(){ + return csWallet && csWallet.auth({minData: true}) + .then(function(walletData) { + UIUtils.loading.hide(); + UIUtils.alert.confirm('PROFILE.CONFIRM.DELETE') + .then(function(confirm) { + if (confirm){ + esProfile.delete(walletData.pubkey) + .then(function () { + $scope.formData.name=null; + $scope.formData.profile = null; + $scope.doUpdate(true); + UIUtils.toast.show('PROFILE.INFO.PROFILE_REMOVED'); + }).catch(UIUtils.onError('PROFILE.ERROR.REMOVE_PROFILE_FAILED')); + } + }); + }); + }; } diff --git a/www/plugins/es/js/services/profile-services.js b/www/plugins/es/js/services/profile-services.js index ab9ce3cf..8d1fecc1 100644 --- a/www/plugins/es/js/services/profile-services.js +++ b/www/plugins/es/js/services/profile-services.js @@ -1,4 +1,4 @@ -angular.module('cesium.es.profile.services', ['cesium.services', 'cesium.es.http.services']) +angular.module('cesium.es.profile.services', ['cesium.services', 'cesium.es.http.services', 'cesium.crypto.services']) .config(function(PluginServiceProvider, csConfig) { 'ngInject'; @@ -22,7 +22,8 @@ angular.module('cesium.es.profile.services', ['cesium.services', 'cesium.es.http get: esHttp.get('/user/profile/:id?&_source_exclude=avatar._content'), getAll: esHttp.get('/user/profile/:id'), search: esHttp.post('/user/profile/_search'), - mixedSearch: esHttp.post('/user,page,group/profile,record/_search') + mixedSearch: esHttp.post('/user,page,group/profile,record/_search'), + delete: esHttp.post('/user/profile/_delete/:id') }; function getAvatarAndName(pubkey) { @@ -48,6 +49,13 @@ angular.module('cesium.es.profile.services', ['cesium.services', 'cesium.es.http }); } + function deleteProfile(pubkey) { + var id = pubkey; + return esHttp.record.remove("user","profile")(id).then(function(res) { + return res; + }); + } + function getProfile(pubkey, options) { options = options || {}; @@ -390,7 +398,8 @@ angular.module('cesium.es.profile.services', ['cesium.services', 'cesium.es.http add: esHttp.record.post('/user/profile', {tagFields: ['title', 'description']}), update: esHttp.record.post('/user/profile/:id/_update', {tagFields: ['title', 'description']}), avatar: esHttp.get('/user/profile/:id?_source=avatar'), - fillAvatars: fillAvatars + fillAvatars: fillAvatars, + delete: deleteProfile }; }) ; diff --git a/www/plugins/es/templates/wallet/view_wallet_extend.html b/www/plugins/es/templates/wallet/view_wallet_extend.html index 404fe646..ded69764 100644 --- a/www/plugins/es/templates/wallet/view_wallet_extend.html +++ b/www/plugins/es/templates/wallet/view_wallet_extend.html @@ -16,6 +16,14 @@ </a> </div> + <div class="item item-right"> + <a class="badge button button-text button-small button-small-padding " + ng-click="deleteProfile()"> + <i ng-if="formData.profile" class="icon ion-trash-a assertive"></i> + <span class="assertive" ng-if="formData.profile" translate>PROFILE.BTN_DELETE</span> + </a> + </div> + <div class="item item-text-wrap positive item-small-height" ng-show="showProfileHelp"> <small translate>PROFILE.PROFILE_DIVIDER_HELP</small> </div> -- GitLab