packages_controller.rb 710 B

1234567891011121314151617181920212223242526272829
  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. }
  10. end
  11. # POST /api/v1/packages
  12. def install
  13. Package.install(string: params[:file_upload].read)
  14. redirect_to '/#system/package'
  15. end
  16. # DELETE /api/v1/packages
  17. def uninstall
  18. package = Package.find(params[:id])
  19. Package.uninstall(name: package.name, version: package.version)
  20. render json: {
  21. success: true
  22. }
  23. end
  24. end