Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update media manager #462

Merged
merged 3 commits into from
Nov 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/Controllers/BadasoMenuController.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,8 @@ public function browseMenuItemByKeys(Request $request)

$data = [];
foreach ($menus as $index => $menu) {
$menu_items = $all_menu_items->whereNull($prefix.'menu_items.parent_id')
$menu_items = $all_menu_items
->where('parent_id', null)
->where('menu_id', $menu->id)->map(function ($item) use ($all_menu_items) {
$children = array_values($all_menu_items->where('parent_id', $item->id)->toArray());

Expand Down
61 changes: 46 additions & 15 deletions src/Seeder/Configurations/FixedMenuItemSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,31 +135,57 @@ public function run()
9 => [
'id' => 10,
'menu_id' => $menu_core,
'title' => 'File Manager',
'url' => '/file-manager',
'title' => 'API Documentation',
'url' => '/api-docs',
'target' => '_self',
'icon_class' => 'perm_media',
'icon_class' => 'menu_book',
'color' => '',
'parent_id' => null,
'order' => 8,
'permissions' => 'browse_file_manager',
'order' => 9,
'permissions' => 'browse_apidocs',
],

// media manager
10 => [
'id' => 11,
'menu_id' => $menu_core,
'title' => 'API Documentation',
'url' => '/api-docs',
'title' => 'Media Manager',
'url' => '#',
'target' => '_self',
'icon_class' => 'menu_book',
'icon_class' => '',
'color' => '',
'parent_id' => null,
'order' => 9,
'permissions' => 'browse_apidocs',
'order' => 10,
'permissions' => '',
],

// general menu
11 => [
'id' => 12,
'menu_id' => $menu_core,
'title' => 'Files',
'url' => '/file-manager',
'target' => '_self',
'icon_class' => 'folder',
'color' => '',
'parent_id' => 11,
'order' => 1,
'permissions' => 'browse_file_manager',
],
12 => [
'id' => 13,
'menu_id' => $menu_core,
'title' => 'Images',
'url' => '/image-manager',
'target' => '_self',
'icon_class' => 'perm_media',
'color' => '',
'parent_id' => 11,
'order' => 2,
'permissions' => 'browse_file_manager',
],

// general menu
13 => [
'id' => 14,
'menu_id' => $menu_general,
'title' => 'Dashboard',
'url' => '/home',
Expand All @@ -182,10 +208,15 @@ public function run()
continue;
}

MenuItem::create($value);
$menu_item = MenuItem::find($value['id']);
if (isset($menu_item)) {
$menu_item->update($value);
} else {
$menu_item = MenuItem::create($value);
}
}
} catch (Exception $e) {
throw new Exception('Exception occur '.$e);
} catch (\Exception $e) {
throw new \Exception('Exception occur '.$e);
\DB::rollBack();
}

Expand Down
2 changes: 1 addition & 1 deletion src/resources/js/pages/file-manager/browse.vue
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export default {
urlFileManager() {
let host = window.location.origin;
let token = localStorage.getItem("token");
let url = `${host}/filemanager?token=${token}`;
let url = `${host}/filemanager?type=Files&token=${token}`;
return url;
},
},
Expand Down
84 changes: 84 additions & 0 deletions src/resources/js/pages/image-manager/browse.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<template>
<div>
<badaso-breadcrumb-row>
<template slot="action"> </template>
</badaso-breadcrumb-row>
<vs-row v-if="$helper.isAllowed('browse_file_manager')">
<vs-col vs-lg="12">
<vs-card>
<div slot="header">
<h3>{{ $t("fileManager.title") }}</h3>
</div>
<iframe
v-if="isShow"
:src="urlIframe"
class="file-manager__iframe"
/>
<div v-else>
{{ message }}
</div>
</vs-card>
</vs-col>
</vs-row>
<vs-row v-else>
<vs-col vs-lg="12">
<vs-card>
<vs-row>
<vs-col vs-lg="12">
<h3>{{ $t("fileManager.warning.notAllowedToBrowse") }}</h3>
</vs-col>
</vs-row>
</vs-card>
</vs-col>
</vs-row>
</div>
</template>
<script>
export default {
name: "ImageManagerBrowse",
components: {},
data() {
return {
statusCode: null,
message: null,
isShow: true,
urlIframe: null,
};
},
async created() {
await this.requestCheckPageIFrame();
},
methods: {
async requestCheckPageIFrame() {
this.$openLoader();

this.$resource
.get(this.urlFileManager)
.then((result) => {
this.urlIframe = this.urlFileManager;
this.isShow = true;
})
.catch((error) => {
let { message } = error;
this.$vs.notify({
title: this.$t("alert.danger"),
text: message,
color: "danger",
});
this.isShow = false;
})
.finally(() => {
this.$closeLoader();
});
},
},
computed: {
urlFileManager() {
let host = window.location.origin;
let token = localStorage.getItem("token");
let url = `${host}/filemanager?type=Images&token=${token}`;
return url;
},
},
};
</script>
2 changes: 2 additions & 0 deletions src/resources/js/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import UserManagementEdit from "./user-management/edit";
import UserManagementAdd from "./user-management/add";
import UserManagementRoles from "./user-management/roles";
import FileManagerBrowse from "./file-manager/browse";
import ImageManagerBrowse from "./image-manager/browse";
import LogViewerBrowse from './log-viewer/browse';
import NotificationBrowse from './notification/browse';
import DataPendingAddBrowse from './data-pending-add/browse';
Expand Down Expand Up @@ -110,6 +111,7 @@ export default {
DataPendingAddBrowse,
DataPendingEditRead,
ApiDocsBrowse,
ImageManagerBrowse,
},
name: "ActivityLogIndex",
data: () => ({
Expand Down
10 changes: 9 additions & 1 deletion src/resources/js/router/admin/configuration-router.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,15 @@ export default [
name: "FileManagerBrowse",
component: Pages,
meta: {
title: "File Manager",
title: "Files",
},
},
{
path: prefix + "/image-manager",
name: "ImageManagerBrowse",
component: Pages,
meta: {
title: "Images",
},
},
{
Expand Down
6 changes: 6 additions & 0 deletions src/resources/js/store/modules/badaso.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ export default {
state.menu = data.map((menu) => {
menu.menuItems.map((menuItem) => {
menuItem.url = "/" + prefix + menuItem.url;
if (menuItem.children) {
menuItem.children = menuItem.children.map((menuChildren) => {
menuChildren.url = "/" + prefix + menuChildren.url;
return menuChildren;
});
}
return menuItem;
});
return menu;
Expand Down