Add links to load GDrive/Dropbox configuration pages

This commit is contained in:
Robin McCorkell 2016-02-08 15:55:09 +00:00 committed by Robin McCorkell
parent de98a6e54c
commit 43abe2b648
6 changed files with 58 additions and 4 deletions

View file

@ -0,0 +1,28 @@
$(document).ready(function() {
function generateUrl($tr) {
var app_key = $tr.find('[data-parameter="app_key"]').val();
if (app_key) {
return 'https://www.dropbox.com/developers/apps/info/' + app_key;
} else {
return 'https://www.dropbox.com/developers/apps';
}
}
OCA.External.Settings.mountConfig.whenSelectBackend(function($tr, backend, onCompletion) {
if (backend === 'dropbox') {
var config = $tr.find('.configuration');
var el = $(document.createElement('a'))
.attr('href', generateUrl($tr))
.attr('target', '_blank')
.text(t('files_external', 'Dropbox Configuration') + ' ↗')
;
el.on('click', function(event) {
var a = $(event.target);
a.attr('href', generateUrl($(this).parent()));
});
config.append(el);
}
});
});

View file

@ -0,0 +1,24 @@
$(document).ready(function() {
function generateUrl($tr) {
// no mapping between client ID and Google 'project', so we always load the same URL
return 'https://console.developers.google.com/';
}
OCA.External.Settings.mountConfig.whenSelectBackend(function($tr, backend, onCompletion) {
if (backend === 'googledrive') {
var config = $tr.find('.configuration');
var el = $(document.createElement('a'))
.attr('href', generateUrl($tr))
.attr('target', '_blank')
.text(t('files_external', 'Google Drive Configuration') + ' ↗')
;
el.on('click', function(event) {
var a = $(event.target);
a.attr('href', generateUrl($(this).parent()));
});
config.append(el);
}
});
});

View file

@ -13,7 +13,7 @@ $(document).ready(function() {
onCompletion.then(function() {
var configured = $tr.find('[data-parameter="configured"]');
if ($(configured).val() == 'true') {
$tr.find('.configuration input').attr('disabled', 'disabled');
$tr.find('.configuration input.auth-param').attr('disabled', 'disabled');
$tr.find('.configuration').append('<span id="access" style="padding-left:0.5em;">'+t('files_external', 'Access granted')+'</span>');
} else {
var app_key = $tr.find('.configuration [data-parameter="app_key"]').val();
@ -33,7 +33,7 @@ $(document).ready(function() {
$(configured).val('true');
OCA.External.Settings.mountConfig.saveStorageConfig($tr, function(status) {
if (status) {
$tr.find('.configuration input').attr('disabled', 'disabled');
$tr.find('.configuration input.auth-param').attr('disabled', 'disabled');
$tr.find('.configuration').append('<span id="access" style="padding-left:0.5em;">'+t('files_external', 'Access granted')+'</span>');
}
});

View file

@ -13,7 +13,7 @@ $(document).ready(function() {
onCompletion.then(function() {
var configured = $tr.find('[data-parameter="configured"]');
if ($(configured).val() == 'true') {
$tr.find('.configuration input').attr('disabled', 'disabled');
$tr.find('.configuration input.auth-param').attr('disabled', 'disabled');
$tr.find('.configuration').append($('<span/>').attr('id', 'access')
.text(t('files_external', 'Access granted')));
} else {
@ -43,7 +43,7 @@ $(document).ready(function() {
$(configured).val('true');
OCA.External.Settings.mountConfig.saveStorageConfig($tr, function(status) {
if (status) {
$tr.find('.configuration input').attr('disabled', 'disabled');
$tr.find('.configuration input.auth-param').attr('disabled', 'disabled');
$tr.find('.configuration').append($('<span/>')
.attr('id', 'access')
.text(t('files_external', 'Access granted')));

View file

@ -44,6 +44,7 @@ class Dropbox extends Backend {
// all parameters handled in OAuth1 mechanism
])
->addAuthScheme(AuthMechanism::SCHEME_OAUTH1)
->addCustomJs('dropbox')
->setLegacyAuthMechanism($legacyAuth)
;
}

View file

@ -44,6 +44,7 @@ class Google extends Backend {
// all parameters handled in OAuth2 mechanism
])
->addAuthScheme(AuthMechanism::SCHEME_OAUTH2)
->addCustomJs('gdrive')
->setLegacyAuthMechanism($legacyAuth)
;
}