add delete button to fileBin table
parent
9ce24bfd3c
commit
4edcf74c48
|
@ -339,7 +339,7 @@ module.exports = function(s,config,lang,app,io){
|
|||
break;
|
||||
case'delete':
|
||||
response.ok = true;
|
||||
await s.deleteFileBinEntry(file)
|
||||
await deleteFileBinEntry(file)
|
||||
break;
|
||||
default:
|
||||
response.msg = user.lang.modifyVideoText1;
|
||||
|
|
|
@ -98,6 +98,7 @@ $(document).ready(function(e){
|
|||
<a class="btn btn-sm btn-primary" href="${href}" download title="${lang.Download}"><i class="fa fa-download"></i></a>
|
||||
${isVideo ? `<a class="btn btn-sm btn-primary preview-video" href="${href}" title="${lang.Play}"><i class="fa fa-play"></i></a>` : ``}
|
||||
${permissionCheck('video_delete',file.mid) ? `<a class="btn btn-sm btn-${file.archive === 1 ? `success status-archived` : `default`} archive-file" title="${lang.Archive}"><i class="fa fa-${file.archive === 1 ? `lock` : `unlock-alt`}"></i></a>` : ''}
|
||||
${permissionCheck('video_delete',file.mid) ? `<a class="btn btn-sm btn-danger delete-file" title="${lang.Delete}"><i class="fa fa-trash-o"></i></a>` : ''}
|
||||
</div>
|
||||
`,
|
||||
}
|
||||
|
@ -126,6 +127,22 @@ $(document).ready(function(e){
|
|||
await unarchiveFile(video)
|
||||
}
|
||||
}
|
||||
function deleteFile(video,callback){
|
||||
return new Promise((resolve,reject) => {
|
||||
var videoEndpoint = getApiPrefix(`fileBin`) + '/' + video.mid + '/' + video.name
|
||||
$.getJSON(videoEndpoint + '/delete',function(data){
|
||||
notifyIfActionFailed(data)
|
||||
if(callback)callback(data)
|
||||
resolve(data)
|
||||
})
|
||||
})
|
||||
}
|
||||
async function deleteFiles(videos){
|
||||
for (let i = 0; i < videos.length; i++) {
|
||||
var video = videos[i];
|
||||
await deleteFile(video)
|
||||
}
|
||||
}
|
||||
$('body')
|
||||
.on('click','.open-fileBin-video',function(e){
|
||||
e.preventDefault()
|
||||
|
@ -161,6 +178,30 @@ $(document).ready(function(e){
|
|||
}
|
||||
return false;
|
||||
})
|
||||
.on('click','.delete-file',function(e){
|
||||
e.preventDefault()
|
||||
var el = $(this).parents('[data-mid]')
|
||||
var monitorId = el.attr('data-mid')
|
||||
var filename = el.attr('data-name')
|
||||
var file = loadedFilesInMemory[`${monitorId}${filename}`]
|
||||
if(!file)return console.log(`No File`,monitorId,filename,unarchive,file);
|
||||
$.confirm.create({
|
||||
title: lang["Delete"] + ' : ' + file.name,
|
||||
body: `${lang.DeleteThisMsg}`,
|
||||
clickOptions: {
|
||||
title: '<i class="fa fa-trash-o"></i> ' + lang.Delete,
|
||||
class: 'btn-danger btn-sm'
|
||||
},
|
||||
clickCallback: function(){
|
||||
deleteFile(file).then(function(data){
|
||||
if(data.ok){
|
||||
drawFileBinViewElements()
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
return false;
|
||||
})
|
||||
addOnTabOpen('fileBinView', function () {
|
||||
drawMonitorListToSelector(monitorsList)
|
||||
drawFileBinViewElements()
|
||||
|
|
Loading…
Reference in New Issue