Files
velour/app/controllers/storage_locations_controller.rb
Dan Milne 88a906064f
Some checks failed
CI / scan_ruby (push) Has been cancelled
CI / scan_js (push) Has been cancelled
CI / lint (push) Has been cancelled
CI / test (push) Has been cancelled
CI / system-test (push) Has been cancelled
Much base work started
2025-10-31 14:36:14 +11:00

50 lines
1.3 KiB
Ruby

class StorageLocationsController < ApplicationController
before_action :set_storage_location, only: [:show, :destroy, :scan]
def index
@storage_locations = StorageLocation.all
# Auto-discover storage locations on index page load
StorageDiscoveryService.discover_and_create
end
def show
@videos = @storage_location.videos.includes(:work).recent
end
def create
@storage_location = StorageLocation.new(storage_location_params)
if @storage_location.save
redirect_to @storage_location, notice: 'Storage location was successfully created.'
else
render :new, status: :unprocessable_entity
end
end
def destroy
@storage_location.destroy
redirect_to storage_locations_url, notice: 'Storage location was successfully destroyed.'
end
def scan
scanner = FileScannerService.new(@storage_location)
result = scanner.scan
if result[:success]
redirect_to @storage_location, notice: result[:message]
else
redirect_to @storage_location, alert: result[:message]
end
end
private
def set_storage_location
@storage_location = StorageLocation.find(params[:id])
end
def storage_location_params
params.require(:storage_location).permit(:name, :path, :storage_type)
end
end