aboutsummaryrefslogtreecommitdiffstats
path: root/shardweb/lib/templates/directory/view.html.eex
blob: b4cbfaf960e2d218d32dcd3c5eb7896642f5b5cd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114

<!-- Page Heading -->
<div class="row">
  <div class="col-lg-12">
    <h1 class="page-header">
      <%= @name %>
      <small class="shard_uri"><%= @manifest |> ShardURI.from_manifest %></small>

    </h1>
    <ol class="breadcrumb">
      <li>
        <i class="fa fa-users"></i> Users
      </li>
      <li>
        <i class="fa fa-user"></i> <%= @owner |> SApp.Identity.get_nick %>
        <a href="<%= identity_path(@conn, :view, @owner |> Base.encode16) %>">
          <small><%= @owner |> Shard.Keys.pk_display %></small>
        </a>
      </li>
      <li class="active">
        <i class="fa fa-folder"></i> <%= @name %>
        <%= if @public do %>
          (public)
        <% else %>
          (private)
        <% end %>
      </li>
    </ol>
  </div>
</div>
<!-- /.row -->

<%= render ShardWeb.LayoutView, "flashes.html", assigns %>

<table class="table table-striped">
  <tr>
    <th>Name</th>
    <th>Shard</th>
    <th style="width: 150px"></th>
    <th>URI</th>
  </tr>
  <%= for {name, {manifest, stored}} <- dir_contents(@conn, @manifest) do %>
    <tr>
      <td>
        <%= if stored do %>
          <i class="fa fa-save"></i>
        <% else %>
          <i class="fa fa-link"></i>
        <% end %>
        <strong><%= name %></strong>
      </td>
      <td>
        <%= render ShardWeb.PageView, "shard_entry.html", conn: @conn, manifest: manifest %>
      </td>
      <td>
        <%= form_for @conn, directory_path(@conn, :dir_rm), [class: "form-inline", style: "display: inline"], fn f -> %>
          <%= hidden_input f, :dir_name, value: @name %>
          <%= hidden_input f, :dir_public, value: @public %>
          <%= hidden_input f, :item_name, value: name %>
          <%= submit "Remove", [class: "btn btn-xs btn-danger"] %>
        <% end %>
        <%= form_for @conn, directory_path(@conn, :dir_set_stored), [class: "form-inline", style: "display: inline"], fn f -> %>
          <%= hidden_input f, :dir_name, value: @name %>
          <%= hidden_input f, :dir_public, value: @public %>
          <%= hidden_input f, :item_name, value: name %>
          <%= hidden_input f, :item_stored, value: (if stored do "false" else "true" end) %>
          <%= if stored do %>
            <%= submit "Don't store", [class: "btn btn-xs btn-warning"] %>
          <% else %>
            <%= submit "Store", [class: "btn btn-xs btn-success"] %>
          <% end %>
        <% end %>
      </td>
      <td><small class="shard_uri"><%= manifest |> ShardURI.from_manifest %></small></td>
    </tr>
  <% end %>
</table>

<%= if @owner == @pk do %>
  <fieldset><legend>Add existing item</legend>
    <%= form_for @conn, directory_path(@conn, :dir_add), [class: "form-horizontal"], fn f -> %>
      <%= hidden_input f, :dir_name, value: @name %>
      <%= hidden_input f, :dir_public, value: @public %>
      <div class="form-group">
        <%= label :add_name, "Name:", class: ["col-sm-2 control-label"] %>
        <div class="col-sm-10">
          <%= text_input f, :add_name, [class: "form-control", value: ""] %>
        </div>
      </div>
      <div class="form-group">
        <%= label :add_uri, "URI:", class: ["col-sm-2 control-label"] %>
        <div class="col-sm-10">
          <%= text_input f, :add_uri, [class: "form-control", placeholder: "example: shard:identity:xxx"] %>
        </div>
      </div>
      <div class="form-group">
        <label class="col-sm-2 control-label">Stored?</label>
        <div class="col-sm-10">
          <div class="radio">
            <label><%= radio_button f, :add_stored, "yes" %>Stored <i class="fa fa-save"></i></label>
          </div>
          <div class="radio">
            <label><%= radio_button f, :add_stored, "no" %>Linked <i class="fa fa-link"></i></label>
          </div>
        </div>
      </div>

      <div class="form-group">
        <div class="col-sm-offset-2 col-sm-10">
          <%= submit "Add", [class: "btn btn-default"] %>
        </div>
      </div>
    <% end %>
  </fieldset>
<% end %>