-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5905 from WoltLab/upload-pipeline-v2
Upload Pipeline v2
- Loading branch information
Showing
97 changed files
with
5,266 additions
and
1,321 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 19 additions & 71 deletions
90
com.woltlab.wcf/templates/shared_messageFormAttachments.tpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,81 +1,29 @@ | ||
<div class="jsOnly formAttachmentContent messageTabMenuContent" id="attachments_{if $wysiwygSelector|isset}{$wysiwygSelector}{else}text{/if}"> | ||
<ul class="formAttachmentList clearfix jsObjectActionContainer" data-object-action-class-name="wcf\data\attachment\AttachmentAction"{if !$attachmentHandler->getAttachmentList()|count} style="display: none"{/if}> | ||
{foreach from=$attachmentHandler->getAttachmentList() item=$attachment} | ||
<li class="box64 formAttachmentListItem jsObjectActionObject" data-object-id="{@$attachment->getObjectID()}" data-height="{@$attachment->height}" data-width="{@$attachment->width}" data-is-image="{@$attachment->isImage}"> | ||
{if $attachment->tinyThumbnailType} | ||
<img src="{$attachment->getThumbnailLink('tiny')}" alt="" class="attachmentTinyThumbnail"> | ||
{else} | ||
{icon size=64 name=$attachment->getIconName()} | ||
{/if} | ||
|
||
<div> | ||
<div> | ||
<p><a href="{$attachment->getLink()}" target="_blank"{if $attachment->isImage} title="{$attachment->filename}" class="jsImageViewer"{/if}>{$attachment->filename}</a></p> | ||
<small>{@$attachment->filesize|filesize}</small> | ||
</div> | ||
|
||
<ul class="buttonGroup"> | ||
<li><button type="button" class="button small jsObjectAction" data-object-action="delete" data-confirm-message="{lang}wcf.attachment.delete.sure{/lang}">{lang}wcf.global.button.delete{/lang}</button></li> | ||
{if $attachment->isImage} | ||
{if $attachment->thumbnailType}<li><button type="button" class="button small jsButtonAttachmentInsertThumbnail" data-object-id="{@$attachment->attachmentID}" data-url="{$attachment->getThumbnailLink('thumbnail')}">{lang}wcf.attachment.insertThumbnail{/lang}</button></li>{/if} | ||
<li><button type="button" class="button small jsButtonAttachmentInsertFull" data-object-id="{@$attachment->attachmentID}" data-url="{$attachment->getLink()}">{lang}wcf.attachment.insertFull{/lang}</button></li> | ||
{else} | ||
<li><button type="button" class="button small jsButtonInsertAttachment" data-object-id="{@$attachment->attachmentID}">{lang}wcf.attachment.insert{/lang}</button></li> | ||
{/if} | ||
</ul> | ||
</div> | ||
</li> | ||
<div class="messageTabMenuContent" id="attachments_{if $wysiwygSelector|isset}{$wysiwygSelector}{else}text{/if}"> | ||
{unsafe:$attachmentHandler->getHtmlElement()} | ||
|
||
<div class="attachment__list__existingFiles"> | ||
{foreach from=$attachmentHandler->getAttachmentList() item=attachment} | ||
{unsafe:$attachment->toHtmlElement()} | ||
{/foreach} | ||
</ul> | ||
</div> | ||
|
||
<dl class="wide"> | ||
<dt></dt> | ||
<dd> | ||
<div data-max-size="{@$attachmentHandler->getMaxSize()}"></div> | ||
<div data-max-size="{$attachmentHandler->getMaxSize()}"></div> | ||
<small>{lang}wcf.attachment.upload.limits{/lang}</small> | ||
</dd> | ||
</dl> | ||
|
||
<script data-relocate="true"> | ||
{jsphrase name='wcf.attachment.insert'} | ||
{jsphrase name='wcf.attachment.insertFull'} | ||
{jsphrase name='wcf.attachment.moreOptions'} | ||
require(["WoltLabSuite/Core/Component/Attachment/List"], ({ setup }) => { | ||
setup("{if $wysiwygSelector|isset}{$wysiwygSelector}{else}text{/if}"); | ||
}); | ||
</script> | ||
|
||
{event name='fields'} | ||
</div> | ||
|
||
<script data-relocate="true"> | ||
$(function() { | ||
WCF.Language.addObject({ | ||
'wcf.attachment.upload.error.invalidExtension': '{jslang}wcf.attachment.upload.error.invalidExtension{/jslang}', | ||
'wcf.attachment.upload.error.tooLarge': '{jslang}wcf.attachment.upload.error.tooLarge{/jslang}', | ||
'wcf.attachment.upload.error.reachedLimit': '{jslang}wcf.attachment.upload.error.reachedLimit{/jslang}', | ||
'wcf.attachment.upload.error.reachedRemainingLimit': '{jslang}wcf.attachment.upload.error.reachedRemainingLimit{/jslang}', | ||
'wcf.attachment.upload.error.uploadFailed': '{jslang}wcf.attachment.upload.error.uploadFailed{/jslang}', | ||
'wcf.attachment.upload.error.http413': '{jslang}wcf.attachment.upload.error.http413{/jslang}', | ||
'wcf.attachment.upload.error.uploadPhpLimit': '{jslang}wcf.attachment.upload.error.uploadPhpLimit{/jslang}', | ||
'wcf.attachment.insert': '{jslang}wcf.attachment.insert{/jslang}', | ||
'wcf.attachment.insertAll': '{jslang}wcf.attachment.insertAll{/jslang}', | ||
'wcf.attachment.insertFull': '{jslang}wcf.attachment.insertFull{/jslang}', | ||
'wcf.attachment.insertThumbnail': '{jslang}wcf.attachment.insertThumbnail{/jslang}', | ||
'wcf.attachment.delete.sure': '{jslang}wcf.attachment.delete.sure{/jslang}' | ||
}); | ||
new WCF.Attachment.Upload( | ||
$('#attachments_{if $wysiwygSelector|isset}{$wysiwygSelector}{else}text{/if} > dl > dd > div'), | ||
$('#attachments_{if $wysiwygSelector|isset}{$wysiwygSelector}{else}text{/if} > ul'), | ||
'{@$attachmentObjectType}', | ||
'{@$attachmentObjectID}', | ||
'{$tmpHash|encodeJS}', | ||
'{@$attachmentParentObjectID}', | ||
{@$attachmentHandler->getMaxCount()}, | ||
'{if $wysiwygSelector|isset}{$wysiwygSelector}{else}text{/if}', | ||
{ | ||
autoScale: { | ||
enable: {if ATTACHMENT_IMAGE_AUTOSCALE}true{else}false{/if}, | ||
maxWidth: {ATTACHMENT_IMAGE_AUTOSCALE_MAX_WIDTH}, | ||
maxHeight: {ATTACHMENT_IMAGE_AUTOSCALE_MAX_HEIGHT}, | ||
fileType: '{ATTACHMENT_IMAGE_AUTOSCALE_FILE_TYPE}', | ||
quality: {ATTACHMENT_IMAGE_AUTOSCALE_QUALITY / 100} | ||
} | ||
} | ||
); | ||
}); | ||
</script> | ||
|
||
<input type="hidden" name="tmpHash" value="{$tmpHash}"> |
95 changes: 25 additions & 70 deletions
95
com.woltlab.wcf/templates/shared_wysiwygAttachmentFormField.tpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,72 +1,27 @@ | ||
<ul id="{$field->getPrefixedID()}_attachmentList" {* | ||
*}class="formAttachmentList jsObjectActionContainer" {* | ||
*}data-object-action-class-name="wcf\data\attachment\AttachmentAction"{* | ||
*}{if !$field->getAttachmentHandler()->getAttachmentList()|count} style="display: none"{/if}{* | ||
*}> | ||
{foreach from=$field->getAttachmentHandler()->getAttachmentList() item=$attachment} | ||
<li class="box64 jsObjectActionObject" {* | ||
*}data-object-id="{@$attachment->getObjectID()}" {* | ||
*}data-height="{@$attachment->height}" {* | ||
*}data-width="{@$attachment->width}" {* | ||
*}data-is-image="{@$attachment->isImage}"{* | ||
*}> | ||
{if $attachment->tinyThumbnailType} | ||
<img src="{$attachment->getThumbnailLink('tiny')}" alt="" class="attachmentTinyThumbnail"> | ||
{else} | ||
{icon size=64 name=$attachment->getIconName()} | ||
{/if} | ||
|
||
<div> | ||
<div> | ||
<p><a href="{$attachment->getLink()}" target="_blank"{if $attachment->isImage} title="{$attachment->filename}" class="jsImageViewer"{/if}>{$attachment->filename}</a></p> | ||
<small>{@$attachment->filesize|filesize}</small> | ||
</div> | ||
|
||
<ul class="buttonGroup"> | ||
<li><button type="button" class="button small jsObjectAction" data-object-action="delete" data-confirm-message="{lang}wcf.attachment.delete.sure{/lang}">{lang}wcf.global.button.delete{/lang}</button></li> | ||
{if $attachment->isImage} | ||
{if $attachment->thumbnailType} | ||
<li><button type="button" class="button small jsButtonAttachmentInsertThumbnail" data-object-id="{@$attachment->attachmentID}" data-url="{$attachment->getThumbnailLink('thumbnail')}">{lang}wcf.attachment.insertThumbnail{/lang}</button></li> | ||
{/if} | ||
<li><button type="button" class="button small jsButtonAttachmentInsertFull" data-object-id="{@$attachment->attachmentID}" data-url="{$attachment->getLink()}">{lang}wcf.attachment.insertFull{/lang}</button></li> | ||
{else} | ||
<li><button type="button" class="button small jsButtonInsertAttachment" data-object-id="{@$attachment->attachmentID}">{lang}wcf.attachment.insert{/lang}</button></li> | ||
{/if} | ||
</ul> | ||
</div> | ||
</li> | ||
{/foreach} | ||
</ul> | ||
<div id="{$field->getPrefixedID()}_uploadButton" class="formAttachmentButtons" data-max-size="{@$field->getAttachmentHandler()->getMaxSize()}"></div> | ||
<div class="messageTabMenuContent" id="attachments_{$field->getPrefixedWysiwygId()}"> | ||
{unsafe:$field->getAttachmentHandler()->getHtmlElement()} | ||
|
||
<script data-relocate="true"> | ||
$(function() { | ||
WCF.Language.addObject({ | ||
'wcf.attachment.upload.error.invalidExtension': '{jslang}wcf.attachment.upload.error.invalidExtension{/jslang}', | ||
'wcf.attachment.upload.error.tooLarge': '{jslang}wcf.attachment.upload.error.tooLarge{/jslang}', | ||
'wcf.attachment.upload.error.reachedLimit': '{jslang}wcf.attachment.upload.error.reachedLimit{/jslang}', | ||
'wcf.attachment.upload.error.reachedRemainingLimit': '{jslang}wcf.attachment.upload.error.reachedRemainingLimit{/jslang}', | ||
'wcf.attachment.upload.error.uploadFailed': '{jslang}wcf.attachment.upload.error.uploadFailed{/jslang}', | ||
'wcf.attachment.upload.error.http413': '{jslang}wcf.attachment.upload.error.http413{/jslang}', | ||
'wcf.attachment.upload.error.uploadPhpLimit': '{jslang}wcf.attachment.upload.error.uploadPhpLimit{/jslang}', | ||
'wcf.attachment.insert': '{jslang}wcf.attachment.insert{/jslang}', | ||
'wcf.attachment.insertAll': '{jslang}wcf.attachment.insertAll{/jslang}', | ||
'wcf.attachment.insertFull': '{jslang}wcf.attachment.insertFull{/jslang}', | ||
'wcf.attachment.insertThumbnail': '{jslang}wcf.attachment.insertThumbnail{/jslang}', | ||
'wcf.attachment.delete.sure': '{jslang}wcf.attachment.delete.sure{/jslang}' | ||
}); | ||
new WCF.Attachment.Upload( | ||
$('#{@$field->getPrefixedID()|encodeJS}_uploadButton'), | ||
$('#{@$field->getPrefixedID()|encodeJS}_attachmentList'), | ||
'{@$field->getAttachmentHandler()->getObjectType()->objectType}', | ||
'{@$field->getAttachmentHandler()->getObjectID()}', | ||
'{$field->getAttachmentHandler()->getTmpHashes()[0]|encodeJS}', | ||
'{@$field->getAttachmentHandler()->getParentObjectID()}', | ||
{@$field->getAttachmentHandler()->getMaxCount()}, | ||
'{@$field->getPrefixedWysiwygId()}' | ||
); | ||
}); | ||
</script> | ||
<div class="attachment__list__existingFiles"> | ||
{foreach from=$field->getAttachmentHandler()->getAttachmentList() item=attachment} | ||
{unsafe:$attachment->toHtmlElement()} | ||
{/foreach} | ||
</div> | ||
|
||
<dl class="wide"> | ||
<dt></dt> | ||
<dd> | ||
<div data-max-size="{$field->getAttachmentHandler()->getMaxSize()}"></div> | ||
<small>{lang}wcf.attachment.upload.limits{/lang}</small> | ||
</dd> | ||
</dl> | ||
|
||
<input type="hidden" id="{$field->getPrefixedID()}_tmpHash" name="{$field->getPrefixedID()}_tmpHash" value="{$field->getAttachmentHandler()->getTmpHashes()[0]}"> | ||
<script data-relocate="true"> | ||
{jsphrase name='wcf.attachment.insert'} | ||
{jsphrase name='wcf.attachment.insertFull'} | ||
{jsphrase name='wcf.attachment.moreOptions'} | ||
require(["WoltLabSuite/Core/Component/Attachment/List"], ({ setup }) => { | ||
setup("{$field->getPrefixedWysiwygId()}"); | ||
}); | ||
</script> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { prepareRequest } from "WoltLabSuite/Core/Ajax/Backend"; | ||
import { ApiResult, apiResultFromError, apiResultFromValue } from "../../Result"; | ||
|
||
export type ResponseIncomplete = { | ||
completed: false; | ||
}; | ||
export type ResponseCompleted = { | ||
completed: true; | ||
generateThumbnails: boolean; | ||
fileID: number; | ||
objectTypeID: number | null; | ||
mimeType: string; | ||
link: string; | ||
data: Record<string, unknown>; | ||
}; | ||
|
||
export type Response = ResponseIncomplete | ResponseCompleted; | ||
|
||
export async function uploadChunk( | ||
identifier: string, | ||
sequenceNo: number, | ||
checksum: string, | ||
payload: Blob, | ||
): Promise<ApiResult<Response>> { | ||
const url = new URL(`${window.WSC_API_URL}index.php?api/rpc/core/files/upload/${identifier}/chunk/${sequenceNo}`); | ||
|
||
let response: Response; | ||
try { | ||
response = (await prepareRequest(url) | ||
.post(payload) | ||
.withHeader("chunk-checksum-sha256", checksum) | ||
.fetchAsJson()) as Response; | ||
} catch (e) { | ||
return apiResultFromError(e); | ||
} | ||
|
||
return apiResultFromValue(response); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { prepareRequest } from "WoltLabSuite/Core/Ajax/Backend"; | ||
import { ApiResult, apiResultFromError, apiResultFromValue } from "../Result"; | ||
|
||
export async function deleteFile(fileId: number): Promise<ApiResult<[]>> { | ||
try { | ||
await prepareRequest(`${window.WSC_API_URL}index.php?api/rpc/core/files/${fileId}`).delete().fetchAsJson(); | ||
} catch (e) { | ||
return apiResultFromError(e); | ||
} | ||
|
||
return apiResultFromValue([]); | ||
} |
Oops, something went wrong.