Adds help text and fixes dropdown displays

Adds help text for users creating a Restore Action item.
Also fixes the fields that get displayed when selecting options
in the Action, Mode, and Storage dropdowns.

(cherry picked from commit ddc6321e6d)
(cherry picked from commit 45ce4f029c)
Change-Id: Ia5fcfa0a3afb8d75c9beb497204ef9b4934a723f
This commit is contained in:
Ryan Peters 2016-08-11 00:41:23 -05:00 committed by Memo Garcia
parent a58235331e
commit a6b1a48f66
4 changed files with 38 additions and 63 deletions

View File

@ -7,6 +7,10 @@
<p>{% blocktrans %}An action is the simplest execution within a job, it could be a backup or a restore
and it contains rules that the action must follow (max retries, interval between executions, etc).{% endblocktrans %}</p>
<p id="restore-warning" class="has-error">
<span class="help-block">*** If creating a Restore Action, you must name the Action the same as the Backup Action
you are restoring. ***</p>
{% endblock %}
<script type='text/javascript' src='{{ STATIC_URL }}freezer/js/freezer.actions.action.js'></script>

View File

@ -36,6 +36,7 @@ function hideEverything() {
$("#id_restore_abs_path").closest(".form-group").hide();
$("#id_restore_from_host").closest(".form-group").hide();
$("#id_restore_from_date").closest(".form-group").hide();
$("#restore-warning").hide();
// Admin specific controls
$("#id_remove_older_than").closest(".form-group").hide();
@ -73,6 +74,7 @@ function showRestoreOptions() {
$("#id_restore_from_host").closest(".form-group").show();
$("#id_restore_from_date").closest(".form-group").show();
$("#id_storage").closest(".form-group").show();
$("#restore-warning").show();
}
function showSSHOptions() {
@ -81,85 +83,54 @@ function showSSHOptions() {
$("#id_ssh_host").closest(".form-group").show();
}
function triggerChanges() {
$("#id_action").trigger('change');
$("#id_mode").trigger('change');
$("#id_storage").trigger('change');
}
function hideModeOptions() {
$("#id_cinder_vol_id").closest(".form-group").hide();
$("#id_nova_inst_id").closest(".form-group").hide();
$("#id_mysql_conf").closest(".form-group").hide();
$("#id_sql_server_conf").closest(".form-group").hide();
}
function hideSSHOptions() {
$("#id_ssh_key").closest(".form-group").hide();
$("#id_ssh_username").closest(".form-group").hide();
$("#id_ssh_host").closest(".form-group").hide();
}
$("#id_action").change(function () {
function setActionOptions() {
// Update the inputs according freezer action
if ($("#id_action").val() === 'backup') {
hideEverything();
var $id_action = $("#id_action").val();
if ($id_action === 'backup') {
showBackupOptions();
} else if ($("#id_action").val() === 'restore') {
hideEverything();
} else if ($id_action === 'restore') {
showRestoreOptions();
} else if ($("#id_action").val() === 'admin') {
hideEverything();
} else if ($id_action === 'admin') {
showAdminOptions();
} else {
hideEverything();
}
});
}
$("#id_storage").change(function () {
function setStorageOptions() {
// Update the inputs according freezer storage backend
if ($("#id_storage").val() === 'swift') {
//hideEverything();
showBackupOptions();
hideSSHOptions();
} else if ($("#id_storage").val() === 'ssh') {
//hideEverything();
showBackupOptions();
showSSHOptions();
} else if ($("#id_storage").val() === 'local') {
//hideEverything();
showBackupOptions();
hideSSHOptions();
var $id_action = $("#id_action").val();
if ($id_action === 'backup' || $id_action === 'restore') {
if ($("#id_storage").val() === 'ssh') {
showSSHOptions();
}
}
});
}
$("#id_mode").change(function () {
function setModeOptions() {
// Update the inputs according freezer mode
if ($("#id_action").val() === 'backup') {
if ($("#id_mode").val() === 'fs') {
hideModeOptions();
} else if ($("#id_mode").val() === 'mysql') {
hideModeOptions();
var $id_mode = $("#id_mode").val();
if ($id_mode === 'mysql') {
$("#id_mysql_conf").closest(".form-group").show();
} else if ($("#id_mode").val() === 'mssql') {
hideModeOptions();
} else if ($id_mode === 'mssql') {
$("#id_sql_server_conf").closest(".form-group").show();
} else if ($("#id_mode").val() === 'mongo') {
hideModeOptions();
} else if ($("#id_mode").val() === 'cinder') {
hideModeOptions();
} else if ($id_mode === 'cinder') {
$("#id_cinder_vol_id").closest(".form-group").show();
} else if ($("#id_mode").val() === 'nova') {
hideModeOptions();
} else if ($id_mode === 'nova') {
$("#id_nova_inst_id").closest(".form-group").show();
}
}
});
}
$("#id_action, #id_storage, #id_mode").change(function () {
hideEverything();
setActionOptions();
setStorageOptions();
setModeOptions();
});
$(function () {
hideEverything();
triggerChanges();
setActionOptions();
setStorageOptions();
setModeOptions();
});

View File

@ -1,6 +1,7 @@
# The order of packages is significant, because pip processes them in the order
# of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later.
pbr>=1.6
astroid<1.4.0 # breaks pylint 1.4.4
hacking>=0.10.2,<0.11
coverage>=3.6
@ -12,7 +13,6 @@ oslotest>=1.10.0 # Apache-2.0
testrepository>=0.0.18
testscenarios>=0.4
testtools>=1.4.0
pbr>=1.6
flake8>=2.2.4,<=2.4.1
pytest
pytest-cov

View File

@ -1,5 +1,5 @@
[tox]
envlist = py27,pep8,pylint
envlist = py27dj18,py34dj18,pep8,pylint
skipsdist = True
[testenv]
@ -9,7 +9,7 @@ setenv =
VIRTUAL_ENV={envdir}
deps = -r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
commands = py.test -v --cov-report term-missing --cov disaster_recovery
commands =
[testenv:pep8]
commands = flake8