-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Progress bar is now present bottom right of the page, this will be wh…
…at is used for all background tasks (#310)
- Loading branch information
Showing
32 changed files
with
257 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<table class="table" id="<%= dom_id %>"> | ||
<thead> | ||
<tr> | ||
<th>#</th> | ||
<th>Name</th> | ||
<th>Duration</th> | ||
<th>Size</th> | ||
<th></th> | ||
</tr> | ||
</thead> | ||
<tbody class="disk_titles"> | ||
<% disks.each do |disk| %> | ||
<% disk.disk_titles.sort_by { |d| movie.runtime_range.include?(d.duration) ? 0 : 1 }.each do |disk_title| %> | ||
<% text_class = 'text-primary-emphasis' if movie.runtime_range.include?(disk_title.duration) %> | ||
|
||
<tr> | ||
<th scope="row" class="<%= text_class %>"><%= disk_title.id %></th> | ||
<td class="<%= text_class %>"><%= disk_title.name %></td> | ||
<td class="<%= text_class %>"><%= distance_of_time_in_words(disk_title.duration.seconds) %></td> | ||
<td class="<%= disk_title.size >= free_disk_space ? 'text-danger' : text_class %>"> | ||
<%= number_to_human_size(disk_title.size, precision: 3) %> | ||
<% if disk_title.size >= free_disk_space %> | ||
WARNING: Not enough space available to rip need another <%= number_to_human_size(disk_title.size - free_disk_space, precision: 3) %> | ||
<% end %> | ||
</td> | ||
<td class="<%= text_class %>"> | ||
<%= link_to 'Rip', video_disk_title_path(movie, disk_title), data: { turbo_method: :patch } %> | ||
</td> | ||
</tr> | ||
<% end %> | ||
|
||
<% end %> | ||
</tbody> | ||
</table> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# frozen_string_literal: true | ||
|
||
class MovieTitleTableComponent < ViewComponent::Base | ||
extend Dry::Initializer | ||
|
||
option :disks, Types::Array.of(Types.Instance(Disk)) | ||
option :movie, Types.Instance(Movie) | ||
|
||
def dom_id | ||
"#{self.class.name.parameterize}-#{movie.id}" | ||
end | ||
|
||
def free_disk_space | ||
@free_disk_space ||= stats.block_size * stats.blocks_available | ||
end | ||
|
||
def total_disk_space | ||
@total_disk_space ||= stats.block_size * stats.blocks | ||
end | ||
|
||
private | ||
|
||
def stats | ||
@stats ||= Sys::Filesystem.stat('/') | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# frozen_string_literal: true | ||
|
||
class FindExistingDisksService | ||
MOUNT_LINE = %r{\A(?<disk_name>\S+)\son\s(?:/Volumes/|)(?<name>\S+)} | ||
class << self | ||
delegate :call, to: :new | ||
end | ||
|
||
# example line: | ||
# /dev/disk4 on /Volumes/PLANET51 (udf, local, nodev, nosuid, read-only, noowners) | ||
def call | ||
mounts = `mount` | ||
disks = [] | ||
mounts.each_line do |line| | ||
next unless line.start_with?('/dev/') | ||
|
||
match = line.match(MOUNT_LINE) | ||
rdisk_name = match[:disk_name].gsub('/dev/', '/dev/r') | ||
disks << Disk.find_by(name: match[:name], disk_name: [match[:disk_name], rdisk_name]) | ||
end | ||
disks.compact | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.