select correct channel on user page, show only filename, fix naming

This commit is contained in:
Jonathan Baecker 2024-10-02 10:26:50 +02:00
parent c4a358a753
commit 414cdbe168
8 changed files with 37 additions and 20 deletions

View File

@ -127,6 +127,7 @@ async function addUpdateChannel() {
indexStore.msgAlert('success', t('config.updateChannelSuccess'), 2) indexStore.msgAlert('success', t('config.updateChannelSuccess'), 2)
await configStore.getPlayoutConfig() await configStore.getPlayoutConfig()
await configStore.getUserConfig()
} else { } else {
indexStore.msgAlert('error', t('config.updateChannelFailed'), 2) indexStore.msgAlert('error', t('config.updateChannelFailed'), 2)
@ -152,6 +153,7 @@ async function deleteChannel() {
i.value = configStore.i - 1 i.value = configStore.i - 1
await configStore.getChannelConfig() await configStore.getChannelConfig()
await configStore.getPlayoutConfig() await configStore.getPlayoutConfig()
await configStore.getUserConfig()
if (response.status === 200) { if (response.status === 200) {
indexStore.msgAlert('success', t('config.errorChannelDelete'), 2) indexStore.msgAlert('success', t('config.errorChannelDelete'), 2)

View File

@ -144,7 +144,7 @@ const user = ref({
password: '', password: '',
confirm: '', confirm: '',
admin: false, admin: false,
channel_ids: [1], channel_ids: [configStore.channels[configStore.i]?.id ?? 1],
role_id: 3, role_id: 3,
} as User) } as User)

View File

@ -39,12 +39,12 @@ export const stringFormatter = () => {
.replace(/\[Validator\]/g, '<span class="log-server">[Validator]</span>') .replace(/\[Validator\]/g, '<span class="log-server">[Validator]</span>')
} }
function timeToSeconds(time: string) { function timeToSeconds(time: string): number {
const t = time.split(':') const t = time.split(':')
return parseInt(t[0]) * 3600 + parseInt(t[1]) * 60 + parseInt(t[2]) return parseInt(t[0]) * 3600 + parseInt(t[1]) * 60 + parseInt(t[2])
} }
function secToHMS(sec: number) { function secToHMS(sec: number): string {
const sign = Math.sign(sec) const sign = Math.sign(sec)
sec = Math.abs(sec) sec = Math.abs(sec)
@ -62,7 +62,7 @@ export const stringFormatter = () => {
return `${hString}:${m}:${s}` return `${hString}:${m}:${s}`
} }
function numberToHex(num: number) { function numberToHex(num: number): string {
return '0x' + Math.round(num * 255).toString(16) return '0x' + Math.round(num * 255).toString(16)
} }
@ -70,7 +70,7 @@ export const stringFormatter = () => {
return parseFloat((parseFloat(parseInt(num, 16).toString()) / 255).toFixed(2)) return parseFloat((parseFloat(parseInt(num, 16).toString()) / 255).toFixed(2))
} }
function filename(path: string) { function filename(path: string): string {
if (path) { if (path) {
const pathArr = path.split('/') const pathArr = path.split('/')
const name = pathArr[pathArr.length - 1] const name = pathArr[pathArr.length - 1]
@ -85,7 +85,7 @@ export const stringFormatter = () => {
} }
} }
function parent(path: string) { function parent(path: string): string {
if (path) { if (path) {
const pathArr = path.split('/') const pathArr = path.split('/')
pathArr.pop() pathArr.pop()
@ -100,7 +100,7 @@ export const stringFormatter = () => {
} }
} }
function toMin(sec: number) { function toMin(sec: number): string {
if (sec) { if (sec) {
const minutes = Math.floor(sec / 60) const minutes = Math.floor(sec / 60)
const seconds = Math.round(sec - minutes * 60) const seconds = Math.round(sec - minutes * 60)
@ -167,6 +167,14 @@ export const stringFormatter = () => {
return null return null
} }
function dir_file(path: string): {dir: string, file: string} {
const index = path.lastIndexOf('/')
const dir = path.substring(0, index + 1) || '/'
const file = path.substring(index + 1)
return {dir, file}
}
return { return {
fileSize, fileSize,
formatLog, formatLog,
@ -179,6 +187,7 @@ export const stringFormatter = () => {
toMin, toMin,
secondsToTime, secondsToTime,
mediaType, mediaType,
dir_file,
} }
} }

View File

@ -93,7 +93,9 @@ export default {
notExists: 'Speicher existiert nicht!', notExists: 'Speicher existiert nicht!',
create: 'Ordner erstellen', create: 'Ordner erstellen',
upload: 'Dateien hochladen', upload: 'Dateien hochladen',
deleteTitle: 'Datei/Ordner löschen', delete: 'Lösche',
file: 'Datei',
folder: 'Ordner',
deleteQuestion: 'Sind Sie sicher, dass Sie löschen möchten', deleteQuestion: 'Sind Sie sicher, dass Sie löschen möchten',
preview: 'Vorschau', preview: 'Vorschau',
rename: 'Datei umbenennen', rename: 'Datei umbenennen',

View File

@ -93,7 +93,9 @@ export default {
notExists: 'Storage not exist!', notExists: 'Storage not exist!',
create: 'Create Folder', create: 'Create Folder',
upload: 'Upload Files', upload: 'Upload Files',
deleteTitle: 'Delete File/Folder', delete: 'Delete',
file: 'File',
folder: 'Folder',
deleteQuestion: 'Are you sure that you want to delete', deleteQuestion: 'Are you sure that you want to delete',
preview: 'Preview', preview: 'Preview',
rename: 'Rename File', rename: 'Rename File',

View File

@ -93,7 +93,9 @@ export default {
notExists: 'O armazenamento não existe!', notExists: 'O armazenamento não existe!',
create: 'Criar Pasta', create: 'Criar Pasta',
upload: 'Enviar Arquivos', upload: 'Enviar Arquivos',
deleteTitle: 'Deletar Arquivo/Pasta', delete: 'Deletar',
file: 'Arquivo',
folder: 'Pasta',
deleteQuestion: 'Tem certeza que deseja deletar?', deleteQuestion: 'Tem certeza que deseja deletar?',
preview: 'Visualizar', preview: 'Visualizar',
rename: 'Renomear Arquivo', rename: 'Renomear Arquivo',

View File

@ -93,7 +93,9 @@ export default {
notExists: 'Папки не существует!', notExists: 'Папки не существует!',
create: 'Сделать папку', create: 'Сделать папку',
upload: 'Загрузить файлы', upload: 'Загрузить файлы',
deleteTitle: 'Удалить Файл/Папку', delete: 'Удалить',
file: 'Файл',
folder: 'Папку',
deleteQuestion: 'Вы уверены что хотите это удалить', deleteQuestion: 'Вы уверены что хотите это удалить',
preview: 'Просмотр', preview: 'Просмотр',
rename: 'Переименовать файл', rename: 'Переименовать файл',

View File

@ -230,12 +230,12 @@
<GenericModal <GenericModal
:show="showDeleteModal" :show="showDeleteModal"
:title="t('media.deleteTitle')" :title="`${t('media.delete')} ${extensionsArr.some(suffix => deleteName.endsWith(suffix)) ? t('media.file') : t('media.folder')}`"
:text="`${t('media.deleteQuestion')}:<br /><strong>${deleteName}</strong>`" :text="`${t('media.deleteQuestion')}:<br /><strong>${deleteName}</strong>`"
:modal-action="deleteFileOrFolder" :modal-action="deleteFileOrFolder"
> >
<div> <div>
<input class="input input-sm w-full" type="text" :value="deleteName" disabled /> <input class="input input-sm w-full" type="text" :value="dir_file(deleteName).file" disabled />
<div v-if="!extensionsArr.some(suffix => deleteName.endsWith(suffix))" class="form-control mt-3"> <div v-if="!extensionsArr.some(suffix => deleteName.endsWith(suffix))" class="form-control mt-3">
<label class="label cursor-pointer w-1/4"> <label class="label cursor-pointer w-1/4">
<input v-model="recursive" type="checkbox" class="checkbox checkbox-sm checkbox-warning" /> <input v-model="recursive" type="checkbox" class="checkbox checkbox-sm checkbox-warning" />
@ -321,7 +321,7 @@ const authStore = useAuth()
const configStore = useConfig() const configStore = useConfig()
const indexStore = useIndex() const indexStore = useIndex()
const mediaStore = useMedia() const mediaStore = useMedia()
const { toMin, mediaType, filename, parent } = stringFormatter() const { toMin, mediaType, filename, parent, dir_file } = stringFormatter()
const { i } = storeToRefs(useConfig()) const { i } = storeToRefs(useConfig())
useHead({ useHead({
@ -528,13 +528,11 @@ async function deleteFileOrFolder(del: boolean) {
} }
function setRenameValues(path: string) { function setRenameValues(path: string) {
const index = path.lastIndexOf('/') const filepath = dir_file(path)
const dir = path.substring(0, index + 1) || '/'
const file = path.substring(index + 1)
renameOldName.value = file renameOldName.value = filepath.file
renameOldPath.value = dir renameOldPath.value = filepath.dir
renameNewName.value = file renameNewName.value = filepath.file
} }
async function renameFile(ren: boolean) { async function renameFile(ren: boolean) {