mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-09 16:25:15 +03:00
eventmanager: allow to filter based on role name
Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
@@ -291,6 +291,60 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card bg-light mb-3 trigger trigger-fs trigger-schedule trigger-provider">
|
||||
<div class="card-header">
|
||||
<b>Role name filters</b>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<h6 class="card-title mb-4">Shell-like pattern filters for role names. For example "role*"" will match role names starting with "role".</h6>
|
||||
<div class="form-group row">
|
||||
<div class="col-md-12 form_field_role_names_outer">
|
||||
{{range $idx, $val := .Rule.Conditions.Options.RoleNames}}
|
||||
<div class="row form_field_role_names_outer_row">
|
||||
<div class="form-group col-md-8">
|
||||
<input type="text" class="form-control" id="idRoleNamePattern{{$idx}}" name="role_name_pattern{{$idx}}" placeholder="" value="{{$val.Pattern}}" maxlength="255">
|
||||
</div>
|
||||
<div class="form-group col-md-3">
|
||||
<select class="form-control selectpicker" id="idRoleNamePatternType{{$idx}}" name="type_role_name_pattern{{$idx}}">
|
||||
<option value=""></option>
|
||||
<option value="inverse" {{if $val.InverseMatch}}selected{{end}}>Inverse match</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-md-1">
|
||||
<button class="btn btn-circle btn-danger remove_role_name_pattern_btn_frm_field">
|
||||
<i class="fas fa-trash"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
{{else}}
|
||||
<div class="row form_field_role_names_outer_row">
|
||||
<div class="form-group col-md-8">
|
||||
<input type="text" class="form-control" id="idRoleNamePattern0" name="role_name_pattern0" placeholder="" value="" maxlength="255">
|
||||
</div>
|
||||
<div class="form-group col-md-3">
|
||||
<select class="form-control selectpicker" id="idRoleNamePatternType0" name="type_role_name_pattern0">
|
||||
<option value=""></option>
|
||||
<option value="inverse">Inverse match</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-md-1">
|
||||
<button class="btn btn-circle btn-danger remove_role_name_pattern_btn_frm_field">
|
||||
<i class="fas fa-trash"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mx-1">
|
||||
<button type="button" class="btn btn-secondary add_new_role_name_pattern_field_btn">
|
||||
<i class="fas fa-plus"></i> Add new filter
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card bg-light mb-3 trigger trigger-fs">
|
||||
<div class="card-header">
|
||||
<b>Path filters</b>
|
||||
@@ -542,6 +596,36 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
$(this).closest(".form_field_group_names_outer_row").remove();
|
||||
});
|
||||
|
||||
$("body").on("click", ".add_new_role_name_pattern_field_btn", function () {
|
||||
var index = $(".form_field_role_names_outer").find(".form_field_role_names_outer_row").length;
|
||||
while (document.getElementById("idRoleNamePattern"+index) != null){
|
||||
index++;
|
||||
}
|
||||
$(".form_field_role_names_outer").append(`
|
||||
<div class="row form_field_role_names_outer_row">
|
||||
<div class="form-group col-md-8">
|
||||
<input type="text" class="form-control" id="idRoleNamePattern${index}" name="role_name_pattern${index}" placeholder="" value="" maxlength="255">
|
||||
</div>
|
||||
<div class="form-group col-md-3">
|
||||
<select class="form-control" id="idRoleNamePatternType${index}" name="type_role_name_pattern${index}">
|
||||
<option value=""></option>
|
||||
<option value="inverse">Inverse match</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-md-1">
|
||||
<button class="btn btn-circle btn-danger remove_role_name_pattern_btn_frm_field">
|
||||
<i class="fas fa-trash"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
`);
|
||||
$("#idRoleNamePatternType"+index).selectpicker();
|
||||
});
|
||||
|
||||
$("body").on("click", ".remove_role_name_pattern_btn_frm_field", function () {
|
||||
$(this).closest(".form_field_role_names_outer_row").remove();
|
||||
});
|
||||
|
||||
$("body").on("click", ".add_new_fs_path_pattern_field_btn", function () {
|
||||
var index = $(".form_field_fs_paths_outer").find("form_field_fs_paths_outer_row").length;
|
||||
while (document.getElementById("idFsPathPattern"+index) != null){
|
||||
|
||||
Reference in New Issue
Block a user