Commit 70a26899 authored by Benoit Lavenier's avatar Benoit Lavenier

[enh] Market record: tap on pictures zoom (large screen)

[fix] read outbox messages
[fix] message: update list on delete or new message
parent faa22d85
......@@ -1155,10 +1155,11 @@ a.underline:hover,
margin-bottom: 15px !important;
float: left;
display: block;
}
/*img {
max-height: 150px;
}*/
.gallery.gallery-small .card-gallery img,
.gallery.gallery-small .card.card-gallery img{
max-height: 150px;
}
.gallery .card-gallery-new {
......
......@@ -43,7 +43,7 @@ angular.module("cesium.config", [])
}
},
"version": "0.6.4",
"build": "2018-01-15T18:03:46.259Z",
"build": "2018-01-26T09:50:45.385Z",
"newIssueUrl": "https://github.com/duniter-gchange/gchange-client/issues/new?labels=bug"
})
......
......@@ -141,6 +141,9 @@ angular.module('cesium.wallet.services', ['ngApi', 'ngFileSaver', 'cesium.bma.se
// Send logout event
api.data.raise.logout();
// Send unauth event (compat with new Cesium auth)
api.data.raise.unauth();
resolve();
});
},
......@@ -149,6 +152,20 @@ angular.module('cesium.wallet.services', ['ngApi', 'ngFileSaver', 'cesium.bma.se
return !!data.pubkey;
},
getKeypair = function(options) {
if (!started) {
return (startPromise || start())
.then(function () {
return getKeypair(options); // loop
});
}
if (isLogin()) {
return $q.when(data.keypair);
}
return $q.reject('Not auth');
},
hasSelf = function() {
return !!data.pubkey && data.requirements && !data.requirements.needSelf;
},
......@@ -1453,6 +1470,7 @@ angular.module('cesium.wallet.services', ['ngApi', 'ngFileSaver', 'cesium.bma.se
api.registerEvent('data', 'load');
api.registerEvent('data', 'finishLoad');
api.registerEvent('data', 'logout');
api.registerEvent('data', 'unauth');
api.registerEvent('data', 'reset');
api.registerEvent('error', 'send');
......@@ -1472,6 +1490,7 @@ angular.module('cesium.wallet.services', ['ngApi', 'ngFileSaver', 'cesium.bma.se
login: login,
logout: logout,
isLogin: isLogin,
getKeypair: getKeypair,
hasSelf: hasSelf,
isDataLoaded: isDataLoaded,
isNeverUsed: isNeverUsed,
......
......@@ -52,8 +52,8 @@ angular.module('cesium.es.message.controllers', ['cesium.es.services'])
;
function ESMessageListController($scope, $rootScope, $state, $translate, $ionicHistory, $ionicPopover,
esModals, UIUtils, esMessage) {
function ESMessageListController($scope, $state, $translate, $ionicHistory, $ionicPopover,
esModals, UIUtils, csWallet, esMessage) {
'ngInject';
$scope.loading = true;
......@@ -81,14 +81,18 @@ function ESMessageListController($scope, $rootScope, $state, $translate, $ionicH
});
});
$scope.load = function(size, offset) {
$scope.refresh = function(silent) {
return $scope.load(undefined, undefined, silent);
};
$scope.load = function(size, offset, silent) {
var options = {};
options.from = offset || 0;
options.size = size || 20;
options.type = $scope.type;
$scope.loading = true;
return esMessage.load($rootScope.walletData.keypair, options)
$scope.loading = !silent;
return esMessage.load(options)
.then(function(messages) {
$scope.messages = messages;
......@@ -170,8 +174,8 @@ function ESMessageListController($scope, $rootScope, $state, $translate, $ionicH
.then(function() {
UIUtils.loading.hide();
return esModals.showMessageCompose(parameters)
.then(function(sent) {
if (sent) UIUtils.toast.show('MESSAGE.INFO.MESSAGE_SENT');
.then(function(id) {
if (id) UIUtils.toast.show('MESSAGE.INFO.MESSAGE_SENT');
});
});
};
......@@ -224,6 +228,65 @@ function ESMessageListController($scope, $rootScope, $state, $translate, $ionicH
}
};
/* -- watch events (delete, received, sent) -- */
// Message deletion
$scope.onMessageDelete = function(id) {
var index = _.findIndex($scope.messages, function(msg) {
return msg.id == id;
});
if (index) {
$scope.messages.splice(index,1); // remove from messages array
}
};
esMessage.api.data.on.delete($scope, $scope.onMessageDelete);
// Watch user sent message
$scope.onNewOutboxMessage = function(id) {
if ($scope.type != 'outbox') return;
// Add message sent to list
$scope.loading = true;
return $timeout(function() {
// Load the message sent
return esMessage.get(id, {type: $scope.type, summary: true});
}, 500 /*waiting ES propagation*/)
.then(function(msg) {
$scope.messages.splice(0,0,msg);
$scope.loading = false;
$scope.motion.show({selector: '.view-messages .list .item'});
})
.catch(function() {
$scope.loading = false;
});
};
esMessage.api.data.on.sent($scope, $scope.onNewOutboxMessage);
// Watch received message
$scope.onNewInboxMessage = function(notification) {
if ($scope.type != 'inbox' || !$scope.entered) return;
// Add message sent to list
$scope.loading = true;
// Load the the message
return esMessage.get(notification.id, {type: $scope.type, summary: true})
.then(function(msg) {
$scope.messages.splice(0,0,msg);
$scope.loading = false;
$scope.motion.show({selector: '.view-messages .list .item'});
})
.catch(function() {
$scope.loading = false;
});
};
esMessage.api.data.on.new($scope, $scope.onNewInboxMessage);
// Watch unauth
$scope.onUnauth = function() {
// Reset all data
$scope.messages = undefined;
$scope.loading = false;
$scope.entered = false;
};
csWallet.api.data.on.unauth($scope, $scope.onUnauth);
// for DEV only
/*$timeout(function() {
......@@ -324,11 +387,11 @@ function ESMessageComposeModalController($scope, Modals, UIUtils, csWallet, esHt
time: esHttp.date.now()
};
esMessage.send(data, csWallet.data.keypair)
esMessage.send(data)
.then(function(id) {
$scope.id=id;
UIUtils.loading.hide();
$scope.closeModal(true);
$scope.closeModal(id);
})
.catch(UIUtils.onError('MESSAGE.ERROR.SEND_MSG_FAILED'));
};
......@@ -374,7 +437,8 @@ function ESMessageComposeModalController($scope, Modals, UIUtils, csWallet, esHt
}
function ESMessageViewController($scope, $state, $timeout, $translate, $ionicHistory, UIUtils, esModals, esMessage) {
function ESMessageViewController($scope, $state, $timeout, $translate, $ionicHistory, $ionicPopover,
UIUtils, esModals, esMessage) {
'ngInject';
$scope.formData = {};
......@@ -447,7 +511,7 @@ function ESMessageViewController($scope, $state, $timeout, $translate, $ionicHis
UIUtils.alert.confirm('MESSAGE.CONFIRM.REMOVE')
.then(function(confirm) {
if (confirm) {
esMessage.remove($scope.id, $scope.type)
return esMessage.remove($scope.id, $scope.type)
.then(function () {
$ionicHistory.nextViewOptions({
historyRoot: true
......@@ -460,6 +524,32 @@ function ESMessageViewController($scope, $state, $timeout, $translate, $ionicHis
});
};
/* -- Popover -- */
$scope.showActionsPopover = function(event) {
if (!$scope.actionsPopover) {
$ionicPopover.fromTemplateUrl('plugins/es/templates/message/view_popover_actions.html', {
scope: $scope
}).then(function(popover) {
$scope.actionsPopover = popover;
//Cleanup the popover when we're done with it!
$scope.$on('$destroy', function() {
$scope.actionsPopover.remove();
});
$scope.actionsPopover.show(event);
});
}
else {
$scope.actionsPopover.show(event);
}
};
$scope.hideActionsPopover = function() {
if ($scope.actionsPopover) {
$scope.actionsPopover.hide();
}
};
/* -- Modals -- */
$scope.showReplyModal = function() {
......@@ -584,8 +674,8 @@ function PopoverMessageController($scope, UIUtils, $state, csWallet, esHttp, esM
$scope.showNewMessageModal = function(parameters) {
$scope.closePopover();
return esModals.showMessageCompose(parameters)
.then(function(sent) {
if (sent) UIUtils.toast.show('MESSAGE.INFO.MESSAGE_SENT');
.then(function(id) {
if (id) UIUtils.toast.show('MESSAGE.INFO.MESSAGE_SENT');
});
};
......
......@@ -25,6 +25,7 @@ angular.module('cesium.es.message.services', ['ngResource', 'cesium.services', '
},
raw = {
postSearch: esHttp.post('/message/inbox/_search'),
postSearchByType: esHttp.post('/message/:type/_search'),
getByTypeAndId : esHttp.get('/message/:type/:id'),
postReadById: esHttp.post('/message/inbox/:id/_read')
},
......@@ -109,27 +110,30 @@ angular.module('cesium.es.message.services', ['ngResource', 'cesium.services', '
});
}
function sendMessage(message, keypair) {
return doSendMessage(message, keypair)
.then(function(res){
var outbox = (csSettings.data.plugins.es.message &&
angular.isDefined(csSettings.data.plugins.es.message.outbox)) ?
csSettings.data.plugins.es.message.outbox : true;
if (!outbox) return res;
// Send to outbox
return doSendMessage(message, keypair, '/message/outbox', 'issuer')
.catch(function(err) {
console.error("Failed to store message to outbox: " + err);
return res; // the first result
});
})
.then(function(res) {
// Raise event
api.data.raise.sent(res);
return res;
function sendMessage(message) {
return csWallet.getKeypair()
.then(function(keypair) {
return doSendMessage(message, keypair)
.then(function(res){
var outbox = (csSettings.data.plugins.es.message &&
angular.isDefined(csSettings.data.plugins.es.message.outbox)) ?
csSettings.data.plugins.es.message.outbox : true;
if (!outbox) return res;
// Send to outbox
return doSendMessage(message, keypair, '/message/outbox', 'issuer')
.catch(function(err) {
console.error("Failed to store message to outbox: " + err);
return res; // the first result
});
})
.then(function(res) {
// Raise event
api.data.raise.sent(res);
return res;
});
});
}
......@@ -197,13 +201,13 @@ angular.module('cesium.es.message.services', ['ngResource', 'cesium.services', '
};
if (options.type == 'inbox') {
request.query = {bool: {filter: {term: {recipient: csWallet.data.pubkey}}}};
request.query = {bool: {filter: {term: {recipient: pubkey}}}};
}
else {
request.query = {bool: {filter: {term: {issuer: csWallet.data.pubkey}}}};
request.query = {bool: {filter: {term: {issuer: pubkey}}}};
}
return esHttp.post('/message/:type/_search')(request, {type: options.type})
return raw.postSearchByType(request, {type: options.type})
.then(function(res) {
if (!res || !res.hits || !res.hits.total) {
return [];
......@@ -405,7 +409,12 @@ angular.module('cesium.es.message.services', ['ngResource', 'cesium.services', '
}
message.read = true;
return CryptoUtils.sign(message.hash, csWallet.data.keypair)
return csWallet.getKeypair()
// Prepare the read_signature to sent
.then(function(keypair) {
return CryptoUtils.sign(message.hash, keypair);
})
// Send read request
.then(function(signature){
......@@ -469,7 +478,7 @@ angular.module('cesium.es.message.services', ['ngResource', 'cesium.services', '
.then(function(keypair) {
return $q.all(developers.reduce(function(res, developer){
return !developer.pubkey ? res :
res.concat(sendMessage(angular.merge({recipient: developer.pubkey}, message), csWallet.data.keypair));
res.concat(doSendMessage(angular.merge({recipient: developer.pubkey}, message), keypair));
}, []));
})
.then(function(res) {
......
<div class="item gallery done in" ng-if="pictures && pictures.length>0" >
<div ng-if="pictures && pictures.length>0"
class="item gallery done in"
ng-class="{'gallery-small': !smallscreen && smallpictures}"
on-tap="smallpictures=!smallpictures;"
>
<div ng-repeat="picture in pictures"
class="item card card-gallery">
<div class="ink">
......
<form name="messageForm" novalidate="" ng-submit="doSend()">
<div class="list" ng-init="setForm(messageForm)">
<div class="list no-margin"
ng-init="setForm(messageForm)">
<a class="item item-icon-right gray ink"
ng-class="{'item-input-error': form.$submitted && !formData.destPub}"
......@@ -74,18 +75,19 @@
</div>
<div class="padding hidden-xs text-right">
<button class="button button-small button-clear button-dark ink"
ng-click="cancel()" type="button" translate>COMMON.BTN_CANCEL
</button>
<button class="button button-small button-positive ink" type="submit">
{{'TRANSFER.BTN_SEND' | translate}}
</button>
<button class="button button-clear button-dark ink"
ng-click="cancel()" type="button"
translate>COMMON.BTN_CANCEL</button>
<button class="button button-positive ink" type="submit"
translate>TRANSFER.BTN_SEND</button>
</div>
<!-- Encryption info -->
<div class="item item-icon-left item-text-wrap">
<i class="icon ion-ios-information-outline positive"></i>
<h4 class="positive" translate>MESSAGE.COMPOSE.ENCRYPTED_HELP</h4>
<div class="list no-padding">
<div class="item item-icon-left item-text-wrap">
<i class="icon ion-ios-information-outline positive"></i>
<h4 class="positive" translate>MESSAGE.COMPOSE.ENCRYPTED_HELP</h4>
</div>
</div>
</form>
......@@ -15,6 +15,9 @@
</ion-nav-buttons>
<ion-content class="padding no-padding-xs">
<ion-refresher pulling-text="{{'COMMON.BTN_REFRESH' | translate}}"
on-refresh="refresh(true)">
</ion-refresher>
<!-- Buttons bar-->
<ion-list>
......
......@@ -4,11 +4,9 @@
</ion-nav-title>
<ion-nav-buttons side="secondary">
<!--<button class="button button-bar button-icon button-clear visible-xs visible-sm" ng-click="edit()" ng-if="canEdit">
<i class="icon ion-android-create"></i>
</button>-->
<button class="button button-bar button-icon button-clear icon ion-android-more-vertical visible-xs visible-sm"
ng-click="actionsPopover.show($event)">
<button class="button button-icon button-clear icon ion-android-more-vertical visible-xs visible-sm"
ng-click="showActionsPopover($event)">
</button>
</ion-nav-buttons>
......@@ -80,8 +78,7 @@
<!-- content -->
<ion-item>
<p class="dark">
<span class="text-keep-lines" ng-bind-html="formData.content"></span>
<p ng-bind-html="formData.html">
</p>
<div class="padding gray" ng-if="!formData.content" translate>
......
<ion-popover-view class="fit has-header">
<ion-header-bar>
<h1 class="title" translate>COMMON.POPOVER_ACTIONS_TITLE</h1>
</ion-header-bar>
<ion-content scroll="false">
<div class="list item-text-wrap">
<a class="item item-icon-left assertive ink"
ng-click="delete()">
<i class="icon ion-trash-a"></i>
{{'MESSAGE.VIEW.DELETE' | translate}}
</a>
</div>
</ion-content>
</ion-popover-view>
......@@ -68,6 +68,8 @@ function MkRecordViewController($scope, $rootScope, $anchorScroll, $ionicPopover
$scope.maxCommentSize = 10;
$scope.loading = true;
$scope.motion = UIUtils.motion.fadeSlideInRight;
$scope.smallscreen = UIUtils.screen.isSmall();
$scope.smallpictures = !$scope.smallscreen;
// Screen options
$scope.options = $scope.options || angular.merge({
......@@ -333,7 +335,7 @@ function MkRecordViewController($scope, $rootScope, $anchorScroll, $ionicPopover
return esModals.showMessageCompose({
title: title,
destPub: $scope.issuer.pubkey,
destUid: $scope.issuer.name || $scope.issuer.uid,
destUid: $scope.issuer.name || $scope.issuer.uid
});
})
.then(function(send) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment