Skip to content

Commit

Permalink
Migrate the maintenance script to a modern module and bundle
Browse files Browse the repository at this point in the history
Signed-off-by: Christoph Wurst <[email protected]>
  • Loading branch information
ChristophWurst committed May 16, 2019
1 parent 633a198 commit 0cfccce
Show file tree
Hide file tree
Showing 10 changed files with 405 additions and 59 deletions.
26 changes: 13 additions & 13 deletions core/js/dist/login.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion core/js/dist/login.js.map

Large diffs are not rendered by default.

50 changes: 25 additions & 25 deletions core/js/dist/main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion core/js/dist/main.js.map

Large diffs are not rendered by default.

312 changes: 312 additions & 0 deletions core/js/dist/maintenance.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions core/js/dist/maintenance.js.map

Large diffs are not rendered by default.

17 changes: 0 additions & 17 deletions core/js/maintenance-check.js

This file was deleted.

49 changes: 49 additions & 0 deletions core/src/maintenance.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* @copyright 2019 Christoph Wurst <[email protected]>
*
* @author 2019 Christoph Wurst <[email protected]>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

import Axios from 'nextcloud-axios'

import OC from './OC/index'

const url = `${OC.getRootPath()}/status.php`

const check = () => {
console.info('checking the Nextcloud maintenance status')
Axios.get(url)
.then(resp => resp.data)
.then(status => {
if (status.maintenance === false) {
console.info('Nextcloud is not in maintenance mode anymore -> reloading')

window.location.reload()
return
}

console.info('Nextcloud is still in maintenance mode')

// Wait 20sec before the next request
setTimeout(check, 20 * 1000);
})
.catch(console.error.bind(this))
};

// Off we go!
check();
3 changes: 2 additions & 1 deletion core/webpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ module.exports = [
{
entry: {
login: path.join(__dirname, 'src/login.js'),
main: path.join(__dirname, 'src/main.js')
main: path.join(__dirname, 'src/main.js'),
maintenance: path.join(__dirname, 'src/maintenance.js'),
},
output: {
filename: '[name].js',
Expand Down
2 changes: 1 addition & 1 deletion lib/base.php
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ public static function checkMaintenanceMode() {

// render error page
$template = new OC_Template('', 'update.user', 'guest');
OC_Util::addScript('maintenance-check');
OC_Util::addScript('dist/maintenance');
OC_Util::addStyle('core', 'guest');
$template->printPage();
die();
Expand Down

0 comments on commit 0cfccce

Please sign in to comment.