Add:Create media item shares with expiration #1768

This commit is contained in:
advplyr 2024-06-22 16:42:13 -05:00
parent e52b695f7e
commit d6eae9b43e
12 changed files with 801 additions and 104 deletions

View file

@ -2,7 +2,10 @@ import Vue from 'vue'
import cronParser from 'cron-parser'
import { nanoid } from 'nanoid'
Vue.prototype.$randomId = () => nanoid()
Vue.prototype.$randomId = (len = null) => {
if (len && !isNaN(len)) return nanoid(len)
return nanoid()
}
Vue.prototype.$bytesPretty = (bytes, decimals = 2) => {
if (isNaN(bytes) || bytes == 0) {
@ -119,7 +122,7 @@ Vue.prototype.$parseCronExpression = (expression) => {
value: '* * * * *'
}
]
const patternMatch = commonPatterns.find(p => p.value === expression)
const patternMatch = commonPatterns.find((p) => p.value === expression)
if (patternMatch) {
return {
description: patternMatch.text
@ -132,13 +135,17 @@ Vue.prototype.$parseCronExpression = (expression) => {
if (pieces[2] !== '*' || pieces[3] !== '*') {
return null
}
if (pieces[4] !== '*' && pieces[4].split(',').some(p => isNaN(p))) {
if (pieces[4] !== '*' && pieces[4].split(',').some((p) => isNaN(p))) {
return null
}
const weekdays = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
var weekdayText = 'day'
if (pieces[4] !== '*') weekdayText = pieces[4].split(',').map(p => weekdays[p]).join(', ')
if (pieces[4] !== '*')
weekdayText = pieces[4]
.split(',')
.map((p) => weekdays[p])
.join(', ')
return {
description: `Run every ${weekdayText} at ${pieces[1]}:${pieces[0].padStart(2, '0')}`
@ -146,7 +153,7 @@ Vue.prototype.$parseCronExpression = (expression) => {
}
Vue.prototype.$getNextScheduledDate = (expression) => {
const interval = cronParser.parseExpression(expression);
const interval = cronParser.parseExpression(expression)
return interval.next().toDate()
}
@ -171,10 +178,8 @@ Vue.prototype.$downloadFile = (url, filename = null, openInNewTab = false) => {
export function supplant(str, subs) {
// source: http://crockford.com/javascript/remedial.html
return str.replace(/{([^{}]*)}/g,
function (a, b) {
var r = subs[b]
return typeof r === 'string' || typeof r === 'number' ? r : a
}
)
return str.replace(/{([^{}]*)}/g, function (a, b) {
var r = subs[b]
return typeof r === 'string' || typeof r === 'number' ? r : a
})
}