Skip to content

Commit

Permalink
Reworked the GUI & A Auto Start for movies
Browse files Browse the repository at this point in the history
  • Loading branch information
brand-it committed Sep 6, 2024
1 parent 49dcb71 commit 802cd22
Show file tree
Hide file tree
Showing 63 changed files with 790 additions and 225 deletions.
10 changes: 8 additions & 2 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config --auto-gen-only-exclude --exclude-limit 1000`
# on 2024-08-29 18:05:38 UTC using RuboCop version 1.65.1.
# on 2024-09-03 17:09:41 UTC using RuboCop version 1.65.1.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
Expand Down Expand Up @@ -97,10 +97,11 @@ RSpec/ExampleLength:
Exclude:
- 'spec/models/video_blob_spec.rb'

# Offense count: 1
# Offense count: 2
# Configuration parameters: Max.
RSpec/MultipleExpectations:
Exclude:
- 'spec/listeners/disk_listener_spec.rb'
- 'spec/requests/movies_request_spec.rb'

# Offense count: 1
Expand All @@ -116,6 +117,11 @@ RSpec/NamedSubject:
Exclude:
- 'spec/models/video_blob_spec.rb'

# Offense count: 1
RSpec/SubjectStub:
Exclude:
- 'spec/listeners/disk_listener_spec.rb'

# Offense count: 12
Rails/I18nLocaleTexts:
Exclude:
Expand Down
46 changes: 42 additions & 4 deletions app/assets/stylesheets/application.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
@import "checkbox_toggle";
@import "bg_process";
@import "autocomplete";
@import "movie";

// @import "./custom";
// app/javascript/packs/stylesheets/_custom.scss
Expand All @@ -33,6 +34,15 @@ body {

body {
font-family: "Lucida Console", Monaco, monospace;

main {
padding: 1em;
padding-bottom: 20em;
}
}

.nav-link {
padding: 0.5em;
}

.height-100 {
Expand All @@ -47,10 +57,8 @@ body {
height: 60px;
}

.sticky-element {
position: -webkit-sticky;
position: sticky;
top: 0;
.margin-auto {
margin: auto;
}

// Console for basic shell output
Expand All @@ -76,6 +84,31 @@ body {
padding: 0.5rem;
}

.certification-rating {
align-content: center;
align-items: center;
border-radius: 2px;
border: 1px solid rgba(255, 255, 255, 0.6);
line-height: 1;
margin-right: 7px;
padding: .06em 4px .06em;
white-space: nowrap;
}

.cast {
display: flex;
overflow-x: scroll;

.cast-member {
.img-poster {
padding-bottom: 1em;
}

width: 200px;
}
}


.h-90 {
height: 90%;
}
Expand All @@ -96,6 +129,10 @@ body {
display: inline-grid;
}

.hidden {
display: none;
}

.overflow-scroll-y {
overflow-y: scroll;
}
Expand All @@ -115,6 +152,7 @@ body {
.img-poster {
height: 300px;
width: 200px;
display: inline-block;
}

.width-225 {
Expand Down
24 changes: 23 additions & 1 deletion app/assets/stylesheets/bg_process.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
#bg-processes.fixed {
max-width: 23%;
position: fixed;
right: 1em;
bottom: 5em;
z-index: 1000;
}

.bg-process {
--bs-toast-bg: rgba(var(--bs-body-bg-rgb), 0.85);
--bs-toast-border-color: var(--bs-border-color-translucent);
Expand Down Expand Up @@ -48,7 +56,6 @@

}


.job {
--bs-toast-bg: rgba(var(--bs-body-bg-rgb), 0.85);
--bs-toast-border-color: var(--bs-border-color-translucent);
Expand Down Expand Up @@ -97,3 +104,18 @@
}

}

#bg-processes.compact {
.bg-process {
margin: 0px;
border-radius: 0;
border: 0.2em solid var(--bs-toast-border-color);

.header {
display: none;
padding: 0.5em;
}

}

}
14 changes: 7 additions & 7 deletions app/assets/stylesheets/minimal.scss
Original file line number Diff line number Diff line change
Expand Up @@ -33,34 +33,34 @@
}

input {
border-radius: 2px 2px 0px 0px;
background-color: transparent;
border-color: transparent;
border-radius: 2px 2px 0px 0px;
border: 0;
color: $white;
display: block;
font-family: "Lucida Console", Monaco, monospace;
font-size: 20px;
height: 35px;
padding-bottom: 3px;
line-height: 1.2;
outline: none;
padding-bottom: 3px;
width: 100%;
border-color: transparent;
}

label {
display: block;
font-size: 22px;
height: 100%;
left: 0;
overflow: hidden;
pointer-events: none;
position: absolute;
width: 100%;
font-size: 22px;
text-overflow: ellipsis;
top: 0px;
transition: all .4s;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
width: 100%;
}

input:focus + label, input.has-val + label {
Expand Down
3 changes: 3 additions & 0 deletions app/assets/stylesheets/movie.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.movie-facts {
color: $light-gray
}
11 changes: 11 additions & 0 deletions app/components/cast_component.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<div class="cast">
<% cast.each do |cast| %>
<div class="cast-member">
<%= imdb_image_tag cast[:profile_path], width: 150, klass: 'img-poster' %>
<div>
<h6 class="cast-name"><%= cast[:name] %></h6>
<p class="cast-character "><%= cast[:character] %></p>
</div>
</div>
<% end %>
</div>
26 changes: 26 additions & 0 deletions app/components/cast_component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# frozen_string_literal: true

class CastComponent < ViewComponent::Base
include ImdbHelper
Member = Types::Hash.schema(
character: Types::String,
name: Types::String,
profile_path: Types::String.optional
).with_key_transform(&:to_sym)
Cast = Types::Coercible::Array.of(Member)

extend Dry::Initializer
option :video, Types.Instance(::Video)

strip_trailing_whitespace

def cast
return [] if video.credits.nil?

@cast ||= Cast[video.credits['cast']]
end

def render?
cast.any?
end
end
46 changes: 25 additions & 21 deletions app/components/load_disk_process_component.html.erb
Original file line number Diff line number Diff line change
@@ -1,25 +1,29 @@
<%= render ProcessComponent.new dom_id: dom_id do |c| %>
<%= c.with_title do %>
Disk Status
<% end %>
<%= c.with_body do %>
<% if job_active? && disks_loading.any? %>
<% disks_loading.each do |disk| %>
<p class="mb-1">
Loading <%= link_to disk.name, the_movie_dbs_path(search: { query: disk.name.titleize }) %> ... <%= link_to 'View Details', job_path(job) %>
</p>
<p><%= Array.wrap(job.metadata['message']).last %></p>
<% end %>
<% elsif disks_not_ejected.any? %>
<% disks_not_ejected.each do |disk| %>
<p class="mb-0">
<%= link_to disk.name, the_movie_dbs_path(search: { query: disk.name.titleize }) %> is ready to be ripped. <%= link_to 'eject', eject_disk_path(disk), data: { turbo_method: :post } %>
</p>
<% if hidden? %>
<div id="<%= dom_id %>" class="hidden"></div>
<% else %>
<%= render ProcessComponent.new dom_id: dom_id do |c| %>
<%= c.with_title do %>
Disk Status
<% end %>
<%= c.with_body do %>
<% if job_active? && disks_loading.any? %>
<% disks_loading.each do |disk| %>
<p class="mb-1">
Loading <%= link_to disk.name, the_movie_dbs_path(search: { query: disk.name.titleize }) %> ... <%= link_to 'View Details', job_path(job) %>
</p>
<p><%= Array.wrap(job.metadata['message']).last %></p>
<% end %>
<% elsif disks_not_ejected.any? %>
<% disks_not_ejected.each do |disk| %>
<p class="mb-0">
<%= link_to disk.name, the_movie_dbs_path(search: { query: disk.name.titleize }) %> is ready to be ripped. <%= link_to 'eject', eject_disk_path(disk), data: { turbo_method: :post } %>
</p>
<% end %>
<% elsif job_active? %>
<p class="mb-1">Loading disk info ...<%= link_to 'View Details', job_path(job) %></p>
<% else %>
<span>No disks found - insert disk to continue</span>
<% end %>
<% elsif job_active? %>
<p class="mb-1">Loading disk info ...<%= link_to 'View Details', job_path(job) %></p>
<% else %>
<span>No disks found - insert disk to continue</span>
<% end %>
<% end %>
<% end %>
8 changes: 8 additions & 0 deletions app/components/load_disk_process_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ def self.job
Job.sort_by_created_at.active.find_by(name: 'LoadDiskWorker')
end

def self.show?
job&.active?
end

def hidden?
!self.class.show? && disks_not_ejected.empty?
end

def job_active?
job&.active?
end
Expand Down
37 changes: 16 additions & 21 deletions app/components/movie_title_table_component.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<% if disks.any? %>
<%= simple_form_for :movies, url: rip_movie_path(movie) do |f| %>
<% disk = disks.first %>
<%= hidden_field_tag :disk_id, disk&.id %>
<table class="table" id="<%= dom_id %>">
<thead>
Expand All @@ -15,16 +14,15 @@
</tr>
</thead>
<tbody class="disk_titles">
<% disk.disk_titles.sort_by { |d| movie.runtime_range.include?(d.duration) ? 0 : 1 }.each do |disk_title| %>
<% disk_titles_with_info.each do |info| %>
<% disk_title = info.disk_title %>
<%= hidden_field_tag "movies[][disk_title_id]", disk_title.id %>
<% in_range = movie.runtime_range.include?(disk_title.duration) %>
<% text_class = 'text-primary-emphasis' if in_range %>
<% text_class = 'text-success-emphasis' if movie.video_blobs.any? && in_range %>
<% text_class = 'text-primary-emphasis' if info.within_range %>
<tr>
<td scope="row" class="<%= text_class %>"><%= disk_title.id %></td>
<td class="text-center">
<h1>
<% if movie.ripped_disk_titles.any? { _1.name == disk_title.name } %>
<% if info.ripped? %>
<%= icon('square-check') %>
<% else %>
<%= icon('square') %>
Expand All @@ -33,7 +31,7 @@
</td>
<td class="text-center">
<h1>
<% if movie.ripped_disk_titles.find { _1.name == disk_title.name }&.video_blob&.uploaded? %>
<% if info.uploaded? %>
<%= icon('square-check') %>
<% else %>
<%= icon('square') %>
Expand All @@ -47,24 +45,17 @@
(<%= disk_title.video&.title %>)
<% end %>
</td>
<td class="<%= text_class %>"><%= distance_of_time_in_words(disk_title.duration.seconds) %></td>
<td class="<%= text_class %>">
<%= distance_of_time_in_words(disk_title.duration.seconds) %>
</td>
<td class="<%= disk_title.size >= free_disk_space ? 'text-warn' : text_class %>">
<%= number_to_human_size(disk_title.size, precision: 3) %>
<% if disk_title.size >= free_disk_space %>
WARNING: There Might Not enough space available to rip, needs another <%= number_to_human_size(disk_title.size - free_disk_space, precision: 3) %>
<% end %>
</td>
<td class="<%= text_class %>">
<% if movie.ripped_disk_titles.find { _1.name == disk_title.name }&.video_blob&.uploaded? %>
<%= select_tag "movies[][extra_type]", options_for_select(VideoBlob.extra_types.keys, nil), prompt: "Don't Rip" %>
<% elsif in_range && feature_film_selected? %>
<%= select_tag "movies[][extra_type]", options_for_select(VideoBlob.extra_types.keys, 'shorts'), prompt: "Don't Rip" %>
<% elsif in_range %>
<% feature_film_selected! %>
<%= select_tag "movies[][extra_type]", options_for_select(VideoBlob.extra_types.keys, 'feature_films'), prompt: "Don't Rip" %>
<% else %>
<%= select_tag "movies[][extra_type]", options_for_select(VideoBlob.extra_types.keys, 'other'), prompt: "Don't Rip" %>
<% end %>
<%= select_tag "movies[][extra_type]", options_for_select(VideoBlob.extra_types.keys, info.extra_type), prompt: "Don't Rip" %>
</td>
</tr>
<% end %>
Expand All @@ -74,8 +65,12 @@
</div>
</table>
<% end %>
<% elsif job&.active? %>
<p class="text-info">Stand by the disk is still being loading from the CD drive this could take a while. Page will update once the disk is ready so no need to refresh the page but if you do it won't hurt anything.</p>
<% else %>
<p class="text-warn">Sorry no Disk is currently loaded or could be detected. Refresh page if your seeing this warning but know a disk is present.</p>
<div class='bg-dark w-100 mt-1 text-right p-3 border-top'>
<% if movie.auto_start %>
<p class="text-success">Will Start ripping movie as soon as the disk is ready.</p>
<% else %>
<%= link_to 'Auto Start', auto_start_movie_path(movie), class: 'btn btn-primary', data: { turbo_method: :post } %>
<% end %>
</div>
<% end %>
Loading

0 comments on commit 802cd22

Please sign in to comment.