Skip to content

Commit

Permalink
Jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
Ioannis committed Apr 27, 2024
1 parent bd9384d commit 5b435d3
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 62 deletions.
107 changes: 45 additions & 62 deletions app/templates/Jobs/fields.inc
Original file line number Diff line number Diff line change
Expand Up @@ -32,73 +32,56 @@ if($vv_action == 'view') {
print $this->Field->control('status');

if($vv_obj->status == \App\Lib\Enum\JobStatusEnum::InProgress) {
print $this->Field->statusControl(
fieldName: 'percent_complete',
status: (string)$vv_obj->percent_complete
);
print $this->element('form/listItem', [
'arguments' => [
'fieldName' => 'percent_complete',
'status' => (string)$vv_obj->percent_complete
]
]);
}

$beforeField = '
<div class="field-suppliment">
<div class="form-check">
<input class="form-check-input" type="checkbox" value="" id="format-toggle">
<label class="form-check-label" for="format-toggle">' .
__d('field','format')
. '</label>
</div>
</div>
';
$afterField = '
<script>
parametersValue = $("#parameters").val();
parametersJSON = JSON.parse(parametersValue);
$("#format-toggle").click(function() {
if($(this).is(":checked")) {
$("#parameters").val(JSON.stringify(parametersJSON, null, 4));
paramsHeight = Object.keys(parametersJSON).length + 6 + "em";
$("#parameters").css("height",paramsHeight);
} else {
$("#parameters").val(parametersValue);
$("#parameters").css("height","4em");
}
});
</script>
';
print $this->Field->control('parameters', beforeField: $beforeField, afterField: $afterField);

print $this->Field->control('register_time');

print $this->Field->control('register_summary');

print $this->Field->control('assigned_host');

print $this->Field->control('assigned_pid');

print $this->Field->control('start_after_time');

print $this->Field->control('start_time');
print $this->Field->control('parameters');
print $this->element('form/listItem', [
'arguments' => [
'fieldName' => 'parameters',
'check' => true
]
]);

print $this->Field->control('start_summary');

print $this->Field->control('finish_time');

print $this->Field->control('finish_summary');

print $this->Field->control('requeue_interval');

print $this->Field->control('retry_interval');
foreach([
'register_time',
'register_summary',
'assigned_host',
'assigned_pid',
'start_after_time',
'start_time',
'start_summary',
'finish_time',
'finish_summary',
'requeue_interval',
'retry_interval',
] as $field) {
print $this->element('form/listItem', [
'arguments' => [
'fieldName' => $field,
]
]);
}

if(!empty($vv_obj->requeued_from_job->id)) {
print $this->Field->statusControl(
fieldName: 'requeued_from_job_id',
status: (string)$vv_obj->requeued_from_job->id,
link: [
'url' => [
'controller' => 'jobs',
'action' => 'view',
$vv_obj->requeued_from_job->id
]
$link = [
'url' => [
'controller' => 'jobs',
'action' => 'view',
$vv_obj->requeued_from_job->id
]
];
print $this->element('form/listItem', [
'arguments' => [
'fieldName' => 'requeued_from_job_id',
'status' => (string)$vv_obj->requeued_from_job->id,
'link' => $link,
]
);
]);
}
}
53 changes: 53 additions & 0 deletions app/templates/element/form/infoDiv/check.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php
/**
* COmanage Registry Form Check Element
*
* Portions licensed to the University Corporation for Advanced Internet
* Development, Inc. ("UCAID") under one or more contributor license agreements.
* See the NOTICE file distributed with this work for additional information
* regarding copyright ownership.
*
* UCAID licenses this file to you under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @link https://www.internet2.edu/comanage COmanage Project
* @package registry
* @since COmanage Registry v5.0.0
* @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
*/


declare(strict_types = 1);

?>

<script>
parametersValue = $("#<?= $fieldName ?>").val();
parametersJSON = JSON.parse(parametersValue);
$("#format-toggle").click(function() {
if($(this).is(":checked")) {
$("#<?= $fieldName ?>").val(JSON.stringify(parametersJSON, null, 4));
paramsHeight = Object.keys(parametersJSON).length + 6 + "em";
$("#<?= $fieldName ?>").css("height",paramsHeight);
} else {
$("#<?= $fieldName ?>").val(parametersValue);
$("#<?= $fieldName ?>").css("height","4em");
}
});
</script>

<div class="field-suppliment">
<div class="form-check">
<input class="form-check-input" type="checkbox" value="" id="format-toggle">
<label class="form-check-label" for="format-toggle"><?= __d('field','format') ?></label>
</div>
</div>
5 changes: 5 additions & 0 deletions app/templates/element/form/infoDiv/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,10 @@
declare(strict_types = 1);
?>
<div class="field-info">
<?php
if(isset($vv_field_arguments['check']) && $vv_field_arguments['check']) {
print $this->element('form/infoDiv/check');
}
?>
<?= $this->Fieeld->formField(...$vv_field_arguments) ?>
</div>

0 comments on commit 5b435d3

Please sign in to comment.