2019-01-16 16:28:25 +01:00
|
|
|
# frozen_string_literal: true
|
2020-04-07 17:53:19 +02:00
|
|
|
|
2019-01-31 12:19:50 +01:00
|
|
|
require 'version'
|
2019-01-16 16:28:25 +01:00
|
|
|
|
2020-02-26 10:19:43 +01:00
|
|
|
# API Controller to get the Fab-manager version
|
2016-09-22 16:46:14 +02:00
|
|
|
class API::VersionController < API::ApiController
|
|
|
|
before_action :authenticate_user!
|
|
|
|
|
|
|
|
def show
|
|
|
|
authorize :version
|
2020-04-07 17:53:19 +02:00
|
|
|
# save the origin
|
|
|
|
origin = Setting.find_or_create_by(name: 'origin')
|
|
|
|
if origin.value != params[:origin]
|
|
|
|
origin.value = params[:origin]
|
|
|
|
origin.save!
|
|
|
|
end
|
|
|
|
# get the last version
|
2020-05-13 15:02:03 +02:00
|
|
|
update_status = Setting.get('hub_last_version') || '{}'
|
2019-01-31 12:19:50 +01:00
|
|
|
|
2020-01-14 17:12:36 +01:00
|
|
|
json = JSON.parse(update_status)
|
|
|
|
json['current'] = Version.current
|
|
|
|
render json: json, status: :ok
|
2016-09-22 16:46:14 +02:00
|
|
|
end
|
2018-11-21 11:42:04 +01:00
|
|
|
end
|