packages_controller.rb 779 B

123456789101112131415161718192021222324252627282930
  1. # Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
  2. class PackagesController < ApplicationController
  3. prepend_before_action { authentication_check && authorize! }
  4. # GET /api/v1/packages
  5. def index
  6. render json: {
  7. packages: Package.all.order('name'),
  8. package_installation: File.exist?('/usr/bin/zammad'),
  9. local_gemfiles: Dir['Gemfile.local.*'].present?
  10. }
  11. end
  12. # POST /api/v1/packages
  13. def install
  14. Package.install(string: params[:file_upload].read)
  15. redirect_to '/#system/package'
  16. end
  17. # DELETE /api/v1/packages
  18. def uninstall
  19. package = Package.find(params[:id])
  20. Package.uninstall(name: package.name, version: package.version)
  21. render json: {
  22. success: true
  23. }
  24. end
  25. end