Skip to content

Commit

Permalink
Merge branch '5.x' into feat/resize_command
Browse files Browse the repository at this point in the history
  • Loading branch information
Davidmattei authored Jul 28, 2024
2 parents 78b1569 + 78eaad1 commit a9bfea8
Show file tree
Hide file tree
Showing 49 changed files with 492 additions and 619 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{% block jobStatus %}
{% set p = line.data.progress %}
<div class="progress">
<div class="progress-bar progress-bar-striped" role="progressbar" aria-valuenow="{{ p }}" aria-valuemin="0" aria-valuemax="100" style="{{ "width: #{p}%;" }}">
{{ "#{p}%" }}
</div>
</div>
<div>{{ line.data.status }}</div>
{% endblock jobStatus %}
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
{%- endif -%}
{%- endif -%}
{% if confirm is defined and confirm != null %}
<div class="btn-group">
<div class="btn-group pull-right">
<button type="button" class="{{ confirm_class|default('btn btn-outline-danger') }} dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
{%- if icon -%}
<span class="{{ icon }}"></span>&nbsp;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@
{% endif %}
{% if toolbar is defined or (table.sortable and table.supportsTableActions) or table.toolbarActions|length > 0 %}
<div class="box-header with-border">
<div class="btn-group pull-right">
<div class="btn-group pull-right">
{% if toolbar is defined %}
{{ toolbar }}
{% endif %}
Expand All @@ -300,8 +300,8 @@
<i class="{{ toolbarAction.icon }}"></i>&nbsp;{{ toolbarAction.labelKey|trans }}
</a>
{% endfor %}
{% if table.sortable and table.supportsTableActions %}
<button type="button" class="btn btn-default" data-toggle="modal" data-target="#{{ table.attributeName|e('html_attr') }}_modal_reorder">
{% if attribute(form, 'reorderAction') is defined %}
<button type="button" class="btn btn-sm btn-default" data-toggle="modal" data-target="#{{ table.attributeName|e('html_attr') }}_modal_reorder">
<i class="fa fa-reorder"></i>&nbsp;{{ form.reorderAction.vars.label|trans }}
</button>
{% endif %}
Expand Down Expand Up @@ -360,24 +360,22 @@
{% if table.supportsTableActions or toolbar is defined %}
<div class="box-footer with-border">
{% if table.supportsTableActions %}
<div class="btn-group">
{% for action in table.tableActions %}
{{ form_widget(attribute(form, action.name)) }}
{% endfor %}
</div>
{% for action in table.tableActions %}
{{ form_widget(attribute(form, action.name)) }}
{% endfor %}
{% endif %}
{% if toolbar is defined %}
<div class="btn-group">
{{ toolbar }}
</div>
{% endif %}
{% for toolbarAction in table.toolbarActions %}
<div class="btn-group">
<div class="btn-group">
{% for toolbarAction in table.toolbarActions %}
<a class="{{ toolbarAction.cssClass }}" href="{{ path(toolbarAction.routeName, toolbarAction.routeParams) }}">
<i class="{{ toolbarAction.icon }}"></i>&nbsp;{{ toolbarAction.labelKey|trans }}
</a>
</div>
{% endfor %}
{% endfor %}
</div>
</div>
{% endif %}
</div>
Expand Down Expand Up @@ -407,8 +405,8 @@
</div>
<div class="modal-footer">
<div class="btn-group">
{{ form_widget(form.reorderAction, { 'attr': { 'class': 'btn btn-primary' } }) }}
<button type="button" class="btn btn-default" data-dismiss="modal"><i class="fa fa-close"></i> {{ t('action.close', [], 'emsco-core')|trans }}</button>
{{ form_widget(form.reorderAction, { 'attr': { 'class': 'btn btn-sm btn-primary' } }) }}
<button type="button" class="btn btn-sm btn-default" data-dismiss="modal"><i class="fa fa-close"></i> {{ t('action.close', [], 'emsco-core')|trans }}</button>
</div>
</div>
</div>
Expand Down

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion EMS/core-bundle/assets/js/EmsListeners.js
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ export default class EmsListeners {
const uploadTab = mainDiv.find(".asset-upload-tab");
const previewLink = mainDiv.find(".img-responsive");
sha1Input.val(data.sha1);
resizedImageHashInput.val('');
resizedImageHashInput.val(data._image_resized_hash ?? '');
assetHashSignature.empty().append(data.sha1);
typeInput.val(data.mimetype);
nameInput.val(data.filename);
Expand Down
32 changes: 27 additions & 5 deletions EMS/core-bundle/assets/js/module/pickFileFromServer.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {pickFileModal} from "../helper/ajaxModal";
import {observeDom} from '../helper/observeDom';
import {resizeImage} from "../helper/resizeImage";

export default class PickFileFromServer {
constructor(target) {
Expand All @@ -20,15 +21,36 @@ export default class PickFileFromServer {
const addClickCallbacks = function(linkList){
for (let i = 0; i < linkList.length; i++) {
linkList[i].onclick = (event) => {
const primaryBox = $('body')
const initUpload = primaryBox.data('init-upload')
const hashAlgo = primaryBox.data('hash-algo');
if (event.target.parentNode === undefined || event.target.parentNode.dataset.json === undefined) {
return;
}
event.preventDefault();
const data = JSON.parse(event.target.parentNode.dataset.json)
const row = button.closest('.file-uploader-row');
row.dispatchEvent(new CustomEvent('updateAssetData', {detail: data}));
pickFileModal.close();
observer.disconnect();
fetch(data.view_url, {mode: 'cors'})
.then(res => res.blob())
.then(blob => {
blob.name = data.filename
return resizeImage(hashAlgo, initUpload, blob)
})
.then((response) => {
if (null === response) {
return
}
data._image_resized_hash = response.hash
data.preview_url = response.url
})
.catch((errorMessage) => {
console.error(errorMessage)
})
.finally(() => {
const row = button.closest('.file-uploader-row');
row.dispatchEvent(new CustomEvent('updateAssetData', {detail: data}));
pickFileModal.close();
observer.disconnect();
})
};
}
}
Expand All @@ -47,4 +69,4 @@ export default class PickFileFromServer {
});
});
}
}
}
61 changes: 37 additions & 24 deletions EMS/core-bundle/src/Controller/ContentManagement/JobController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@

namespace EMS\CoreBundle\Controller\ContentManagement;

use EMS\CommonBundle\Contracts\Log\LocalizedLoggerInterface;
use EMS\CommonBundle\Helper\Text\Encoder;
use EMS\CoreBundle\Controller\CoreControllerTrait;
use EMS\CoreBundle\Core\DataTable\DataTableFactory;
use EMS\CoreBundle\DataTable\Type\Job\JobDataTableType;
use EMS\CoreBundle\Entity\Job;
use EMS\CoreBundle\Form\Data\TableAbstract;
use EMS\CoreBundle\Form\Form\JobType;
use EMS\CoreBundle\Form\Form\TableType;
use EMS\CoreBundle\Helper\EmsCoreResponse;
use EMS\CoreBundle\Service\JobService;
use EMS\Helpers\Standard\Json;
use Psr\Log\LoggerInterface;
use SensioLabs\AnsiConverter\AnsiToHtmlConverter;
use SensioLabs\AnsiConverter\Theme\Theme;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
Expand All @@ -20,32 +25,47 @@
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use Symfony\Component\Security\Core\User\UserInterface;

use function Symfony\Component\Translation\t;

class JobController extends AbstractController
{
use CoreControllerTrait;

public function __construct(
private readonly LoggerInterface $logger,
private readonly JobService $jobService,
private readonly int $pagingSize,
private readonly DataTableFactory $dataTableFactory,
private readonly LocalizedLoggerInterface $logger,
private readonly bool $triggerJobFromWeb,
private readonly string $templateNamespace
) {
}

public function index(Request $request): Response
{
$size = $this->pagingSize;
$page = $request->query->getInt('page', 1);
$from = ($page - 1) * $size;
$total = $this->jobService->count();
$lastPage = \ceil($total / $size);

return $this->render("@$this->templateNamespace/job/index.html.twig", [
'jobs' => $this->jobService->scroll($size, $from),
'page' => $page,
'size' => $size,
'from' => $from,
'lastPage' => $lastPage,
'paginationPath' => 'job.index',
$table = $this->dataTableFactory->create(JobDataTableType::class);
$form = $this->createForm(TableType::class, $table);
$form->handleRequest($request);

if ($form->isSubmitted() && $form->isValid()) {
match ($this->getClickedButtonName($form)) {
TableAbstract::DELETE_ACTION => $this->jobService->deleteByIds(...$table->getSelected()),
JobDataTableType::ACTION_CLEAN => $this->jobService->clean(),
default => $this->logger->messageError(t('log.error.invalid_table_action', [], 'emsco-core'))
};

return $this->redirectToRoute('job.index');
}

return $this->render("@$this->templateNamespace/crud/overview.html.twig", [
'form' => $form->createView(),
'icon' => 'fa fa-file-text-o',
'title' => t('type.title_overview', ['type' => 'job'], 'emsco-core'),
'subTitle' => t('type.title_sub', ['type' => 'job'], 'emsco-core'),
'breadcrumb' => [
'admin' => t('key.admin', [], 'emsco-core'),
'jobs' => t('key.jobs', [], 'emsco-core'),
'page' => t('key.job_logs', [], 'emsco-core'),
],
]);
}

Expand Down Expand Up @@ -96,16 +116,9 @@ public function delete(Job $job): RedirectResponse
return $this->redirectToRoute('job.index');
}

public function clean(): RedirectResponse
{
$this->jobService->clean();

return $this->redirectToRoute('job.index');
}

public function startJob(Job $job, Request $request, UserInterface $user): Response
{
if ($job->getUser() != $user->getUserIdentifier()) {
if ($job->getUser() !== $user->getUserIdentifier()) {
throw new AccessDeniedHttpException();
}

Expand Down
Loading

0 comments on commit a9bfea8

Please sign in to comment.