Merge remote-tracking branch 'origin/support' into notifications

pull/1/head
ClemDee 5 years ago
commit 1c226d92b9

@ -3,6 +3,18 @@
@ticket-bg: #F7F7F7;
@msg-bg: #eee;
@fromme-bg: #ddd;
.cp-support-form-container {
[type="text"] {
width: @sidebar_button-width;
margin-bottom: 10px;
}
textarea {
width: 2*@sidebar_button-width;
max-width: 90%;
padding: 10px 15px;
height: 300px;
}
}
.cp-support-container {
.cp-support-list-ticket {
display: flex;
@ -61,6 +73,10 @@
display: none !important;
}
}
button {
margin-left: 2px;
margin-right: 5px;
}
}
}
}

@ -240,10 +240,10 @@ define([
var error = h('div.cp-admin-support-error');
var input = h('input.cp-admin-add-private-key');
var button = h('button.btn.btn-primary', Messages.admin_supportAddKey || 'add key'); // XXX
var button = h('button.btn.btn-primary', Messages.admin_supportAddKey);
if (APP.privateKey && !checkAdminKey(APP.privateKey)) {
$(error).text(Messages.admin_supportAddError || 'invalid'); // XXX
$(error).text(Messages.admin_supportAddError);
}
$div.append(h('div', [
@ -256,15 +256,12 @@ define([
var key = $(input).val();
if (!checkAdminKey(key)) {
$(input).val('');
return void $(error).text(Messages.admin_supportAddError || 'invalid'); // XXX
return void $(error).text(Messages.admin_supportAddError);
}
sFrameChan.query("Q_ADMIN_MAILBOX", key, function () {
console.log(key);
console.log(arguments);
APP.privateKey = key;
console.log('ok');
$('.cp-admin-support-init').hide();
APP.$rightside.append(create['support-list']()); // TODO: check?
APP.$rightside.append(create['support-list']());
});
});
return $div;

@ -1866,6 +1866,13 @@ define([
content: h('span', Messages.adminPage || 'Admin')
});
}
if (padType !== 'support' && accountName) {
options.push({
tag: 'a',
attributes: {'class': 'cp-toolbar-menu-support fa fa-life-ring'},
content: h('span', Messages.supportPage || 'Support')
});
}
// Add login or logout button depending on the current status
if (accountName) {
options.push({
@ -1961,6 +1968,13 @@ define([
window.parent.location = origin+'/settings/';
}
});
$userAdmin.find('a.cp-toolbar-menu-support').click(function () {
if (padType) {
window.open(origin+'/support/');
} else {
window.parent.location = origin+'/support/';
}
});
$userAdmin.find('a.cp-toolbar-menu-admin').click(function () {
if (padType) {
window.open(origin+'/admin/');

@ -339,6 +339,7 @@ proxy.mailboxes = {
if (!req) { return; }
if (type === 'HISTORY_RANGE') {
if (!Array.isArray(_msg)) { return; }
var message;
try {
var decrypted = box.encryptor.decrypt(_msg[4]);
@ -348,6 +349,7 @@ proxy.mailboxes = {
}
ctx.emit('HISTORY', {
txid: txid,
time: _msg[5],
message: message,
hash: _msg[4].slice(0,64)
}, [req.cId]);
@ -375,7 +377,7 @@ proxy.mailboxes = {
var network = ctx.store.network;
network.sendto(network.historyKeeper, JSON.stringify(msg)).then(function () {
}, function (err) {
throw new Error(err);
console.error(err);
});
};

@ -199,6 +199,7 @@ define([
type: type,
content: {
msg: data.message,
time: data.time,
hash: data.hash
}
});

@ -162,7 +162,6 @@ define([
create['disabled'] = function () {
var key = 'disabled';
var $div = makeBlock(key);
// XXX add text
return $div;
};
@ -219,7 +218,7 @@ define([
displayed: displayed,
sfCommon: common,
$container: APP.$toolbar,
pageTitle: Messages.supportPage || 'Support', // XXX
pageTitle: Messages.supportPage,
metadataMgr: common.getMetadataMgr(),
};
APP.toolbar = Toolbar.create(configTb);
@ -240,7 +239,7 @@ define([
createToolbar();
metadataMgr = common.getMetadataMgr();
privateData = metadataMgr.getPrivateData();
common.setTabTitle(Messages.supportPage || 'Support');
common.setTabTitle(Messages.supportPage);
APP.origin = privateData.origin;
APP.readOnly = privateData.readOnly;

@ -2,17 +2,11 @@ define([
'jquery',
'/api/config',
'/common/hyperscript.js',
'/common/common-interface.js',
'/common/common-hash.js',
'/common/common-util.js',
'/customize/messages.js',
], function ($, ApiConfig, h, Hash, Util, Messages) {
var showError = function (form, msg) {
if (!msg) {
return void $(form).find('.cp-support-form-error').text('').hide();
}
$(form).find('.cp-support-form-error').text(msg).show();
};
], function ($, ApiConfig, h, UI, Hash, Util, Messages) {
var send = function (common, id, type, data, dest) {
var supportKey = ApiConfig.supportMailbox;
@ -49,14 +43,12 @@ define([
var title = $title.val();
if (!title) {
return void showError(form, Messages.support_formTitleError || 'title error'); // XXX
return void UI.alert(Messages.support_formTitleError);
}
var content = $content.val();
if (!content) {
return void showError(form, Messages.support_formContentError || 'content error'); // XXX
return void UI.alert(form, Messages.support_formContentError);
}
// Success: hide any error
showError(form, null);
$content.val('');
$title.val('');
@ -72,7 +64,7 @@ define([
var button;
if (typeof(cb) === "function") {
button = h('button.btn.btn-primary.cp-support-list-send', Messages.support_send || 'Send'); // XXX
button = h('button.btn.btn-primary.cp-support-list-send', Messages.contacts_send);
$(button).click(cb);
}
@ -80,16 +72,14 @@ define([
var content = [
h('hr'),
h('div.cp-support-form-error'),
h('label' + (title ? '.cp-hidden' : ''), Messages.support_formTitle || 'title...'), // XXX
h('input.cp-support-form-title' + (title ? '.cp-hidden' : ''), {
placeholder: Messages.support_formTitlePlaceholder || 'title here...', // XXX
placeholder: Messages.support_formTitle,
type: 'text',
value: title || ''
}),
cb ? undefined : h('br'),
h('label', Messages.support_formMessage || 'content...'), // XXX
h('textarea.cp-support-form-msg', {
placeholder: Messages.support_formMessagePlaceholder || 'describe your problem here...' // XXX
placeholder: Messages.support_formMessage
}),
h('hr'),
button,
@ -107,10 +97,10 @@ define([
};
var makeTicket = function ($div, common, content, onHide) {
var ticketTitle = content.id + ' - ' + content.title;
var answer = h('button.btn.btn-primary.cp-support-answer', Messages.support_answer || 'Answer'); // XXX
var close = h('button.btn.btn-danger.cp-support-close', Messages.support_close || 'Close'); // XXX
var hide = h('button.btn.btn-danger.cp-support-hide', Messages.support_remove || 'Remove'); // XXX
var ticketTitle = content.title + ' (#' + content.id + ')';
var answer = h('button.btn.btn-primary.cp-support-answer', Messages.support_answer);
var close = h('button.btn.btn-danger.cp-support-close', Messages.support_close);
var hide = h('button.btn.btn-danger.cp-support-hide', Messages.support_remove);
var actions = h('div.cp-support-list-actions', [
answer,
@ -156,11 +146,10 @@ define([
var privateData = metadataMgr.getPrivateData();
// Check content.sender to see if it comes from us or from an admin
// XXX admins should send their personal public key?
var fromMe = content.sender && content.sender.edPublic === privateData.edPublic;
var userData = h('div.cp-support-showdata', [
Messages.support_showData || 'Show/hide data', // XXX
Messages.support_showData,
h('pre.cp-support-message-data', JSON.stringify(content.sender, 0, 2))
]);
$(userData).click(function () {
@ -170,9 +159,10 @@ define([
return h('div.cp-support-list-message', {
'data-hash': hash
}, [
h('div.cp-support-message-from' + (fromMe ? '.cp-support-fromme' : ''),
//Messages._getKey('support_from', [content.sender.name, new Date(content.time)])), // XXX
[h('b', 'From: '), content.sender.name, h('span.cp-support-message-time', content.time ? new Date(content.time).toLocaleString() : '')]),
h('div.cp-support-message-from' + (fromMe ? '.cp-support-fromme' : ''), [
h('span', Messages._getKey('support_from', [content.sender.name])),
h('span.cp-support-message-time', content.time ? new Date(content.time).toLocaleString() : '')
]),
h('pre.cp-support-message-content', content.message),
isAdmin ? userData : undefined,
]);
@ -186,10 +176,11 @@ define([
return h('div.cp-support-list-message', {
'data-hash': hash
}, [
h('div.cp-support-message-from' + (fromMe ? '.cp-support-fromme' : ''),
//Messages._getKey('support_from', [content.sender.name, new Date(content.time)])), // XXX
[h('b', 'From: '), content.sender.name, h('span.cp-support-message-time', content.time ? new Date(content.time).toLocaleString() : '')]),
h('pre.cp-support-message-content', Messages.support_closed || 'Ticket closed...') // XXX
h('div.cp-support-message-from' + (fromMe ? '.cp-support-fromme' : ''), [
h('span', Messages._getKey('support_from', [content.sender.name])),
h('span.cp-support-message-time', content.time ? new Date(content.time).toLocaleString() : '')
]),
h('pre.cp-support-message-content', Messages.support_closed)
]);
};

Loading…
Cancel
Save