This repository has been archived by the owner on Apr 25, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
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
98b42ce
commit b158a19
Showing
7 changed files
with
73 additions
and
5 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 |
---|---|---|
@@ -1,3 +1,7 @@ | ||
{ | ||
"settings":"Einstellungen" | ||
"settings":"Einstellungen", | ||
"add-server":{ | ||
"title":"Möchten Sie den Server {{name}} hinzufügen?", | ||
"body": "Der Server {{name}} mit der URL {{url}} wird auf der Kursseite angezeigt." | ||
} | ||
} |
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,3 +1,7 @@ | ||
{ | ||
"settings":"Settings" | ||
"settings":"Settings", | ||
"add-server":{ | ||
"title":"Do you want to add the server {{name}}?", | ||
"body": "The server {{name}} with the url {{url}} will displayed on the courses page." | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { Button, Dialog, DialogActions, DialogContent, DialogContentText, DialogTitle } from '@material-ui/core' | ||
import React, { ReactElement } from 'react' | ||
import { Trans, useTranslation } from 'react-i18next'; | ||
import { RouteComponentProps, useLocation, withRouter } from 'react-router-dom'; | ||
import IndexPage from '..' | ||
import CoursesServer from '../../models/server'; | ||
|
||
interface Props extends RouteComponentProps { | ||
} | ||
function useQuery() { | ||
return new URLSearchParams(useLocation().search); | ||
} | ||
|
||
|
||
export function AddServerPage(props: Props): ReactElement { | ||
let query = useQuery(); | ||
const handleClose = () => { | ||
props.history.push('/'); | ||
}; | ||
if(CoursesServer.servers.find((server) => server.url === query.get('url'))) | ||
handleClose(); | ||
const { t } = useTranslation('settings'); | ||
var servers = CoursesServer.servers; | ||
var server = new CoursesServer({url: query.get('url'), name: query.get('name')}); | ||
servers.push(server); | ||
return ( | ||
<div> | ||
<Dialog | ||
open={true} | ||
onClose={handleClose} | ||
aria-labelledby="alert-dialog-title" | ||
aria-describedby="alert-dialog-description" | ||
> | ||
<DialogTitle id="alert-dialog-title"><Trans t={t} i18nKey="add-server.title" values={{name: server.name, url: server.url}} /></DialogTitle> | ||
<DialogContent> | ||
<DialogContentText id="alert-dialog-description"> | ||
<Trans t={t} i18nKey="add-server.body" values={{name: server.name, url: server.url}} /> | ||
</DialogContentText> | ||
</DialogContent> | ||
<DialogActions> | ||
<Button onClick={handleClose} color="primary"> | ||
Disagree | ||
</Button> | ||
<Button onClick={() => { | ||
CoursesServer.servers = servers; | ||
handleClose(); | ||
}} color="primary" autoFocus> | ||
Agree | ||
</Button> | ||
</DialogActions> | ||
</Dialog> | ||
<IndexPage /> | ||
</div> | ||
) | ||
} | ||
export default withRouter(AddServerPage); | ||
|
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