2020-09-15 16:01:50 +03:00
|
|
|
/**
|
2019-05-16 17:40:02 +03:00
|
|
|
* @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
|
|
|
|
*
|
|
|
|
* @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
|
|
|
|
*
|
|
|
|
* @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/>.
|
|
|
|
*/
|
|
|
|
|
2019-10-04 13:17:09 +03:00
|
|
|
import Axios from '@nextcloud/axios'
|
2020-06-05 09:48:28 +03:00
|
|
|
import { getRootUrl } from '@nextcloud/router'
|
2019-05-16 17:40:02 +03:00
|
|
|
|
2020-06-05 09:48:28 +03:00
|
|
|
const url = getRootUrl() + '/status.php'
|
2019-05-16 17:40:02 +03:00
|
|
|
|
|
|
|
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
|
2019-09-25 19:19:42 +03:00
|
|
|
setTimeout(check, 20 * 1000)
|
2019-05-16 17:40:02 +03:00
|
|
|
})
|
|
|
|
.catch(console.error.bind(this))
|
2019-09-25 19:19:42 +03:00
|
|
|
}
|
2019-05-16 17:40:02 +03:00
|
|
|
|
|
|
|
// Off we go!
|
2019-09-25 19:19:42 +03:00
|
|
|
check()
|