简体   繁体   English

CKAN“ autocomplete.js”模块不起作用(CKAN版本2.8)

[英]CKAN “autocomplete.js” module is not working ( CKAN version 2.8)

I installed CKAN 2.8 version and I am trying to fetch keywords/terminologies from https://terminologies.gfbio.org/api/ using build in CKAN javascript module name "autocomplete.js".[ https://github.com/ckan/ckan/blob/master/ckan/public/base/javascript/modules/autocomplete.js#L76] 我安装了CKAN 2.8版本,并尝试使用CKAN javascript模块名称“ autocomplete.js”中的构建从https://terminologies.gfbio.org/api/获取关键字/术语。[ https://github.com/ckan /ckan/blob/master/ckan/public/base/javascript/modules/autocomplete.js#L76]

But as I have supplied endpoint link to "data-module-source = https://terminologies.gfbio.org/api/terminologies/search?query=Acetobacter%20aceti " there is no response.... My frontend HTML code at CKAN >> 但是,因为我提供了指向“数据模块源= https://terminologies.gfbio.org/api/terminologies/search?query=Acetobacter%20aceti ”的端点链接,所以没有任何响应。...我的前端HTML代码位于卡恩>>

<input name="search" data-module="autocomplete" data-module- 
source="https://terminologies.gfbio.org/api/terminologies/search? 
query=Acetobacter%20aceti" />

but there is no API call generated from CKAN site to the remote endpoint ie " https://terminologies.gfbio.org/api " with the following code. 但不会从CKAN站点生成到具有以下代码的API调用,该API调用是从远程节点(即https://terminologies.gfbio.org/api )生成的。

<input name="search" data-module="autocomplete" data-module- 
source="https://terminologies.gfbio.org/api/terminologies/search? 
query=Acetobacter%20aceti" />

The autocomplete module is in ckan/javascript modules and is therefore designed to run on the client side. 自动完成模块位于ckan / javascript模块中,因此被设计为在客户端上运行。 ie the input form on the browser should be calling the API. 也就是说,浏览器上的输入表单应调用API。

So you probably don't see a call from your ckan server to the API. 因此,您可能看不到ckan服务器对API的调用。 But you may see it in the network output of the browser. 但是您可能会在浏览器的网络输出中看到它。

Second you need to generate an appropriate API call that takes an incomplete string and returns a match list. 其次,您需要生成一个适当的API调用,该API调用不完整的字符串并返回匹配列表。

for example the standard tag search calls (after typing java) http://ckan:5000/api/2/util/tag/autocomplete?incomplete=ora might return {"ResultSet": {"Result": [{id: "orange", text: "orange"}] 例如,标准标签搜索调用(在输入Java之后) http:// ckan:5000 / api / 2 / util / tag / autocomplete?incomplete = ora可能返回{“ ResultSet”:{“ Result”:[{id:“橙色”,文本:“橙色”}]

So you will need the remote API to return as similar array of strings that can be displayed. 因此,您将需要远程API作为可以显示的相似字符串数组返回。

There may be ways to override the plugin so as to parse and restructure the API result on the client side - If you find them let me know :). 可能有一些方法可以覆盖插件,以便在客户端解析和重组API结果-如果找到它们,请告诉我:)。 Otherwise you may need a server side microservice that takes a partial request, calls the gfbio api and reshapes the result. 否则,您可能需要一个接受部分请求的服务器端微服务,调用gfbio api并调整结果的形状。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM