generated from ensaremirerol/nextjs-fastapi-starter
-
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.
- Loading branch information
1 parent
0718c11
commit bf5b066
Showing
24 changed files
with
2,010 additions
and
176 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -415,4 +415,6 @@ $RECYCLE.BIN/ | |
public/ | ||
!server/services/local/ | ||
!test/services/local/ | ||
!app/src/lib/ | ||
!app/src/lib/ | ||
|
||
bin/ |
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
Large diffs are not rendered by default.
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
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,67 @@ | ||
import RMLGenerator from '@rmlio/yarrrml-parser/lib/rml-generator'; | ||
import { Writer } from 'n3'; | ||
import ApiService from '../../services/api_service'; | ||
|
||
class YARRRMLService { | ||
private static getApiClient(): ApiService { | ||
return ApiService.getInstance('default'); | ||
} | ||
|
||
public static async getYARRRMLMapping( | ||
workspaceUuid: string, | ||
mappingUuid: string, | ||
): Promise<string> { | ||
const result = await this.getApiClient().callApi<string>( | ||
`/workspaces/${workspaceUuid}/mapping/${mappingUuid}/yarrrml`, | ||
{ | ||
method: 'GET', | ||
parser: data => data as string, | ||
}, | ||
); | ||
|
||
if (result.type === 'success') { | ||
return result.data; | ||
} | ||
|
||
throw new Error( | ||
`Failed to get YARRRML mapping: ${result.message} (status: ${result.status})`, | ||
); | ||
} | ||
|
||
public static async yarrrmlToRML(yarrrml: string): Promise<string> { | ||
const y2r = new RMLGenerator(); | ||
const quads = y2r.convert(yarrrml); | ||
const writer = new Writer(); | ||
writer.addQuads(quads); | ||
return new Promise((resolve, reject) => { | ||
writer.end((error, result) => { | ||
if (error) { | ||
reject(error); | ||
} else { | ||
resolve(result); | ||
} | ||
}); | ||
}); | ||
} | ||
|
||
public static async rmlToTTL(rml: string): Promise<string> { | ||
const result = await this.getApiClient().callApi<string>( | ||
'/rml/run-rml-mapping', | ||
{ | ||
method: 'POST', | ||
body: rml, | ||
parser: data => data as string, | ||
}, | ||
); | ||
|
||
if (result.type === 'success') { | ||
return result.data; | ||
} | ||
|
||
throw new Error( | ||
`Failed to convert RML to TTL: ${result.message} (status: ${result.status})`, | ||
); | ||
} | ||
} | ||
|
||
export default YARRRMLService; |
95 changes: 95 additions & 0 deletions
95
app/src/pages/mapping_page/components/MappingDialog/index.tsx
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,95 @@ | ||
import { | ||
Button, | ||
Dialog, | ||
DialogBody, | ||
DialogFooter, | ||
Tab, | ||
TabPanel, | ||
Tabs, | ||
} from '@blueprintjs/core'; | ||
import { Editor } from '@monaco-editor/react'; | ||
import { useState } from 'react'; | ||
|
||
type MappingDialogProps = { | ||
open: boolean; | ||
yarrrml: string; | ||
rml: string; | ||
ttl: string; | ||
onClose: () => void; | ||
}; | ||
|
||
const MappingDialog = ({ | ||
open, | ||
yarrrml, | ||
rml, | ||
ttl, | ||
onClose, | ||
}: MappingDialogProps) => { | ||
const [activeTab, setActiveTab] = useState('yarrrml'); | ||
|
||
return ( | ||
<Dialog | ||
className='bp5-dark' | ||
isOpen={open} | ||
onClose={onClose} | ||
title='Mapping' | ||
style={{ width: '80vw', height: '80vh' }} | ||
> | ||
<DialogBody> | ||
<Tabs | ||
id='Tabs' | ||
onChange={newTabId => setActiveTab(String(newTabId))} | ||
selectedTabId={activeTab} | ||
> | ||
<Tab | ||
id='yarrrml' | ||
title='YARRRML' | ||
panel={ | ||
<Editor | ||
height='60vh' | ||
theme='vs-dark' | ||
defaultLanguage='yaml' | ||
defaultValue={yarrrml} | ||
options={{ | ||
readOnly: true, | ||
}} | ||
/> | ||
} | ||
/> | ||
<Tab | ||
id='rml' | ||
title='RML' | ||
panel={ | ||
<Editor | ||
height='60vh' | ||
theme='vs-dark' | ||
defaultLanguage='yaml' | ||
defaultValue={rml} | ||
options={{ readOnly: true }} | ||
/> | ||
} | ||
/> | ||
<Tab | ||
id='ttl' | ||
title='TTL' | ||
panel={ | ||
<Editor | ||
height='60vh' | ||
theme='vs-dark' | ||
defaultLanguage='turtle' | ||
defaultValue={ttl} | ||
options={{ readOnly: true }} | ||
/> | ||
} | ||
/> | ||
</Tabs> | ||
<TabPanel id='yarrrml' parentId='Tabs' selectedTabId={activeTab} /> | ||
</DialogBody> | ||
<DialogFooter> | ||
<Button onClick={onClose}>Close</Button> | ||
</DialogFooter> | ||
</Dialog> | ||
); | ||
}; | ||
|
||
export default MappingDialog; |
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
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
Oops, something went wrong.