2022-01-01 13:38:12 +00:00
|
|
|
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
|
2013-06-12 15:59:58 +00:00
|
|
|
|
2012-12-27 20:17:33 +00:00
|
|
|
class PackagesController < ApplicationController
|
2020-03-19 09:39:51 +00:00
|
|
|
prepend_before_action { authentication_check && authorize! }
|
2012-12-27 20:17:33 +00:00
|
|
|
|
2013-08-06 22:10:28 +00:00
|
|
|
# GET /api/v1/packages
|
2012-12-27 20:17:33 +00:00
|
|
|
def index
|
2021-07-16 13:29:38 +00:00
|
|
|
packages = Package.all.order('name')
|
2021-07-20 11:11:38 +00:00
|
|
|
commands = ['rails zammad:package:migrate', 'rails assets:precompile']
|
2021-07-20 09:38:58 +00:00
|
|
|
if File.exist?('/usr/bin/zammad')
|
|
|
|
commands.map! { |s| "zammad run #{s}" }
|
|
|
|
end
|
2015-04-27 13:42:53 +00:00
|
|
|
render json: {
|
2021-07-20 09:38:58 +00:00
|
|
|
packages: packages,
|
|
|
|
commands: commands
|
2012-12-27 20:17:33 +00:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2013-08-06 22:10:28 +00:00
|
|
|
# POST /api/v1/packages
|
2012-12-27 23:29:11 +00:00
|
|
|
def install
|
2016-06-30 08:24:03 +00:00
|
|
|
Package.install(string: params[:file_upload].read)
|
2013-09-22 22:28:33 +00:00
|
|
|
redirect_to '/#system/package'
|
2012-12-27 23:29:11 +00:00
|
|
|
end
|
|
|
|
|
2013-08-06 22:10:28 +00:00
|
|
|
# DELETE /api/v1/packages
|
2012-12-27 23:29:11 +00:00
|
|
|
def uninstall
|
2016-06-30 08:24:03 +00:00
|
|
|
package = Package.find(params[:id])
|
|
|
|
Package.uninstall(name: package.name, version: package.version)
|
2015-04-27 13:42:53 +00:00
|
|
|
render json: {
|
|
|
|
success: true
|
2012-12-27 20:17:33 +00:00
|
|
|
}
|
|
|
|
end
|
2012-12-27 23:29:11 +00:00
|
|
|
|
2013-06-12 15:59:58 +00:00
|
|
|
end
|