From eece4d08c921f074c97102af6f8e0907e1f866c0 Mon Sep 17 00:00:00 2001 From: nachoparker Date: Thu, 5 Apr 2018 02:08:39 +0200 Subject: ncp-web: collapse sidebar menu when clicking in new sections --- ncp-web/index.php | 2 +- ncp-web/ncp.css | 6 +++ ncp-web/ncp.js | 81 +++++++++++++++------------- ncp-web/wizard/CSS/wizard.css | 1 + update.sh | 120 ------------------------------------------ 5 files changed, 52 insertions(+), 158 deletions(-) diff --git a/ncp-web/index.php b/ncp-web/index.php index 575c5a3c..814420c6 100644 --- a/ncp-web/index.php +++ b/ncp-web/index.php @@ -84,7 +84,7 @@ echo <<
-
+

NextCloudPi First Run

Click to start the configuration wizard


diff --git a/ncp-web/ncp.css b/ncp-web/ncp.css index 2db2bb97..de91fc9c 100644 --- a/ncp-web/ncp.css +++ b/ncp-web/ncp.css @@ -1193,11 +1193,17 @@ a#versionlink:hover { cursor:pointer; } +#first-run-wizard img { + width: 70%; + max-width: 210px; +} + .dialog { display:block; background: white; position:relative; width:50%; + max-width: 400px; top:25%; margin:0px auto; } diff --git a/ncp-web/ncp.js b/ncp-web/ncp.js index 2d82c91f..cac619b4 100644 --- a/ncp-web/ncp.js +++ b/ncp-web/ncp.js @@ -10,7 +10,7 @@ var MINI = require('minified'); var $ = MINI.$, $$ = MINI.$$, EE = MINI.EE; var selectedID = null; -var confLock = false; +var lock = false; function errorMsg() { @@ -27,8 +27,12 @@ function switch_to_section( name ) selectedID = null; } +// slide menu +var slide_menu_enabled = false; + function open_menu() { + if ( !slide_menu_enabled ) return; if ( $('#app-navigation').get('$width') != '250px' ) { $('#overlay').show(); @@ -39,6 +43,7 @@ function open_menu() function close_menu() { + if ( !slide_menu_enabled ) return; if ( $('#app-navigation').get('$width') == '250px' ) { $('#app-navigation').animate( {$width: '0px'}, 150 ); @@ -47,6 +52,32 @@ function close_menu() } } +function hide_overlay(e) { $('#overlay').hide() } + +function close_menu_on_click_out(e) { close_menu(); } + +function enable_slide_menu() +{ + if ( slide_menu_enabled ) return; + $( '#app-navigation' ).set( { $width: '0px' } ); + $( '#app-navigation' ).set( { $position: 'absolute' } ); + $( '#app-navigation-toggle' ).on('click', open_menu ); + $( '#app-content' ).on('|click', close_menu_on_click_out ); + slide_menu_enabled = true; +} + +function disable_slide_menu() +{ + if ( !slide_menu_enabled ) return; + $.off( open_menu ); + $.off( close_menu ); + $.off( close_menu_on_click_out ); + $( '#app-navigation' ).set( { $width: '250px' } ); + $( '#app-navigation' ).set( { $position: 'unset' } ); + $('#overlay').hide(); + slide_menu_enabled = false; +} + function set_sidebar_click_handlers() { // Show selected option configuration box @@ -55,8 +86,8 @@ function set_sidebar_click_handlers() if ( selectedID == this.get( '.id' ) ) // already selected return; - if ( confLock ) return; - confLock = true; + if ( lock ) return; + lock = true; if ( window.innerWidth <= 768 ) close_menu(); @@ -69,7 +100,7 @@ function set_sidebar_click_handlers() function success( result ) { cfgreqReceive( result, that ); - confLock = false; + lock = false; }).error( errorMsg ); }); } @@ -138,7 +169,7 @@ $(function() // Launch selected script $( '#config-button' ).on('click', function(e) { - confLock = true; + lock = true; $('#details-box').hide( '' ); $('#config-button').set('@disabled',true); $('#loading-gif').set( { $display: 'inline' } ); @@ -201,15 +232,15 @@ $(function() $( 'input' , '#config-box-wrapper' ).set('@disabled', null); $('#config-button').set('@disabled',null); $('#loading-gif').hide(); - confLock = false; + lock = false; }).error( errorMsg ); }); // Update notification $( '#notification' ).on('click', function(e) { - if ( confLock ) return; - confLock = true; + if ( lock ) return; + lock = true; $( '#' + selectedID ).set('-active'); @@ -220,7 +251,7 @@ $(function() function success( result ) { cfgreqReceive( result, $( '#nc-update' ) ); - confLock = false; + lock = false; } ).error( errorMsg ); @@ -229,34 +260,6 @@ $(function() } ); // slide menu - var slide_menu_enabled = false; - - function hide_overlay(e) { $('#overlay').hide() } - - function close_menu_on_click_out(e) { close_menu(); } - - function enable_slide_menu() - { - if ( slide_menu_enabled ) return; - $( '#app-navigation' ).set( { $width: '0px' } ); - $( '#app-navigation' ).set( { $position: 'absolute' } ); - $( '#app-navigation-toggle' ).on('click', open_menu ); - $( '#app-content' ).on('|click', close_menu_on_click_out ); - slide_menu_enabled = true; - } - - function disable_slide_menu() - { - if ( !slide_menu_enabled ) return; - $.off( open_menu ); - $.off( close_menu ); - $.off( close_menu_on_click_out ); - $( '#app-navigation' ).set( { $width: '250px' } ); - $( '#app-navigation' ).set( { $position: 'unset' } ); - $('#overlay').hide(); - slide_menu_enabled = false; - } - if ( window.innerWidth <= 768 ) enable_slide_menu(); @@ -350,12 +353,16 @@ $(function() // dashboard button $( '#dashboard-btn' ).on('click', function(e) { + if ( lock ) return; + close_menu(); switch_to_section( 'dashboard' ); } ); // config button $( '#config-btn' ).on('click', function(e) { + if ( lock ) return; + close_menu(); switch_to_section( 'nc-config' ); } ); } ); diff --git a/ncp-web/wizard/CSS/wizard.css b/ncp-web/wizard/CSS/wizard.css index dbef15a7..9e1a36b1 100644 --- a/ncp-web/wizard/CSS/wizard.css +++ b/ncp-web/wizard/CSS/wizard.css @@ -23,6 +23,7 @@ a:hover, a:active, a:link { .ncp-tab-pane { display: table; margin: 0 auto; + text-align: center; } .ncp-tab-pane p { text-align: center; diff --git a/update.sh b/update.sh index 376bdb21..16a56a4d 100755 --- a/update.sh +++ b/update.sh @@ -121,103 +121,6 @@ done # not for image builds, only live updates [[ ! -f /.ncp-image ]] && { - # update ncp-backup - cd "$CONFDIR" &>/dev/null - install_script nc-backup.sh &>/dev/null - cd - &>/dev/null - - # randomize passwords for old images ( older than v0.46.30 ) - cat > /usr/lib/systemd/system/nc-provisioning.service <<'EOF' -[Unit] -Description=Randomize passwords on first boot -Requires=network.target -After=mysql.service - -[Service] -ExecStart=/bin/bash /usr/local/bin/ncp-provisioning.sh - -[Install] -WantedBy=multi-user.target -EOF - systemctl enable nc-provisioning - - NEED_UPDATE=false - - MAJOR=0 MINOR=46 PATCH=30 - - MAJ=$( grep -oP "\d+\.\d+\.\d+" /usr/local/etc/ncp-version | cut -d. -f1 ) - MIN=$( grep -oP "\d+\.\d+\.\d+" /usr/local/etc/ncp-version | cut -d. -f2 ) - PAT=$( grep -oP "\d+\.\d+\.\d+" /usr/local/etc/ncp-version | cut -d. -f3 ) - - if [ "$MAJOR" -gt "$MAJ" ]; then - NEED_UPDATE=true - elif [ "$MAJOR" -eq "$MAJ" ] && [ "$MINOR" -gt "$MIN" ]; then - NEED_UPDATE=true - elif [ "$MAJOR" -eq "$MAJ" ] && [ "$MINOR" -eq "$MIN" ] && [ "$PATCH" -gt "$PAT" ]; then - NEED_UPDATE=true - fi - - [[ "$NEED_UPDATE" == "true" ]] && { - REDISPASS="default" - DBPASSWD="default" - sed -i -E "s|^requirepass .*|requirepass $REDISPASS|" /etc/redis/redis.conf - echo -e "[client]\npassword=$DBPASSWD" > /root/.my.cnf - chmod 600 /root/.my.cnf - systemctl start nc-provisioning - } - - # adjust services - systemctl mask nfs-blkmap - grep -q '^ACTIVE_=yes$' "$CONFDIR"/samba.sh || update-rc.d nmbd disable - - # fix automount dependencies with other ncp-apps - sed -i \ - 's|^Before=.*|Before=mysqld.service dphys-swapfile.service fail2ban.service smbd.service nfs-server.service|' \ - /usr/lib/systemd/system/nc-automount.service - - sed -i \ - 's|^Before=.*|Before=nc-automount.service|' \ - /usr/lib/systemd/system/nc-automount-links.service - - # adjust when other services start - DBUNIT=/lib/systemd/system/mariadb.service - F2BUNIT=/lib/systemd/system/fail2ban.service - SWPUNIT=/etc/init.d/dphys-swapfile - grep -q sleep "$DBUNIT" || sed -i "/^ExecStart=/iExecStartPre=/bin/sleep 10" "$DBUNIT" - grep -q sleep "$F2BUNIT" || sed -i "/^ExecStart=/iExecStartPre=/bin/sleep 10" "$F2BUNIT" - grep -q sleep "$SWPUNIT" || sed -i "/\/dev/null || { - cd "$CONFDIR" &>/dev/null - install_script nc-ramlogs.sh &>/dev/null - grep -q '^ACTIVE_=yes$' "$CONFDIR"/nc-ramlogs.sh && \ - systemctl enable log2ram - cd - &>/dev/null - } - - # update nc-backup-auto to use cron - [[ -f /etc/systemd/system/nc-backup.timer ]] && { - systemctl stop nc-backup.timer - systemctl disable nc-backup.timer - rm -f /etc/systemd/system/nc-backup.timer /etc/systemd/system/nc-backup.service - cd "$CONFDIR" &>/dev/null - grep -q '^ACTIVE_=yes$' "$CONFDIR"/nc-backup-auto.sh && \ - activate_script nc-backup-auto.sh - cd - &>/dev/null - } - # make sure the redis directory exists mkdir -p /var/log/redis chown redis /var/log/redis @@ -271,29 +174,6 @@ EOF systemctl stop log2ram } - # add new virtual host for initial password setup - cat > /etc/apache2/sites-available/ncp-activation.conf < - DocumentRoot /var/www/ncp-web/ - SSLEngine on - SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem - SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key - - - - - - - Require host localhost - Require local - Require ip 192.168 - Require ip 172 - Require ip 10 - - - - -EOF } # end - only live updates exit 0 -- cgit v1.2.3