Skip to content

Commit

Permalink
Merge pull request #4 from ARCANESOFT/dev
Browse files Browse the repository at this point in the history
Updating the Media Manager
  • Loading branch information
arcanedev-maroc authored Feb 12, 2017
2 parents 209aaf1 + f86cf3b commit f9b28a8
Show file tree
Hide file tree
Showing 16 changed files with 375 additions and 85 deletions.
28 changes: 24 additions & 4 deletions config/media.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

return [
/* ------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------
| Filesystem
| ------------------------------------------------------------------------------------------------
| -----------------------------------------------------------------
*/
'filesystem' => [
'default' => 'media',
Expand All @@ -17,11 +17,31 @@
],
],

/* ------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------
| Route
| ------------------------------------------------------------------------------------------------
| -----------------------------------------------------------------
*/
'route' => [
'prefix' => 'media',
],

/* -----------------------------------------------------------------
| Directories
| -----------------------------------------------------------------
*/
'directories' => [
'excluded' => [
//
],
],

/* -----------------------------------------------------------------
| Files
| -----------------------------------------------------------------
*/
'files' => [
'excluded' => [
'.gitignore',
],
],
];
23 changes: 23 additions & 0 deletions resources/assets/js/Helpers/Errors.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<template>
<ul class="list-unstyled" v-if="hasErrors">
<li v-for="error in errors">
<span class="label label-danger">{{ displayFirstError(error) }}</span>
</li>
</ul>
</template>

<script>
export default {
props: ['errors'],
methods: {
hasErrors() {
return this.errors.length > 0
},
displayFirstError(error) {
return _.first(error)
},
}
}
</script>
9 changes: 5 additions & 4 deletions resources/assets/js/MediaManager.vue
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@
</template>

<script>
import config from './Config'
import eventHub from './../../../shared/EventHub'
import config from './Config';
export default {
props: {
Expand Down Expand Up @@ -173,12 +172,14 @@
currentUri() {
return this.breadcrumbs.length == 0 ? '/' : this.breadcrumbs.join('/')
},
selectedUri() {
if (this.selected == null)
return this.currentUri;
return this.currentUri + this.selected.name;
},
mediasCount() {
return this.medias.length;
}
Expand All @@ -189,7 +190,7 @@
this.breadcrumbs = [];
this.resetSelected();
axios.get(config.endpoint + '/all').then((response) => {
axios.get(config.endpoint+'/all').then((response) => {
this.medias = response.data.data;
this.loading = false;
});
Expand Down Expand Up @@ -244,7 +245,7 @@
this.resetSelected();
this.loading = true;
axios.get(config.endpoint + '/all?location=' + location).then(response => {
axios.get(config.endpoint+'/all?location='+location).then(response => {
this.medias = response.data.data;
this.loading = false;
});
Expand Down
46 changes: 22 additions & 24 deletions resources/assets/js/Modals/CreateFolderModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@
<div class="modal-body">
<input type="text" placeholder="Folder name" v-model="newDirectory" class="form-control" autofocus>

<ul class="list-unstyled">
<li v-for="error in errors">
<span class="label label-danger">{{ errors.length }} {{ displayFirstError(error) }}</span>
</li>
</ul>
<media-errors :errors="errors"></media-errors>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-sm btn-default pull-left" data-dismiss="modal">
Expand All @@ -31,33 +27,40 @@
</template>

<script>
import config from './../Config'
import eventHub from './../../../../shared/EventHub'
import config from './../Config';
export default {
props: ['location'],
data () {
return {
newDirectory: '',
errors: {}
modal: null,
submitBtn: null,
errors: []
}
},
components: {
'media-errors': require('./../Helpers/Errors.vue')
},
created() {
let that = this;
let me = this;
eventHub.$on('open-new-folder-modal', data => {
let modal = $('div#newFolderModal');
me.modal = $('div#newFolderModal');
me.submitBtn = me.modal.find('button[type="submit"]');
modal.modal('show');
me.modal.modal('show');
modal.on('shown.bs.modal', () => {
me.modal.on('shown.bs.modal', () => {
$(this).find('[autofocus]').focus();
});
modal.on('hidden.bs.modal', () => {
that.resetErrors();
me.modal.on('hidden.bs.modal', () => {
me.resetErrors();
})
});
},
Expand All @@ -66,35 +69,30 @@
createFolder(e) {
this.resetErrors();
let $submitBtn = $(e.target.querySelector('button[type="submit"]'));
$submitBtn.button('loading');
this.submitBtn.button('loading');
axios.post(config.endpoint + '/create', {
axios.post(config.endpoint+'/create', {
name: this.newDirectory,
location: this.location
})
.then(response => {
this.$parent.refreshDirectory();
$('div#newFolderModal').modal('hide');
this.modal.modal('hide');
this.$parent.mediaModalClosed();
this.newDirectory = '';
})
.catch(error => {
$submitBtn.button('reset');
this.submitBtn.button('reset');
this.errors = error.response.data.errors;
});
},
displayFirstError(error) {
return _.first(error)
},
resetErrors() {
this.errors = {};
this.errors = [];
}
}
}
Expand Down
38 changes: 27 additions & 11 deletions resources/assets/js/Modals/DeleteMediaModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,43 +25,59 @@
</template>

<script>
import config from './../Config'
import eventHub from './../../../../shared/EventHub'
import config from './../Config';
export default {
props: ['media'],
data() {
return {
modal: null,
submitBtn: null
}
},
components: {
'media-errors': require('./../Helpers/Errors.vue')
},
created() {
let that = this;
let me = this;
eventHub.$on('open-delete-media-modal', data => {
let modal = $('div#deleteFolderModal');
me.modal = $('div#deleteFolderModal');
me.submitBtn = me.modal.find('button[type="submit"]');
modal.modal({
me.modal.modal({
backdrop: 'static',
keyboard: false
});
})
});
},
methods: {
deleteFolder(e) {
let $submitBtn = $(e.target.querySelector('button[type="submit"]'));
$submitBtn.button('loading');
this.submitBtn.button('loading');
axios.post(config.endpoint + '/delete', {
axios.post(config.endpoint+'/delete', {
media: this.media
})
.then(response => {
this.$parent.refreshDirectory();
$('div#deleteFolderModal').modal('hide');
this.modal.modal('hide');
this.$parent.mediaModalClosed();
this.newDirectory = '';
$submitBtn.button('reset');
this.submitBtn.button('reset');
})
.catch(error => {
this.submitBtn.button('reset');
this.errors = error.response.data.errors;
});
}
}
Expand Down
3 changes: 1 addition & 2 deletions resources/assets/js/Modals/RenameMediaModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
</template>

<script>
import config from './../Config'
import eventHub from './../../../../shared/EventHub'
import config from './../Config';
export default {
props: ['location', 'media'],
Expand Down
6 changes: 2 additions & 4 deletions resources/assets/js/Modals/UploadMediaModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@
</template>

<script>
import config from './../Config'
import eventHub from './../../../../shared/EventHub'
import Dropzone from 'dropzone'
import config from './../Config';
import Dropzone from 'dropzone';
Dropzone.autoDiscover = false;
Expand Down
40 changes: 31 additions & 9 deletions src/Contracts/Media.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,31 +49,31 @@ public function disk($driver = null);
public function defaultDisk();

/**
* Get all of the directories within a given directory.
* Get all the directories & files from a given location.
*
* @param string $directory
*
* @return \Arcanesoft\Media\Entities\DirectoryCollection
* @return array
*/
public function directories($directory);
public function all($directory);

/**
* Get a collection of all files in a directory.
* Get all of the directories within a given directory.
*
* @param string $directory
*
* @return \Arcanesoft\Media\Entities\FileCollection
* @return \Arcanesoft\Media\Entities\DirectoryCollection
*/
public function files($directory);
public function directories($directory);

/**
* Get all the directories & files from a given location.
* Get a collection of all files in a directory.
*
* @param string $directory
*
* @return array
* @return \Arcanesoft\Media\Entities\FileCollection
*/
public function all($directory);
public function files($directory);

/**
* Store an array of files.
Expand Down Expand Up @@ -111,4 +111,26 @@ public function makeDirectory($path);
* @return bool
*/
public function move($from, $to);

/* -----------------------------------------------------------------
| Check Methods
| -----------------------------------------------------------------
*/
/**
* Determine if a file/directory exists.
*
* @param string $path
*
* @return bool
*/
public function exists($path);

/**
* Check if the directory is excluded.
*
* @param string $directory
*
* @return bool
*/
public function isExcludedDirectory($directory);
}
Loading

0 comments on commit f9b28a8

Please sign in to comment.