Skip to content

Commit b3c101a

Browse files
committed
Implement new route, tweak UI
1 parent a7d5b8f commit b3c101a

File tree

4 files changed

+46
-4
lines changed

4 files changed

+46
-4
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ Default routes:
5252
* **files/thumbnail/{fileId}** - Displays the thumbnail for a file
5353

5454
CRUD:
55-
* **files/upload** - Accepts upload requests from Dropzone
55+
* **files/new** - Basic Dropzone form
56+
* **files/upload** - Accepts AJAX upload requests from Dropzone
5657
* **files/delete/{fileId}** - Removes a file
5758
* **files/rename/{fileId}** - Accepts POST data to rename a file
5859

src/Controllers/Files.php

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,8 @@ public function user($userId = null)
176176

177177
$this->setData([
178178
'access' => 'display',
179-
'title' => 'User Files',
180-
'username' => 'User',
179+
'title' => 'All Files',
180+
'username' => '',
181181
]);
182182
}
183183
// Logged in, looking at another user
@@ -215,6 +215,22 @@ public function user($userId = null)
215215

216216
//--------------------------------------------------------------------
217217

218+
/**
219+
* Display the Dropzone uploader.
220+
*
221+
* @return ResponseInterface|string
222+
*/
223+
public function new()
224+
{
225+
// Check for create permission
226+
if (! $this->model->mayCreate())
227+
{
228+
return $this->failure(403, lang('Permits.notPermitted'));
229+
}
230+
231+
return view('Tatter\Files\Views\new');
232+
}
233+
218234
/**
219235
* Displays or processes the form to rename a file.
220236
*

src/Views/layout.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,17 @@
77
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
88
<meta name="description" content="">
99
<meta name="author" content="Matthew Gatner">
10-
<title>Files</title>
10+
<title><?= $title ?? 'Files' ?></title>
1111

1212
<?= service('assets')->tag('vendor/jquery/jquery.min.js') ?>
1313
<?= service('assets')->tag('vendor/bootstrap/bootstrap.min.css') ?>
1414
<?= service('assets')->tag('vendor/font-awesome/css/all.min.css') ?>
1515
<?= service('assets')->tag('vendor/dropzone/dropzone.min.css') ?>
1616

1717
<?= service('alerts')->css() ?>
18+
19+
<?= $this->renderSection('headerAssets') ?>
20+
1821
</head>
1922
<body>
2023
<nav class="navbar navbar-expand-md navbar-dark bg-dark">
@@ -31,6 +34,9 @@
3134
<li class="nav-item <?= ($menu === 'user') ? 'active' : '' ?>">
3235
<a class="nav-link" href="<?= site_url('files/user') ?>">User Files <?= ($menu === 'user') ? '<span class="sr-only">(current)</span>' : '' ?></a>
3336
</li>
37+
<li class="nav-item <?= ($menu === 'new') ? 'active' : '' ?>">
38+
<a class="nav-link" href="<?= site_url('files/new') ?>" data-toggle="modal" data-target="#dropzoneModal">Add Files</a>
39+
</li>
3440
</ul>
3541
</div>
3642
</nav>
@@ -46,5 +52,7 @@
4652
<?= service('assets')->tag('vendor/bootstrap/bootstrap.bundle.min.js') ?>
4753
<?= service('assets')->tag('vendor/dropzone/dropzone.min.js') ?>
4854

55+
<?= $this->renderSection('footerAssets') ?>
56+
4957
</body>
5058
</html>

src/Views/new.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?= $this->extend(config('Files')->layouts[$layout ?? 'public']) ?>
2+
<?= $this->section('main') ?>
3+
4+
<?= view('Tatter\Files\Views\Dropzone\modal') ?>
5+
6+
<?= $this->endSection() ?>
7+
<?= $this->section('footerAssets') ?>
8+
9+
<?= view(config('Files')->views['dropzone']) ?>
10+
11+
<script>
12+
$(function() {
13+
$('#dropzoneModal').modal('show');
14+
});
15+
</script>
16+
17+
<?= $this->endSection() ?>

0 commit comments

Comments
 (0)