Skip to content
Snippets Groups Projects
Verified Commit e5c400e6 authored by Andrej Ramašeuski's avatar Andrej Ramašeuski
Browse files

Editace popisu

parent ade04dde
Branches
Tags
No related merge requests found
Pipeline #4583 passed
...@@ -2,7 +2,7 @@ image: docker:19.03.12 ...@@ -2,7 +2,7 @@ image: docker:19.03.12
variables: variables:
DOCKER_TLS_CERTDIR: "/certs" DOCKER_TLS_CERTDIR: "/certs"
IMAGE_VER: 1.9.3 IMAGE_VER: 1.10.0
services: services:
- docker:19.03.12-dind - docker:19.03.12-dind
......
...@@ -85,6 +85,7 @@ sub startup { ...@@ -85,6 +85,7 @@ sub startup {
$r->get('/archive')->to(cb => sub { shift->render('archive'); }); $r->get('/archive')->to(cb => sub { shift->render('archive'); });
$r->get('/api/records')->to('Record#list'); $r->get('/api/records')->to('Record#list');
$r->delete('/api/records/:id')->to('Record#delete'); $r->delete('/api/records/:id')->to('Record#delete');
$r->put('/api/records/:id')->to('Record#update');
$r->get('/archive/:id')->to('Record#player'); $r->get('/archive/:id')->to('Record#player');
# $r->get('/streams/add')->over( is => 'administrator' )->to('Stream#add'); # $r->get('/streams/add')->over( is => 'administrator' )->to('Stream#add');
......
...@@ -5,8 +5,10 @@ use constant PAGE_SIZE => 5; ...@@ -5,8 +5,10 @@ use constant PAGE_SIZE => 5;
use constant SORT_COLUMNS => qr/stream_name|publish_user_name|begin/; use constant SORT_COLUMNS => qr/stream_name|publish_user_name|begin/;
use constant SORT_DIRS => qr/asc|desc/; use constant SORT_DIRS => qr/asc|desc/;
sub list { use feature 'signatures';
my $c = shift; no warnings 'experimental::signatures';
sub list ($c) {
my $readable = $c->schema->resultset('ACL')->user_acl( my $readable = $c->schema->resultset('ACL')->user_acl(
$c->session->{user}, 4 $c->session->{user}, 4
...@@ -56,8 +58,7 @@ sub list { ...@@ -56,8 +58,7 @@ sub list {
}); });
} }
sub player { sub player ($c) {
my $c = shift;
# vzdy aktualizovat # vzdy aktualizovat
$c->session->{user}{acl} = $c->schema->resultset('ACL')->user_acl( $c->session->{user}{acl} = $c->schema->resultset('ACL')->user_acl(
...@@ -77,6 +78,7 @@ sub player { ...@@ -77,6 +78,7 @@ sub player {
$c->stash->{record} = { $c->stash->{record} = {
$record->get_columns, $record->get_columns,
is_editable => $record->is_editable( $c->session->{user}{id} ), is_editable => $record->is_editable( $c->session->{user}{id} ),
is_deletable => $record->is_deletable( $c->session->{user}{id} ),
}; };
if ( ! ( $c->session->{user}{acl}{ $record->stream_key } & 4 ) ) { # TODO:constant if ( ! ( $c->session->{user}{acl}{ $record->stream_key } & 4 ) ) { # TODO:constant
...@@ -87,6 +89,26 @@ sub player { ...@@ -87,6 +89,26 @@ sub player {
$c->render(); $c->render();
} }
sub update ($c) {
my $args = $c->req->params->to_hash();
my $record = $c->schema->resultset('Record')->search({
id => $c->stash->{id},
publish_user_id => $c->session->{user}{id}
})->first;
if ( ! $record ) {
$c->render( status => 404, text => '');
return;
}
$record->update({
description => $args->{description},
});
$c->render( status => 204, text => '' );
}
sub delete { sub delete {
my $c = shift; my $c = shift;
......
...@@ -9,10 +9,9 @@ ...@@ -9,10 +9,9 @@
<thead> <thead>
<tr> <tr>
<th data-field="stream_name" data-width="25" data-width-unit="%" data-sortable="true">Stream</th> <th data-field="stream_name" data-width="25" data-width-unit="%" data-sortable="true">Stream</th>
<th data-field="description" data-width="30" data-width-unit="%" data-sortable="true">Popis</th>
<th data-field="publish_user_name" data-width="20" data-width-unit="%" data-sortable="true">Vysílal</th> <th data-field="publish_user_name" data-width="20" data-width-unit="%" data-sortable="true">Vysílal</th>
<th data-field="description" data-width="40" data-width-unit="%" data-sortable="true">Popis</th>
<th data-field="begin" data-width="15" data-width-unit="%" data-sortable="true">Odvysíláno</th> <th data-field="begin" data-width="15" data-width-unit="%" data-sortable="true">Odvysíláno</th>
<th data-field="id" data-width="5" data-width-unit="%" data-formatter="formatterActions"></th>
</tr> </tr>
</thead> </thead>
</table> </table>
...@@ -25,18 +24,7 @@ $('#Records').bootstrapTable({ ...@@ -25,18 +24,7 @@ $('#Records').bootstrapTable({
paginationParts: ['pageInfo', 'pageList'], paginationParts: ['pageInfo', 'pageList'],
sidePagination: 'server', sidePagination: 'server',
onClickCell: function (field, value, row, $element) { onClickCell: function (field, value, row, $element) {
if ( field == 'id' ) {
$.ajax({
method: 'delete',
url: '/api/records/' + row.id,
success: function(rc) {
$('#Records').bootstrapTable('refresh', {silent: true})
}
});
}
else {
window.location.href ='/archive/' + row.id; window.location.href ='/archive/' + row.id;
}
}, },
}); });
...@@ -48,10 +36,5 @@ function rowStyle(row, index) { ...@@ -48,10 +36,5 @@ function rowStyle(row, index) {
} }
} }
function formatterActions(value, row) {
if ( row.is_deletable ) {
return '<i class="fas fa-trash-alt text-3xl" title="Smazat"></i>';
}
}
</script> </script>
% layout 'default'; % layout 'default';
% title $c->stash->{record}{stream_name} . ' - ' . $c->stash->{record}{begin}; % title $c->stash->{record}{stream_name} . ' - ' . $c->stash->{record}{begin};
%= include 'includes/player', src => $c->stash->{record}{path}, live => 0; %= include 'includes/player', src => $c->stash->{record}{path}, live => 0;
% if ( $c->stash->{record}{is_editable} ) {
<div class="grid grid-cols-8 gap-4 row-gap-6" style="padding-top: 2em;">
<div class="form-field col-span-8">
<form>
<label class="form-field__label" for="description">Kratký popis videa</label>
<div class="form-field__wrapper form-field__wrapper--shadowed">
<input type="text" name="description" id="description" class="text-input form-field__control" value="<%= $c->stash->{record}{description} %>" placeholder="" />
</div>
</form>
</div>
<button class="btn col-span-2 text-lg max-w-full btn--black-100" id="buttonSave">
<div class="btn__body ">Uložit</div>
</button>
<button class="btn col-span-2 text-lg max-w-full btn--black-100" id="buttonDownload">
<div class="btn__body "><a href="<%= $c->stash->{record}{path} %>">Stahnout</a></div>
</button>
% if ( $c->stash->{record}{is_deletable} ) {
<button class="btn col-span-2 text-lg max-w-full btn--red-100" id="buttonDelete">
<div class="btn__body ">Smazat</div>
</button>
% }
</div>
% }
<script>
$(function() {
$('#buttonSave').on('click', function (e) {
var data = $("form").serialize();
$.ajax({
method: 'put',
data: data,
url: '/api/records/<%= $c->stash->{record}{id} %>',
success: function(rc) {
console.log('updated');
}
});
});
$('#buttonDelete').on('click', function (e) {
$.ajax({
method: 'delete',
url: '/api/records/<%= $c->stash->{record}{id} %>',
success: function(rc) {
window.location.href ='/archive/';
}
});
});
})
</script>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment