diff --git a/VERSION b/VERSION new file mode 100644 index 000000000..9370d0503 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +1.3.x diff --git a/app/assets/javascripts/app/controllers/version.coffee b/app/assets/javascripts/app/controllers/version.coffee new file mode 100644 index 000000000..44bad0de8 --- /dev/null +++ b/app/assets/javascripts/app/controllers/version.coffee @@ -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' ) diff --git a/app/assets/javascripts/app/views/version.jst.eco b/app/assets/javascripts/app/views/version.jst.eco new file mode 100644 index 000000000..93883b72c --- /dev/null +++ b/app/assets/javascripts/app/views/version.jst.eco @@ -0,0 +1,8 @@ +
+

<%- @T('Version') %>

+
+
+

+ <%- @T('This is Zammad version %s', @version) %> +

+
diff --git a/app/controllers/version_controller.rb b/app/controllers/version_controller.rb new file mode 100644 index 000000000..221715f1e --- /dev/null +++ b/app/controllers/version_controller.rb @@ -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 diff --git a/config/routes/version.rb b/config/routes/version.rb new file mode 100644 index 000000000..ae54d1ae1 --- /dev/null +++ b/config/routes/version.rb @@ -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 diff --git a/lib/version.rb b/lib/version.rb new file mode 100644 index 000000000..011ba1a3d --- /dev/null +++ b/lib/version.rb @@ -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