packages_controller.rb 678 B

1234567891011121314151617181920212223242526272829
  1. # Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/
  2. class PackagesController < ApplicationController
  3. before_action { authentication_check(permission: 'admin.package') }
  4. # GET /api/v1/packages
  5. def index
  6. packages = Package.all().order('name')
  7. render json: {
  8. packages: packages
  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