Skip to content

Commit

Permalink
Show server url to connect in settings.
Browse files Browse the repository at this point in the history
Not everyone know that this can be copied from the browser url    bar

Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
  • Loading branch information
karlitschek authored and skjnldsv committed Apr 10, 2019
1 parent f4b96cc commit 5e93372
Show file tree
Hide file tree
Showing 5 changed files with 175 additions and 146 deletions.
10 changes: 10 additions & 0 deletions css/personalsettings.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,13 @@
margin-top: 20px;
margin-bottom: 20px;
}
.clipboardButton {
display: inline-block;
position: relative;
top: 2px;
margin-left: 5px;
}
#endpoint-url {
width: 80%;
max-width: 415px;
}
71 changes: 71 additions & 0 deletions js/personalsettings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
(function($, OC, _) {
$(document).ready(function() {
initLinkToClipboard()
$('#endpoint-url').on('click', function() {
$(this).select()
})
})

function initLinkToClipboard() {
var originalTitle = t('firstrunwizard', 'Copy to clipboard')

/* reused from settings/js/authtoken_view.js */
$('#endpoint-url + .clipboardButton').tooltip({
placement: 'bottom',
title: originalTitle,
trigger: 'hover'
})

// Clipboard!
var clipboard = new Clipboard('.clipboardButton')
clipboard.on('success', function(e) {
var $input = $(e.trigger)

// show copied notification
$input.tooltip('hide')
.attr('data-original-title', t('firstrunwizard', 'Copied!'))
.tooltip('fixTitle')
.tooltip({
placement: 'bottom',
trigger: 'manual'
})
.tooltip('show')

// revert back to original title
_.delay(function() {
$input.tooltip('hide')
.attr('data-original-title', originalTitle)
.tooltip('fixTitle')
}, 3000)
})

clipboard.on('error', function(e) {
var $input = $(e.trigger)
var actionMsg = ''
if (/iPhone|iPad/i.test(navigator.userAgent)) {
actionMsg = t('firstrunwizard', 'Not supported!')
} else if (/Mac/i.test(navigator.userAgent)) {
actionMsg = t('firstrunwizard', 'Press ⌘-C to copy.')
} else {
actionMsg = t('firstrunwizard', 'Press Ctrl-C to copy.')
}

// show error
$input.tooltip('hide')
.attr('data-original-title', actionMsg)
.tooltip('fixTitle')
.tooltip({
placement: 'bottom',
trigger: 'manual'
})
.tooltip('show')

// revert back to original title
_.delay(function() {
$input.tooltip('hide')
.attr('data-original-title', originalTitle)
.tooltip('fixTitle')
}, 3000)
})
}
})(jQuery, OC, _)
7 changes: 5 additions & 2 deletions lib/Settings/Personal.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
use OCP\AppFramework\Http\TemplateResponse;
use OCP\IConfig;
use OCP\Settings\ISettings;
use OCP\IURLGenerator;

class Personal implements ISettings {

Expand All @@ -35,8 +36,9 @@ class Personal implements ISettings {
/** @var \OC_Defaults */
private $defaults;

public function __construct(IConfig $config, \OC_Defaults $defaults) {
public function __construct(IConfig $config, IURLGenerator $urlGenerator, \OC_Defaults $defaults) {
$this->config = $config;
$this->urlGenerator = $urlGenerator;
$this->defaults = $defaults;
}

Expand All @@ -45,7 +47,8 @@ public function __construct(IConfig $config, \OC_Defaults $defaults) {
* @since 9.1
*/
public function getForm() {
$parameters = [ 'clients' => $this->getClientLinks() ];
$url = $this->urlGenerator->getAbsoluteURL('');
$parameters = [ 'clients' => $this->getClientLinks() ,'url' => $url];
return new TemplateResponse('firstrunwizard', 'personal-settings', $parameters);
}

Expand Down
Loading

0 comments on commit 5e93372

Please sign in to comment.