Added status attribute to videos; added ability to edit video status and serial independently

This commit is contained in:
Gregory Ballantine 2023-03-06 17:59:58 -05:00
parent f243452783
commit 4735047682
5 changed files with 63 additions and 0 deletions

26
assets/coffee/wyrm.coffee Normal file
View File

@ -0,0 +1,26 @@
$(document).ready(() ->
$('.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))
)
)
$('.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)
)
)
)
capitalizeWord = (str) ->
return str.charAt(0).toUpperCase() + str.slice(1)

View File

@ -149,6 +149,16 @@ hr{
}
}
}
.video-status,
.video-serial{
transition: background 230ms ease-in-out;
&:hover{
background: rgba(0, 0, 0, 0.1);
cursor: pointer;
}
}
}
}

View File

@ -0,0 +1,11 @@
Sequel.migration do
up do
add_column(:videos, :status, String, default: 'backlog')
end
down do
drop_column(:videos, :status)
end
end

View File

@ -99,6 +99,17 @@ namespace '/video' do
redirect "/video/#{video.id}"
end
post '/:video_id/edit/:attr' do
# find video and temporarily save the old video path
video = Video.where(id: params[:video_id]).first()
attrToEdit = params[:attr]
video[attrToEdit.to_sym] = params[attrToEdit]
video.save()
return "success"
end
get '/:video_id/delete' do
# find the video and delete it
video = Video.where(id: params[:video_id]).first()

View File

@ -20,6 +20,9 @@
<div class="video-serial">
<p>Serial: <span><%= serialize(video.serial) %></span></p>
</div>
<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>
@ -41,3 +44,5 @@
</div>
</div>
</div>
<input type="hidden" id="video-id" value="<%= video.id %>">