Add "Hold Uploads" option to configuration

This commit is contained in:
Justin Hawkins 2021-11-07 13:43:25 +10:30
parent 1228920004
commit ced209a7db
4 changed files with 17 additions and 3 deletions

View File

@ -27,6 +27,7 @@ type Watcher struct {
Path string
Username string
NoWatermark bool
HoldUploads bool
Exclude []string
}

View File

@ -28,7 +28,6 @@ func (ip *Processor) ThumbPNG(ul *upload.Upload, w io.Writer) error {
}
newXY := image.Point{}
// test width
if im.Bounds().Max.X/thumbnailMaxX > im.Bounds().Max.Y/thumbnailMaxY {
newXY.X = thumbnailMaxX
newXY.Y = im.Bounds().Max.Y / (im.Bounds().Max.X / thumbnailMaxX)

View File

@ -83,7 +83,12 @@ func (u *Uploader) AddFile(file string, conf config.Watcher) {
watermark: !conf.NoWatermark,
webhookURL: conf.WebHookURL,
usernameOverride: conf.Username,
State: StatePending,
State: StateQueued,
}
// if the user wants uploads to be held for editing etc,
// set it to Pending instead
if conf.HoldUploads {
thisUpload.State = StatePending
}
u.Uploads = append(u.Uploads, &thisUpload)
}

View File

@ -105,6 +105,15 @@
</div>
</div>
<div class="form-row align-items-center">
<div class="col-sm-6 my-1">
<span>Hold Uploads</span>
</div>
<div class="col-sm-6 my-1">
<button type="button" @click="config.Watchers[i].HoldUploads = ! config.Watchers[i].HoldUploads" class="btn btn-success" x-text="watcher.HoldUploads ? 'Enabled' : 'Disabled'"></button>
</div>
</div>
<div class="form-row align-items-center">
<div class="col-sm-6 my-1">
@ -141,7 +150,7 @@
<div class="my-5">
<button type="button" class="btn btn-secondary" href="#"
@click.prevent="config.Watchers.push({Username: '', WebHookURL: 'https://webhook.url.here/', Path: '/directory/path/here', NoWatermark: false, Exclude: []});">
@click.prevent="config.Watchers.push({Username: '', WebHookURL: 'https://webhook.url.here/', Path: '/directory/path/here', NoWatermark: false, HoldUploads: false, Exclude: []});">
Add a new watcher</button>
</div>