2020-01-30 15:25:10 -05:00
|
|
|
<template>
|
|
|
|
<div>
|
2020-04-15 12:11:14 -04:00
|
|
|
<Menu />
|
2023-01-11 04:54:25 -05:00
|
|
|
<div class="container-fluid browser-container">
|
2023-03-27 10:28:13 -04:00
|
|
|
<div class="h-100">
|
|
|
|
<div>
|
|
|
|
<nav aria-label="breadcrumb">
|
|
|
|
<ol class="breadcrumb">
|
|
|
|
<li
|
|
|
|
class="breadcrumb-item"
|
|
|
|
v-for="(crumb, index) in mediaStore.crumbs"
|
|
|
|
:key="index"
|
|
|
|
:active="index === mediaStore.crumbs.length - 1"
|
|
|
|
@click="getPath(crumb.path)"
|
|
|
|
>
|
2023-12-07 16:00:05 -05:00
|
|
|
<a v-if="mediaStore.crumbs.length > 1 && mediaStore.crumbs.length - 1 > index" href="#">
|
2023-03-27 10:28:13 -04:00
|
|
|
{{ crumb.text }}
|
|
|
|
</a>
|
|
|
|
<span v-else>{{ crumb.text }}</span>
|
|
|
|
</li>
|
|
|
|
</ol>
|
|
|
|
</nav>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="browser-div">
|
|
|
|
<div v-if="browserIsLoading" class="d-flex justify-content-center loading-overlay">
|
|
|
|
<div class="spinner-border" role="status" />
|
|
|
|
</div>
|
|
|
|
<splitpanes
|
|
|
|
class="pane-row"
|
|
|
|
:class="$route.path === '/player' ? 'browser-splitter' : ''"
|
|
|
|
:horizontal="$route.path === '/player'"
|
|
|
|
>
|
|
|
|
<pane
|
|
|
|
min-size="14"
|
|
|
|
max-size="80"
|
|
|
|
size="24"
|
|
|
|
:style="
|
|
|
|
$route.path === '/player'
|
|
|
|
? `height: ${mediaStore.folderTree.folders.length * 47 + 2}px`
|
|
|
|
: ''
|
|
|
|
"
|
|
|
|
>
|
|
|
|
<ul v-if="mediaStore.folderTree.parent" class="list-group media-browser-scroll m-1">
|
|
|
|
<li
|
|
|
|
class="list-group-item browser-item"
|
|
|
|
v-for="folder in mediaStore.folderTree.folders"
|
2023-09-08 04:16:34 -04:00
|
|
|
:key="folder.uid"
|
2023-03-27 10:28:13 -04:00
|
|
|
>
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-1 browser-icons-col">
|
|
|
|
<i class="bi-folder-fill browser-icons" />
|
|
|
|
</div>
|
|
|
|
<div class="col browser-item-text">
|
|
|
|
<a
|
|
|
|
class="link-light"
|
|
|
|
href="#"
|
2023-09-08 04:16:34 -04:00
|
|
|
@click="getPath(`/${mediaStore.folderTree.source}/${folder.name}`)"
|
2023-03-27 10:28:13 -04:00
|
|
|
>
|
2023-09-08 04:16:34 -04:00
|
|
|
{{ folder.name }}
|
2023-03-27 10:28:13 -04:00
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
<div class="col-1 folder-delete">
|
|
|
|
<a
|
|
|
|
href="#"
|
|
|
|
class="btn-link"
|
|
|
|
data-bs-toggle="modal"
|
|
|
|
data-bs-target="#deleteModal"
|
|
|
|
@click="
|
2023-12-07 16:00:05 -05:00
|
|
|
deleteName =
|
|
|
|
`/${mediaStore.folderTree.source}/${folder.name}`.replace(
|
|
|
|
/\/[/]+/g,
|
|
|
|
'/'
|
|
|
|
)
|
2023-03-27 10:28:13 -04:00
|
|
|
"
|
|
|
|
>
|
|
|
|
<i class="bi-x-circle-fill" />
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</pane>
|
|
|
|
<pane
|
|
|
|
:style="
|
|
|
|
$route.path === '/player'
|
|
|
|
? `height: ${mediaStore.folderTree.files.length * 26 + 2}px`
|
|
|
|
: ''
|
|
|
|
"
|
|
|
|
>
|
|
|
|
<ul v-if="mediaStore.folderTree.parent" class="list-group media-browser-scroll m-1">
|
|
|
|
<li
|
|
|
|
v-for="(element, index) in mediaStore.folderTree.files"
|
|
|
|
:id="`file_${index}`"
|
|
|
|
class="draggable list-group-item browser-item"
|
|
|
|
:key="element.name"
|
|
|
|
>
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-1 browser-icons-col">
|
|
|
|
<i
|
|
|
|
v-if="mediaType(element.name) === 'audio'"
|
|
|
|
class="bi-music-note-beamed browser-icons"
|
|
|
|
/>
|
|
|
|
<i
|
|
|
|
v-else-if="mediaType(element.name) === 'video'"
|
|
|
|
class="bi-film browser-icons"
|
|
|
|
/>
|
|
|
|
<i
|
|
|
|
v-else-if="mediaType(element.name) === 'image'"
|
|
|
|
class="bi-file-earmark-image browser-icons"
|
|
|
|
/>
|
|
|
|
<i v-else class="bi-file-binary browser-icons" />
|
|
|
|
</div>
|
|
|
|
<div class="col browser-item-text grabbing">
|
|
|
|
{{ element.name }}
|
|
|
|
</div>
|
|
|
|
<div class="col-1 browser-play-col">
|
|
|
|
<a
|
|
|
|
href="#"
|
|
|
|
class="btn-link"
|
|
|
|
data-bs-toggle="modal"
|
|
|
|
data-bs-target="#previewModal"
|
|
|
|
@click="setPreviewData(element.name)"
|
|
|
|
>
|
|
|
|
<i class="bi-play-fill" />
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
<div class="col-1 browser-dur-col">
|
|
|
|
<span class="duration">{{ toMin(element.duration) }}</span>
|
|
|
|
</div>
|
|
|
|
<div class="col-1 file-rename">
|
|
|
|
<a
|
|
|
|
href="#"
|
|
|
|
class="btn-link"
|
|
|
|
data-bs-toggle="modal"
|
|
|
|
data-bs-target="#renameModal"
|
|
|
|
@click="
|
|
|
|
setRenameValues(
|
|
|
|
`/${mediaStore.folderTree.source}/${element.name}`.replace(
|
|
|
|
/\/[/]+/g,
|
|
|
|
'/'
|
|
|
|
)
|
|
|
|
)
|
|
|
|
"
|
|
|
|
>
|
|
|
|
<i class="bi-pencil-square" />
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
<div class="col-1 file-delete">
|
|
|
|
<a
|
|
|
|
href="#"
|
|
|
|
class="btn-link"
|
|
|
|
data-bs-toggle="modal"
|
|
|
|
data-bs-target="#deleteModal"
|
|
|
|
@click="
|
|
|
|
deleteName =
|
|
|
|
`/${mediaStore.folderTree.source}/${element.name}`.replace(
|
|
|
|
/\/[/]+/g,
|
|
|
|
'/'
|
|
|
|
)
|
|
|
|
"
|
|
|
|
>
|
|
|
|
<i class="bi-x-circle-fill" />
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</pane>
|
|
|
|
</splitpanes>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div id="previewModal" class="modal" tabindex="-1" aria-labelledby="previewModalLabel" aria-hidden="true">
|
|
|
|
<div class="modal-dialog modal-dialog-centered modal-xl">
|
|
|
|
<div class="modal-content">
|
|
|
|
<div class="modal-header">
|
|
|
|
<h1 class="modal-title fs-5" id="previewModalLabel">Preview: {{ previewName }}</h1>
|
|
|
|
<button
|
|
|
|
type="button"
|
|
|
|
class="btn-close"
|
|
|
|
data-bs-dismiss="modal"
|
|
|
|
aria-label="Cancel"
|
|
|
|
@click="closePlayer()"
|
|
|
|
></button>
|
|
|
|
</div>
|
|
|
|
<div class="modal-body">
|
|
|
|
<VideoPlayer v-if="isVideo && previewOpt" reference="previewPlayer" :options="previewOpt" />
|
|
|
|
<img v-else :src="previewUrl" class="img-fluid" :alt="previewName" />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div id="deleteModal" class="modal" tabindex="-1" aria-labelledby="deleteModalLabel" aria-hidden="true">
|
|
|
|
<div class="modal-dialog modal-dialog-centered">
|
|
|
|
<div class="modal-content">
|
|
|
|
<div class="modal-header">
|
|
|
|
<h1 class="modal-title fs-5" id="deleteModalLabel">Delete File/Folder</h1>
|
|
|
|
<button
|
|
|
|
type="button"
|
|
|
|
class="btn-close"
|
|
|
|
data-bs-dismiss="modal"
|
|
|
|
aria-label="Cancel"
|
|
|
|
></button>
|
|
|
|
</div>
|
|
|
|
<div class="modal-body">
|
|
|
|
<p>
|
|
|
|
Are you sure that you want to delete:<br />
|
|
|
|
<strong>{{ deleteName }}</strong>
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
<div class="modal-footer">
|
|
|
|
<button
|
|
|
|
type="reset"
|
|
|
|
class="btn btn-primary"
|
|
|
|
data-bs-dismiss="modal"
|
|
|
|
aria-label="Cancel"
|
|
|
|
@click="deleteName = ''"
|
|
|
|
>
|
|
|
|
Cancel
|
|
|
|
</button>
|
|
|
|
<button
|
|
|
|
type="submit"
|
|
|
|
class="btn btn-primary"
|
|
|
|
data-bs-dismiss="modal"
|
|
|
|
@click="deleteFileOrFolder"
|
|
|
|
>
|
|
|
|
Ok
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div id="renameModal" class="modal" tabindex="-1" aria-labelledby="renameModalLabel" aria-hidden="true">
|
|
|
|
<div class="modal-dialog modal-dialog-centered">
|
|
|
|
<div class="modal-content">
|
|
|
|
<div class="modal-header">
|
|
|
|
<h1 class="modal-title fs-5" id="renameModalLabel">Rename File</h1>
|
|
|
|
<button
|
|
|
|
type="button"
|
|
|
|
class="btn-close"
|
|
|
|
data-bs-dismiss="modal"
|
|
|
|
aria-label="Cancel"
|
|
|
|
></button>
|
|
|
|
</div>
|
|
|
|
<form @submit.prevent="onSubmitRenameFile" @reset="onCancelRenameFile">
|
|
|
|
<div class="modal-body">
|
|
|
|
<input type="text" class="form-control" v-model="renameNewName" />
|
|
|
|
</div>
|
|
|
|
<div class="modal-footer">
|
|
|
|
<button
|
|
|
|
type="reset"
|
|
|
|
class="btn btn-primary"
|
|
|
|
data-bs-dismiss="modal"
|
|
|
|
aria-label="Cancel"
|
|
|
|
>
|
|
|
|
Cancel
|
|
|
|
</button>
|
|
|
|
<button type="submit" class="btn btn-primary" data-bs-dismiss="modal">Ok</button>
|
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2023-01-11 04:54:25 -05:00
|
|
|
</div>
|
|
|
|
<div class="btn-group media-button">
|
|
|
|
<button
|
|
|
|
type="button"
|
|
|
|
class="btn btn-primary"
|
|
|
|
title="Create Folder"
|
|
|
|
data-bs-toggle="modal"
|
|
|
|
data-bs-target="#folderModal"
|
|
|
|
>
|
|
|
|
<i class="bi-folder-plus" />
|
|
|
|
</button>
|
|
|
|
<button
|
|
|
|
type="button"
|
|
|
|
class="btn btn-primary"
|
|
|
|
title="Upload File"
|
|
|
|
data-bs-toggle="modal"
|
|
|
|
data-bs-target="#uploadModal"
|
|
|
|
>
|
|
|
|
<i class="bi-upload" />
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div id="folderModal" class="modal" tabindex="-1" aria-labelledby="folderModalLabel" aria-hidden="true">
|
|
|
|
<div class="modal-dialog modal-dialog-centered">
|
|
|
|
<div class="modal-content">
|
|
|
|
<div class="modal-header">
|
|
|
|
<h1 class="modal-title fs-5" id="folderModalLabel">Create Folder</h1>
|
|
|
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Cancel"></button>
|
|
|
|
</div>
|
|
|
|
<form @submit.prevent="onSubmitCreateFolder" @reset="onCancelCreateFolder">
|
|
|
|
<div class="modal-body">
|
2023-09-08 04:16:34 -04:00
|
|
|
<input type="text" class="form-control" v-model="folderName.name" />
|
2020-01-31 07:45:56 -05:00
|
|
|
</div>
|
2023-01-11 04:54:25 -05:00
|
|
|
<div class="modal-footer">
|
|
|
|
<button type="reset" class="btn btn-primary" data-bs-dismiss="modal" aria-label="Cancel">
|
|
|
|
Cancel
|
|
|
|
</button>
|
|
|
|
<button type="submit" class="btn btn-primary" data-bs-dismiss="modal">Ok</button>
|
2020-04-20 12:07:12 -04:00
|
|
|
</div>
|
2023-01-11 04:54:25 -05:00
|
|
|
</form>
|
2020-04-21 09:29:55 -04:00
|
|
|
</div>
|
2023-01-11 04:54:25 -05:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div
|
|
|
|
id="uploadModal"
|
|
|
|
ref="uploadModal"
|
|
|
|
class="modal"
|
|
|
|
tabindex="-1"
|
|
|
|
aria-labelledby="uploadModalLabel"
|
|
|
|
data-bs-backdrop="static"
|
2020-04-20 12:07:12 -04:00
|
|
|
>
|
2023-01-11 04:54:25 -05:00
|
|
|
<div class="modal-dialog modal-dialog-centered modal-xl">
|
|
|
|
<div class="modal-content">
|
|
|
|
<div class="modal-header">
|
|
|
|
<h1 class="modal-title fs-5" id="uploadModalLabel">Upload Files</h1>
|
2024-02-21 08:23:20 -05:00
|
|
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Cancel" @click.prevent="onResetUpload()"></button>
|
2023-01-11 04:54:25 -05:00
|
|
|
</div>
|
2024-02-21 08:23:20 -05:00
|
|
|
<form @submit.prevent="onSubmitUpload" @reset.prevent="onResetUpload">
|
2023-01-11 04:54:25 -05:00
|
|
|
<div class="modal-body">
|
|
|
|
<input
|
|
|
|
class="form-control"
|
|
|
|
type="file"
|
2023-04-06 05:05:15 -04:00
|
|
|
ref="fileInputName"
|
2023-01-11 04:54:25 -05:00
|
|
|
:accept="extensions"
|
|
|
|
v-on:change="onFileChange"
|
|
|
|
multiple
|
|
|
|
/>
|
|
|
|
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-10">
|
|
|
|
<div class="row progress-row">
|
2023-04-06 05:05:15 -04:00
|
|
|
<div class="col-1" style="min-width: 125px">Current:</div>
|
2023-03-27 04:40:11 -04:00
|
|
|
<div class="col-10">
|
|
|
|
<div class="progress">
|
|
|
|
<div
|
|
|
|
class="progress-bar bg-warning"
|
|
|
|
role="progressbar"
|
2023-04-06 05:05:15 -04:00
|
|
|
:aria-valuenow="currentProgress"
|
|
|
|
:style="`width: ${currentProgress}%`"
|
2023-03-27 04:40:11 -04:00
|
|
|
/>
|
|
|
|
</div>
|
2023-01-11 04:54:25 -05:00
|
|
|
</div>
|
|
|
|
<div class="w-100" />
|
2023-04-06 05:05:15 -04:00
|
|
|
<div class="col-1" style="min-width: 125px">
|
|
|
|
Overall ({{ currentNumber }}/{{ inputFiles.length }}):
|
|
|
|
</div>
|
2023-03-27 04:40:11 -04:00
|
|
|
<div class="col-10">
|
|
|
|
<div class="progress">
|
|
|
|
<div
|
|
|
|
class="progress-bar bg-warning"
|
|
|
|
role="progressbar"
|
2023-04-06 05:05:15 -04:00
|
|
|
:aria-valuenow="overallProgress"
|
|
|
|
:style="`width: ${overallProgress}%`"
|
2023-03-27 04:40:11 -04:00
|
|
|
/>
|
|
|
|
</div>
|
2023-01-11 04:54:25 -05:00
|
|
|
</div>
|
|
|
|
<div class="w-100" />
|
|
|
|
<div class="col-1" style="min-width: 125px">Uploading:</div>
|
|
|
|
<div class="col-10">
|
|
|
|
<strong>{{ uploadTask }}</strong>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="col-2">
|
|
|
|
<div class="media-button">
|
|
|
|
<button type="reset" class="btn btn-primary me-2" data-bs-dismiss="modal">
|
|
|
|
Cancel
|
|
|
|
</button>
|
|
|
|
<button type="submit" class="btn btn-primary">Upload</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2020-01-31 07:45:56 -05:00
|
|
|
</div>
|
2023-01-11 04:54:25 -05:00
|
|
|
</form>
|
2020-05-12 15:33:34 -04:00
|
|
|
</div>
|
2020-01-31 07:45:56 -05:00
|
|
|
</div>
|
2023-01-11 04:54:25 -05:00
|
|
|
</div>
|
2020-01-30 15:25:10 -05:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
2023-01-11 04:54:25 -05:00
|
|
|
<script setup lang="ts">
|
2023-03-27 10:28:13 -04:00
|
|
|
import { storeToRefs } from 'pinia'
|
|
|
|
import { Splitpanes, Pane } from 'splitpanes'
|
|
|
|
import 'splitpanes/dist/splitpanes.css'
|
|
|
|
|
2023-01-11 04:54:25 -05:00
|
|
|
const { $bootstrap } = useNuxtApp()
|
|
|
|
const authStore = useAuth()
|
|
|
|
const configStore = useConfig()
|
|
|
|
const indexStore = useIndex()
|
|
|
|
const mediaStore = useMedia()
|
2023-03-27 10:28:13 -04:00
|
|
|
const { toMin, mediaType } = stringFormatter()
|
2023-01-11 04:54:25 -05:00
|
|
|
const contentType = { 'content-type': 'application/json;charset=UTF-8' }
|
|
|
|
|
2023-03-27 10:28:13 -04:00
|
|
|
const { configID } = storeToRefs(useConfig())
|
|
|
|
|
2023-01-11 04:54:25 -05:00
|
|
|
useHead({
|
2023-03-27 10:28:13 -04:00
|
|
|
title: 'Media | ffplayout',
|
2023-01-11 04:54:25 -05:00
|
|
|
})
|
|
|
|
|
2023-03-27 10:28:13 -04:00
|
|
|
const browserIsLoading = ref(false)
|
|
|
|
const deleteName = ref('')
|
|
|
|
const renameOldName = ref('')
|
|
|
|
const renameNewName = ref('')
|
|
|
|
const previewName = ref('')
|
|
|
|
const previewUrl = ref('')
|
|
|
|
const previewOpt = ref()
|
|
|
|
const isVideo = ref(false)
|
2023-01-11 04:54:25 -05:00
|
|
|
const uploadModal = ref()
|
|
|
|
const extensions = ref('')
|
2023-09-08 04:16:34 -04:00
|
|
|
const folderName = ref({} as Folder)
|
2023-01-11 04:54:25 -05:00
|
|
|
const inputFiles = ref([] as File[])
|
2023-04-06 05:05:15 -04:00
|
|
|
const fileInputName = ref()
|
2023-01-11 04:54:25 -05:00
|
|
|
const currentNumber = ref(0)
|
|
|
|
const uploadTask = ref('')
|
|
|
|
const overallProgress = ref(0)
|
|
|
|
const currentProgress = ref(0)
|
|
|
|
const lastPath = ref('')
|
|
|
|
const thisUploadModal = ref()
|
|
|
|
const xhr = ref(new XMLHttpRequest())
|
|
|
|
|
|
|
|
onMounted(async () => {
|
2023-07-14 07:45:48 -04:00
|
|
|
let config_extensions = configStore.configPlayout.storage.extensions
|
|
|
|
let extra_extensions = configStore.configGui[configStore.configID].extra_extensions
|
|
|
|
|
|
|
|
if (typeof config_extensions === 'string') {
|
|
|
|
config_extensions = config_extensions.split(',')
|
|
|
|
}
|
|
|
|
|
|
|
|
if (typeof extra_extensions === 'string') {
|
|
|
|
extra_extensions = extra_extensions.split(',')
|
|
|
|
}
|
|
|
|
|
2023-12-07 16:00:05 -05:00
|
|
|
const exts = [...config_extensions, ...extra_extensions].map((ext) => {
|
2023-01-11 04:54:25 -05:00
|
|
|
return `.${ext}`
|
|
|
|
})
|
|
|
|
|
|
|
|
extensions.value = exts.join(', ')
|
2023-07-14 07:45:48 -04:00
|
|
|
// @ts-ignore
|
2023-01-11 04:54:25 -05:00
|
|
|
thisUploadModal.value = $bootstrap.Modal.getOrCreateInstance(uploadModal.value)
|
2023-03-27 10:28:13 -04:00
|
|
|
|
|
|
|
if (!mediaStore.folderTree.parent) {
|
|
|
|
getPath('')
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
watch([configID], () => {
|
|
|
|
getPath('')
|
2023-01-11 04:54:25 -05:00
|
|
|
})
|
|
|
|
|
2023-03-27 10:28:13 -04:00
|
|
|
async function getPath(path: string) {
|
|
|
|
browserIsLoading.value = true
|
|
|
|
await mediaStore.getTree(path)
|
|
|
|
browserIsLoading.value = false
|
|
|
|
}
|
|
|
|
|
|
|
|
function setPreviewData(path: string) {
|
|
|
|
/*
|
|
|
|
Set path and player options for video preview.
|
|
|
|
*/
|
|
|
|
let fullPath = path
|
|
|
|
if (!path.includes('/')) {
|
|
|
|
fullPath = `/${mediaStore.folderTree.parent}/${mediaStore.folderTree.source}/${path}`.replace(/\/[/]+/g, '/')
|
|
|
|
}
|
|
|
|
|
|
|
|
previewName.value = fullPath.split('/').slice(-1)[0]
|
2023-12-07 16:00:05 -05:00
|
|
|
previewUrl.value = encodeURIComponent(`/file/${configStore.configGui[configStore.configID].id}${fullPath}`).replace(
|
|
|
|
/%2F/g,
|
|
|
|
'/'
|
|
|
|
)
|
2023-03-27 10:28:13 -04:00
|
|
|
|
|
|
|
const ext = previewName.value.split('.').slice(-1)[0].toLowerCase()
|
2023-12-07 16:00:05 -05:00
|
|
|
const fileType =
|
|
|
|
mediaType(previewName.value) === 'audio'
|
|
|
|
? `audio/${ext}`
|
|
|
|
: mediaType(previewName.value) === 'live'
|
|
|
|
? 'application/x-mpegURL'
|
|
|
|
: `video/${ext}`
|
2023-03-27 10:28:13 -04:00
|
|
|
|
|
|
|
if (configStore.configPlayout.storage.extensions.includes(`${ext}`)) {
|
|
|
|
isVideo.value = true
|
|
|
|
previewOpt.value = {
|
|
|
|
liveui: false,
|
|
|
|
controls: true,
|
|
|
|
suppressNotSupportedError: true,
|
|
|
|
autoplay: false,
|
|
|
|
preload: 'auto',
|
|
|
|
sources: [
|
|
|
|
{
|
|
|
|
type: fileType,
|
|
|
|
src: previewUrl.value,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
isVideo.value = false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
async function deleteFileOrFolder() {
|
|
|
|
/*
|
|
|
|
Delete function, works for files and folders.
|
|
|
|
*/
|
|
|
|
await fetch(`/api/file/${configStore.configGui[configStore.configID].id}/remove/`, {
|
|
|
|
method: 'POST',
|
|
|
|
headers: { ...contentType, ...authStore.authHeader },
|
|
|
|
body: JSON.stringify({ source: deleteName.value }),
|
|
|
|
})
|
|
|
|
.then(async (response) => {
|
|
|
|
if (response.status !== 200) {
|
2024-04-04 17:28:25 -04:00
|
|
|
indexStore.msgAlert('alert-error', `${await response.text()}`, 5)
|
2023-03-27 10:28:13 -04:00
|
|
|
}
|
|
|
|
getPath(mediaStore.folderTree.source)
|
|
|
|
})
|
|
|
|
.catch((e) => {
|
2024-04-04 17:28:25 -04:00
|
|
|
indexStore.msgAlert('alert-error', `Delete error: ${e}`, 5)
|
2023-03-27 10:28:13 -04:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
function setRenameValues(path: string) {
|
|
|
|
renameNewName.value = path
|
|
|
|
renameOldName.value = path
|
|
|
|
}
|
|
|
|
|
|
|
|
async function onSubmitRenameFile(evt: any) {
|
|
|
|
/*
|
|
|
|
Form submit for file rename request.
|
|
|
|
*/
|
|
|
|
evt.preventDefault()
|
|
|
|
|
|
|
|
await fetch(`/api/file/${configStore.configGui[configStore.configID].id}/rename/`, {
|
|
|
|
method: 'POST',
|
|
|
|
headers: { ...contentType, ...authStore.authHeader },
|
|
|
|
body: JSON.stringify({ source: renameOldName.value, target: renameNewName.value }),
|
|
|
|
})
|
|
|
|
.then(() => {
|
|
|
|
getPath(mediaStore.folderTree.source)
|
|
|
|
})
|
|
|
|
.catch((e) => {
|
2024-04-04 17:28:25 -04:00
|
|
|
indexStore.msgAlert('alert-error', `Delete error: ${e}`, 3)
|
2023-03-27 10:28:13 -04:00
|
|
|
})
|
|
|
|
|
|
|
|
renameOldName.value = ''
|
|
|
|
renameNewName.value = ''
|
|
|
|
}
|
|
|
|
|
|
|
|
function onCancelRenameFile(evt: any) {
|
|
|
|
evt.preventDefault()
|
|
|
|
|
|
|
|
renameOldName.value = ''
|
|
|
|
renameNewName.value = ''
|
|
|
|
}
|
|
|
|
|
|
|
|
function closePlayer() {
|
|
|
|
isVideo.value = false
|
|
|
|
}
|
|
|
|
|
2023-01-11 04:54:25 -05:00
|
|
|
async function onSubmitCreateFolder(evt: any) {
|
|
|
|
evt.preventDefault()
|
2023-09-08 04:16:34 -04:00
|
|
|
const path = `${mediaStore.folderTree.source}/${folderName.value.name}`.replace(/\/[/]+/g, '/')
|
2023-01-11 04:54:25 -05:00
|
|
|
lastPath.value = mediaStore.folderTree.source
|
|
|
|
|
|
|
|
if (mediaStore.folderTree.folders.includes(folderName.value)) {
|
2024-02-21 08:23:20 -05:00
|
|
|
indexStore.msgAlert('alert-warning', `Folder "${folderName.value.name}" exists already!`, 2)
|
2023-01-11 04:54:25 -05:00
|
|
|
|
|
|
|
return
|
|
|
|
}
|
2020-04-13 15:35:24 -04:00
|
|
|
|
2023-01-11 07:41:22 -05:00
|
|
|
await $fetch(`/api/file/${configStore.configGui[configStore.configID].id}/create-folder/`, {
|
2023-01-11 04:54:25 -05:00
|
|
|
method: 'POST',
|
|
|
|
headers: { ...contentType, ...authStore.authHeader },
|
|
|
|
body: JSON.stringify({ source: path }),
|
|
|
|
})
|
|
|
|
.then(() => {
|
2024-02-21 08:23:20 -05:00
|
|
|
indexStore.msgAlert('alert-success', 'Folder create done...', 2)
|
2023-01-11 04:54:25 -05:00
|
|
|
})
|
2023-01-11 07:41:22 -05:00
|
|
|
.catch((e: string) => {
|
2024-04-04 17:28:25 -04:00
|
|
|
indexStore.msgAlert('alert-error', `Folder create error: ${e}`, 3)
|
|
|
|
indexStore.alertVariant = 'alert-error'
|
2023-01-11 04:54:25 -05:00
|
|
|
})
|
2020-01-31 07:45:56 -05:00
|
|
|
|
2023-09-08 04:16:34 -04:00
|
|
|
folderName.value = {} as Folder
|
2023-03-27 10:28:13 -04:00
|
|
|
getPath(lastPath.value)
|
2020-01-30 15:25:10 -05:00
|
|
|
}
|
|
|
|
|
2023-01-11 04:54:25 -05:00
|
|
|
function onCancelCreateFolder(evt: any) {
|
|
|
|
evt.preventDefault()
|
2023-09-08 04:16:34 -04:00
|
|
|
folderName.value = {} as Folder
|
2020-04-20 12:07:12 -04:00
|
|
|
}
|
|
|
|
|
2023-01-11 04:54:25 -05:00
|
|
|
function onFileChange(evt: any) {
|
|
|
|
const files = evt.target.files || evt.dataTransfer.files
|
2020-05-04 06:16:35 -04:00
|
|
|
|
2023-01-11 04:54:25 -05:00
|
|
|
if (!files.length) {
|
|
|
|
return
|
|
|
|
}
|
2020-05-04 06:16:35 -04:00
|
|
|
|
2023-01-11 04:54:25 -05:00
|
|
|
inputFiles.value = files
|
2020-05-04 06:16:35 -04:00
|
|
|
}
|
|
|
|
|
2023-12-20 06:55:24 -05:00
|
|
|
async function upload(file: any): Promise<null | undefined> {
|
2023-04-06 05:05:15 -04:00
|
|
|
const formData = new FormData()
|
|
|
|
formData.append(file.name, file)
|
|
|
|
xhr.value = new XMLHttpRequest()
|
2023-06-28 05:01:17 -04:00
|
|
|
|
2023-12-07 16:00:05 -05:00
|
|
|
return new Promise((resolve) => {
|
2023-01-11 04:54:25 -05:00
|
|
|
xhr.value.open(
|
|
|
|
'PUT',
|
2023-01-11 07:41:22 -05:00
|
|
|
`/api/file/${configStore.configGui[configStore.configID].id}/upload/?path=${encodeURIComponent(
|
2023-01-11 04:54:25 -05:00
|
|
|
mediaStore.crumbs[mediaStore.crumbs.length - 1].path
|
|
|
|
)}`
|
|
|
|
)
|
2020-04-20 12:07:12 -04:00
|
|
|
|
2023-01-11 04:54:25 -05:00
|
|
|
xhr.value.setRequestHeader('Authorization', `Bearer ${authStore.jwtToken}`)
|
2020-04-20 12:07:12 -04:00
|
|
|
|
2023-06-28 05:01:17 -04:00
|
|
|
xhr.value.upload.onprogress = (event: any) => {
|
2023-01-11 04:54:25 -05:00
|
|
|
currentProgress.value = Math.round((100 * event.loaded) / event.total)
|
|
|
|
}
|
2020-01-31 07:45:56 -05:00
|
|
|
|
2023-06-28 05:01:17 -04:00
|
|
|
xhr.value.upload.onerror = () => {
|
2024-04-04 17:28:25 -04:00
|
|
|
indexStore.msgAlert('alert-error', `Upload error: ${xhr.value.status}`, 3)
|
2024-02-21 08:23:20 -05:00
|
|
|
|
2023-04-06 05:05:15 -04:00
|
|
|
resolve(undefined)
|
2023-01-11 04:54:25 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// upload completed successfully
|
2023-06-28 05:01:17 -04:00
|
|
|
xhr.value.onload = () => {
|
2023-01-11 04:54:25 -05:00
|
|
|
currentProgress.value = 100
|
2023-06-28 05:01:17 -04:00
|
|
|
resolve(xhr.value.response)
|
2023-01-11 04:54:25 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
xhr.value.send(formData)
|
2023-12-07 16:00:05 -05:00
|
|
|
})
|
2023-04-06 05:05:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
async function onSubmitUpload(evt: any) {
|
|
|
|
evt.preventDefault()
|
|
|
|
|
|
|
|
lastPath.value = mediaStore.folderTree.source
|
|
|
|
|
|
|
|
for (let i = 0; i < inputFiles.value.length; i++) {
|
|
|
|
const file = inputFiles.value[i]
|
|
|
|
uploadTask.value = file.name
|
|
|
|
currentProgress.value = 0
|
|
|
|
currentNumber.value = i + 1
|
|
|
|
|
2024-02-21 08:23:20 -05:00
|
|
|
if (mediaStore.folderTree.files.find((f) => f.name === file.name)) {
|
|
|
|
indexStore.msgAlert('alert-warning', 'File exists already!', 3)
|
|
|
|
} else {
|
|
|
|
await upload(file)
|
|
|
|
}
|
2023-04-06 05:05:15 -04:00
|
|
|
|
|
|
|
overallProgress.value = (currentNumber.value * 100) / inputFiles.value.length
|
2023-01-11 04:54:25 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
uploadTask.value = 'Done...'
|
2023-03-27 10:28:13 -04:00
|
|
|
getPath(lastPath.value)
|
2023-01-11 04:54:25 -05:00
|
|
|
|
|
|
|
setTimeout(() => {
|
2023-04-06 05:05:15 -04:00
|
|
|
fileInputName.value.value = null
|
2023-01-11 04:54:25 -05:00
|
|
|
thisUploadModal.value.hide()
|
|
|
|
currentNumber.value = 0
|
|
|
|
currentProgress.value = 0
|
|
|
|
overallProgress.value = 0
|
|
|
|
inputFiles.value = []
|
2023-04-06 05:05:15 -04:00
|
|
|
uploadTask.value = ''
|
|
|
|
}, 1500)
|
2020-01-31 07:45:56 -05:00
|
|
|
}
|
|
|
|
|
2024-02-21 08:23:20 -05:00
|
|
|
function onResetUpload() {
|
|
|
|
fileInputName.value.value = null
|
2023-01-11 04:54:25 -05:00
|
|
|
inputFiles.value = []
|
|
|
|
overallProgress.value = 0
|
|
|
|
currentProgress.value = 0
|
|
|
|
uploadTask.value = ''
|
|
|
|
xhr.value.abort()
|
2020-05-12 15:33:34 -04:00
|
|
|
}
|
2023-01-11 04:54:25 -05:00
|
|
|
</script>
|
2020-05-12 15:33:34 -04:00
|
|
|
|
2023-01-11 04:54:25 -05:00
|
|
|
<style lang="scss">
|
2023-03-27 10:28:13 -04:00
|
|
|
.browser-container .browser-item:hover {
|
|
|
|
background-color: $item-hover;
|
|
|
|
|
|
|
|
div > .folder-delete {
|
|
|
|
display: inline;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.browser-div {
|
|
|
|
height: calc(100% - 34px);
|
|
|
|
}
|
|
|
|
|
|
|
|
.folder-delete {
|
|
|
|
margin-right: 0.8em;
|
|
|
|
display: none;
|
|
|
|
min-width: 30px;
|
|
|
|
}
|
|
|
|
|
2023-04-06 05:05:15 -04:00
|
|
|
#deleteModal strong {
|
2023-12-07 16:00:05 -05:00
|
|
|
display: inline-block;
|
2023-04-06 05:05:15 -04:00
|
|
|
width: 100%;
|
|
|
|
overflow: hidden;
|
|
|
|
white-space: nowrap;
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
}
|
|
|
|
|
2023-03-27 10:28:13 -04:00
|
|
|
.file-delete,
|
|
|
|
.file-rename {
|
|
|
|
margin-right: 0.8em;
|
|
|
|
max-width: 35px !important;
|
|
|
|
min-width: 35px !important;
|
|
|
|
}
|
|
|
|
|
2023-01-11 04:54:25 -05:00
|
|
|
.browser-container {
|
|
|
|
position: relative;
|
|
|
|
width: 100%;
|
|
|
|
max-width: 100%;
|
|
|
|
height: calc(100% - 140px);
|
2020-04-20 12:07:12 -04:00
|
|
|
}
|
|
|
|
|
2023-01-11 04:54:25 -05:00
|
|
|
.browser-container > div {
|
|
|
|
height: 100%;
|
2020-04-20 12:07:12 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
.progress-row {
|
|
|
|
margin-top: 1em;
|
|
|
|
}
|
|
|
|
|
|
|
|
.progress-row .col-1 {
|
2023-01-11 04:54:25 -05:00
|
|
|
min-width: 60px;
|
2020-04-20 12:07:12 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
.progress-row .col-10 {
|
2023-01-11 04:54:25 -05:00
|
|
|
margin: auto 0 auto 0;
|
2020-01-31 07:45:56 -05:00
|
|
|
}
|
2023-03-27 04:40:11 -04:00
|
|
|
|
|
|
|
.progress {
|
|
|
|
padding: 0;
|
|
|
|
}
|
2020-01-30 15:25:10 -05:00
|
|
|
</style>
|