packages_controller.rb 758 B

123456789101112131415161718192021222324252627282930
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class PackagesController < ApplicationController
  3. prepend_before_action :authenticate_and_authorize!
  4. # GET /api/v1/packages
  5. def index
  6. render json: {
  7. packages: Package.reorder('name'),
  8. package_installation: Package.app_package_installation?,
  9. local_gemfiles: Package.gem_files?,
  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