mirror of
https://github.com/Karaka-Management/oms-OnlineResourceWatcher.git
synced 2026-02-17 16:38:41 +00:00
many small fixes
This commit is contained in:
parent
7d72ca7800
commit
8e010c0ab0
34
Admin/Install/Workflow.install.json
Normal file
34
Admin/Install/Workflow.install.json
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
{
|
||||||
|
"triggers": [
|
||||||
|
],
|
||||||
|
"actions": {
|
||||||
|
"1008000001": {
|
||||||
|
"name": "Check resources",
|
||||||
|
"description": {
|
||||||
|
"en": "Check resources",
|
||||||
|
"de": "Ueberpruefe Ressourcen"
|
||||||
|
},
|
||||||
|
"function_type": "API",
|
||||||
|
"function": "apiResourceCheck",
|
||||||
|
"inputs": [
|
||||||
|
"unit",
|
||||||
|
"{*}"
|
||||||
|
],
|
||||||
|
"outputs": [
|
||||||
|
"resources[]",
|
||||||
|
"{*}"
|
||||||
|
],
|
||||||
|
"settings": {
|
||||||
|
"unit": {
|
||||||
|
"type": "input",
|
||||||
|
"subtype": "number",
|
||||||
|
"default": null,
|
||||||
|
"title": {
|
||||||
|
"en": "Unit",
|
||||||
|
"de": "Unit"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
43
Admin/Install/Workflow.php
Normal file
43
Admin/Install/Workflow.php
Normal file
|
|
@ -0,0 +1,43 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Karaka
|
||||||
|
*
|
||||||
|
* PHP Version 8.1
|
||||||
|
*
|
||||||
|
* @package Modules\OnlineResourceWatcher\Admin\Install
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link https://jingga.app
|
||||||
|
*/
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Modules\OnlineResourceWatcher\Admin\Install;
|
||||||
|
|
||||||
|
use phpOMS\Application\ApplicationAbstract;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Workflow class.
|
||||||
|
*
|
||||||
|
* @package Modules\OnlineResourceWatcher\Admin\Install
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @link https://jingga.app
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
class Workflow
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Install workflow providing
|
||||||
|
*
|
||||||
|
* @param ApplicationAbstract $app Application
|
||||||
|
* @param string $path Module path
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public static function install(ApplicationAbstract $app, string $path) : void
|
||||||
|
{
|
||||||
|
\Modules\Workflow\Admin\Installer::installExternal($app, ['path' => __DIR__ . '/Workflow.install.json']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -18,7 +18,7 @@ use phpOMS\Account\PermissionType;
|
||||||
use phpOMS\Router\RouteVerb;
|
use phpOMS\Router\RouteVerb;
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'^.*/orw/resource.*$' => [
|
'^.*/orw/resource(\?.*|$)' => [
|
||||||
[
|
[
|
||||||
'dest' => '\Modules\OnlineResourceWatcher\Controller\ApiController:apiResourceCreate',
|
'dest' => '\Modules\OnlineResourceWatcher\Controller\ApiController:apiResourceCreate',
|
||||||
'verb' => RouteVerb::PUT,
|
'verb' => RouteVerb::PUT,
|
||||||
|
|
@ -56,4 +56,16 @@ return [
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
|
||||||
|
'^.*/orw/resource/render.*$' => [
|
||||||
|
[
|
||||||
|
'dest' => '\Modules\OnlineResourceWatcher\Controller\ApiController:apiResourceRender',
|
||||||
|
'verb' => RouteVerb::GET,
|
||||||
|
'permission' => [
|
||||||
|
'module' => ApiController::NAME,
|
||||||
|
'type' => PermissionType::READ,
|
||||||
|
'state' => PermissionCategory::RESOURCE,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ use Modules\OnlineResourceWatcher\Models\ReportStatus;
|
||||||
use Modules\OnlineResourceWatcher\Models\Resource;
|
use Modules\OnlineResourceWatcher\Models\Resource;
|
||||||
use Modules\OnlineResourceWatcher\Models\ResourceMapper;
|
use Modules\OnlineResourceWatcher\Models\ResourceMapper;
|
||||||
use Modules\OnlineResourceWatcher\Models\ResourceStatus;
|
use Modules\OnlineResourceWatcher\Models\ResourceStatus;
|
||||||
|
use phpOMS\Message\Http\HttpRequest;
|
||||||
use phpOMS\Message\Http\RequestStatusCode;
|
use phpOMS\Message\Http\RequestStatusCode;
|
||||||
use phpOMS\Message\NotificationLevel;
|
use phpOMS\Message\NotificationLevel;
|
||||||
use phpOMS\Message\RequestAbstract;
|
use phpOMS\Message\RequestAbstract;
|
||||||
|
|
@ -41,6 +42,50 @@ use phpOMS\Utils\StringUtils;
|
||||||
*/
|
*/
|
||||||
final class ApiController extends Controller
|
final class ApiController extends Controller
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Api method to create resource
|
||||||
|
*
|
||||||
|
* @param RequestAbstract $request Request
|
||||||
|
* @param ResponseAbstract $response Response
|
||||||
|
* @param mixed $data Generic data
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @api
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public function apiResourceRender(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void
|
||||||
|
{
|
||||||
|
/** @var \Modules\OnlineResourceWatcher\Models\Resource $resource */
|
||||||
|
$resource = ResourceMapper::get()
|
||||||
|
->where('id', (int) $request->getData('id'))
|
||||||
|
->execute();
|
||||||
|
|
||||||
|
$path = '';
|
||||||
|
if (\is_dir($basePath = __DIR__ . '/' . $resource->path . '/' . $resource->lastVersionPath)) {
|
||||||
|
if (\is_file($basePath . '/index.htm')) {
|
||||||
|
$path = 'Modules/OnlineResourceWatcher/Files/' . $resource->path . '/' . $resource->lastVersionPath . '/index.htm';
|
||||||
|
} elseif (\is_file($basePath . '/index.html')) {
|
||||||
|
$path = 'Modules/OnlineResourceWatcher/Files/' . $resource->path . '/' . $resource->lastVersionPath . '/index.html';
|
||||||
|
} else {
|
||||||
|
$files = \scandir($basePath);
|
||||||
|
foreach ($files as $file) {
|
||||||
|
if ($file === '.' || $files === '..') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$path = 'Modules/OnlineResourceWatcher/Files/' . $resource->path . '/' . $resource->lastVersionPath . '/' . $file;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$internalRequest = new HttpRequest();
|
||||||
|
$internalRequest->header->account = $request->header->account;
|
||||||
|
$internalRequest->setData('path', $path);
|
||||||
|
$this->app->moduleManager->get('Media')->apiMediaExport($internalRequest, $response, ['guard' => __DIR__ . '/../Files']);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate resource create request
|
* Validate resource create request
|
||||||
*
|
*
|
||||||
|
|
@ -170,6 +215,7 @@ final class ApiController extends Controller
|
||||||
// Check downloaded resources
|
// Check downloaded resources
|
||||||
// @todo: this may not work correctly because the download runs async.
|
// @todo: this may not work correctly because the download runs async.
|
||||||
$totalCount = \count($toCheck);
|
$totalCount = \count($toCheck);
|
||||||
|
$maxLoops = (int) \min(60 * 10, $totalCount * 10 / 4);
|
||||||
|
|
||||||
// @todo: the following code is INSANE, simplify!!!
|
// @todo: the following code is INSANE, simplify!!!
|
||||||
$baseLen = \strlen($basePath . '/temp');
|
$baseLen = \strlen($basePath . '/temp');
|
||||||
|
|
@ -179,7 +225,7 @@ final class ApiController extends Controller
|
||||||
$resource = $check['resource'];
|
$resource = $check['resource'];
|
||||||
|
|
||||||
// too many tries
|
// too many tries
|
||||||
if ($check['loop'] > 60 * 10) {
|
if ($check['loop'] > $maxLoops) {
|
||||||
$report = new Report();
|
$report = new Report();
|
||||||
$report->resource = $resource->getId();
|
$report->resource = $resource->getId();
|
||||||
$report->versionPath = (string) $check['timestamp'];
|
$report->versionPath = (string) $check['timestamp'];
|
||||||
|
|
@ -205,7 +251,7 @@ final class ApiController extends Controller
|
||||||
$id = (int) \substr($path, $baseLen + 1, $end - $baseLen - 1);
|
$id = (int) \substr($path, $baseLen + 1, $end - $baseLen - 1);
|
||||||
|
|
||||||
// new resource
|
// new resource
|
||||||
if ($check['loop'] === 60 * 10 && !\is_dir($basePath . '/' . $id)) {
|
if ($check['loop'] === $maxLoops && !\is_dir($basePath . '/' . $id)) {
|
||||||
$filesNew = \scandir($path);
|
$filesNew = \scandir($path);
|
||||||
if ($filesNew === false) {
|
if ($filesNew === false) {
|
||||||
$filesNew = [];
|
$filesNew = [];
|
||||||
|
|
|
||||||
|
|
@ -132,6 +132,7 @@ final class BackendController extends Controller
|
||||||
$view = new View($this->app->l11nManager, $request, $response);
|
$view = new View($this->app->l11nManager, $request, $response);
|
||||||
$view->setTemplate('/Modules/OnlineResourceWatcher/Theme/Backend/resource-single');
|
$view->setTemplate('/Modules/OnlineResourceWatcher/Theme/Backend/resource-single');
|
||||||
|
|
||||||
|
/** @var \Modules\OnlineResourceWatcher\Models\Resource $resource */
|
||||||
$resource = ResourceMapper::get()
|
$resource = ResourceMapper::get()
|
||||||
->where('id', (int) $request->getData('id'))
|
->where('id', (int) $request->getData('id'))
|
||||||
->execute();
|
->execute();
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
*/
|
*/
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
return [[
|
return ['OnlineResourceWatcher' => [
|
||||||
'Action' => 'Action',
|
'Action' => 'Action',
|
||||||
'Add' => 'Add',
|
'Add' => 'Add',
|
||||||
'Admin' => 'Admin',
|
'Admin' => 'Admin',
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
*/
|
*/
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
return [[
|
return ['OnlineResourceWatcher' => [
|
||||||
'Action' => 'Action',
|
'Action' => 'Action',
|
||||||
'Add' => 'Add',
|
'Add' => 'Add',
|
||||||
'Admin' => 'Admin',
|
'Admin' => 'Admin',
|
||||||
|
|
@ -83,4 +83,8 @@ return [[
|
||||||
'Element' => 'Element',
|
'Element' => 'Element',
|
||||||
'Exit' => 'Exit',
|
'Exit' => 'Exit',
|
||||||
'Url' => 'Url',
|
'Url' => 'Url',
|
||||||
|
'Preview' => 'Preview',
|
||||||
|
'XPath' => 'XPath',
|
||||||
|
'Comparison' => 'Comparison',
|
||||||
|
'History' => 'History',
|
||||||
]];
|
]];
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,7 @@ use phpOMS\Uri\UriFactory;
|
||||||
<td><?= $this->getHtml('User', '0', '0'); ?><i class="sort-asc fa fa-chevron-up"></i><i class="sort-desc fa fa-chevron-down"></i>
|
<td><?= $this->getHtml('User', '0', '0'); ?><i class="sort-asc fa fa-chevron-up"></i><i class="sort-desc fa fa-chevron-down"></i>
|
||||||
<td><?= $this->getHtml('Email', '0', '0'); ?><i class="sort-asc fa fa-chevron-up"></i><i class="sort-desc fa fa-chevron-down"></i>
|
<td><?= $this->getHtml('Email', '0', '0'); ?><i class="sort-asc fa fa-chevron-up"></i><i class="sort-desc fa fa-chevron-down"></i>
|
||||||
<tbody>
|
<tbody>
|
||||||
<?php $c = 0; foreach ([] as $key => $value) : ++$c; $url = UriFactory::build('{/lang}/{/app}/{/prefix}admin/account/settings?{?}&id=' . $value->getId()); ?>
|
<?php $c = 0; foreach ([] as $key => $value) : ++$c; $url = UriFactory::build('{/lang}/{/app}/admin/account/settings?{?}&id=' . $value->getId()); ?>
|
||||||
<tr data-href="<?= $url; ?>">
|
<tr data-href="<?= $url; ?>">
|
||||||
<td>
|
<td>
|
||||||
<td>
|
<td>
|
||||||
|
|
|
||||||
|
|
@ -78,12 +78,12 @@ $next = $tableView->getNextLink(
|
||||||
<tbody>
|
<tbody>
|
||||||
<?php $count = 0;
|
<?php $count = 0;
|
||||||
foreach ($resources as $key => $resource) : ++$count;
|
foreach ($resources as $key => $resource) : ++$count;
|
||||||
$url = UriFactory::build('{/lang}/{/app}/{/prefix}orw/resource?id=' . $resource->getId()); ?>
|
$url = UriFactory::build('{/lang}/{/app}/orw/resource?id=' . $resource->getId()); ?>
|
||||||
<tr tabindex="0" data-href="<?= $url; ?>">
|
<tr tabindex="0" data-href="<?= $url; ?>">
|
||||||
<td><?= $resource->getId(); ?>
|
<td><?= $resource->getId(); ?>
|
||||||
<td><?= $this->printHtml($resource->title); ?>
|
<td><?= $this->printHtml($resource->title); ?>
|
||||||
<td><?= $this->printHtml((string) $resource->getStatus()); ?>
|
<td><?= $this->printHtml((string) $resource->getStatus()); ?>
|
||||||
<td>
|
<td><?= $this->printHtml($resource->checkedAt->format('Y-m-d H:i')); ?>
|
||||||
<td><?= $this->printHtml($resource->createdAt->format('Y-m-d')); ?>
|
<td><?= $this->printHtml($resource->createdAt->format('Y-m-d')); ?>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
<?php if ($count === 0) : ?>
|
<?php if ($count === 0) : ?>
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,8 @@ declare(strict_types=1);
|
||||||
|
|
||||||
use phpOMS\Uri\UriFactory;
|
use phpOMS\Uri\UriFactory;
|
||||||
|
|
||||||
$resource = $this->getData('resource');
|
/** @var \Modules\OnlineResourceWatcher\Models\Resource */
|
||||||
|
$resource = $this->getData('resource') ?? new \Modules\OnlineResourceWatcher\Models\NullResource();
|
||||||
?>
|
?>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-xs-8">
|
<div class="col-xs-8">
|
||||||
|
|
@ -37,12 +38,12 @@ $resource = $this->getData('resource');
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="iUrl"><?= $this->getHtml('Url'); ?></label>
|
<label for="iUrl"><?= $this->getHtml('Url'); ?></label>
|
||||||
<input id="iUrl" name="uri" type="text" required>
|
<input id="iUrl" name="uri" type="text" value="<?= $this->printHtml($resource->uri); ?>" required>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="iXPath"><?= $this->getHtml('XPath'); ?></label>
|
<label for="iXPath"><?= $this->getHtml('XPath'); ?></label>
|
||||||
<input id="iXPath" name="xpath" type="text">
|
<input id="iXPath" name="xpath" type="text" value="<?= $this->printHtml($resource->xpath); ?>">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="portlet-foot">
|
<div class="portlet-foot">
|
||||||
|
|
@ -61,19 +62,27 @@ $resource = $this->getData('resource');
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row col-simple">
|
||||||
<div class="col-xs-12">
|
<div class="col-xs-12 col-simple">
|
||||||
<div class="portlet">
|
<div class="portlet col-simple">
|
||||||
<div class="portlet-body">
|
<div class="portlet-body col-simple">
|
||||||
<div id="resource" class="tabview tab-2 m-editor wf-100">
|
<div id="resource" class="tabview tab-2 m-editor col-simple">
|
||||||
<ul class="tab-links">
|
<ul class="tab-links">
|
||||||
<li><label tabindex="0" for="resource-c-tab-1"><?= $this->getHtml('Preview'); ?></label>
|
<li><label tabindex="0" for="resource-c-tab-1"><?= $this->getHtml('Preview'); ?></label>
|
||||||
<li><label tabindex="1" for="resource-c-tab-2"><?= $this->getHtml('Comparison'); ?></label>
|
<li><label tabindex="1" for="resource-c-tab-2"><?= $this->getHtml('Comparison'); ?></label>
|
||||||
</ul>
|
</ul>
|
||||||
<div class="tab-content">
|
<div class="tab-content col-simple">
|
||||||
<input type="radio" id="resource-c-tab-1" name="tabular-1" checked>
|
<input type="radio" id="resource-c-tab-1" name="tabular-1" checked>
|
||||||
<div class="tab">
|
<div class="tab col-simple">
|
||||||
|
<div class="col-simple">
|
||||||
|
<div class="col-xs-12 col-simple">
|
||||||
|
<section id="mediaFile" class="portlet col-simple">
|
||||||
|
<div class="portlet-body col-simple">
|
||||||
|
<iframe class="col-simple" id="iRenderFrame" src="<?= UriFactory::build('{/api}/orw/resource/render?id=' . $resource->getId()); ?>" loading="lazy" allowfullscreen></iframe>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<input type="radio" id="resource-c-tab-2" name="tabular-1">
|
<input type="radio" id="resource-c-tab-2" name="tabular-1">
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user