enable editing of loopplay-flag and fileupload in one step

3.4
Christian Veigl 14 years ago
parent 0827f21035
commit c1031b7574

@ -50,49 +50,40 @@ sub edit_handle : Chained('handle') PathPart('edit') Args(0) {
$c->stash->{template} = 'tt/sound_edit_files.tt';
}
sub upload_soundfile : Chained('handle') PathPart('soundfile/upload') Args(0) {
sub save_handle : Chained('handle') PathPart('save') Args(0) {
my ($self, $c) = @_;
my %messages;
my ($soundfile, $filename);
my $upload = $c->req->upload('soundfile');
my ($file, $filename);
if (defined $upload) {
$file = eval { $upload->slurp };
$soundfile = eval { $upload->slurp };
$filename = eval { $upload->filename };
}
# ne radi :(
# my $checkresult;
# return unless $c->model('Provisioning')->call_prov( $c, 'voip',
# 'check_filetype',
# { filetype => 'audio/x-wav',
# file => $file,
# },
# \$checkresult
# );
# if ($checkresult) {
use File::Type;
my $ft = File::Type->new();
if ($ft->checktype_contents($file) eq 'audio/x-wav') {
if ($c->model('Provisioning')->call_prov($c, 'voip',
'add_sound_file',
{ set_id => $c->stash->{set_id},
handle_id => $c->stash->{handle_id},
soundfile => $file,
filename => $filename,
},
undef))
{
$messages{sound_set_msg} = 'Server.Voip.SavedSettings';
} else {
$messages{sound_set_err} = 'Client.Voip.InputErrorFound';
use File::Type;
my $ft = File::Type->new();
unless ($ft->checktype_contents($soundfile) eq 'audio/x-wav') {
$messages{sound_set_err} = 'Client.Syntax.InvalidFileType';
$c->session->{refill} = { set_id => $c->stash->{set_id}, handle_id => $c->stash->{handle_id}, filename => $filename };
return;
}
}
else {
$messages{sound_set_err} = 'Client.Syntax.InvalidFileType';
$c->session->{refill} = { set_id => $c->stash->{set_id}, handle_id => $c->stash->{handle_id}, filename => $filename };
}
if ($c->model('Provisioning')->call_prov($c, 'voip',
'update_sound_handle',
{ set_id => $c->stash->{set_id},
handle_id => $c->stash->{handle_id},
soundfile => $soundfile,
filename => $filename,
loopplay => $c->request->params->{loopplay} eq 'on' ? 1 : 0,
},
undef))
{
$messages{sound_set_msg} = 'Server.Voip.SavedSettings';
} else {
$messages{sound_set_err} = 'Client.Voip.InputErrorFound';
}
$c->session->{messages} = \%messages;
@ -205,29 +196,6 @@ sub save_set : Chained('set') PathPart('save') Args(0) {
$c->response->redirect("/sound");
}
sub save_handle : Chained('handle') PathPart('save') Args(0) {
my ($self, $c) = @_;
$c->stash->{template} = 'tt/sound_edit_files.tt';
my %messages;
if ($c->model('Provisioning')->call_prov($c, 'voip',
'update_sound_handle',
{ set_id => $c->stash->{set_id},
handle_id => $c->stash->{handle_id},
loopplay => $c->request->params->{loopplay} eq 'on' ? 1 : 0,
},
undef))
{
$messages{sound_set_msg} = 'Server.Voip.SavedSettings';
}
else {
$messages{sound_set_err} = 'Client.Voip.InputErrorFound';
}
$c->session->{messages} = \%messages;
$c->response->redirect('/sound/set/' . $c->stash->{set_id} . '/edithandles');
}
sub load_sets :Private {
my ($self, $c) = @_;

@ -3,49 +3,42 @@
<a href="/sound"><span class="button-back">Back</span></a>
<div class="hspace-20"</div>
<h3>Edit sound files</h3>
<h3>Edit sound files for sound set [% set.name %]</h3>
[% IF messages.sound_set_err %]<div class="error">[% messages.sound_set_err %]</div>[% END %]
[% IF messages.sound_set_msg %]<div class="success">[% messages.sound_set_msg %]</div>[% END %]
<ul class="cleanlist">
<li class="ui-state-default">
<div class="span-2">Setname</div>
<div class="prepend-1 span-2">Handle</div>
<div class="span-2">Handle</div>
<div class="prepend-1 span-1">Loopplay</div>
<div class="prepend-1 span-4">Filename</div>
</li>
<li class="ui-state-default">
<div class="span-5">
[% set.name %]
[% count = set.mapped.domains + set.mapped.subscribers + set.mapped.peers %]
[% IF count > 0 %]
[% plural = 's' IF count > 1 %]
<font class="small"><i>(mapped [% count %] time[% plural %])</i></font>
[% END %]
</div>
</li>
[% FOREACH h IN set.handles %]
<li class="ui-state-default">
<div class="span-2"></div>
<div class="prepend-1 span-2">[% h.name %]</div>
<div class="span-2">[% h.name %]</div>
[% IF NOT h.filename.length %] [%# kein file %]
<form action="/sound/set/[% set.id %]/handle/[% h.id %]/soundfile/upload" method="post" enctype="multipart/form-data">
<div class="prepend-1 span-1"></div>
<form action="/sound/set/[% set.id %]/handle/[% h.id %]/save" method="post" enctype="multipart/form-data">
<div class="prepend-1 span-1"><input type="checkbox" class="checkbox" id="loopplay_"[% h.id %] name="loopplay"></div>
<div class="prepend-1 span-2"></div>
<div class="prepend-1 span-6">
[%# value='' is ignored by browsers for security reasons for file-input-fields %]
<input id="soundfile" name="soundfile" class="file" type="file" size="10" value="[% IF h.filename.length %][% h.filename %][% END %]">
<input id="soundfile" name="soundfile" class="file" type="file" size="10" value="">
</div>
<div class="prepend-1 span-1">
<button class="button-add" id="soundadd" />
</div>
</form>
</form>
[% ELSIF handle_id == h.id %] [%# edit %]
<form action="/sound/set/[% set.id %]/handle/[% h.id %]/save" method="post">
<div class="prepend-1 span-1"><input type="checkbox" class="checkbox" id="loopplay_"[% h.id %] name="loopplay" [% IF h.loopplay %]checked="checked"[% END %]></div>
<div class="prepend-1 span-4">[% h.filename %]</div>
<div class="prepend-3 span-1">
<form action="/sound/set/[% set.id %]/handle/[% h.id %]/save" method="post" enctype="multipart/form-data">
<div class="prepend-1 span-1"><input type="checkbox" class="checkbox" id="loopplay_"[% h.id %] name="loopplay" [% IF h.loopplay %]checked=
"checked"[% END %]></div>
<div class="prepend-1 span-2">[% h.filename %]</div>
<div class="prepend-1 span-6">
[%# value='' is ignored by browsers for security reasons for file-input-fields %]
<input id="soundfile" name="soundfile" class="file" type="file" size="10" value="">
</div>
<div class="prepend-1 span-1">
<button class="button-save" id="handlesave[% id %]">Save</button>
</div>
<div class="span-1">
@ -53,19 +46,21 @@
</div>
</form>
[% ELSE %] [%# view %]
<div class="prepend-1 span-1"><input type="checkbox" class="checkbox" id="loopplay_"[% h.id %] name="loopplay" [% IF h.loopplay %]checked="checked"[% END %] disabled="disabled"></div>
<div class="prepend-1 span-4"><a href="/sound/set/[% set.id %]/handle/[% h.id %]/soundfile/get">[% h.filename %]</a></div>
<div class="prepend-1 span-1"><input type="checkbox" class="checkbox" id="loopplay_"[% h.id %] name="loopplay" [% IF h.loopplay %]checked="che
cked"[% END %] disabled="disabled"></div>
<div class="prepend-1 span-2"><a href="/sound/set/[% set.id %]/handle/[% h.id %]/soundfile/get">[% h.filename %]</a></div>
<form action="/sound/set/[% set.id %]/handle/[% h.id %]/delete" method="post">
[% UNLESS Catalyst.session.admin.read_only %]
<div class="prepend-3 span-1">
<div class="prepend-1 span-6"></div>
<div class="prepend-1 span-1">
<a href="/sound/set/[% set.id %]/handle/[% h.id %]/edit"><span class="button-edit">Edit</span></a>
</div>
<div class="span-1">
<button class="button-delete" id="setdel[% id %]">Delete</button>
</div>
[% END %]
</form>
</form>
[% END %]
</li>
[% END %]
</ul>
[% END %]
</ul>

Loading…
Cancel
Save