diff --git a/www/js/config.js b/www/js/config.js index 2221ba573ba946c0d7a0c76576680dfc6e8e6c34..7cf7dfe5d0f42002fbe48dea6f80a1b65acd7002 100644 --- a/www/js/config.js +++ b/www/js/config.js @@ -70,7 +70,7 @@ angular.module("cesium.config", []) } }, "version": "0.18.3", - "build": "2017-10-20T17:44:25.876Z", + "build": "2017-10-20T18:07:51.522Z", "newIssueUrl": "https://github.com/duniter/cesium/issues/new?labels=bug" }) diff --git a/www/plugins/es/i18n/locale-fr-FR.json b/www/plugins/es/i18n/locale-fr-FR.json index 36ff7cc538f7625ab15a22aabd3754fb12c7a2b9..34cdb2f66700cbce95fe4dce3b20212e1a0fb865 100644 --- a/www/plugins/es/i18n/locale-fr-FR.json +++ b/www/plugins/es/i18n/locale-fr-FR.json @@ -426,6 +426,7 @@ "HEADER_ISSUER": "Emetteur", "HEADER_RECIPIENT": "Destinataire", "READ": "Lu", + "BTN_REMOVE": "Supprimer ce document", "POPOVER_ACTIONS": { "TITLE": "Actions", "REMOVE_ALL": "Supprimer ces documents..." diff --git a/www/plugins/es/js/controllers/document-controllers.js b/www/plugins/es/js/controllers/document-controllers.js index f16187b566bf69405bc4781d6c6377aece9c6883..f2274f6c109e45a2b5441172274142259b383715 100644 --- a/www/plugins/es/js/controllers/document-controllers.js +++ b/www/plugins/es/js/controllers/document-controllers.js @@ -126,10 +126,17 @@ function ESDocumentLookupController($scope, $ionicPopover, $location, $timeout, return UIUtils.alert.confirm('DOCUMENT.CONFIRM.REMOVE_ALL') .then(function(confirm) { - if (confirm) { - return esDocument.removeAll($scope.search.results) - .catch(UIUtils.onError('DOCUMENT.ERROR.REMOVE_ALL_FAILED')); - } + if (!confirm) return; + UIUtils.loading.show(); + return esDocument.removeAll($scope.search.results) + .then(function() { + $scope.search.loading = false; + return $timeout(function() { + UIUtils.toast.show('DOCUMENT.INFO.REMOVED'); // toast + return $scope.load(); + }, 1000 /*waiting propagation*/); + }) + .catch(UIUtils.onError('DOCUMENT.ERROR.REMOVE_ALL_FAILED')); }); }; @@ -139,14 +146,14 @@ function ESDocumentLookupController($scope, $ionicPopover, $location, $timeout, UIUtils.alert.confirm('DOCUMENT.CONFIRM.REMOVE') .then(function(confirm) { - if (confirm) { - esDocument.remove(doc) - .then(function () { - $scope.search.results.splice(index,1); // remove from messages array - UIUtils.toast.show('DOCUMENT.INFO.REMOVED'); - }) - .catch(UIUtils.onError('MESSAGE.ERROR.REMOVE_FAILED')); - } + if (!confirm) return; + return esDocument.remove(doc) + .then(function () { + $scope.search.results.splice(index,1); // remove from messages array + $scope.$broadcast('$$rebind::rebind'); // notify binder + UIUtils.toast.show('DOCUMENT.INFO.REMOVED'); // toast + }) + .catch(UIUtils.onError('MESSAGE.ERROR.REMOVE_FAILED')); }); }; diff --git a/www/plugins/es/js/controllers/profile-controllers.js b/www/plugins/es/js/controllers/profile-controllers.js index 1a572d1b09a37867eb565e45724dae371051067f..3ca009adb1bd3938adb9986649b5095e5831fb4c 100644 --- a/www/plugins/es/js/controllers/profile-controllers.js +++ b/www/plugins/es/js/controllers/profile-controllers.js @@ -225,7 +225,7 @@ function ESViewEditProfileController($scope, $rootScope, $q, $timeout, $state, $ // Workaround for old data if (formData.position) { - delete formData.position; + formData.position = null; } if (formData.geoPoint && formData.geoPoint.lat && formData.geoPoint.lon) { formData.geoPoint.lat = parseFloat(formData.geoPoint.lat); diff --git a/www/plugins/es/js/services/document-services.js b/www/plugins/es/js/services/document-services.js index 24bf8eceb506d24ba4b52831fdeaeaaf3578df31..7270bf180bf4cfcef0f894a9dec0329f4b6166bf 100644 --- a/www/plugins/es/js/services/document-services.js +++ b/www/plugins/es/js/services/document-services.js @@ -20,7 +20,8 @@ angular.module('cesium.es.document.services', ['ngResource', 'cesium.platform', }, fields = { commons: ["issuer", "pubkey", "hash", "time", "recipient", "nonce", "read_signature"], - peer: ["*"] + peer: ["*"], + movement: ["*"] }, raw = { search: esHttp.post('/:index/:type/_search'), @@ -64,7 +65,7 @@ angular.module('cesium.es.document.services', ['ngResource', 'cesium.platform', function search(options) { options = options || {}; - if (options.type == 'peer') { + if (options.type == 'movement') { if (!options.sort) { options.sort = 'stats.medianTime:desc'; } @@ -80,10 +81,32 @@ angular.module('cesium.es.document.services', ['ngResource', 'cesium.platform', ]; options._source = fields.peer; options.getTimeFunction = function(doc) { - return doc.stats && doc.stats.medianTime; + doc.time = doc.stats && doc.stats.medianTime; + return doc.time; }; } } + else if (options.type == 'movement') { + if (!options.sort) { + options.sort = 'medianTime:desc'; + } + else { + var sortParts = options.sort.split(':'); + var side = sortParts.length > 1 ? sortParts[1] : 'desc'; + + options.sort = [ + {'medianTime': { + order: side + }} + ]; + options._source = fields.movement; + options.getTimeFunction = function(doc) { + doc.time = doc.medianTime; + return doc.time; + }; + } + } + if (!options || !options.index || !options.type) throw new Error('Missing mandatory options [index, type]'); var request = { @@ -141,7 +164,7 @@ angular.module('cesium.es.document.services', ['ngResource', 'cesium.platform', } function remove(document) { - if (document || !document.index || !document.type || !document.id) return; + if (!document || !document.index || !document.type || !document.id) return $q.reject('Could not remove document: missing mandatory fields'); return esHttp.record.remove(document.index, document.type)(document.id); } diff --git a/www/plugins/es/js/services/http-services.js b/www/plugins/es/js/services/http-services.js index 4de5bf99083e41b43e4441502d93572cd6511732..74654c4123f70cd1bff4c9da595db79690371494 100644 --- a/www/plugins/es/js/services/http-services.js +++ b/www/plugins/es/js/services/http-services.js @@ -258,6 +258,9 @@ angular.module('cesium.es.http.services', ['ngResource', 'ngApi', 'cesium.servic delete obj.signature; delete obj.hash; obj.issuer = walletData.pubkey; + if (!obj.version) { + obj.version = 2; + } // Fill tags if (options.tagFields) { @@ -268,11 +271,13 @@ angular.module('cesium.es.http.services', ['ngResource', 'ngApi', 'cesium.servic return CryptoUtils.util.hash(str) .then(function(hash) { - return CryptoUtils.sign(str, walletData.keypair) + return CryptoUtils.sign(hash, walletData.keypair) .then(function(signature) { obj.hash = hash; obj.signature = signature; - return postRequest(obj, params) + str = '{"hash":"' + hash + '","signature":"' + signature + '",' + + str.substring(1); + return postRequest(str, params) .then(function (id){ return id; }); @@ -288,6 +293,7 @@ angular.module('cesium.es.http.services', ['ngResource', 'ngApi', 'cesium.servic .then(function(walletData) { var obj = { + version: 2, index: index, type: type, id: id, @@ -297,7 +303,7 @@ angular.module('cesium.es.http.services', ['ngResource', 'ngApi', 'cesium.servic var str = JSON.stringify(obj); return CryptoUtils.util.hash(str) .then(function (hash) { - return CryptoUtils.sign(str, walletData.keypair) + return CryptoUtils.sign(hash, walletData.keypair) .then(function (signature) { obj.hash = hash; obj.signature = signature; diff --git a/www/plugins/es/templates/document/item_document.html b/www/plugins/es/templates/document/item_document.html index b2698d1e22258fd0f0e7316bc079b89848343f58..9f5eaf60f4e3affa9e5bbafcc24e26b311284cc6 100644 --- a/www/plugins/es/templates/document/item_document.html +++ b/www/plugins/es/templates/document/item_document.html @@ -28,6 +28,13 @@ </div> <div class="col"> + <a + ng-if=":rebind:login && doc.pubkey==$root.walletData.pubkey" + ng-click="remove($index)" + class="gray pull-right" + title="{{'DOCUMENT.LOOKUP.BTN_REMOVE'|translate}}"> + <i class="ion-trash-a"></i> + </a> <h3 ng-if=":rebind:doc.recipient"> <a ui-sref="app.wot_identity({pubkey: doc.recipient.pubkey, uid: doc.recipient.uid})"> <span class="gray"> diff --git a/www/plugins/es/templates/document/lookup_form.html b/www/plugins/es/templates/document/lookup_form.html index b0d2f504412767a6feb0c0dfdbdb464940ab2a6c..c940bdd646ded8d9a13935fa0946441a275adcfc 100644 --- a/www/plugins/es/templates/document/lookup_form.html +++ b/www/plugins/es/templates/document/lookup_form.html @@ -67,6 +67,7 @@ <div class=" pull-right hidden-xs hidden-sm"> <a class="button button-text button-small ink" + ng-if="login" ng-click="showActionsPopover($event)"> {{'DOCUMENT.LOOKUP.BTN_ACTIONS' | translate}} <i class="icon ion-arrow-down-b"></i> diff --git a/www/plugins/es/templates/registry/edit_record.html b/www/plugins/es/templates/registry/edit_record.html index 9660fecc2a7c930865bc320be3431e922e3acc35..278641dca806fd978d4b77e17772a8bf519f2c16 100644 --- a/www/plugins/es/templates/registry/edit_record.html +++ b/www/plugins/es/templates/registry/edit_record.html @@ -112,8 +112,6 @@ </div> </div> - <div class="item item-divider" translate>REGISTRY.LOCATION_DIVIDER</div> - <!-- position --> <ng-include src="'plugins/es/templates/common/edit_position.html'"></ng-include>