Fixed issue #264, provide version number within Zammad.
This commit is contained in:
parent
29ec431810
commit
50a31f4c1f
6 changed files with 88 additions and 0 deletions
1
VERSION
Normal file
1
VERSION
Normal file
|
@ -0,0 +1 @@
|
|||
1.3.x
|
28
app/assets/javascripts/app/controllers/version.coffee
Normal file
28
app/assets/javascripts/app/controllers/version.coffee
Normal file
|
@ -0,0 +1,28 @@
|
|||
class Index extends App.ControllerSubContent
|
||||
requiredPermission: 'admin.version'
|
||||
header: 'Version'
|
||||
|
||||
constructor: ->
|
||||
super
|
||||
@load()
|
||||
|
||||
# fetch data, render view
|
||||
load: ->
|
||||
@startLoading()
|
||||
@ajax(
|
||||
id: 'version'
|
||||
type: 'GET'
|
||||
url: "#{@apiPath}/version"
|
||||
success: (data) =>
|
||||
@stopLoading()
|
||||
@version = data.version
|
||||
@render()
|
||||
)
|
||||
|
||||
render: ->
|
||||
|
||||
@html App.view('version')(
|
||||
version: @version
|
||||
)
|
||||
|
||||
App.Config.set('Version', { prio: 3800, name: 'Version', parent: '#system', target: '#system/version', controller: Index, permission: ['admin.version'] }, 'NavBarAdmin' )
|
8
app/assets/javascripts/app/views/version.jst.eco
Normal file
8
app/assets/javascripts/app/views/version.jst.eco
Normal file
|
@ -0,0 +1,8 @@
|
|||
<div class="page-header-title">
|
||||
<h1><%- @T('Version') %><small></small></h1>
|
||||
</div>
|
||||
<div class="page-content">
|
||||
<p>
|
||||
<%- @T('This is Zammad version %s', @version) %>
|
||||
</p>
|
||||
</div>
|
13
app/controllers/version_controller.rb
Normal file
13
app/controllers/version_controller.rb
Normal file
|
@ -0,0 +1,13 @@
|
|||
# Copyright (C) 2012-2017 Zammad Foundation, http://zammad-foundation.org/
|
||||
|
||||
class VersionController < ApplicationController
|
||||
before_action { authentication_check(permission: 'admin.version') }
|
||||
|
||||
# GET /api/v1/version
|
||||
def index
|
||||
render json: {
|
||||
version: Version.get
|
||||
}
|
||||
end
|
||||
|
||||
end
|
6
config/routes/version.rb
Normal file
6
config/routes/version.rb
Normal file
|
@ -0,0 +1,6 @@
|
|||
Zammad::Application.routes.draw do
|
||||
api_path = Rails.configuration.api_path
|
||||
|
||||
match api_path + '/version', to: 'version#index', via: :get
|
||||
|
||||
end
|
32
lib/version.rb
Normal file
32
lib/version.rb
Normal file
|
@ -0,0 +1,32 @@
|
|||
# Copyright (C) 2012-2017 Zammad Foundation, http://zammad-foundation.org/
|
||||
|
||||
class Version
|
||||
|
||||
=begin
|
||||
|
||||
Returns version number of application
|
||||
|
||||
version = Version.get
|
||||
|
||||
returns
|
||||
|
||||
'1.3.0' # example
|
||||
|
||||
=end
|
||||
|
||||
def self.get
|
||||
|
||||
begin
|
||||
version = File.read("#{Rails.root}/VERSION")
|
||||
version.strip!
|
||||
rescue => e
|
||||
message = e.to_s
|
||||
Rails.logger.error "VERSION file could not be read: #{message}"
|
||||
|
||||
version = ''
|
||||
end
|
||||
|
||||
version
|
||||
end
|
||||
|
||||
end
|
Loading…
Reference in a new issue