Merge "Allowing for HDFS data sources without hdfs://"
This commit is contained in:
commit
148088b713
@ -15,10 +15,6 @@
|
||||
|
||||
import logging
|
||||
|
||||
from django.forms.util import flatatt
|
||||
from django.forms import widgets
|
||||
|
||||
from django.utils.safestring import mark_safe
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
from horizon import forms
|
||||
@ -29,16 +25,6 @@ from saharadashboard.api.client import client as saharaclient
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class LabeledInput(widgets.Input):
|
||||
def render(self, name, values, attrs=None):
|
||||
final_attrs = self.build_attrs(attrs, type=self.input_type, name=name)
|
||||
output = "<span id='%s'>%s</span>%s" %\
|
||||
("id_%s_label" % name,
|
||||
"swift://",
|
||||
('<input%s />' % flatatt(final_attrs)))
|
||||
return mark_safe(output)
|
||||
|
||||
|
||||
class GeneralConfigAction(workflows.Action):
|
||||
data_source_name = forms.CharField(label=_("Name"),
|
||||
required=True)
|
||||
@ -50,8 +36,7 @@ class GeneralConfigAction(workflows.Action):
|
||||
widget=forms.Select(attrs={"class": "data_source_type_choice"}))
|
||||
|
||||
data_source_url = forms.CharField(label=_("URL"),
|
||||
required=True,
|
||||
widget=LabeledInput())
|
||||
required=True)
|
||||
|
||||
data_source_credential_user = forms.CharField(label=_("Source username"),
|
||||
required=True)
|
||||
@ -94,10 +79,13 @@ class GeneralConfig(workflows.Step):
|
||||
for k, v in data.items():
|
||||
context["general_" + k] = v
|
||||
|
||||
context["source_url"] = "%s://%s" % \
|
||||
(context["general_data_source_type"],
|
||||
context["general_data_source_url"])
|
||||
context["source_url"] = context["general_data_source_url"]
|
||||
|
||||
if context["general_data_source_type"] == "swift":
|
||||
if not context["general_data_source_url"].startswith("swift://"):
|
||||
context["source_url"] = "%s://%s" % \
|
||||
("swift",
|
||||
context["general_data_source_url"])
|
||||
return context
|
||||
|
||||
|
||||
|
@ -3,19 +3,16 @@
|
||||
addHorizonLoadEvent(function () {
|
||||
horizon.modals.addModalInitFunction(function (modal) {
|
||||
$("#id_data_source_type").change(function() {
|
||||
var label = $("#id_data_source_url_label");
|
||||
var username = $("#id_data_source_credential_user").closest(".control-group");
|
||||
var password = $("#id_data_source_credential_pass").closest(".control-group")
|
||||
switch($(this).val()) {
|
||||
case "hdfs":
|
||||
label.html("hdfs://");
|
||||
username.hide();
|
||||
password.hide();
|
||||
break;
|
||||
case "swift":
|
||||
username.show();
|
||||
password.show();
|
||||
label.html("swift://");
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user