Add Percent Share to addStorage for videos and frames
parent
6766a5afc6
commit
7bc3e8bc06
|
@ -314,6 +314,8 @@ module.exports = function(s,config,lang,io){
|
||||||
storageIndex.path = path
|
storageIndex.path = path
|
||||||
storageIndex.usedSpace = 0
|
storageIndex.usedSpace = 0
|
||||||
storageIndex.sizeLimit = parseFloat(storageData.limit) || parseFloat(userDetails.size) || 10000
|
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 usedSpaceVideos = 0
|
||||||
var usedSpaceTimelapseFrames = 0
|
var usedSpaceTimelapseFrames = 0
|
||||||
var usedSpaceFilebin = 0
|
var usedSpaceFilebin = 0
|
||||||
|
|
10
libs/user.js
10
libs/user.js
|
@ -342,6 +342,7 @@ module.exports = function(s,config,lang){
|
||||||
if(details.size){formDetails.size = details.size;}
|
if(details.size){formDetails.size = details.size;}
|
||||||
if(details.days){formDetails.days = details.days;}
|
if(details.days){formDetails.days = details.days;}
|
||||||
}
|
}
|
||||||
|
const theGroup = s.group[d.ke]
|
||||||
var newSize = parseFloat(formDetails.size) || 10000
|
var newSize = parseFloat(formDetails.size) || 10000
|
||||||
//load addStorageUse
|
//load addStorageUse
|
||||||
var currentStorageNumber = 0
|
var currentStorageNumber = 0
|
||||||
|
@ -365,11 +366,10 @@ module.exports = function(s,config,lang){
|
||||||
storageIndex.name = storage.name
|
storageIndex.name = storage.name
|
||||||
storageIndex.path = path
|
storageIndex.path = path
|
||||||
storageIndex.usedSpace = storageIndex.usedSpace || 0
|
storageIndex.usedSpace = storageIndex.usedSpace || 0
|
||||||
if(detailsContainerAddStorage && detailsContainerAddStorage[path] && detailsContainerAddStorage[path].limit){
|
const storageInfoToSave = detailsContainerAddStorage && detailsContainerAddStorage[path] ? detailsContainerAddStorage[path] : {}
|
||||||
storageIndex.sizeLimit = parseFloat(detailsContainerAddStorage[path].limit)
|
storageIndex.sizeLimit = parseFloat(storageInfoToSave.limit) || newSize
|
||||||
}else{
|
storageIndex.videoPercent = parseFloat(storageInfoToSave.videoPercent) || theGroup.sizeLimitVideoPercent
|
||||||
storageIndex.sizeLimit = newSize
|
storageIndex.timelapsePercent = parseFloat(storageInfoToSave.timelapsePercent) || theGroup.sizeLimitTimelapseFramesPercent
|
||||||
}
|
|
||||||
}
|
}
|
||||||
readStorageArray()
|
readStorageArray()
|
||||||
///
|
///
|
||||||
|
|
|
@ -204,7 +204,7 @@ module.exports = (s,config,lang) => {
|
||||||
}
|
}
|
||||||
var storageIndex = theGroup.addStorageUse[storageId]
|
var storageIndex = theGroup.addStorageUse[storageId]
|
||||||
//run purge command
|
//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){
|
if(storageIndex.usedSpaceVideos > maxSize){
|
||||||
s.knexQuery({
|
s.knexQuery({
|
||||||
action: "select",
|
action: "select",
|
||||||
|
@ -261,7 +261,7 @@ module.exports = (s,config,lang) => {
|
||||||
}
|
}
|
||||||
var storageIndex = theGroup.addStorageUse[storageId]
|
var storageIndex = theGroup.addStorageUse[storageId]
|
||||||
//run purge command
|
//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){
|
if(storageIndex.usedSpaceTimelapseFrames > maxSize){
|
||||||
s.knexQuery({
|
s.knexQuery({
|
||||||
action: "select",
|
action: "select",
|
||||||
|
|
|
@ -10,14 +10,22 @@ $(document).ready(function(){
|
||||||
var addStorageData = JSON.parse($user.details.addStorage || '{}')
|
var addStorageData = JSON.parse($user.details.addStorage || '{}')
|
||||||
var html = ''
|
var html = ''
|
||||||
$.each(addStorage,function(n,storage){
|
$.each(addStorage,function(n,storage){
|
||||||
var limit = ""
|
var theStorage = addStorageData[storage.path]
|
||||||
if(addStorageData[storage.path] && addStorageData[storage.path].limit){
|
html += `
|
||||||
limit = addStorageData[storage.path].limit
|
<div addStorageFields="${storage.path}">
|
||||||
}
|
<div class="form-group">
|
||||||
html += `<div class="form-group">
|
<div class="mb-2"><span>${lang['Max Storage Amount']} : ${storage.name}</span></div>
|
||||||
<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><input class="form-control" placeholder="10000" addStorageLimit="${storage.path}" value="${limit}"></div>
|
</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)
|
addStorageMaxAmounts.html(html)
|
||||||
}catch(err){
|
}catch(err){
|
||||||
|
@ -35,20 +43,25 @@ $(document).ready(function(){
|
||||||
extender(theForm)
|
extender(theForm)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
addStorageMaxAmounts.on('change','[addStorageLimit]',function(){
|
function getAddStorageFields(){
|
||||||
var json = {}
|
var json = {}
|
||||||
$.each(addStorage,function(n,storage){
|
$.each(addStorage,function(n,storage){
|
||||||
var storageId = storage.path
|
var storageId = storage.path
|
||||||
var el = addStorageMaxAmounts.find('[addStorageLimit="' + storageId + '"]')
|
var miniContainer = addStorageMaxAmounts.find(`[addStorageFields="${storageId}"]`)
|
||||||
var value = el.val()
|
var fields = miniContainer.find('[addStorageItem]')
|
||||||
json[storageId] = {
|
json[storageId] = {
|
||||||
name: storage.name,
|
name: storage.name,
|
||||||
path: storage.path,
|
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')
|
$('body')
|
||||||
theForm.find('[detail]').change(onDetailFieldChange)
|
theForm.find('[detail]').change(onDetailFieldChange)
|
||||||
theForm.find('[detail]').change(function(){
|
theForm.find('[detail]').change(function(){
|
||||||
|
@ -77,6 +90,7 @@ $(document).ready(function(){
|
||||||
})
|
})
|
||||||
var details = getDetailValues(theForm)
|
var details = getDetailValues(theForm)
|
||||||
formData.details = details
|
formData.details = details
|
||||||
|
formData.details.addStorage = getAddStorageFields()
|
||||||
accountSettings.onSaveFieldsExtensions.forEach(function(extender){
|
accountSettings.onSaveFieldsExtensions.forEach(function(extender){
|
||||||
extender(formData)
|
extender(formData)
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue