mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
finish db
This commit is contained in:
@@ -12,14 +12,14 @@
|
|||||||
href="#db-form-container"
|
href="#db-form-container"
|
||||||
aria-expanded="@if($valid_credentials) false @else true @endif"
|
aria-expanded="@if($valid_credentials) false @else true @endif"
|
||||||
>
|
>
|
||||||
<span id="database-status">
|
<span id="credential-status">
|
||||||
@if($valid_credentials === null)
|
@if($valid_credentials === null)
|
||||||
<i class="fa fa-lg fa-question-circle text-muted"></i>
|
<i class="fa fa-lg fa-question-circle text-muted"></i>
|
||||||
@elseif($valid_credentials)
|
@elseif($valid_credentials)
|
||||||
<i class="fa fa-lg fa-check-circle text-success"></i>
|
<i class="fa fa-lg fa-check-circle text-success"></i>
|
||||||
@else
|
@else
|
||||||
<i class="fa fa-lg fa-times-circle text-danger"></i>
|
<i class="fa fa-lg fa-times-circle text-danger"></i>
|
||||||
@endif
|
@endif
|
||||||
</span>
|
</span>
|
||||||
@lang('install.database.credentials')
|
@lang('install.database.credentials')
|
||||||
<i class="fa fa-lg fa-chevron-down rotate-if-collapsed fa-pull-right"></i>
|
<i class="fa fa-lg fa-chevron-down rotate-if-collapsed fa-pull-right"></i>
|
||||||
@@ -79,45 +79,40 @@
|
|||||||
<div id="db-form-header"
|
<div id="db-form-header"
|
||||||
class="card-header h6"
|
class="card-header h6"
|
||||||
data-toggle="collapse"
|
data-toggle="collapse"
|
||||||
href="#db-migration-container"
|
href="#migrate-container"
|
||||||
aria-expanded="@if($migrated) false @else true @endif"
|
aria-expanded="@if($migrated) false @else true @endif"
|
||||||
>
|
>
|
||||||
@if($migrated === null)
|
<span id="migrate-status">
|
||||||
<i class="fa fa-lg fa-question-circle text-muted"></i>
|
@if($migrated === null)
|
||||||
@elseif($migrated)
|
<i class="fa fa-lg fa-question-circle text-muted"></i>
|
||||||
<i class="fa fa-lg fa-check-circle text-success"></i>
|
@elseif($migrated)
|
||||||
@else
|
<i class="fa fa-lg fa-check-circle text-success"></i>
|
||||||
<i class="fa fa-lg fa-times-circle text-danger"></i>
|
@else
|
||||||
@endif
|
<i class="fa fa-lg fa-times-circle text-danger"></i>
|
||||||
@lang('install.migrate.migrate')
|
@endif
|
||||||
<i class="fa fa-lg fa-chevron-down rotate-if-collapsed fa-pull-right"></i>
|
</span>
|
||||||
|
@lang('install.migrate.migrate')
|
||||||
|
<i class="fa fa-lg fa-chevron-down rotate-if-collapsed fa-pull-right"></i>
|
||||||
|
</div>
|
||||||
|
<div id="migrate-container" class="card-body collapse @if(!$migrated) show @endif">
|
||||||
|
<div class="mb-2 text-right">
|
||||||
|
<button id="migrate-btn" type="button" class="btn btn-primary">
|
||||||
|
@lang('install.migrate.migrate')
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div id="migrate-warning" class="alert alert-warning">@lang('install.migrate.building_interrupt')</div>
|
||||||
|
<textarea readonly id="db-update" class="form-control" rows="20" placeholder="@lang('install.migrate.wait')"></textarea>
|
||||||
</div>
|
</div>
|
||||||
<div id="db-migration-container" class="card-body collapse @if(!$migrated) show @endif">
|
|
||||||
<div class="mb-2 text-right">
|
|
||||||
<button type="button" id="retry-btn" onClick="alert('do something')" class="btn btn-primary">
|
|
||||||
@lang('install.migrate.retry')
|
|
||||||
</button>
|
|
||||||
<button type="button" class="btn btn-primary">
|
|
||||||
@lang('install.migrate.migrate')
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
<div class="alert alert-warning">@lang('install.migrate.building_interrupt')</div>
|
|
||||||
<textarea readonly id="db-update" class="form-control" rows="20" placeholder="@lang('install.migrate.wait')"></textarea>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
|
||||||
<div class="col-12">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@endsection
|
@endsection
|
||||||
|
|
||||||
@section('scripts')
|
@section('scripts')
|
||||||
<script>
|
<script>
|
||||||
$('#database-form').submit(function (event) {
|
$('#database-form').submit(function (event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
$('#database-status>i').attr('class', 'fa fa-lg fa-spinner fa-spin');
|
$('#credential-status>i').attr('class', 'fa fa-lg fa-spinner fa-spin');
|
||||||
$('#error-box').empty();
|
$('#error-box').empty();
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
@@ -127,11 +122,11 @@
|
|||||||
data: $('#database-form').serialize(),
|
data: $('#database-form').serialize(),
|
||||||
success: function (response) {
|
success: function (response) {
|
||||||
if (response.result === 'ok') {
|
if (response.result === 'ok') {
|
||||||
$('#database-status>i').attr('class', 'fa fa-lg fa-check-circle text-success');
|
$('#credential-status>i').attr('class', 'fa fa-lg fa-check-circle text-success');
|
||||||
$('#migration-output').show();
|
$('#migration-output').show();
|
||||||
$('#db-form-container').collapse('hide')
|
$('#db-form-container').collapse('hide')
|
||||||
} else {
|
} else {
|
||||||
$('#database-status>i').attr('class', 'fa fa-lg fa-times-circle text-danger')
|
$('#credential-status>i').attr('class', 'fa fa-lg fa-times-circle text-danger')
|
||||||
if (response.message) {
|
if (response.message) {
|
||||||
$('#error-box').append($('<div class="alert alert-danger">' + response.message + '</div>'))
|
$('#error-box').append($('<div class="alert alert-danger">' + response.message + '</div>'))
|
||||||
}
|
}
|
||||||
@@ -141,7 +136,12 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
function run_migrations() {
|
$('#migrate-btn').click(function () {
|
||||||
|
$('#migrate-warning').show()
|
||||||
|
$('#migrate-status>i').attr('class', 'fa fa-lg fa-spinner fa-spin');
|
||||||
|
$('#error-box').empty();
|
||||||
|
$('#migrate-btn').addClass('disabled')
|
||||||
|
|
||||||
var output = document.getElementById("db-update");
|
var output = document.getElementById("db-update");
|
||||||
var xhr = new XMLHttpRequest();
|
var xhr = new XMLHttpRequest();
|
||||||
xhr.open("GET", "{{ route('install.action.migrate') }}", true);
|
xhr.open("GET", "{{ route('install.action.migrate') }}", true);
|
||||||
@@ -152,22 +152,32 @@
|
|||||||
output.scrollTop = output.scrollHeight - output.clientHeight; // scrolls the output area
|
output.scrollTop = output.scrollHeight - output.clientHeight; // scrolls the output area
|
||||||
if (output.innerHTML.indexOf('Error!') !== -1) {
|
if (output.innerHTML.indexOf('Error!') !== -1) {
|
||||||
// if error word in output, show the retry button
|
// if error word in output, show the retry button
|
||||||
$("#retry-btn").css("display", "");
|
$('#migrate-warning').hide();
|
||||||
$('#error-box').append($('<div class="alert alert-danger">@lang('install.migrate.error')</div>'))
|
$('#migrate-status>i').attr('class', 'fa fa-lg fa-times-circle text-danger')
|
||||||
|
$('#migrate-btn').removeClass('disabled').text('@lang('install.migrate.retry')')
|
||||||
|
$('#error-box').append($('<div class="alert alert-danger">@lang('install.migrate.error')</div>'));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
xhr.timeout = 240000; // if no response for 4m, allow the user to retry
|
xhr.timeout = 240000; // if no response for 4m, allow the user to retry
|
||||||
xhr.ontimeout = function (e) {
|
xhr.ontimeout = function (e) {
|
||||||
$("#retry-btn").css("display", "");
|
$("#retry-btn").css("display", "");
|
||||||
$('#error-box').append($('<div class="alert alert-danger">@lang('install.migrate.timeout')</div>'))
|
$('#migrate-warning').hide();
|
||||||
|
$('#error-box').append($('<div class="alert alert-danger">@lang('install.migrate.timeout')</div>'));
|
||||||
};
|
};
|
||||||
xhr.onreadystatechange = function () {
|
xhr.onreadystatechange = function () {
|
||||||
if (xhr.readyState === XMLHttpRequest.DONE && xhr.status === 200) {
|
if (xhr.readyState === XMLHttpRequest.DONE && xhr.status === 200) {
|
||||||
checkStepStatus();
|
$('#migrate-warning').hide();
|
||||||
|
checkStepStatus(function (status) {
|
||||||
|
console.log(status);
|
||||||
|
if (status.database) {
|
||||||
|
$('#migrate-status>i').attr('class', 'fa fa-lg fa-check-circle text-success');
|
||||||
|
$('#migrate-container').collapse('hide');
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
xhr.send();
|
xhr.send();
|
||||||
}
|
});
|
||||||
</script>
|
</script>
|
||||||
@endsection
|
@endsection
|
||||||
|
|
||||||
@@ -180,5 +190,8 @@
|
|||||||
#retry-btn {
|
#retry-btn {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
#migrate-warning {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
@endsection
|
@endsection
|
||||||
|
@@ -121,10 +121,9 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
function checkStepStatus() {
|
function checkStepStatus(callback) {
|
||||||
$.ajax('{{ route('install.action.steps') }}')
|
$.ajax('{{ route('install.action.steps') }}')
|
||||||
.success(function (data) {
|
.success(function (data) {
|
||||||
console.log(data);
|
|
||||||
Object.keys(data).forEach(function (key) {
|
Object.keys(data).forEach(function (key) {
|
||||||
if (data[key]) {
|
if (data[key]) {
|
||||||
$('.install-enable-' + key).removeClass('disabled');
|
$('.install-enable-' + key).removeClass('disabled');
|
||||||
@@ -132,6 +131,10 @@
|
|||||||
$('.install-enable-' + key).addClass('disabled');
|
$('.install-enable-' + key).addClass('disabled');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (callback && typeof callback === "function") {
|
||||||
|
callback(data);
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
Reference in New Issue
Block a user