diff options
author | Julius Härtl <jus@bitgrid.net> | 2020-03-11 16:06:25 +0300 |
---|---|---|
committer | Julius Härtl <jus@bitgrid.net> | 2020-03-11 16:06:25 +0300 |
commit | bba26cb2ebf48413ed938af572ee46b7cb9f0ba2 (patch) | |
tree | 56d651c210a12db278ec00b97fe87ca8446c5a9f | |
parent | 24d0fb9fcd8b190b6c16c4608c95785036b1eb31 (diff) |
Move install scripts to bundle
Signed-off-by: Julius Härtl <jus@bitgrid.net>
-rw-r--r-- | core/js/installation.js | 5 | ||||
-rw-r--r-- | core/js/setup.js | 126 | ||||
-rw-r--r-- | core/src/install.js | 133 | ||||
-rw-r--r-- | core/templates/installation.php | 2 | ||||
-rw-r--r-- | core/webpack.js | 1 |
5 files changed, 135 insertions, 132 deletions
diff --git a/core/js/installation.js b/core/js/installation.js deleted file mode 100644 index 20ff346215f..00000000000 --- a/core/js/installation.js +++ /dev/null @@ -1,5 +0,0 @@ - -$(document).ready(function() { - $('#adminpass').showPassword().keyup(); - $('#dbpass').showPassword().keyup(); -}); diff --git a/core/js/setup.js b/core/js/setup.js deleted file mode 100644 index 7cf4c38071e..00000000000 --- a/core/js/setup.js +++ /dev/null @@ -1,126 +0,0 @@ -var dbtypes; -$(document).ready(function() { - dbtypes={ - sqlite:!!$('#hasSQLite').val(), - mysql:!!$('#hasMySQL').val(), - postgresql:!!$('#hasPostgreSQL').val(), - oracle:!!$('#hasOracle').val() - }; - - $('#selectDbType').buttonset(); - // change links inside an info box back to their default appearance - $('#selectDbType p.info a').button('destroy'); - - if($('#hasSQLite').val()){ - $('#use_other_db').hide(); - $('#use_oracle_db').hide(); - } else { - $('#sqliteInformation').hide(); - } - $('#adminlogin').change(function(){ - $('#adminlogin').val($.trim($('#adminlogin').val())); - }); - $('#sqlite').click(function() { - $('#use_other_db').slideUp(250); - $('#use_oracle_db').slideUp(250); - $('#sqliteInformation').show(); - $('#dbname').attr('pattern','[0-9a-zA-Z$_-]+'); - }); - - $('#mysql,#pgsql').click(function() { - $('#use_other_db').slideDown(250); - $('#use_oracle_db').slideUp(250); - $('#sqliteInformation').hide(); - $('#dbname').attr('pattern','[0-9a-zA-Z$_-]+'); - }); - - $('#oci').click(function() { - $('#use_other_db').slideDown(250); - $('#use_oracle_db').show(250); - $('#sqliteInformation').hide(); - $('#dbname').attr('pattern','[0-9a-zA-Z$_-.]+'); - }); - - $('#showAdvanced').click(function(e) { - e.preventDefault(); - $('#datadirContent').slideToggle(250); - $('#databaseBackend').slideToggle(250); - $('#databaseField').slideToggle(250); - }); - $("form").submit(function(){ - // Save form parameters - var post = $(this).serializeArray(); - - // Show spinner while finishing setup - $('.float-spinner').show(250); - - // Disable inputs - $(':submit', this).attr('disabled','disabled').val($(':submit', this).data('finishing')); - $('input', this).addClass('ui-state-disabled').attr('disabled','disabled'); - // only disable buttons if they are present - if($('#selectDbType').find('.ui-button').length > 0) { - $('#selectDbType').buttonset('disable'); - } - $('.strengthify-wrapper, .tipsy') - .css('-ms-filter', '"progid:DXImageTransform.Microsoft.Alpha(Opacity=30)"') - .css('filter', 'alpha(opacity=30)') - .css('opacity', 0.3); - - // Create the form - var form = $('<form>'); - form.attr('action', $(this).attr('action')); - form.attr('method', 'POST'); - - for(var i=0; i<post.length; i++){ - var input = $('<input type="hidden">'); - input.attr(post[i]); - form.append(input); - } - - // Add redirect_url - var redirectURL = getURLParameter('redirect_url'); - if (redirectURL) { - var redirectURLInput = $('<input type="hidden">'); - redirectURLInput.attr({ - name: 'redirect_url', - value: redirectURL - }); - form.append(redirectURLInput); - } - - // Submit the form - form.appendTo(document.body); - form.submit(); - return false; - }); - - // Expand latest db settings if page was reloaded on error - var currentDbType = $('input[type="radio"]:checked').val(); - - if (currentDbType === undefined){ - $('input[type="radio"]').first().click(); - } - - if ( - currentDbType === 'sqlite' || - (dbtypes.sqlite && currentDbType === undefined) - ){ - $('#datadirContent').hide(250); - $('#databaseBackend').hide(250); - $('#databaseField').hide(250); - $('.float-spinner').hide(250); - } - - $('#adminpass').strengthify({ - zxcvbn: OC.linkTo('core','vendor/zxcvbn/dist/zxcvbn.js'), - titles: [ - t('core', 'Very weak password'), - t('core', 'Weak password'), - t('core', 'So-so password'), - t('core', 'Good password'), - t('core', 'Strong password') - ], - drawTitles: true, - nonce: btoa(OC.requestToken), - }); -}); diff --git a/core/src/install.js b/core/src/install.js new file mode 100644 index 00000000000..2e69c3e3c99 --- /dev/null +++ b/core/src/install.js @@ -0,0 +1,133 @@ +import $ from 'jquery' +import { translate as t } from '@nextcloud/l10n' +import { getToken } from './OC/requesttoken' +import getURLParameter from './Util/get-url-parameter' + +import 'strengthify' +import 'strengthify/strengthify.css' + +$(document).ready(function() { + const dbtypes = { + sqlite: !!$('#hasSQLite').val(), + mysql: !!$('#hasMySQL').val(), + postgresql: !!$('#hasPostgreSQL').val(), + oracle: !!$('#hasOracle').val(), + } + + $('#selectDbType').buttonset() + // change links inside an info box back to their default appearance + $('#selectDbType p.info a').button('destroy') + + if ($('#hasSQLite').val()) { + $('#use_other_db').hide() + $('#use_oracle_db').hide() + } else { + $('#sqliteInformation').hide() + } + $('#adminlogin').change(function() { + $('#adminlogin').val($.trim($('#adminlogin').val())) + }) + $('#sqlite').click(function() { + $('#use_other_db').slideUp(250) + $('#use_oracle_db').slideUp(250) + $('#sqliteInformation').show() + $('#dbname').attr('pattern', '[0-9a-zA-Z$_-]+') + }) + + $('#mysql,#pgsql').click(function() { + $('#use_other_db').slideDown(250) + $('#use_oracle_db').slideUp(250) + $('#sqliteInformation').hide() + $('#dbname').attr('pattern', '[0-9a-zA-Z$_-]+') + }) + + $('#oci').click(function() { + $('#use_other_db').slideDown(250) + $('#use_oracle_db').show(250) + $('#sqliteInformation').hide() + $('#dbname').attr('pattern', '[0-9a-zA-Z$_-.]+') + }) + + $('#showAdvanced').click(function(e) { + e.preventDefault() + $('#datadirContent').slideToggle(250) + $('#databaseBackend').slideToggle(250) + $('#databaseField').slideToggle(250) + }) + $('form').submit(function() { + // Save form parameters + const post = $(this).serializeArray() + + // Show spinner while finishing setup + $('.float-spinner').show(250) + + // Disable inputs + $(':submit', this).attr('disabled', 'disabled').val($(':submit', this).data('finishing')) + $('input', this).addClass('ui-state-disabled').attr('disabled', 'disabled') + // only disable buttons if they are present + if ($('#selectDbType').find('.ui-button').length > 0) { + $('#selectDbType').buttonset('disable') + } + $('.strengthify-wrapper, .tipsy') + .css('-ms-filter', '"progid:DXImageTransform.Microsoft.Alpha(Opacity=30)"') + .css('filter', 'alpha(opacity=30)') + .css('opacity', 0.3) + + // Create the form + const form = $('<form>') + form.attr('action', $(this).attr('action')) + form.attr('method', 'POST') + + for (let i = 0; i < post.length; i++) { + const input = $('<input type="hidden">') + input.attr(post[i]) + form.append(input) + } + + // Add redirect_url + const redirectURL = getURLParameter('redirect_url') + if (redirectURL) { + const redirectURLInput = $('<input type="hidden">') + redirectURLInput.attr({ + name: 'redirect_url', + value: redirectURL, + }) + form.append(redirectURLInput) + } + + // Submit the form + form.appendTo(document.body) + form.submit() + return false + }) + + // Expand latest db settings if page was reloaded on error + const currentDbType = $('input[type="radio"]:checked').val() + + if (currentDbType === undefined) { + $('input[type="radio"]').first().click() + } + + if ( + currentDbType === 'sqlite' + || (dbtypes.sqlite && currentDbType === undefined) + ) { + $('#datadirContent').hide(250) + $('#databaseBackend').hide(250) + $('#databaseField').hide(250) + $('.float-spinner').hide(250) + } + + $('#adminpass').strengthify({ + zxcvbn: OC.linkTo('core', 'vendor/zxcvbn/dist/zxcvbn.js'), + titles: [ + t('core', 'Very weak password'), + t('core', 'Weak password'), + t('core', 'So-so password'), + t('core', 'Good password'), + t('core', 'Strong password'), + ], + drawTitles: true, + nonce: btoa(getToken()), + }) +}) diff --git a/core/templates/installation.php b/core/templates/installation.php index e4a232fc965..5a351e97416 100644 --- a/core/templates/installation.php +++ b/core/templates/installation.php @@ -1,6 +1,6 @@ <?php script('core', [ - 'installation' + 'dist/install' ]); ?> <input type='hidden' id='hasMySQL' value='<?php p($_['hasMySQL']) ?>'> diff --git a/core/webpack.js b/core/webpack.js index cb80f049fab..94d9c019fff 100644 --- a/core/webpack.js +++ b/core/webpack.js @@ -8,6 +8,7 @@ module.exports = [ main: path.join(__dirname, 'src/main.js'), maintenance: path.join(__dirname, 'src/maintenance.js'), recommendedapps: path.join(__dirname, 'src/recommendedapps.js'), + install: path.join(__dirname, 'src/install.js') }, output: { filename: '[name].js', |