Skip to content
This repository has been archived by the owner on Jan 8, 2019. It is now read-only.

Commit

Permalink
first parts of support for dropdown plugin config
Browse files Browse the repository at this point in the history
  • Loading branch information
Lennart Koopmann committed Sep 1, 2013
1 parent 574ad96 commit 83bb849
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 5 deletions.
44 changes: 44 additions & 0 deletions app/lib/plugin/configuration/DropdownField.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/**
* Copyright 2013 Lennart Koopmann <[email protected]>
*
* This file is part of Graylog2.
*
* Graylog2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Graylog2 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Graylog2. If not, see <http://www.gnu.org/licenses/>.
*
*/
package lib.plugin.configuration;

import java.util.Map;

/**
* @author Lennart Koopmann <[email protected]>
*/
public class DropdownField extends RequestedConfigurationField {

private final static String TYPE = "dropdown";

public DropdownField(Map.Entry<String, Map<String, Object>> c) {
super(TYPE, c);
}

@Override
public String getType() {
return TYPE;
}

@Override
public String attributeToJSValidation(String attribute) {
throw new RuntimeException("This type does not have any validatable attributes.");
}
}
7 changes: 3 additions & 4 deletions app/models/api/responses/system/InputTypeSummaryResponse.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@

import com.google.common.collect.Lists;
import com.google.gson.annotations.SerializedName;
import lib.plugin.configuration.BooleanField;
import lib.plugin.configuration.NumberField;
import lib.plugin.configuration.RequestedConfigurationField;
import lib.plugin.configuration.TextField;
import lib.plugin.configuration.*;
import play.Logger;

import java.util.List;
Expand Down Expand Up @@ -67,6 +64,8 @@ public List<RequestedConfigurationField> getRequestedConfiguration() {
case "boolean":
tmpBools.add(new BooleanField(c));
continue;
case "dropdown":
fields.add(new DropdownField(c));
default:
Logger.info("Unknown field type [" + fieldType + "].");
}
Expand Down
21 changes: 21 additions & 0 deletions app/views/system/inputs/fields/dropdown_field.scala.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
@(field: lib.plugin.configuration.RequestedConfigurationField)

<label>@field.getHumanName</label>
<span class="help-block">@field.getDescription</span>

<select name="[email protected]"
class="input-xlarge"
@if(!field.isOptional) {
required
}
>

</select>


<!-- TODO:
pre-selected field:
@if(!field.getDefaultValue().toString().isEmpty()) {
field.getDefaultValue().toString)"
}
-->
1 change: 0 additions & 1 deletion app/views/system/inputs/fields/number_field.scala.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
@(field: lib.plugin.configuration.RequestedConfigurationField)
@import lib.plugin.configuration.NumberField

<label>@field.getHumanName</label>
<span class="help-block">@field.getDescription</span>
Expand Down
4 changes: 4 additions & 0 deletions app/views/system/inputs/manage.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ <h2>
@if(field.getType().equals("boolean")) {
@views.html.system.inputs.fields.boolean_field(field)
}

@if(field.getType().equals("dropdown")) {
@views.html.system.inputs.fields.dropdown_field(field)
}
}
</div>
<div class="modal-footer">
Expand Down

0 comments on commit 83bb849

Please sign in to comment.