Add Percent Share to addStorage for videos and frames

fix-timelapse-in-addstorage
Moe 2023-01-21 07:40:07 -08:00
parent 6766a5afc6
commit 7bc3e8bc06
4 changed files with 37 additions and 21 deletions

View File

@ -314,6 +314,8 @@ module.exports = function(s,config,lang,io){
storageIndex.path = path
storageIndex.usedSpace = 0
storageIndex.sizeLimit = parseFloat(storageData.limit) || parseFloat(userDetails.size) || 10000
storageIndex.videoPercent = parseFloat(storageData.videoPercent) || parseFloat(userDetails.size_video_percent) || 95
storageIndex.timelapsePercent = parseFloat(storageData.timelapsePercent) || parseFloat(userDetails.size_timelapse_percent) || 5
var usedSpaceVideos = 0
var usedSpaceTimelapseFrames = 0
var usedSpaceFilebin = 0

View File

@ -342,6 +342,7 @@ module.exports = function(s,config,lang){
if(details.size){formDetails.size = details.size;}
if(details.days){formDetails.days = details.days;}
}
const theGroup = s.group[d.ke]
var newSize = parseFloat(formDetails.size) || 10000
//load addStorageUse
var currentStorageNumber = 0
@ -365,11 +366,10 @@ module.exports = function(s,config,lang){
storageIndex.name = storage.name
storageIndex.path = path
storageIndex.usedSpace = storageIndex.usedSpace || 0
if(detailsContainerAddStorage && detailsContainerAddStorage[path] && detailsContainerAddStorage[path].limit){
storageIndex.sizeLimit = parseFloat(detailsContainerAddStorage[path].limit)
}else{
storageIndex.sizeLimit = newSize
}
const storageInfoToSave = detailsContainerAddStorage && detailsContainerAddStorage[path] ? detailsContainerAddStorage[path] : {}
storageIndex.sizeLimit = parseFloat(storageInfoToSave.limit) || newSize
storageIndex.videoPercent = parseFloat(storageInfoToSave.videoPercent) || theGroup.sizeLimitVideoPercent
storageIndex.timelapsePercent = parseFloat(storageInfoToSave.timelapsePercent) || theGroup.sizeLimitTimelapseFramesPercent
}
readStorageArray()
///

View File

@ -204,7 +204,7 @@ module.exports = (s,config,lang) => {
}
var storageIndex = theGroup.addStorageUse[storageId]
//run purge command
const maxSize = (storageIndex.sizeLimit * (theGroup.sizeLimitVideoPercent / 100) * config.cron.deleteOverMaxOffset);
const maxSize = (storageIndex.sizeLimit * (storageIndex.videoPercent / 100) * config.cron.deleteOverMaxOffset);
if(storageIndex.usedSpaceVideos > maxSize){
s.knexQuery({
action: "select",
@ -261,7 +261,7 @@ module.exports = (s,config,lang) => {
}
var storageIndex = theGroup.addStorageUse[storageId]
//run purge command
const maxSize = (storageIndex.sizeLimit * (theGroup.sizeLimitTimelapseFramesPercent / 100) * config.cron.deleteOverMaxOffset);
const maxSize = (storageIndex.sizeLimit * (storageIndex.timelapsePercent / 100) * config.cron.deleteOverMaxOffset);
if(storageIndex.usedSpaceTimelapseFrames > maxSize){
s.knexQuery({
action: "select",

View File

@ -10,14 +10,22 @@ $(document).ready(function(){
var addStorageData = JSON.parse($user.details.addStorage || '{}')
var html = ''
$.each(addStorage,function(n,storage){
var limit = ""
if(addStorageData[storage.path] && addStorageData[storage.path].limit){
limit = addStorageData[storage.path].limit
}
html += `<div class="form-group">
<div class="mb-2"><span>${lang['Max Storage Amount']} : ${storage.name}</span></div>
<div><input class="form-control" placeholder="10000" addStorageLimit="${storage.path}" value="${limit}"></div>
</div>`
var theStorage = addStorageData[storage.path]
html += `
<div addStorageFields="${storage.path}">
<div class="form-group">
<div class="mb-2"><span>${lang['Max Storage Amount']} : ${storage.name}</span></div>
<div><input class="form-control" placeholder="10000" addStorageItem="limit" value="${theStorage.limit || ''}"></div>
</div>
<div class="form-group">
<div class="mb-2"><span>${lang["Video Share"]} : ${storage.name}</span></div>
<div><input class="form-control" placeholder="95" addStorageItem="videoPercent" value="${theStorage.videoPercent || ''}"></div>
</div>
<div class="form-group">
<div class="mb-2"><span>${lang["Timelapse Frames Share"]} : ${storage.name}</span></div>
<div><input class="form-control" placeholder="5" addStorageItem="timelapsePercent" value="${theStorage.timelapsePercent || ''}"></div>
</div>
</div>`
})
addStorageMaxAmounts.html(html)
}catch(err){
@ -35,20 +43,25 @@ $(document).ready(function(){
extender(theForm)
})
}
addStorageMaxAmounts.on('change','[addStorageLimit]',function(){
function getAddStorageFields(){
var json = {}
$.each(addStorage,function(n,storage){
var storageId = storage.path
var el = addStorageMaxAmounts.find('[addStorageLimit="' + storageId + '"]')
var value = el.val()
var miniContainer = addStorageMaxAmounts.find(`[addStorageFields="${storageId}"]`)
var fields = miniContainer.find('[addStorageItem]')
json[storageId] = {
name: storage.name,
path: storage.path,
limit: value
}
$.each(fields,function(n,el){
var field = $(el)
var keyName = field.attr('addStorageItem')
var value = field.val()
json[storageId][keyName] = value
})
})
addStorageMaxAmountsField.val(JSON.stringify(json))
})
return json
}
$('body')
theForm.find('[detail]').change(onDetailFieldChange)
theForm.find('[detail]').change(function(){
@ -77,6 +90,7 @@ $(document).ready(function(){
})
var details = getDetailValues(theForm)
formData.details = details
formData.details.addStorage = getAddStorageFields()
accountSettings.onSaveFieldsExtensions.forEach(function(extender){
extender(formData)
})