-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #142 from CS3219-AY2425S1/feat/live_collaboration
Feat/code execution
- Loading branch information
Showing
11 changed files
with
989 additions
and
911 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { LANGUAGE_EXTENSION, LANGUAGE_VERSIONS } from '@/lib/constants'; | ||
import axios from 'axios'; | ||
|
||
const API = axios.create({ | ||
baseURL: 'https://emkc.org/api/v2/piston', | ||
}); | ||
|
||
export const executeCode = async (language: string, sourceCode: string) => { | ||
console.log(`Language executed: ${language}`); | ||
const response = await API.post('/execute', { | ||
language: language, | ||
version: LANGUAGE_VERSIONS[language], | ||
files: [ | ||
{ | ||
name: 'main.' + LANGUAGE_EXTENSION[language], | ||
content: sourceCode, | ||
}, | ||
], | ||
stdin: '', // Add stdin field | ||
args: [], // Add args field | ||
compile_timeout: 10000, // Add compile timeout | ||
run_timeout: 10000, // Add run timeout | ||
}); | ||
return response.data.run.output; | ||
}; |
54 changes: 54 additions & 0 deletions
54
peerprep-fe/src/app/collaboration/components/AlertDialogues.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,54 @@ | ||
'use client'; | ||
|
||
import { | ||
AlertDialog, | ||
AlertDialogAction, | ||
AlertDialogCancel, | ||
AlertDialogContent, | ||
AlertDialogDescription, | ||
AlertDialogFooter, | ||
AlertDialogHeader, | ||
AlertDialogTitle, | ||
AlertDialogTrigger, | ||
} from '@/components/ui/alert-dialog'; | ||
import { Button } from '@/components/ui/button'; | ||
|
||
interface LeaveSessionDialogProps { | ||
onLeave: () => void; | ||
triggerClassName?: string; | ||
} | ||
|
||
const LeaveSessionDialog = ({ | ||
onLeave, | ||
triggerClassName = 'border border-amber-700/50 bg-amber-950/90 text-amber-100 hover:bg-amber-900/90', | ||
}: LeaveSessionDialogProps) => { | ||
return ( | ||
<AlertDialog> | ||
<AlertDialogTrigger asChild> | ||
<Button size="sm" className={triggerClassName}> | ||
Leave Session | ||
</Button> | ||
</AlertDialogTrigger> | ||
<AlertDialogContent className="bg-black"> | ||
<AlertDialogHeader> | ||
<AlertDialogTitle>Leave Collaboration Session?</AlertDialogTitle> | ||
<AlertDialogDescription> | ||
Are you sure you want to leave this session? Any unsaved progress | ||
will be lost. | ||
</AlertDialogDescription> | ||
</AlertDialogHeader> | ||
<AlertDialogFooter> | ||
<AlertDialogCancel>Cancel</AlertDialogCancel> | ||
<AlertDialogAction | ||
onClick={onLeave} | ||
className="border border-amber-700/50 bg-amber-950/90 text-amber-100 hover:bg-amber-900/90" | ||
> | ||
Leave Session | ||
</AlertDialogAction> | ||
</AlertDialogFooter> | ||
</AlertDialogContent> | ||
</AlertDialog> | ||
); | ||
}; | ||
|
||
export default LeaveSessionDialog; |
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
127 changes: 104 additions & 23 deletions
127
peerprep-fe/src/app/collaboration/components/CodeEditor.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
Oops, something went wrong.