<commit_before><h1>Authorization Rules Graph</h1>
<p>Currently active rules in this application.</p>
<p><%= navigation %></p>

<% javascript_tag do %>
    function update_graph (form) {
        base_url = "<%= url_for :format => 'svg' %>";
        $('graph').data = base_url + '?' + form.serialize();
    }

    function set_filter (filter) {
        for (f in filter) {
            var select = $("filter_" + f);
            if (select) {
                var opt = select.down("option[value='"+ filter[f] + "']");
                if (opt) {
                    opt.selected = true;
                    update_graph(select.form);
                }
            }
        }
    }
<% end %>
<p>
  <% form_tag do %>
  <%#= link_to_graph "Rules" %>
  <%#= link_to_graph "Privilege hierarchy", :type => 'priv_hierarchy' %>
  
  <%= select_tag "filter_roles", options_for_select([["All roles",'']] + controller.authorization_engine.roles), :onchange => 'update_graph(this.form)' %>
  <%= select_tag "filter_contexts", options_for_select([["All contexts",'']] + controller.authorization_engine.auth_rules.collect {|ar| ar.contexts.to_a}.flatten.uniq), :onchange => 'update_graph(this.form)' %>
  <%= check_box_tag "effective_role_privs", "1", false, :onclick => 'update_graph(this.form)'  %> <%= label_tag "effective_role_privs", "Effective privileges"  %>
  <%= check_box_tag "privilege_hierarchy", "1", false, :onclick => 'update_graph(this.form)'  %> <%= label_tag "privilege_hierarchy", "Show full privilege hierarchy"  %>
  <% end %>
</p>
<div style="margin: 1em;border:1px solid #ccc;max-width:95%">
<object id="graph" data="<%= url_for :format => 'svg' %>" type="image/svg+xml" style="max-width:100%"/>
</div>
<%= button_to_function "Zoom in", '$("graph").style.maxWidth = "";$(this).toggle();$(this).next().toggle()' %>
<%= button_to_function "Zoom out", '$("graph").style.maxWidth = "100%";$(this).toggle();$(this).previous().toggle()', :style => 'display:none' %><commit_msg>Sort role and context filters options<commit_after><h1>Authorization Rules Graph</h1>
<p>Currently active rules in this application.</p>
<p><%= navigation %></p>

<% javascript_tag do %>
    function update_graph (form) {
        base_url = "<%= url_for :format => 'svg' %>";
        $('graph').data = base_url + '?' + form.serialize();
    }

    function set_filter (filter) {
        for (f in filter) {
            var select = $("filter_" + f);
            if (select) {
                var opt = select.down("option[value='"+ filter[f] + "']");
                if (opt) {
                    opt.selected = true;
                    update_graph(select.form);
                }
            }
        }
    }
<% end %>
<p>
  <% form_tag do %>
  <%#= link_to_graph "Rules" %>
  <%#= link_to_graph "Privilege hierarchy", :type => 'priv_hierarchy' %>
  
  <%= select_tag "filter_roles", options_for_select([["All roles",'']] + controller.authorization_engine.roles.map(&:to_s).sort), :onchange => 'update_graph(this.form)' %>
  <%= select_tag "filter_contexts", options_for_select([["All contexts",'']] + controller.authorization_engine.auth_rules.collect {|ar| ar.contexts.to_a}.flatten.uniq.map(&:to_s).sort), :onchange => 'update_graph(this.form)' %>
  <%= check_box_tag "effective_role_privs", "1", false, :onclick => 'update_graph(this.form)'  %> <%= label_tag "effective_role_privs", "Effective privileges"  %>
  <%= check_box_tag "privilege_hierarchy", "1", false, :onclick => 'update_graph(this.form)'  %> <%= label_tag "privilege_hierarchy", "Show full privilege hierarchy"  %>
  <% end %>
</p>
<div style="margin: 1em;border:1px solid #ccc;max-width:95%">
<object id="graph" data="<%= url_for :format => 'svg' %>" type="image/svg+xml" style="max-width:100%"/>
</div>
<%= button_to_function "Zoom in", '$("graph").style.maxWidth = "";$(this).toggle();$(this).next().toggle()' %>
<%= button_to_function "Zoom out", '$("graph").style.maxWidth = "100%";$(this).toggle();$(this).previous().toggle()', :style => 'display:none' %>
{'fraction_non_alphanumeric': 0.20687936191425724, 'fraction_numerical': 0.006979062811565304, 'mean_word_length': 3.710093896713615, 'pattern_counts': {'":': 0, '<': 59, '<?xml version=': 0, '>': 75, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2756516', 'n_tokens_mistral': 1435, 'n_tokens_neox': 1341, 'n_words': 251}