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

Nahravky

parent e26ed187
Branches
Tags
No related merge requests found
package PiTube::Controller::Record;
use Mojo::Base 'Mojolicious::Controller';
sub list {
my $c = shift;
my $cond = {
is_active => 't'
};
my $records = $c->schema->resultset('Record_view')->search(
$cond,
{ order_by => { -desc => 'begin' }}
);
my @records = ();
RECORD:
while ( my $record = $records->next()) {
my %record = (
$record->get_columns(),
);
push @records, \%record;
}
$c->render( json => \@records );
}
sub player {
my $c = shift;
# vzdy aktualizovat
$c->session->{user}{acl} = $c->schema->resultset('ACL')->user_acl(
$c->session->{user}
);
# record
my $record = $c->schema->resultset('Record_view')->find({
id => $c->stash->{id}
});
if ( ! $record ) {
$c->render('record/404');
return;
}
$c->stash->{record} = {
$record->get_columns,
};
if ( ! ( $c->session->{user}{acl}{ $record->stream_key } & 4 ) ) { # TODO:constant
$c->render('record/403');
return;
}
$c->render();
}
1;
package PiTube::Schema::Result::Record;
use strict;
use warnings;
use base 'DBIx::Class::Core';
our $VERSION = 1;
__PACKAGE__->table('records');
__PACKAGE__->add_columns(
id => {
data_type => 'integer',
is_auto_increment => 1,
is_nullable => 0,
sequence => 'uid_seq'
},
qw(
begin
end
is_active
is_protected
stream_id
publish_user_id
recorder
path
description
info
),
);
__PACKAGE__->belongs_to(
stream => 'PiTube::Schema::Result::Stream',
{
'foreign.id' => 'self.stream_id',
},
);
__PACKAGE__->set_primary_key('id');
1;
package PiTube::Schema::Result::Record_view;
use strict;
use warnings;
use base 'PiTube::Schema::Result::Record';
our $VERSION = 1;
__PACKAGE__->table('records_view');
__PACKAGE__->add_columns(qw(
stream_key
stream_name
stream_is_public
publish_user_name
));
1;
...@@ -63,3 +63,34 @@ select "streams".*, ...@@ -63,3 +63,34 @@ select "streams".*,
from "streams" from "streams"
left join "users" on ("streams"."publish_user_id" = "users"."id") left join "users" on ("streams"."publish_user_id" = "users"."id")
; ;
-- 4 up
create table "records" (
"id" integer not null default nextval('uid_seq'),
"begin" timestamp(0) not null default now(),
"end" timestamp(0),
"is_active" bool not null default true,
"is_protected" bool not null default false,
"stream_id" integer not null,
"publish_user_id" integer not null,
"recorder" text,
"path" text,
"description" text,
"info" text,
primary key("id"),
foreign key ("stream_id") references "streams" ("id") on update cascade on delete restrict,
foreign key ("publish_user_id") references "users" ("id") on update cascade on delete restrict
);
-- 5 up
create view "records_view" as
select "records".*,
"streams"."key" as "stream_key",
"streams"."name" as "stream_name",
"streams"."is_public" as "stream_is_public",
"users"."name" as "publish_user_name"
from "records"
left join "users" on ("records"."publish_user_id" = "users"."id")
join "streams" on ("records"."stream_id" = "streams"."id")
;
% layout 'default';
% title 'Archiv vysílání';
<div class="container pt-2 lg:pb-2 ">
<table id="Records"
class="table table--bordered"
data-row-style="rowStyle"
data-url="/api/records">
<thead>
<tr>
<th data-field="stream_name" data-width="50" data-width-unit="%">Stream</th>
<th data-field="publish_user_name" data-width="30" data-width-unit="%">Vysílal</th>
<th data-field="begin" data-width="20" data-width-unit="%">Datum vysílání</th>
</tr>
</thead>
</table>
</div>
<script>
$('#Records').bootstrapTable({
onClickCell: function (field, value, row, $element) {
window.location.href ='/archive/' + row.id;
},
});
function rowStyle(row, index) {
return {
css: {
cursor: 'pointer'
}
}
}
</script>
% layout 'default';
% title $c->stash->{record}{stream_name} . ' - ' . $c->stash->{record}{begin};
%= include 'includes/player', src => $c->stash->{record}{path}, live => 0;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment