Improve UI styling

This commit is contained in:
Lena Fuhrimann 2019-08-18 14:26:29 +02:00
parent 5ee6a263bc
commit 6a50b1b1c7
4 changed files with 54 additions and 53 deletions

View file

@ -62,7 +62,7 @@ func HandleBucketView(s3 S3, tmplDir string) http.HandlerFunc {
func icon(fileName string) string { func icon(fileName string) string {
e := path.Ext(fileName) e := path.Ext(fileName)
switch e { switch e {
case ".tgz", ".gz": case ".tgz", ".gz", ".zip":
return "archive" return "archive"
case ".png", ".jpg", ".gif", ".svg": case ".png", ".jpg", ".gif", ".svg":
return "photo" return "photo"

View file

@ -1,44 +1,49 @@
{{ define "content" }} {{ define "content" }}
<nav class="purple" role="navigation"> <nav>
<div class="nav-wrapper container"> <div class="nav-wrapper container">
<span href="#" class="brand-logo"><i class="material-icons">folder_open</i>{{ .BucketName }}</span> <span href="#" class="brand-logo"><i class="material-icons">folder_open</i>{{ .BucketName }}</span>
{{ if not .Objects }} {{ if not .Objects }}
<a href="#" class="right" onclick="deleteBucket({{ .BucketName }})"><i class="material-icons">delete</i> Delete</a> <ul class="right">
<li>
<a class="waves-effect waves-light btn" href="#" onclick="deleteBucket({{ .BucketName }})">
Delete <i class="material-icons right">delete</i>
</a>
</li>
</ul>
{{ end }} {{ end }}
</div> </div>
</nav> </nav>
<div class="section"> <div class="section">
<a href="/buckets" style="padding-left: 25px; vertical-align: middle;"><i class="material-icons" style="vertical-align: middle;">arrow_back</i> Buckets</a> <a href="/buckets" style="padding-left:25px;vertical-align:middle;">
<i class="material-icons" style="vertical-align: middle;">arrow_back</i> Buckets
</a>
{{ if .Objects }} {{ if .Objects }}
<table class="highlight bordered"> <table class="striped">
<thead> <thead>
<tr> <tr>
<th></th> <th style="width:75px;"></th>
<th>Key</th> <th>Key</th>
<th>Size</th> <th>Size</th>
<th>Owner</th> <th>Owner</th>
<th>Last Modified</th> <th>Last Modified</th>
<th></th> <th style="min-width:165px;"></th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{{ range $index, $object := .Objects }} {{ range $index, $object := .Objects }}
<tr> <tr>
<td style="padding-left: 25px;"><i class="material-icons">{{ $object.Icon }}</i></td> <td style="padding-left:25px;"><i class="material-icons">{{ $object.Icon }}</i></td>
<td>{{ $object.Info.Key }}</td> <td>{{ $object.Info.Key }}</td>
<td>{{ $object.Info.Size }} bytes</td> <td>{{ $object.Info.Size }} bytes</td>
<td>{{ $object.Info.Owner }}</td> <td>{{ $object.Info.Owner }}</td>
<td>{{ $object.Info.LastModified }}</td> <td>{{ $object.Info.LastModified }}</td>
<td> <td>
<!-- Dropdown Trigger --> <button class="dropdown-trigger waves-effect waves-teal btn" data-target="actions-dropdown-{{ $index }}">
<a class="dropdown-button waves-effect waves-teal btn-flat" href="#" data-activates="actions-dropdown-{{ $index }}">
Actions <i class="material-icons right">arrow_drop_down</i> Actions <i class="material-icons right">arrow_drop_down</i>
</a> </button>
<!-- Dropdown Structure --> <!-- Dropdown Structure -->
<ul id="actions-dropdown-{{ $index }}" class="dropdown-content"> <ul id="actions-dropdown-{{ $index }}" class="dropdown-content">
<li><a href="/api/buckets/{{ $.BucketName }}/objects/{{ $object.Info.Key }}">Download</a></li> <li><a href="/api/buckets/{{ $.BucketName }}/objects/{{ $object.Info.Key }}">Download</a></li>
@ -48,20 +53,19 @@
</tr> </tr>
{{ end }} {{ end }}
</tbody> </tbody>
</table> </table>
{{ end }} {{ end }}
{{ if not .Objects }} {{ if not .Objects }}
<p style="text-align: center;margin-top: 2em;">No objects in <strong>{{ .BucketName }}</strong> yet</p> <p style="text-align:center;margin-top:2em;color:gray;">No objects in <strong>{{ .BucketName }}</strong> yet</p>
{{ end }} {{ end }}
</div> </div>
<div class="fixed-action-btn"> <div class="fixed-action-btn">
<a class="btn-floating btn-large red modal-trigger" href="#modal-create-object"> <button type="button" class="btn-floating btn-large red modal-trigger" data-target="modal-create-object">
<i class="large material-icons">add</i> <i class="large material-icons">add</i>
</a> </button>
</div> </div>
<div id="modal-create-object" class="modal"> <div id="modal-create-object" class="modal">
@ -86,8 +90,8 @@
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="submit" class="modal-action modal-close waves-effect waves-green btn-flat">Upload</button> <button type="button" class="modal-close waves-effect waves-green btn-flat">Cancel</button>
<button class="modal-action modal-close waves-effect waves-green btn-flat">Cancel</button> <button type="submit" class="modal-close waves-effect waves-green btn">Upload</button>
</div> </div>
</form> </form>

View file

@ -1,5 +1,5 @@
{{ define "content" }} {{ define "content" }}
<nav class="purple" role="navigation"> <nav>
<div class="nav-wrapper container"> <div class="nav-wrapper container">
<a href="/" class="brand-logo">S3 Manager</a> <a href="/" class="brand-logo">S3 Manager</a>
</div> </div>
@ -11,11 +11,11 @@
{{ if . }} {{ if . }}
{{ range $bucket := . }} {{ range $bucket := . }}
<div class="col m12 l6"> <div class="col l6 m12">
<a href="/buckets/{{ $bucket.Name }}" style="color: black;"> <a href="/buckets/{{ $bucket.Name }}" style="color:black;">
<div class="card"> <div class="card">
<div class="card-content"> <div class="card-content">
<div class="row" style="margin-bottom: 0;"> <div class="row">
<div class="col"> <div class="col">
<i class="material-icons large">folder_open</i> <i class="material-icons large">folder_open</i>
</div> </div>
@ -23,7 +23,7 @@
<span class="card-title"> <span class="card-title">
{{ $bucket.Name }} {{ $bucket.Name }}
</span> </span>
<p style="color: gray;">Created on {{ $bucket.CreationDate }}</p> <p style="color:gray;">Created on {{ $bucket.CreationDate }}</p>
</div> </div>
</div> </div>
</div> </div>
@ -34,7 +34,7 @@
{{ end }} {{ end }}
{{ if not . }} {{ if not . }}
<p style="text-align: center;margin-top: 2em;">No buckets yet</p> <p style="text-align:center;margin-top:2em;color:gray;">No buckets yet</p>
{{ end }} {{ end }}
</div> </div>
@ -42,50 +42,46 @@
</div> </div>
<div class="fixed-action-btn"> <div class="fixed-action-btn">
<a class="btn-floating btn-large red modal-trigger" href="#modal-create-bucket"> <button type="button" class="btn-floating btn-large red modal-trigger" data-target="modal-create-bucket">
<i class="large material-icons">add</i> <i class="material-icons large">add</i>
</a> </button>
</div> </div>
<div id="modal-create-bucket" class="modal"> <div id="modal-create-bucket" class="modal">
<form id="create-bucket-form"> <form id="create-bucket-form">
<div class="modal-content"> <div class="modal-content">
<h4>Create Bucket</h4> <h4>Create Bucket</h4>
<br> <br>
<div class="row"> <div class="row">
<div class="col s6"> <div class="input-field col m6">
<div class="input-field"> <input id="name" type="text" name="name" placeholder="My Bucket">
<input placeholder="My Bucket" id="name" type="text" name="name"> <label for="name">Name</label>
<label for="name">Name</label>
</div>
</div> </div>
</div> </div>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" onclick="createBucket()" class="modal-action modal-close waves-effect waves-green btn-flat">Create</button> <button type="button" class="modal-close waves-effect waves-green btn-flat">Cancel</button>
<button class="modal-action modal-close waves-effect waves-green btn-flat">Cancel</button> <button type="button" class="modal-close waves-effect waves-green btn" onclick="createBucket()">Create</button>
</div> </div>
</form> </form>
</div> </div>
<script> <script>
function createBucket() { function createBucket() {
var formData = {}; var formData = {};
$.each($('#create-bucket-form') $.each($('#create-bucket-form')
.serializeArray(), function(i, field) { .serializeArray(), function(i, field) {
formData[field.name] = field.value; formData[field.name] = field.value;
});
$.ajax({
type: 'POST',
url: '/api/buckets',
data: JSON.stringify(formData),
dataType: 'json',
contentType: 'application/json; charset=utf-8',
success: function() { location.reload(); }
}); });
$.ajax({ }
type: 'POST',
url: '/api/buckets',
data: JSON.stringify(formData),
dataType: 'json',
contentType: 'application/json; charset=utf-8',
success: function() { location.reload(); }
});
}
</script> </script>
{{ end }} {{ end }}

View file

@ -18,13 +18,14 @@
{{ template "content" . }} {{ template "content" . }}
<script <script
src="https://code.jquery.com/jquery-3.3.1.min.js" src="https://code.jquery.com/jquery-3.4.1.min.js"
integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo="
crossorigin="anonymous" crossorigin="anonymous"
></script> ></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js" integrity="sha256-U/cHDMTIHCeMcvehBv1xQ052bPSbJtbuiw4QA9cTKz0=" crossorigin="anonymous"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js" integrity="sha256-U/cHDMTIHCeMcvehBv1xQ052bPSbJtbuiw4QA9cTKz0=" crossorigin="anonymous"></script>
<script> <script>
$(document).ready(function(){ $(document).ready(function(){
$('.dropdown-trigger').dropdown();
$('.modal').modal(); $('.modal').modal();
}); });
</script> </script>