Skip to content

Commit 1519e26

Browse files
karlitschekskjnldsv
authored andcommitted
Show server url to connect in settings.
Not everyone know that this can be copied from the browser url bar Signed-off-by: John Molakvoæ (skjnldsv) <[email protected]>
1 parent f4b96cc commit 1519e26

File tree

8 files changed

+182
-153
lines changed

8 files changed

+182
-153
lines changed

.drone.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ steps:
125125
- name: vue-build
126126
image: nextcloudci/node:node-4
127127
commands:
128-
- find js/ -type f ! -name 'activate.js' ! -name 'about.js' -delete
128+
- find js/ -type f ! -name 'activate.js' ! -name 'personalsettings.js' ! -name 'about.js' -delete
129129
- npm ci
130130
- npm run build
131131
- git status

css/personalsettings.css

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,13 @@
22
margin-top: 20px;
33
margin-bottom: 20px;
44
}
5+
.clipboardButton {
6+
display: inline-block;
7+
position: relative;
8+
top: 2px;
9+
margin-left: 5px;
10+
}
11+
#endpoint-url {
12+
width: 80%;
13+
max-width: 415px;
14+
}

js/firstrunwizard.js

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/firstrunwizard.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/personalsettings.js

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
(function($, OC, _) {
2+
$(document).ready(function() {
3+
initLinkToClipboard()
4+
$('#endpoint-url').on('click', function() {
5+
$(this).select()
6+
})
7+
})
8+
9+
function initLinkToClipboard() {
10+
var originalTitle = t('firstrunwizard', 'Copy to clipboard')
11+
12+
/* reused from settings/js/authtoken_view.js */
13+
$('#endpoint-url + .clipboardButton').tooltip({
14+
placement: 'bottom',
15+
title: originalTitle,
16+
trigger: 'hover'
17+
})
18+
19+
// Clipboard!
20+
var clipboard = new Clipboard('.clipboardButton')
21+
clipboard.on('success', function(e) {
22+
var $input = $(e.trigger)
23+
24+
// show copied notification
25+
$input.tooltip('hide')
26+
.attr('data-original-title', t('firstrunwizard', 'Copied!'))
27+
.tooltip('fixTitle')
28+
.tooltip({
29+
placement: 'bottom',
30+
trigger: 'manual'
31+
})
32+
.tooltip('show')
33+
34+
// revert back to original title
35+
_.delay(function() {
36+
$input.tooltip('hide')
37+
.attr('data-original-title', originalTitle)
38+
.tooltip('fixTitle')
39+
}, 3000)
40+
})
41+
42+
clipboard.on('error', function(e) {
43+
var $input = $(e.trigger)
44+
var actionMsg = ''
45+
if (/iPhone|iPad/i.test(navigator.userAgent)) {
46+
actionMsg = t('firstrunwizard', 'Not supported!')
47+
} else if (/Mac/i.test(navigator.userAgent)) {
48+
actionMsg = t('firstrunwizard', 'Press ⌘-C to copy.')
49+
} else {
50+
actionMsg = t('firstrunwizard', 'Press Ctrl-C to copy.')
51+
}
52+
53+
// show error
54+
$input.tooltip('hide')
55+
.attr('data-original-title', actionMsg)
56+
.tooltip('fixTitle')
57+
.tooltip({
58+
placement: 'bottom',
59+
trigger: 'manual'
60+
})
61+
.tooltip('show')
62+
63+
// revert back to original title
64+
_.delay(function() {
65+
$input.tooltip('hide')
66+
.attr('data-original-title', originalTitle)
67+
.tooltip('fixTitle')
68+
}, 3000)
69+
})
70+
}
71+
})(jQuery, OC, _)

lib/Settings/Personal.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
use OCP\AppFramework\Http\TemplateResponse;
2828
use OCP\IConfig;
2929
use OCP\Settings\ISettings;
30+
use OCP\IURLGenerator;
3031

3132
class Personal implements ISettings {
3233

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

38-
public function __construct(IConfig $config, \OC_Defaults $defaults) {
39+
public function __construct(IConfig $config, IURLGenerator $urlGenerator, \OC_Defaults $defaults) {
3940
$this->config = $config;
41+
$this->urlGenerator = $urlGenerator;
4042
$this->defaults = $defaults;
4143
}
4244

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

0 commit comments

Comments
 (0)