Skip to content

Commit b518349

Browse files
committed
feat: remove idt and idc in first call
1 parent 6c67b0f commit b518349

4 files changed

Lines changed: 8 additions & 16 deletions

File tree

app/controllers/ontologies_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ def external_tool_connect
496496
return render json: { error: t('ontologies.external_tool_not_recognized') }, status: :unprocessable_entity
497497
end
498498

499-
result = connector.connect(api_key: api_key, acronym: acronym, concept_id: params[:idc])
499+
result = connector.connect(api_key: api_key, acronym: acronym)
500500
if result[:redirect_url]
501501
render json: { redirectUrl: result[:redirect_url] }
502502
else

app/helpers/ontologies_helper.rb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -697,15 +697,11 @@ def edit_with_button
697697
return unless @submission_latest
698698

699699
connect_url = ontology_external_tool_connect_path(@ontology.acronym)
700-
idt = ''
701-
idc = ''
702700

703701
button = content_tag(:div, style: 'margin-left: 10px;', data: { controller: 'tooltip' }, title: t('application.edit_with_tooltip')) do
704702
link_to('#', class: 'pill-button',
705703
data: { controller: 'external-tool', action: 'click->external-tool#connect',
706-
external_tool_url_value: connect_url,
707-
external_tool_idt_value: idt,
708-
external_tool_idc_value: idc }) do
704+
external_tool_url_value: connect_url }) do
709705
(inline_svg_tag('edit.svg') +
710706
content_tag(:span, t('application.edit_with'), class: 'ml-1')).html_safe
711707
end

app/javascript/controllers/external_tool_controller.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Controller } from "@hotwired/stimulus"
22

33
export default class extends Controller {
4-
static values = { url: String, idt: String, idc: String }
4+
static values = { url: String }
55

66
async connect(event) {
77
event.preventDefault()
@@ -17,11 +17,7 @@ export default class extends Controller {
1717
headers: {
1818
'Content-Type': 'application/json',
1919
'X-CSRF-Token': csrfToken
20-
},
21-
body: JSON.stringify({
22-
idt: this.idtValue,
23-
idc: this.idcValue
24-
})
20+
}
2521
})
2622

2723
const data = await response.json()

app/services/external_tools/opentheso_connector.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ def initialize(tool)
99
@base_url = tool[:url].to_s.chomp('/')
1010
end
1111

12-
def connect(api_key:, acronym:, concept_id: nil)
12+
def connect(api_key:, acronym:)
1313
idt = resolve_thesaurus(acronym)
1414
if idt.blank?
1515
return { error: I18n.t('ontologies.external_tool_resolve_failed', tool: @tool[:label]), status: :not_found }
1616
end
1717

18-
data = request_sso_token(api_key, idt, concept_id)
18+
data = request_sso_token(api_key, idt)
1919
if data && data['redirectUrl']
2020
{ redirect_url: "#{@base_url}#{data['redirectUrl']}" }
2121
else
@@ -42,15 +42,15 @@ def resolve_thesaurus(acronym)
4242
JSON.parse(response.body)['idTheso']
4343
end
4444

45-
def request_sso_token(api_key, idt, idc)
45+
def request_sso_token(api_key, idt)
4646
uri = URI("#{@base_url}/api/v2/auth/token")
4747
http = Net::HTTP.new(uri.host, uri.port)
4848
http.use_ssl = uri.scheme == 'https'
4949

5050
request = Net::HTTP::Post.new(uri)
5151
request['X-API-Key'] = api_key
5252
request['Content-Type'] = 'application/json'
53-
request.body = { idc: idc.to_s, idt: idt }.to_json
53+
request.body = { idc: '', idt: idt }.to_json
5454

5555
response = http.request(request)
5656
JSON.parse(response.body)

0 commit comments

Comments
 (0)