Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dc45bc9b2a |
No files matched your search
@@ -47,14 +47,9 @@ class ApiActionLog implements EntityInterface, \JsonSerializable
|
|||||||
#[Field(name: "created_at")]
|
#[Field(name: "created_at")]
|
||||||
public \Ulmus\Entity\Field\Datetime $createdAt;
|
public \Ulmus\Entity\Field\Datetime $createdAt;
|
||||||
|
|
||||||
#[Relation("oneToOne", key: "user", foreignKey: "id")]
|
#[Relation("oneToOne", key: "userId", foreignKey: "id")]
|
||||||
public UserInterface $userEntity;
|
public UserInterface $userEntity;
|
||||||
|
|
||||||
public function getUser() : ? UserInterface
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getHash() : string
|
public function getHash() : string
|
||||||
{
|
{
|
||||||
return md5(sprintf("%d:%s", $this->id, $this->objectType));
|
return md5(sprintf("%d:%s", $this->id, $this->objectType));
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ class EntityDescriptor
|
|||||||
$table = $reflector->reflectClass()->getAttribute(Table::class);
|
$table = $reflector->reflectClass()->getAttribute(Table::class);
|
||||||
|
|
||||||
foreach ($reflector->reflectProperties() as $property) {
|
foreach ($reflector->reflectProperties() as $property) {
|
||||||
|
$possibleValues = null;
|
||||||
$entityField = $property->getAttribute(EntityField::class);
|
$entityField = $property->getAttribute(EntityField::class);
|
||||||
$field = $property->getAttribute(Field::class);
|
$field = $property->getAttribute(Field::class);
|
||||||
|
|
||||||
@@ -45,6 +46,12 @@ class EntityDescriptor
|
|||||||
$default = $field->object->attributes['default'] ?? null;
|
$default = $field->object->attributes['default'] ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach($types as $type) {
|
||||||
|
if (! $type->builtIn && enum_exists($type->type)) {
|
||||||
|
$possibleValues = array_map(fn($e) => $e->value, $type->type::cases());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$fields[] = [
|
$fields[] = [
|
||||||
'name' => $property->name,
|
'name' => $property->name,
|
||||||
'description' => $entityField->object->description ?? "",
|
'description' => $entityField->object->description ?? "",
|
||||||
@@ -55,6 +62,7 @@ class EntityDescriptor
|
|||||||
'length' => $field->object->length ?? null,
|
'length' => $field->object->length ?? null,
|
||||||
'readonly' => $field->object->readonly,
|
'readonly' => $field->object->readonly,
|
||||||
'default' => $default,
|
'default' => $default,
|
||||||
|
'possibleValues' => $possibleValues,
|
||||||
'arrayOf' => $arrayOf ?? null,
|
'arrayOf' => $arrayOf ?? null,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,10 +50,19 @@ class ApiRenderer implements MiddlewareInterface {
|
|||||||
|
|
||||||
# For now, we match only response having a 'data' field
|
# For now, we match only response having a 'data' field
|
||||||
if ( (is_array($payload) || $payload instanceof \ArrayAccess) && isset($payload['data'])) {
|
if ( (is_array($payload) || $payload instanceof \ArrayAccess) && isset($payload['data'])) {
|
||||||
|
$humanSize = fn($size) => @round($size / pow(1024, $i=floor(log($size,1024))),2) . ['b','kb','mb','gb',][$i];
|
||||||
|
|
||||||
return HttpFactory::createJsonResponse([
|
return HttpFactory::createJsonResponse([
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'ts' => time(),
|
'ts' => time(),
|
||||||
] + $payload, 200);
|
] + $payload + (getenv('DEBUG') ? [
|
||||||
|
'debug' => [
|
||||||
|
'elapsed_time' => round(1000 * (microtime(true) - $_SERVER["REQUEST_TIME_FLOAT"]), 2),
|
||||||
|
'memory_usage' => $humanSize(memory_get_usage()),
|
||||||
|
'memory_peak_usage' => $humanSize(memory_get_peak_usage()),
|
||||||
|
'pid' => getmypid(),
|
||||||
|
]
|
||||||
|
] : []), 200);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -73,6 +73,10 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
<div class="length"><u>Taille</u> : {{ length($field['length']) }}</div>
|
<div class="length"><u>Taille</u> : {{ length($field['length']) }}</div>
|
||||||
<div class="readonly"><u>Lecture seule</u> : {{ yesOrNo($field['readonly']) }}</div>
|
<div class="readonly"><u>Lecture seule</u> : {{ yesOrNo($field['readonly']) }}</div>
|
||||||
|
|
||||||
|
{% if $field['possibleValues'] ?? false %}
|
||||||
|
<div><u>Valeurs possibles</u> : [ <u class="enum-value">{{= implode('</u><u class="enum-value">', $field['possibleValues']) }}</u> ]</div>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
{% endforeach %}
|
{% endforeach %}
|
||||||
|
|||||||
@@ -38,6 +38,7 @@
|
|||||||
<div class="response-head">
|
<div class="response-head">
|
||||||
<span class="response-code"></span>
|
<span class="response-code"></span>
|
||||||
<span class="response-message"></span>
|
<span class="response-message"></span>
|
||||||
|
<span class="response-timing"></span>
|
||||||
</div>
|
</div>
|
||||||
<hr>
|
<hr>
|
||||||
<pre id="response" class="code" ace-theme="ace/theme/cloud9_day"></pre>
|
<pre id="response" class="code" ace-theme="ace/theme/cloud9_day"></pre>
|
||||||
@@ -61,6 +62,7 @@
|
|||||||
.response-head[data-code^="5"] .response-code{background: #ffa8a8;}
|
.response-head[data-code^="5"] .response-code{background: #ffa8a8;}
|
||||||
.response-head .response-code {background:#dfdfdf;padding:0 8px;font-weight: bold;line-height: 30px;font-size: 80%;}
|
.response-head .response-code {background:#dfdfdf;padding:0 8px;font-weight: bold;line-height: 30px;font-size: 80%;}
|
||||||
.response-head .response-message {padding:0 10px;background:#fbfbfb;line-height: 30px;font-size: 80%;}
|
.response-head .response-message {padding:0 10px;background:#fbfbfb;line-height: 30px;font-size: 80%;}
|
||||||
|
.response-head .response-timing {line-height: 30px;font-size: 75%;font-weight: bold;flex: 1;text-align: right;color: #646060;padding:0 8px;}
|
||||||
|
|
||||||
.request-compose {position:relative;}
|
.request-compose {position:relative;}
|
||||||
.loading-anim {display:none;position:absolute;left:0;right:0;top:0;bottom:0;justify-content: center;align-items: center;z-index: 15;background: rgba(122, 121, 121, 0.25);}
|
.loading-anim {display:none;position:absolute;left:0;right:0;top:0;bottom:0;justify-content: center;align-items: center;z-index: 15;background: rgba(122, 121, 121, 0.25);}
|
||||||
@@ -158,11 +160,14 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let timeStart = performance.now();
|
||||||
|
|
||||||
launchRequest(requestMethod, input.value, editor.getValue())
|
launchRequest(requestMethod, input.value, editor.getValue())
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
responseHead.setAttribute("data-code", response.status);
|
responseHead.setAttribute("data-code", response.status);
|
||||||
responseHead.querySelector('.response-code').innerText = response.status;
|
responseHead.querySelector('.response-code').innerText = response.status;
|
||||||
responseHead.querySelector('.response-message').innerText = response.statusText;
|
responseHead.querySelector('.response-message').innerText = response.statusText;
|
||||||
|
responseHead.querySelector('.response-timing').innerText = (performance.now() - timeStart) + "ms";
|
||||||
|
|
||||||
aceMode = parseContentType(response);
|
aceMode = parseContentType(response);
|
||||||
|
|
||||||
|
|||||||
@@ -52,7 +52,7 @@
|
|||||||
|
|
||||||
.enum-value:nth-child(odd) {color:gray}
|
.enum-value:nth-child(odd) {color:gray}
|
||||||
.enum-value:after {content: ", "; color:#677b8c}
|
.enum-value:after {content: ", "; color:#677b8c}
|
||||||
.enum-value:not(:last-child):after {content:"":}
|
.enum-value:last-child:after {content:"";}
|
||||||
|
|
||||||
.routes-wrapper {padding:5px}
|
.routes-wrapper {padding:5px}
|
||||||
.routes-wrapper li {display:flex;border: 1px solid #ccc;align-items: stretch;cursor:pointer}
|
.routes-wrapper li {display:flex;border: 1px solid #ccc;align-items: stretch;cursor:pointer}
|
||||||
|
|||||||
Reference in new issue
Block a user