Skip to content

Commit

Permalink
Merge pull request #2 from ARCANESOFT/develop
Browse files Browse the repository at this point in the history
Updating the media vuejs assets & Other stuff
  • Loading branch information
arcanedev-maroc authored Dec 17, 2016
2 parents ba3d7bc + 601ab9e commit ae8d2ea
Show file tree
Hide file tree
Showing 12 changed files with 79 additions and 48 deletions.
2 changes: 1 addition & 1 deletion config/sidebar/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
return [
'title' => 'Media',
'name' => 'media',
'route' => 'media::foundation.index',
'route' => 'admin::media.index',
'icon' => 'fa fa-fw fa-picture-o',
'roles' => [Role::ADMINISTRATOR],
'permissions' => [],
Expand Down
10 changes: 9 additions & 1 deletion resources/assets/js/Config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,15 @@ const config = {
'image/jpeg',
'image/png',
'image/svg+xml'
]
],

"default-icon": "fa-file-pdf-o",

icons: {
"application/pdf": "fa-file-pdf-o",
"application/vnd.ms-excel": "fa-file-excel-o",
"text/plain": "fa-file-text-o"
}
};

export default config;
51 changes: 32 additions & 19 deletions resources/assets/js/MediaManager.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,34 +54,26 @@
>
<div class="media-icon">
<i class="fa fa-fw fa-folder-o" v-if="isMediaDirectory(media)"></i>
<div class="media-image"
v-if="isMediaImage(media)"

<div v-if="isMediaImage(media)"
:style="'background-image: url(' + media.url + ');'"
class="media-image"
></div>

<i v-if="isMediaNotImage(media)" :class="getMediaFileIcon(media)" class="fa fa-fw"></i>
</div>
<div class="media-details">
<h4 class="media-name">{{ media.name }}</h4>
</div>
</a>
<!--<a class="media-item media-file"-->
<!--v-for="file in files"-->
<!--:class="{selected: file.name == selected.name}"-->
<!--@click="selectMedia(file.name, 'file')">-->
<!--<div class="media-icon">-->
<!--<div class="media-image" :style="'background-image: url(' + file.url + ');'"></div>-->
<!--</div>-->
<!--<div class="media-details">-->
<!--<h4 class="media-name">{{ file.name }}</h4>-->
<!--</div>-->
<!--</a>-->
</div>
<div class="media-status-bar">

</div>
<transition name="fade">
<div class="media-loader" v-show="loading">
<i class="fa fa-circle-o-notch fa-spin fa-3x fa-fw"></i>
<p>LOADING&hellip;</p>
<p>{{ loadingText }}</p>
</div>
</transition>
</div>
Expand All @@ -99,6 +91,12 @@
import eventHub from './../../../shared/EventHub'
export default {
props: {
loadingText: {
type: String,
default: "LOADING..."
},
},
data () {
return {
breadcrumbs: [],
Expand Down Expand Up @@ -185,8 +183,8 @@
this.breadcrumbs = [];
this.resetSelected();
this.$http.get(config.endpoint + '/all').then((response) => {
this.medias = response.body.data;
axios.get(config.endpoint + '/all').then((response) => {
this.medias = response.data.data;
this.loading = false;
});
},
Expand All @@ -209,6 +207,15 @@
return _.indexOf(config.supportedImages, media.mimetype) >= 0;
},
isMediaNotImage(media) {
return ! (this.isMediaDirectory(media) || this.isMediaImage(media));
},
getMediaFileIcon(media) {
return _.has(config.icons, media.mimetype)
? config.icons[media.mimetype]
: config['default-icon'];
},
openMedia(media) {
if (this.isMediaDirectory(media)) {
Expand All @@ -225,8 +232,8 @@
this.resetSelected();
this.loading = true;
this.$http.get(config.endpoint + '/all?location=' + location).then((response) => {
this.medias = response.body.data;
axios.get(config.endpoint + '/all?location=' + location).then((response) => {
this.medias = response.data.data;
this.loading = false;
});
},
Expand Down Expand Up @@ -291,7 +298,7 @@
}
</script>

<style lang="sass-loader" rel="stylesheet/scss">
<style lang="sass-loader" rel="stylesheet/scss" scoped>
$container-height: 400px;
$base-color: #4da7e8;
Expand Down Expand Up @@ -370,6 +377,12 @@
font-size: 14px;
font-weight: 600;
line-height: 1.4em;
-webkit-touch-callout: none;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions resources/assets/js/Modals/CreateFolderModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@
},
methods: {
createFolder() {
this.$http
.post(config.endpoint + '/create', {
axios.post(config.endpoint + '/create', {
name: this.newDirectory,
location: this.location
})
Expand Down
3 changes: 1 addition & 2 deletions resources/assets/js/Modals/DeleteMediaModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@
},
methods: {
deleteFolder() {
this.$http
.post(config.endpoint + '/delete', {
axios.post(config.endpoint + '/delete', {
media: this.media
})
.then((response) => {
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 @@ -44,8 +44,7 @@
methods: {
renameFolder() {
if (this.isDirty) {
this.$http
.post(config.endpoint + '/rename', {
axios.post(config.endpoint + '/rename', {
location: this.location,
media: this.media,
newName: this.newName
Expand Down
3 changes: 1 addition & 2 deletions resources/assets/js/Modals/UploadMediaModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@
});
},
upload() {
this.$http
.post(config.endpoint + '/upload', this.formData)
axios.post(config.endpoint + '/upload', this.formData)
.then((response) => {
if (response.data.status == 'success') {
this.$parent.refreshDirectory();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php namespace Arcanesoft\Media\Http\Controllers;
<?php namespace Arcanesoft\Media\Http\Controllers\Admin;

use Arcanesoft\Core\Bases\FoundationController as BaseController;
use Arcanesoft\Core\Traits\Notifyable;

/**
* Class Controller
*
* @package Arcanesoft\Auth\Http\Controllers\Foundation
* @package Arcanesoft\Media\Http\Controllers\Admin
* @author ARCANEDEV <[email protected]>
*/
abstract class Controller extends BaseController
Expand Down Expand Up @@ -39,6 +39,6 @@ public function __construct()
{
parent::__construct();

$this->addBreadcrumbRoute('Media', 'media::foundation.index');
$this->addBreadcrumbRoute('Media', 'admin::media.index');
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php namespace Arcanesoft\Media\Http\Controllers;
<?php namespace Arcanesoft\Media\Http\Controllers\Admin;

use Arcanesoft\Media\Http\Controllers\Admin\Controller;
use Carbon\Carbon;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage;
Expand All @@ -8,7 +9,7 @@
/**
* Class MediasController
*
* @package Arcanesoft\Media\Http\Controllers
* @package Arcanesoft\Media\Http\Controllers\Admin
* @author ARCANEDEV <[email protected]>
*/
class MediasController extends Controller
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php namespace Arcanesoft\Media\Http\Routes;
<?php namespace Arcanesoft\Media\Http\Routes\Admin;

use Arcanedev\Support\Bases\RouteRegister;
use Illuminate\Contracts\Routing\Registrar;
Expand Down Expand Up @@ -28,20 +28,22 @@ public function map(Registrar $router)
$this->registerApiRoutes();
}

/**
* Register the media api routes.
*/
private function registerApiRoutes()
{
// TODO: Adding ajax middleware
$this->group(['prefix' => 'api', 'as' => 'api.'], function () {
// media::foundation.api.get
// admin::media.api.get
$this->get('all', 'MediasController@getAll')->name('get');
// media::foundation.api.upload
// admin::media.api.upload
$this->post('upload', 'MediasController@uploadMedia')->name('upload');
// media::foundation.api.delete
// admin::media.api.delete
$this->post('rename', 'MediasController@renameMedia')->name('rename');
// media::foundation.api.delete
// admin::media.api.delete
$this->post('delete', 'MediasController@deleteMedia')->name('delete');

// media::foundation.api.create
// admin::media.api.create
$this->post('create', 'MediasController@createDirectory')->name('create');
});
}
Expand Down
8 changes: 7 additions & 1 deletion src/Providers/PackagesServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@

use Arcanedev\Support\ServiceProvider;

/**
* Class PackagesServiceProvider
*
* @package Arcanesoft\Media\Providers
* @author ARCANEDEV <[email protected]>
*/
class PackagesServiceProvider extends ServiceProvider
{

//
}
17 changes: 11 additions & 6 deletions src/Providers/RouteServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,25 +40,30 @@ public function getFoundationAuthPrefix()
/**
* Define the routes for the application.
*
* @param \Illuminate\Contracts\Routing\Registrar $router
* @param \Illuminate\Contracts\Routing\Registrar $router
*/
public function map(Router $router)
{
$this->mapFoundationRoutes($router);
$this->mapAdminRoutes($router);
}

private function mapFoundationRoutes(Router $router)
/**
* Register the admin routes.
*
* @param \Illuminate\Contracts\Routing\Registrar $router
*/
private function mapAdminRoutes(Router $router)
{
$attributes = array_merge($this->getFoundationRouteGroup(), [
'as' => 'media::foundation.',
'namespace' => 'Arcanesoft\\Media\\Http\\Controllers',
'as' => 'admin::media.',
'namespace' => 'Arcanesoft\\Media\\Http\\Controllers\\Admin',
]);

$router->group(array_merge(
$attributes,
['prefix' => $this->getFoundationAuthPrefix()]
), function (Router $router) {
Routes\MediaRoutes::register($router);
Routes\Admin\MediaRoutes::register($router);
});
}
}

0 comments on commit ae8d2ea

Please sign in to comment.