diff --git a/www/plugins/es/i18n/locale-en-GB.json b/www/plugins/es/i18n/locale-en-GB.json index c10a831035769362eea079603a80798a515abece..d794995151f4ef398a20c9ed41634758837a447f 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 c10a831035769362eea079603a80798a515abece..d794995151f4ef398a20c9ed41634758837a447f 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 08c8bbaa48bd58c7b69ad3f3c91c9fec19fc54ba..f144705b5bb5cbe113123c7c726cd6253941a3fa 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 6f1693c3bcc9d969c15f25fe314e592a02944dfe..f7ab555f11b7d9d87ac966dc1ac8a3b2197339ce 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 ab9ce3cfa66bae8790f2014a4e8913f89387c781..8d1fecc152cbd4b7700b48271f5ef5a51872580a 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 404fe6469aac60cb5c77ed9476886c844c79d722..ded69764e967322e7d447df582cc103400b09480 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>