-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added feature to reconcile artsdata entities
- Loading branch information
1 parent
ba6e0f2
commit 23b68c9
Showing
6 changed files
with
47 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
const artsdataSearch = () => { | ||
const ui = SpreadsheetApp.getUi(); | ||
const cell = SpreadsheetApp.getActiveSpreadsheet() | ||
.getActiveSheet() | ||
.getActiveCell(); | ||
const value = cell.getValue(); | ||
|
||
const query = encodeURIComponent(`{"q0":{"query":"${value}"}}`); | ||
const url = `https://api.artsdata.ca/recon?queries=${query}`; | ||
|
||
try { | ||
const response = JSON.parse(UrlFetchApp.fetch(url).getContentText()); | ||
const results = response?.q0?.result; | ||
|
||
if (results && results.length > 0) { | ||
const choices = results.map(result => `${result.id} - ${result.name}`).join('\n'); | ||
const userChoice = ui.prompt('Enter an ID from the list:', choices, ui.ButtonSet.OK_CANCEL); | ||
|
||
if (userChoice.getSelectedButton() === ui.Button.OK) { | ||
const chosenId = userChoice.getResponseText(); | ||
cell.setValue(`https://kg.artsdata.ca/resource/${chosenId}`); | ||
} else { | ||
ui.alert('No ID chosen.'); | ||
} | ||
} else { | ||
ui.alert('No results found.'); | ||
} | ||
} catch (e) { | ||
ui.alert(`An error occurred: ${e.message}`); | ||
} | ||
}; | ||
|
||
export default artsdataSearch; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
import artsdataPreview from './artsdata_preview'; | ||
import getEntityDetails from './get_entity_details'; | ||
import onOpen from './onOpen'; | ||
import menuItem from './menuItem'; | ||
import artsdataSearch from './artsdata_search'; | ||
|
||
global.artsdataPreview = artsdataPreview; | ||
global.getEntityDetails = getEntityDetails; | ||
global.onOpen = onOpen; | ||
global.menuItem = menuItem; | ||
global.artsdataSearch = artsdataSearch; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,8 @@ | ||
const onOpen = () => { | ||
SpreadsheetApp.getUi() | ||
.createMenu('Custom Menu') | ||
.addItem('First Item', 'menuItem') | ||
.createMenu('Artsdata Reconciliation') | ||
.addItem('Search', 'artsdataSearch') | ||
.addToUi(); | ||
|
||
|
||
}; | ||
|
||
export default onOpen; |