Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2.2] Permite utilizar o instalador para fazer o upgrade de versão #659

Merged
merged 2 commits into from Sep 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions public/install.php
Expand Up @@ -107,7 +107,7 @@ function boolIcon(bool $bool): string
crossorigin="anonymous">
<link rel="stylesheet"
href="https://fonts.googleapis.com/css?family=Open+Sans:400,700|PT+Mono">
<link rel="stylesheet" href="css/install.css">
<link rel="stylesheet" href="css/install.css?version=<?php echo $currIeducarVersion ?>">
</head>

<body>
Expand Down Expand Up @@ -335,6 +335,6 @@ function boolIcon(bool $bool): string
<script
src="https://www.promisejs.org/polyfills/promise-7.0.4.min.js">
</script>
<script src="js/install.js"></script>
<script src="js/install.js?version=<?php echo $currIeducarVersion ?>"></script>
</body>
</html>
49 changes: 39 additions & 10 deletions public/js/install.js
Expand Up @@ -36,10 +36,34 @@ if (updateButton) {
loading.style.display = 'block';
parent.parentNode.removeChild(parent);

get('/install.php?command=exec&param=migrate&id=' + timestamp)
.then(function (result) {
const steps = [
{
command: 'link',
description: 'Gerando symlinks'
}, {
command: 'migrate',
description: 'Executando migrações'
}
];

let base = new Promise(function (resolve) {
return resolve(true);
});

for (let i = 0; i < steps.length; i++) {
const step = steps[i];

base = base.then(function () {
let url = '/install.php?command=exec&param=' + step.command + '&id=' + timestamp;

if (step.extra) {
url += '&extra=' + step.extra;
}

return get(url);
}).then(function (result) {
return new Promise(function (resolve, reject) {
const interval = setInterval(function() {
const interval = setInterval(function () {
get('/install.php?command=consult&pid=' + result + '&id=' + timestamp)
.then(function (result) {
result = parseInt(result, 10);
Expand All @@ -48,19 +72,24 @@ if (updateButton) {
resolve(result);
clearInterval(interval);
} else if (result > 0) {
reject();
reject(step);
clearInterval(interval);
}
});
}, 1000);
});
}).then(function () {
alert('Atualização realizada com sucesso!');
$.location.reload(true);
}).catch(function () {
alert('Ocorreu um erro ao atualizar sua instalação' + "\n" + 'Verifique o log em storage/logs para identificar o problema e tente novamente.');
$.location.reload(true);
});
}

base.then(function () {
alert('Atualização realizada com sucesso!');
$.location.reload(true);
});

base.catch(function (error) {
alert('Ocorreu um erro ao atualizar sua instalação' + "\n" + 'Verifique o log em storage/logs para identificar o problema e tente novamente.');
$.location.reload(true);
});

return false;
});
Expand Down