Skip to content

Commit

Permalink
List running events (#286)
Browse files Browse the repository at this point in the history
* show events in progress

* show current operation in tooltip and title
  • Loading branch information
tgloeggl authored Apr 30, 2020
1 parent fb863c3 commit b4be3a6
Show file tree
Hide file tree
Showing 7 changed files with 132 additions and 50 deletions.
35 changes: 35 additions & 0 deletions classes/OCRestClient/ApiEventsClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,41 @@ public function getEpisode($episode_id)
return [$code, $data];
}

/**
* getEpisodes() - retrieves episode metadata for a given series identifier
* from connected Opencast
*
* @param string series_id Identifier for a Series
*
* @return array response of episodes
*/
function getEpisodes($series_id, $refresh = false)
{
global $perm;

$cache = StudipCacheFactory::getCache();
$cache_key = 'oc_episodesforseries/' . $series_id;
$episodes = $cache->read($cache_key);

if ($refresh || $episodes === false || $perm->have_perm('dozent')) {
$service_url = "/episode.json?sid=" . $series_id . "&q=&episodes=true&sort=&limit=0&offset=0";
$service_url = '/?sign=false&withacl=false&withmetadata=false&withscheduling=false&withpublications=true&filter=is_part_of:'
. $series_id . '&sort=&limit=0&offset=0';

if ($episodes = $this->getJSON($service_url)) {
foreach ($episodes as $key => $val) {
$episodes[$key]->id = $val->identifier;
}

$cache->write($cache_key, serialize($episodes), 7200);
return $episodes ?: [];
} else {
return [];
}
} else {
return unserialize($episodes) ?: [];
}
}

public function getAclForEpisode($series_id, $episode_id)
{
Expand Down
11 changes: 9 additions & 2 deletions classes/OCRestClient/WorkflowClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,20 @@ function getWorkflowInstance($id)
*
* @return array Workflow Instances
*/
function getInstances($seriesID)
function getRunningInstances($seriesID)
{
$service_url = sprintf( "/instances.json?state=&q=&seriesId=%s&seriesTitle=&creator=&contributor=&fromdate=&todate=&language="
. "&license=&title=&subject=&workflowdefinition=&mp=&op=&sort=&startPage=0&count=1000&compact=true", $seriesID);

$ret = [];
if ($instances = $this->getJSON($service_url)) {
return $instances;
foreach ($instances->workflows->workflow as $wf) {
if ($wf->state == 'RUNNING') {
$ret[$wf->mediapackage->id] = $wf;
}
}

return $ret;
}

return false;
Expand Down
17 changes: 13 additions & 4 deletions controllers/course.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,6 @@ function index_action($active_id = 'false', $upload_message = false)
}

$reload = true;
$this->states = false;


foreach (OCSeminarSeries::getMissingSeries($this->course_id) as $series) {
PageLayout::postError(sprintf($this->_(
Expand All @@ -181,26 +179,37 @@ function index_action($active_id = 'false', $upload_message = false)

$this->connectedSeries = OCSeminarSeries::getSeries($this->course_id);

$this->wip_episodes = [];
$this->instances = [];

if (
$GLOBALS['perm']->have_studip_perm('tutor', $this->course_id)
&& !empty($this->connectedSeries)
) {
foreach ($this->connectedSeries as $key => $series) {
$this->workflow_client = WorkflowClient::getInstance();

foreach ($this->connectedSeries as $key => $series) {
if ($series['schedule']) {
$this->can_schedule = true;
}

$api_client = ApiEventsClient::getInstance(OCConfig::getConfigIdForSeries($series['series_id']));

$oc_series = OCSeriesModel::getSeriesFromOpencast($series);
$this->connectedSeries[$key] = array_merge($series->toArray(), $oc_series);
$this->wip_episodes = array_merge($api_client->getEpisodes($series['series_id']), $this->wip_episodes);
$this->instances = array_merge($this->workflow_client->getRunningInstances($series['series_id']), $this->instances);
}


$this->workflow_client = WorkflowClient::getInstance();
/*
$workflow_ids = OCModel::getWorkflowIDsforCourse($this->course_id);
if (!empty($workflow_ids)) {
$this->states = OCModel::getWorkflowStates($this->course_id, $workflow_ids);
}
*/

//workflow
$occourse = new OCCourseModel($this->course_id);
$this->tagged_wfs = $this->workflow_client->getTaggedWorkflowDefinitions();
Expand Down
2 changes: 1 addition & 1 deletion plugin.manifest
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pluginname=OpenCast
pluginclassname=OpenCast
origin=elan-ev
version=1.2.117
version=1.2.119
studipMinVersion=4.0
studipMaxVersion=4.4
summary=Vorlesungsaufzeichnung
Expand Down
44 changes: 5 additions & 39 deletions views/course/_episode.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,54 +10,20 @@
OC.visibility_text = <?= json_encode($visibility_text) ?>;
</script>

<h1><?= $_('Vorlesungsaufzeichnungen') ?></h1>

<div class="oc_flex">
<div id="episodes" class="oc_flexitem oc_flexepisodelist">
<span class="oce_episode_search">
<!--<span class="oce_episode_search">
<input class="search" placeholder="<?= $_('Nach Aufzeichnung suchen') ?>" size="30"/>
<?= Icon::create('search', 'clickable', [
'class' => 'sort',
'data-sort' => 'name'
]) ?>
-->
</span>
<ul class="oce_list list"
<?= ($GLOBALS['perm']->have_studip_perm('tutor', $course_id)) ? 'id="oce_sortablelist"' : '' ?>>
<? if ($GLOBALS['perm']->have_studip_perm('tutor', $course_id) && !empty($states)) : ?>
<? foreach ($states as $workflow_id => $state) : ?>
<li class="uploaded oce_item">
<? if (in_array($state->state, ['FAILING', 'FAILED'])) : ?>
<div class="oce_wip">
<div class="oce_wip_preview">
<img src="<?= $plugin->getPluginURL() . '/images/opencast-red.svg' ?>">
</div>
</div>
<div class="oce_metadatacontainer oce_failedstate">
<h2 class="oce_list_title">
<?= htmlready($state->mediapackage->title) ?>
</h2>

<div>
<?= $_("Videoverarbeitung fehlgeschlagen") ?>
</div>

<?= Studip\LinkButton::create($_('Daten vom Server entfernen'), PluginEngine::getLink('opencast/course/remove_failed/' . $state->id)); ?>
</div>
<? else : ?>
<div class="oce_wip" id="<?= $workflow_id ?>">
<div class="oce_wip_preview">
<img src="<?= $plugin->getPluginURL() . '/images/opencast-black.svg' ?>">
</div>

<div style="clear: both;"></div>
</div>
<div style="margin-left:110px;">
<h3 class="oce_list_title"><?= $_('Video wird verarbeitet: ') ?>
<?= htmlready($state->mediapackage->title) ?></h3>
<span class="oce_list_date"><?= sprintf($_("Hochgeladen am %s"), date("d.m.Y H:i", strtotime($state->mediapackage->start))) ?></span>
</div>
<? endif; ?>
</li>
<? endforeach; ?>
<? endif; ?>
<? foreach ($ordered_episode_ids as $pos => $item) : ?>
<?
$image = $item['presentation_preview'];
Expand Down Expand Up @@ -130,7 +96,7 @@ class="previewimage <?= $item['visibility'] == 'false' ? 'ocinvisible' : '' ?>"
<?= $item['author'] ? htmlReady($item['author']) : 'Keine Angaben vorhanden' ?>
</li>
<li>
<?= $_('Beschreibung') ?>:
<?= $_('Beschreibung:') ?>
<?= $item['description'] ? htmlReady($item['description']) : 'Keine Beschreibung vorhanden' ?>
</li>
</ul>
Expand Down
65 changes: 65 additions & 0 deletions views/course/_wip_episode.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<? if (!empty($wip_episodes)) : ?>
<h1><?= $_('Aufzeichnungen in Bearbeitung') ?></h1>

<div class="oc_flex">
<div id="episodes" class="oc_flexitem oc_flexepisodelist">
<ul class="oce_list list">
<? foreach ($wip_episodes as $episode) : ?>
<li class="uploaded oce_item">
<? if ($episode->processing_state == 'FAILED') : ?>
<div class="oce_wip">
<div class="oce_wip_preview">
<img src="<?= $plugin->getPluginURL() . '/images/opencast-red.svg' ?>">
</div>
</div>
<div class="oce_metadatacontainer oce_failedstate">
<h2 class="oce_list_title">
<?= htmlready($state->mediapackage->title) ?>
</h2>

<div>
<?= $_("Videoverarbeitung fehlgeschlagen") ?>
</div>

<?= Studip\LinkButton::create($_('Daten vom Server entfernen'), PluginEngine::getLink('opencast/course/remove_failed/' . $state->id)); ?>
</div>
<? elseif ($episode->processing_state == 'RUNNING'): ?>
<div class="oce_wip" id="<?= $workflow_id ?>" title="<?= $_('Aktueller Arbeitsschritt:')
.' '. $instances[$episode->identifier]->operations->operation->description ?>"
>
<div class="oce_wip_preview">
<img src="<?= $plugin->getPluginURL() . '/images/opencast-black.svg' ?>">
</div>

<div style="clear: both;"></div>
</div>
<div class="oce_metadatacontainer">
<h2 class="oce_list_title">
<?= htmlready($episode->title) ?>
<?= tooltipIcon($_('Aktueller Arbeitsschritt:') .' '. $instances[$episode->identifier]->operations->operation->description) ?>
</h2>

<ul class="oce_contetlist">
<li>
<?= $_('Video wird verarbeitet...') ?>
</li>
<li class="oce_list_date">
<?= $_('Hochgeladen am:') ?>
<?= date("d.m.Y H:i", strtotime($episode->created)) ?>
<?= $_("Uhr") ?>
</li>
<li>
<?= $_('Beschreibung:') ?>
<?= $item['description'] ? htmlReady($episode->description) : 'Keine Beschreibung vorhanden' ?>
</li>
<li>
</li>
</ul>
</div>
<? endif; ?>
</li>
<? endforeach; ?>
</ul>
</div>
</div>
<? endif; ?>
8 changes: 4 additions & 4 deletions views/course/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -238,11 +238,11 @@
Helpbar::get()->addLink('Bei Problemen: ' . $GLOBALS['UNI_CONTACT'], 'mailto:' . $GLOBALS['UNI_CONTACT'] . '?subject=[Opencast] Feedback');
?>

<h1>
<?= $_('Vorlesungsaufzeichnungen') ?>
</h1>

<? if (!(empty($ordered_episode_ids)) || !(empty($states))) : ?>
<? if ($perm->have_studip_perm('tutor', Context::getId())) : ?>
<?= $this->render_partial('course/_wip_episode') ?>
<? endif ?>

<?= $this->render_partial('course/_episode') ?>
<? else: ?>
<? if (empty($this->connectedSeries) && $GLOBALS['perm']->have_studip_perm('dozent', $course_id)) : ?>
Expand Down

0 comments on commit b4be3a6

Please sign in to comment.