2014-02-03 19:24:49 +00:00
|
|
|
# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
|
2013-06-12 15:59:58 +00:00
|
|
|
|
2012-12-27 20:17:33 +00:00
|
|
|
class PackagesController < ApplicationController
|
2015-05-07 11:23:55 +00:00
|
|
|
before_action :authentication_check
|
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
|
2015-02-15 09:12:27 +00:00
|
|
|
return if deny_if_not_role(Z_ROLENAME_ADMIN)
|
2014-05-20 20:19:19 +00:00
|
|
|
packages = Package.all().order('name')
|
2015-04-27 13:42:53 +00:00
|
|
|
render json: {
|
|
|
|
packages: packages
|
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
|
2015-02-15 09:12:27 +00:00
|
|
|
return if deny_if_not_role(Z_ROLENAME_ADMIN)
|
2012-12-27 20:17:33 +00:00
|
|
|
|
2015-04-27 13:42:53 +00:00
|
|
|
Package.install( string: params[:file_upload].read )
|
2012-12-27 23:29:11 +00:00
|
|
|
|
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
|
2015-02-15 09:12:27 +00:00
|
|
|
return if deny_if_not_role(Z_ROLENAME_ADMIN)
|
2012-12-27 23:29:11 +00:00
|
|
|
|
|
|
|
package = Package.find( params[:id] )
|
|
|
|
|
2015-04-27 13:42:53 +00:00
|
|
|
Package.uninstall( name: package.name, version: package.version )
|
2012-12-27 23:29:11 +00:00
|
|
|
|
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
|