Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Token polish #806

Merged
merged 5 commits into from
Aug 10, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions settings/css/settings.css
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,16 @@ table.nostyle td { padding: 0.2em 0; }
.app-password-row {
display: table-row;
}

.app-password-row .icon {
background-size: 16px 16px;
display: inline-block;
position: relative;
top: 3px;
margin-left: 5px;
margin-right: 8px;
}

.app-password-label {
display: table-cell;
padding-right: 1em;
Expand Down
50 changes: 48 additions & 2 deletions settings/js/authtoken_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@

_newAppPassword: undefined,

_newAppId: undefined,

_hideAppPasswordBtn: undefined,

_addingToken: false,
Expand Down Expand Up @@ -216,6 +218,38 @@
this._newAppPassword.on('focus', _.bind(this._onNewTokenFocus, this));
this._hideAppPasswordBtn = $('#app-password-hide');
this._hideAppPasswordBtn.click(_.bind(this._hideToken, this));

// Clipboard!
var clipboard = new Clipboard('.clipboardButton');
clipboard.on('success', function(e) {
var $input = $(e.trigger);
$input.tooltip({placement: 'bottom', trigger: 'manual', title: t('core', 'Copied!')});
$input.tooltip('show');
_.delay(function() {
$input.tooltip('hide');
}, 3000);
});
clipboard.on('error', function (e) {
var $input = $(e.trigger);
var actionMsg = '';
if (/iPhone|iPad/i.test(navigator.userAgent)) {
actionMsg = t('core', 'Not supported!');
} else if (/Mac/i.test(navigator.userAgent)) {
actionMsg = t('core', 'Press ⌘-C to copy.');
} else {
actionMsg = t('core', 'Press Ctrl-C to copy.');
}

$input.tooltip({
placement: 'bottom',
trigger: 'manual',
title: actionMsg
});
$input.tooltip('show');
_.delay(function () {
$input.tooltip('hide');
}, 3000);
});
},

render: function () {
Expand Down Expand Up @@ -255,10 +289,13 @@
});

$.when(creatingToken).done(function (resp) {
// We can delete token we add
resp.deviceToken.canDelete = true;
_this.collection.add(resp.deviceToken);
_this.render();
_this._newAppLoginName.val(resp.loginName);
_this._newAppPassword.val(resp.token);
_this._newAppId = resp.deviceToken.id;
_this._toggleFormResult(false);
_this._newAppPassword.select();
_this._tokenName.val('');
Expand Down Expand Up @@ -293,6 +330,10 @@
var $row = $target.closest('tr');
var id = $row.data('id');

if (id === this._newAppId) {
this._toggleFormResult(true);
}

var token = this.collection.get(id);
if (_.isUndefined(token)) {
// Ignore event
Expand All @@ -313,8 +354,13 @@
},

_toggleFormResult: function (showForm) {
this._form.toggleClass('hidden', !showForm);
this._result.toggleClass('hidden', showForm);
if (showForm) {
this._result.slideUp();
this._form.slideDown();
} else {
this._form.slideUp();
this._result.slideDown();
}
}
});

Expand Down
6 changes: 5 additions & 1 deletion settings/templates/personal.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,14 +200,18 @@
<button id="add-app-password" class="button"><?php p($l->t('Create new app password')); ?></button>
</div>
<div id="app-password-result" class="hidden">
<span><?php p($l->t('Use the credentials below to configure your app or device.')); ?></span>
<span>
<?php p($l->t('Use the credentials below to configure your app or device.')); ?>
<?php p($l->t('For security reasons this password will only be shown once.')); ?>
</span>
<div class="app-password-row">
<span class="app-password-label"><?php p($l->t('Username')); ?></span>
<input id="new-app-login-name" type="text" readonly="readonly"/>
</div>
<div class="app-password-row">
<span class="app-password-label"><?php p($l->t('Password')); ?></span>
<input id="new-app-password" type="text" readonly="readonly"/>
<a class="clipboardButton icon icon-clippy" data-clipboard-target="#new-app-password"></a>
<button id="app-password-hide" class="button"><?php p($l->t('Done')); ?></button>
</div>
</div>
Expand Down