Various changes

This commit is contained in:
Gregory Ballantine 2023-03-07 10:53:18 -05:00
parent 26a4f25631
commit 0d652ffc90
5 changed files with 60 additions and 19 deletions

View File

@ -1,24 +1,39 @@
$(document).ready(() ->
$('.channel-path').click((e) ->
newPath = prompt('New channel directory path', $('.channel-path').val())
if newPath
payload =
directory_path: newPath
channelId = $('#channel-id').val()
$.post('/channel/' + channelId + '/edit/directory_path', payload, (data) ->
if data == 'success'
$('.channel-path span').text(newPath)
)
)
$('.video-status').click((e) ->
newStatus = prompt('New video status').toLowerCase()
payload =
status: newStatus
videoId = $('#video-id').val()
$.post('/video/' + videoId + '/edit/status', payload, (data) ->
if data == 'success'
$('.video-status span').text(capitalizeWord(newStatus))
)
newStatus = prompt('New video status', $('.video-status').val())
if newStatus
newStatus = newStatus.toLowerCase()
payload =
status: newStatus
videoId = $('#video-id').val()
$.post('/video/' + videoId + '/edit/status', payload, (data) ->
if data == 'success'
$('.video-status span').text(capitalizeWord(newStatus))
)
)
$('.video-serial').click((e) ->
newSerial = prompt('New video serial number')
payload =
serial: newSerial
videoId = $('#video-id').val()
$.post('/video/' + videoId + '/edit/serial', payload, (data) ->
if data == 'success'
$('.video-serial span').text(newSerial)
)
newSerial = prompt('New video serial number', $('.video-serial').val())
if newSerial
payload =
serial: newSerial
videoId = $('#video-id').val()
$.post('/video/' + videoId + '/edit/serial', payload, (data) ->
if data == 'success'
$('.video-serial span').text(newSerial)
)
)
)

View File

@ -92,6 +92,12 @@ hr{
font-style: italic;
}
.video-path{
margin-top: 10px;
font-size: 2rem;
text-decoration: underline;
}
.channel-description,
.video-description{
margin-top: 10px;
@ -150,6 +156,7 @@ hr{
}
}
.channel-path,
.video-status,
.video-serial{
transition: background 230ms ease-in-out;

View File

@ -73,4 +73,23 @@ namespace '/channel' do
redirect "/channel/#{channel.id}"
end
post '/:channel_id/edit/:attr' do
# find channel and temporarily save the old channel path
channel = Channel.where(id: params[:channel_id]).first()
attrToEdit = params[:attr]
if attrToEdit == 'directory_path'
File.rename(channel.directory_path, params[attrToEdit])
channel.videos.each do |v|
video_path = v.directory_path.sub(channel.directory_path, params[attrToEdit])
v.update(directory_path: video_path)
end
end
channel[attrToEdit.to_sym] = params[attrToEdit]
channel.save()
return "success"
end
end

View File

@ -59,3 +59,5 @@
<% end %>
</div>
</div>
<input type="hidden" id="channel-id" value="<%= channel.id %>">

View File

@ -5,6 +5,7 @@
<% if video.updated_at %>
<h4 class="video-updated">Last updated at: <%= date_format(video.updated_at) %></h4>
<% end %>
<h4 class="video-path"><%= video.directory_path %></h4>
<p class="video-description"><%= video.description %></p>
</div>
@ -23,9 +24,6 @@
<div class="video-status">
<p>Status: <span><%= video.status.capitalize() %></span></p>
</div>
<div class="video-path">
<p><span><%= video.directory_path %></span></p>
</div>
<div class="script-controls">
<span><a href="/video/<%= video.id %>/script">View script <i class="fa-solid fa-scroll"></i></a></span><span>
<a href="/video/<%= video.id %>/edit/script">Edit script <i class="fa-solid fa-pen-to-square"></i></a></span>