Separating front and back

This commit is contained in:
Unknown committed 2019-02-10 17:56:08 +01:00
1 parent 8086edc9a6
commit f72b7eb8f5
129 files changed
+2232 -9689

No files matched your search

+1
View File
@@ -0,0 +1 @@
postcss.config.js
+1
View File
@@ -10,6 +10,7 @@ module.exports = {
'no-param-reassign': 'off',
'react/prop-types': 0,
'react/jsx-indent': ['error', 2],
'import/prefer-default-export': 'off',
},
settings: {
'react': {
View File
File renamed without changes.
View File
File renamed without changes.
+1 -2
View File
@@ -1,2 +1 @@
# HostsModule
This module manages competition events
EventsClient
-46
View File
@@ -1,46 +0,0 @@
# Contributor Covenant Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
## Scope
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at feedback at advancedalgos dot org. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/
-45
View File
@@ -1,45 +0,0 @@
# Contributing
We are thrilled you are interested in contributing to this repository. Your help may be essential to the project's success and we want you in!
Advanced Algos LTD is a startup, currently at a very early stage. Although this repository is not open source software yet, we do welcome contributions from the community.
Contributions are deemed _voluntary work_. There might be incentives in place for certain kinds of contributions. Contact us for more information in this regards.
In any case, contributors agree to provide an express grant of patent rights for their contributions. Submitting Pull Requests to this repository represents an express agreement with the terms of our Balanced Contributor Intellectual Property Agreement. This agreement is a direct implementation of GitHub's [Balanced Employee Intellectual Property Agreement 1.0.1](https://github.com/github/balanced-employee-ip-agreement/blob/master/Balanced_Employee_IP_Agreement.md).
# Balanced Contributor Intellectual Property Agreement 1.0.1
This BALANCED CONTRIBUTOR INTELLECTUAL PROPERTY AGREEMENT is between person or team submitting Pull Requests to this repository and Advanced Algos LTD ("Company").
**What is this?** This is the Company's Intellectual Property Agreement ("Agreement"). If you've worked in the technology space before, there's a good chance that you've run across one or more of these in the past. This document is the official, entire and exclusive agreement on what intellectual property ("IP") is yours, and what belongs to the Company.
**Why is this?** The Company needs to be clear on what IP it owns and has rights to. Its customers, contributors, and investors depend on the Company having the legal rights to the products and services it is providing so that the Company can continue operating and doing business.
The Company also believes that it's important to be clear on what it doesn't own. The Company doesn't want you looking over your shoulder every time you work on something personal or worrying that the Company will someday seize your open source non-lethal mousetrap simulation software. In other words, the Company isn't interested in appropriating your personal projects.
**Read this.** Please read this document and be sure you understand it before you submit any Pull Requests. Due to legal risk and corporate obligations, the Company cannot, by and large, negotiate its terms. If you feel you have a particular circumstance that keeps you from signing, please let the Company's legal department ("Legal") know. And, of course, you're always free and encouraged to get your own legal counsel to explain anything you're not clear on.
Cool? Then, by submitting your first Pull Request, and as a condition of your contribution, you agree to the following:
1. **What the Company owns.** The Company owns any IP ("Company IP") that you create, or help create _as its contributor_, but only if it meets one or more of these additional conditions: The IP was (i) related to an existing or prospective Company product or service at the time you developed, invented, or created it, (ii) developed for use by the Company, or (iii) developed or promoted with existing Company IP or with the Company's endorsement. You hereby grant and assign, and will grant and assign, to the Company all rights and interests in all Company IP.
"Company IP" includes concepts, designs, developments, discoveries, ideas, improvements, inventions, trade secrets, trademarks, and works of authorship.
2. **What the Company doesn't own.** If you create IP that doesn't fit into one of the categories listed above, the Company doesn't own it. In other words, the Company doesn't own concepts, designs, developments, discoveries, ideas, improvements, inventions, trade secrets, trademarks, or works of authorship that you develop, invent, or create that do not meet any of the conditions in Section 1.
3. **Contribution of your IP to Company projects.** If you include your own IP – such as IP you created prior to working for the Company – into a Company product or service, it's still yours, of course, but you grant the Company a non-exclusive, irrevocable, fully paid-up, royalty-free, perpetual, sublicensable, transferable, worldwide license to use it without restriction in any way or implementation, in modified form, or as is, by itself, or incorporated into another product or service ("License"). If you include your name in any project over which the Company would have rights under this Agreement, such as in a copyright notice or a comment in code or documentation, then the License covers the rights associated with that use of your name as well.
4. **Your contributions to non-Company projects.** The Company recognizes that you may be engaged in work that requires you to submit IP to entities other than the Company, such as open source projects used by the Company. Please make sure that Legal is aware of what you're working on so that Legal can help with any licensing issues. If any project asks you to sign a contribution agreement, you should check with Legal before doing so. These agreements may be legally binding on the Company and so should be run through Legal first.
5. **Voluntary Works** All Company IP that you are involved with or create as part of your work for the Company is voluntary work which does not require compensation. There might be incentives in place for certain kinds of contributions. Feel free to contact the Company to learn more.
6. **No conflicts.** You agree that you don't have any outstanding agreements or obligations that conflict with those in this Agreement, and that you won't enter into conflicting agreements in the future.
7. **IP protection.** The Company might someday need to show the work that went into the development of IP that it uses or has used, or to make government filings to establish that it owns the IP or has rights over it. To help in those situations, you agree not to destroy any records you maintain relating to the development of any Company IP or IP under License (together, "All IP"), and, if the Company asks, to provide those records to the Company. You agree to help the Company secure and defend its rights in All IP. For your help the Company will compensate you at a reasonable rate. If the Company is unable to secure your help, you authorize the Company to act on your behalf (as your agent and attorney-in-fact) in securing all rights related to All IP.
8. **Confidentiality.** As an contributor or contractor of the Company, you will have access to sensitive confidential information that is important to the Company's business. You are responsible for keeping this information confidential, including after you end your work for the Company.
"Confidential Information" includes non-public technical details about our products or services, financial information, business strategies and forecasts, customer data, or any other information, data or know-how that is valuable to the Company because it is not publicly known.
The Company's Confidential Information is sensitive and we expect that you'll treat it as such. You agree to only use the Company's Confidential Information for the purpose of performing your contribution and for the benefit of the Company. You will do your best to keep Confidential Information secret. If you are not sure if something is Confidential Information, you should assume that it is, until you can confirm otherwise.
-42
View File
@@ -1,42 +0,0 @@
COPYRIGHT NOTICE
© Copyright 2018 Advanced Algos LTD.
LICENSE NOTICE
Advanced Algos LTD. is a startup, currently at a very early stage. Because certain aspects of
the business are still not clearly defined, we have chosen to --temporarily-- grant a
restrictive license for the use of this repository, until those business aspects are clarified
and a proper open source license can be granted.
Advanced Algos LTD. is publishing the code of this software for several reasons. However,
it shall not be considered free software yet. Advanced Algos LTD. is a for-profit company
in the crypto space and this module is still proprietary software.
The reasons for opening up the code of this module at this stage are the following:
* We believe that transparency is paramount to achieving our goals, so we want everyone
to be able to understand what this module does and how. Opening up the code of this module
allows anyone to take a close look.
* We welcome contributions from the community. Contributions are regarded as voluntary work.
There may be incentives in place for certain kinds of contributions. Contact us to learn more.
Contributors agree to provide an express grant of patent rights for their contributions.
LICENSE WORDING
Advanced Algos LTD. grants a limited license for the following uses:
1. CODE REVIEW AND AUDITS. You are granted permission to clone this repository to analyze,
review or audit the code.
2. COLLABORATING WITH ADVANCED ALGOS LTD. You are granted permission to fork this repository
with the sole purpose of correcting bugs and developing functionality in agreement with
Advanced Algos LTD. By contributing to this repository you explicitely agree to the terms
detailed in CONTRIBUTING.MD.
PLEASE SEE CONTRIBUTING.MD FOR MORE DETAILS ON THE IMPLICATIONS SURROUNDING YOUR CONTRIBUTIONS TO THIS REPOSITORY.
@@ -1,110 +0,0 @@
import React from 'react';
import {
Dialog,
DialogTitle,
DialogContent,
DialogContentText,
Button,
TextField,
} from '@material-ui/core';
import { Mutation } from 'react-apollo';
import { getOptionsCalls } from '../../../../../GraphQL/Calls/index';
class NewPlotter extends React.Component {
constructor() {
super();
this.state = {
name: '',
host: '',
repo: '',
moduleName: '',
};
}
render() {
const {
name, host, repo, moduleName,
} = this.state;
return (
<Dialog
open={true}
onClose={() => this.props.closeDialogs()}
aria-labelledby='createPlotter-dialog-title'
>
<DialogTitle id='createPlotter-dialog-title'>
Create a new plotter
</DialogTitle>
<DialogContent>
<DialogContentText>
At least for now, all the plotters are publically available, creating it here will let you select it in the select element.
</DialogContentText>
<Mutation mutation={getOptionsCalls.EVENTS_CREATEPLOTTER}
update={(store, { data }) => {
const { events_Plotters: plotters } = store.readQuery({
query: getOptionsCalls.EVENTS_PLOTTERS,
});
store.writeQuery({
query: getOptionsCalls.EVENTS_PLOTTERS,
data: { events_Plotters: plotters.concat([data.events_CreatePlotter]) },
});
this.props.closeDialogs();
}
}
>
{createPlotter => (
<div className='container'>
<form
onSubmit={(e) => {
e.preventDefault();
createPlotter({
variables: {
plotter: {
name,
host,
repo,
moduleName,
},
},
});
}}
>
<TextField
label='Name'
value={name}
onChange={e => this.setState({ name: e.target.value })}
fullWidth
/>
<TextField
label='Host'
value={host}
onChange={e => this.setState({ host: e.target.value })}
fullWidth
/>
<TextField
label='Repository'
value={repo}
onChange={e => this.setState({ repo: e.target.value })}
fullWidth
/>
<TextField
label='Module Name'
value={moduleName}
onChange={e => this.setState({ moduleName: e.target.value })}
fullWidth
/>
<Button type='submit' variant='contained' color='secondary'>Create a new plotter</Button>
</form>
</div>
)}
</Mutation>
</DialogContent>
</Dialog>
);
}
}
export default NewPlotter;
@@ -1,4 +0,0 @@
const styles = () => ({
});
export default styles;
-63
View File
@@ -1,63 +0,0 @@
import gql from 'graphql-tag';
export const eventMinimalInfo = gql`
fragment EventMinimalInfo on events_Event {
id
state
name
startDatetime
finishDatetime
host {
alias
firstName
lastName
}
description
}
`;
export const eventFullInfo = gql`
fragment EventFullInfo on events_Event {
id
state
name
host{
alias
firstName
lastName
}
description
startDatetime
finishDatetime
formula{
name
}
plotter{
name
host
repo
moduleName
}
rules{
position
title
description
}
participants{
team{
name
}
botId
releaseId
}
prizes{
rank
amount
additional{
condition
amount
asset
}
}
}
`;
File diff suppressed because it is too large. Load diff
+9 -6
View File
@@ -1,10 +1,14 @@
{
"name": "@advancedalgos/events-client",
"version": "0.0.4",
"description": "Advanced Algos Event client-side web app",
"name": "@superalgos/events-client",
"version": "0.0.1",
"description": "SuperAlgos Event client-side web app",
"author": "",
"license": "",
"main": "src/index.js",
"repository": {
"type": "git",
"url": "git+https://github.com/nikolabjelo/EventsClientModule.git"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
@@ -12,19 +16,18 @@
"parser": "babel-eslint"
},
"devDependencies": {
"autoprefixer": "^9.2.0",
"babel-eslint": "^10.0.1",
"eslint": "^5.8.0",
"eslint-config-airbnb-base": "^13.1.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-react": "^7.11.1",
"react-hot-loader": "^4.3.11",
"standard": "^12.0.1"
"react-hot-loader": "^4.3.11"
},
"dependencies": {
"@material-ui/core": "^3.2.0",
"@material-ui/icons": "^3.0.1",
"apollo-client": "^2.4.4",
"classnames": "^2.2.6",
"graphql": "^14.0.2",
"graphql-tag": "^2.10.0",
"luxon": "^1.4.4",
+5
View File
@@ -0,0 +1,5 @@
module.exports = {
plugins: [
require('autoprefixer'),
],
};
-3
View File
@@ -1,3 +0,0 @@
{
"presets": ["env", "stage-2"]
}
-10
View File
@@ -1,10 +0,0 @@
PRESHARED_GATEWAY_KEY=SECRET_STUFF
PORT=3000
DB_USERNAME=example_name
DB_PASSWORD=example_password
DB_DOMAIN=example.com:1234/example_name
SENTRY_DNS=https://some-val@sentry.io/some-id
GATEWAY_ENDPOINT=https://app-api.advancedalgos.net/graphql/
-9
View File
@@ -1,9 +0,0 @@
module.exports = {
parser: 'babel-eslint',
extends: 'airbnb-base',
rules: {
'max-len': ['error', 140, 2],
'no-underscore-dangle': 'off',
'no-param-reassign': 'off',
}
};
-23
View File
@@ -1,23 +0,0 @@
# Logs
logs
*.log
npm-debug.log*
# Dependency directories
node_modules/
# Optional npm cache directory
.npm
# dotenv environment variables file
.env
# Build folder js files
build/
dist/
# Visual Studio Code
.vscode
#Mac specific files
.DS_Store
-46
View File
@@ -1,46 +0,0 @@
# Contributor Covenant Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
## Scope
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at feedback at advancedalgos dot org. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/
-45
View File
@@ -1,45 +0,0 @@
# Contributing
We are thrilled you are interested in contributing to this repository. Your help may be essential to the project's success and we want you in!
Advanced Algos LTD is a startup, currently at a very early stage. Although this repository is not open source software yet, we do welcome contributions from the community.
Contributions are deemed _voluntary work_. There might be incentives in place for certain kinds of contributions. Contact us for more information in this regards.
In any case, contributors agree to provide an express grant of patent rights for their contributions. Submitting Pull Requests to this repository represents an express agreement with the terms of our Balanced Contributor Intellectual Property Agreement. This agreement is a direct implementation of GitHub's [Balanced Employee Intellectual Property Agreement 1.0.1](https://github.com/github/balanced-employee-ip-agreement/blob/master/Balanced_Employee_IP_Agreement.md).
# Balanced Contributor Intellectual Property Agreement 1.0.1
This BALANCED CONTRIBUTOR INTELLECTUAL PROPERTY AGREEMENT is between person or team submitting Pull Requests to this repository and Advanced Algos LTD ("Company").
**What is this?** This is the Company's Intellectual Property Agreement ("Agreement"). If you've worked in the technology space before, there's a good chance that you've run across one or more of these in the past. This document is the official, entire and exclusive agreement on what intellectual property ("IP") is yours, and what belongs to the Company.
**Why is this?** The Company needs to be clear on what IP it owns and has rights to. Its customers, contributors, and investors depend on the Company having the legal rights to the products and services it is providing so that the Company can continue operating and doing business.
The Company also believes that it's important to be clear on what it doesn't own. The Company doesn't want you looking over your shoulder every time you work on something personal or worrying that the Company will someday seize your open source non-lethal mousetrap simulation software. In other words, the Company isn't interested in appropriating your personal projects.
**Read this.** Please read this document and be sure you understand it before you submit any Pull Requests. Due to legal risk and corporate obligations, the Company cannot, by and large, negotiate its terms. If you feel you have a particular circumstance that keeps you from signing, please let the Company's legal department ("Legal") know. And, of course, you're always free and encouraged to get your own legal counsel to explain anything you're not clear on.
Cool? Then, by submitting your first Pull Request, and as a condition of your contribution, you agree to the following:
1. **What the Company owns.** The Company owns any IP ("Company IP") that you create, or help create _as its contributor_, but only if it meets one or more of these additional conditions: The IP was (i) related to an existing or prospective Company product or service at the time you developed, invented, or created it, (ii) developed for use by the Company, or (iii) developed or promoted with existing Company IP or with the Company's endorsement. You hereby grant and assign, and will grant and assign, to the Company all rights and interests in all Company IP.
"Company IP" includes concepts, designs, developments, discoveries, ideas, improvements, inventions, trade secrets, trademarks, and works of authorship.
2. **What the Company doesn't own.** If you create IP that doesn't fit into one of the categories listed above, the Company doesn't own it. In other words, the Company doesn't own concepts, designs, developments, discoveries, ideas, improvements, inventions, trade secrets, trademarks, or works of authorship that you develop, invent, or create that do not meet any of the conditions in Section 1.
3. **Contribution of your IP to Company projects.** If you include your own IP – such as IP you created prior to working for the Company – into a Company product or service, it's still yours, of course, but you grant the Company a non-exclusive, irrevocable, fully paid-up, royalty-free, perpetual, sublicensable, transferable, worldwide license to use it without restriction in any way or implementation, in modified form, or as is, by itself, or incorporated into another product or service ("License"). If you include your name in any project over which the Company would have rights under this Agreement, such as in a copyright notice or a comment in code or documentation, then the License covers the rights associated with that use of your name as well.
4. **Your contributions to non-Company projects.** The Company recognizes that you may be engaged in work that requires you to submit IP to entities other than the Company, such as open source projects used by the Company. Please make sure that Legal is aware of what you're working on so that Legal can help with any licensing issues. If any project asks you to sign a contribution agreement, you should check with Legal before doing so. These agreements may be legally binding on the Company and so should be run through Legal first.
5. **Voluntary Works** All Company IP that you are involved with or create as part of your work for the Company is voluntary work which does not require compensation. There might be incentives in place for certain kinds of contributions. Feel free to contact the Company to learn more.
6. **No conflicts.** You agree that you don't have any outstanding agreements or obligations that conflict with those in this Agreement, and that you won't enter into conflicting agreements in the future.
7. **IP protection.** The Company might someday need to show the work that went into the development of IP that it uses or has used, or to make government filings to establish that it owns the IP or has rights over it. To help in those situations, you agree not to destroy any records you maintain relating to the development of any Company IP or IP under License (together, "All IP"), and, if the Company asks, to provide those records to the Company. You agree to help the Company secure and defend its rights in All IP. For your help the Company will compensate you at a reasonable rate. If the Company is unable to secure your help, you authorize the Company to act on your behalf (as your agent and attorney-in-fact) in securing all rights related to All IP.
8. **Confidentiality.** As an contributor or contractor of the Company, you will have access to sensitive confidential information that is important to the Company's business. You are responsible for keeping this information confidential, including after you end your work for the Company.
"Confidential Information" includes non-public technical details about our products or services, financial information, business strategies and forecasts, customer data, or any other information, data or know-how that is valuable to the Company because it is not publicly known.
The Company's Confidential Information is sensitive and we expect that you'll treat it as such. You agree to only use the Company's Confidential Information for the purpose of performing your contribution and for the benefit of the Company. You will do your best to keep Confidential Information secret. If you are not sure if something is Confidential Information, you should assume that it is, until you can confirm otherwise.
-42
View File
@@ -1,42 +0,0 @@
COPYRIGHT NOTICE
© Copyright 2018 Advanced Algos LTD.
LICENSE NOTICE
Advanced Algos LTD. is a startup, currently at a very early stage. Because certain aspects of
the business are still not clearly defined, we have chosen to --temporarily-- grant a
restrictive license for the use of this repository, until those business aspects are clarified
and a proper open source license can be granted.
Advanced Algos LTD. is publishing the code of this software for several reasons. However,
it shall not be considered free software yet. Advanced Algos LTD. is a for-profit company
in the crypto space and this module is still proprietary software.
The reasons for opening up the code of this module at this stage are the following:
* We believe that transparency is paramount to achieving our goals, so we want everyone
to be able to understand what this module does and how. Opening up the code of this module
allows anyone to take a close look.
* We welcome contributions from the community. Contributions are regarded as voluntary work.
There may be incentives in place for certain kinds of contributions. Contact us to learn more.
Contributors agree to provide an express grant of patent rights for their contributions.
LICENSE WORDING
Advanced Algos LTD. grants a limited license for the following uses:
1. CODE REVIEW AND AUDITS. You are granted permission to clone this repository to analyze,
review or audit the code.
2. COLLABORATING WITH ADVANCED ALGOS LTD. You are granted permission to fork this repository
with the sole purpose of correcting bugs and developing functionality in agreement with
Advanced Algos LTD. By contributing to this repository you explicitely agree to the terms
detailed in CONTRIBUTING.MD.
PLEASE SEE CONTRIBUTING.MD FOR MORE DETAILS ON THE IMPLICATIONS SURROUNDING YOUR CONTRIBUTIONS TO THIS REPOSITORY.
-7165
View File
File diff suppressed because it is too large. Load diff
-36
View File
@@ -1,36 +0,0 @@
{
"name": "events-server",
"version": "0.1.0",
"description": "Advanced Algos Event backend API",
"author": "",
"license": "",
"main": "src/index.js",
"scripts": {
"start": "nodemon --exec babel-node --presets env,stage-2 src/index.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"standard": {
"ignore": [
"/src/errors/index.js"
]
},
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-eslint": "^10.0.1",
"babel-preset-env": "^1.7.0",
"babel-preset-stage-2": "^6.24.1",
"eslint": "^5.8.0",
"eslint-config-airbnb-base": "^13.1.0",
"eslint-plugin-import": "^2.14.0",
"nodemon": "^1.18.4"
},
"dependencies": {
"@sentry/node": "^4.1.1",
"apollo-server-express": "^2.1.0",
"axios": "^0.18.0",
"dotenv": "^6.0.0",
"express": "^4.16.3",
"graphql": "^0.13.2",
"mongoose": "^5.3.4"
}
}
-52
View File
@@ -1,52 +0,0 @@
import 'dotenv/config';
import express from 'express';
import { ApolloServer } from 'apollo-server-express';
import * as Sentry from '@sentry/node';
import schema from './schema';
import wrongPreshared from './errors/notAllowed.json';
const app = express();
// Initialising sentry
Sentry.init({ dsn: process.env.SENTRY_DNS });
app.use(Sentry.Handlers.requestHandler());
app.post('/graphql', (req, res, next) => {
if (req.headers.preshared === process.env.PRESHARED_GATEWAY_KEY) {
next();
} else {
res.send(wrongPreshared);
}
});
// Starting the graphql server
const server = new ApolloServer({
schema,
playground: {
settings: {
'editor.theme': 'dark',
'editor.cursorShape': 'line',
},
},
context: ({ req }) => ({
userId: req.headers.userid,
authorization: req.headers.authorization,
}),
formatError: error => ({
code: error.extensions.exception.code,
message: error.message,
path: error.path,
}),
introspection: true,
});
server.applyMiddleware({
app,
cors: true,
});
// Sentry error handling middleware if anything pass through
app.use(Sentry.Handlers.errorHandler());
export default app;
-11
View File
@@ -1,11 +0,0 @@
import 'dotenv/config';
import mongoose from 'mongoose';
mongoose.connect(`mongodb://${process.env.DB_USERNAME}:${process.env.DB_PASSWORD}@${process.env.DB_DOMAIN}`, { useNewUrlParser: true });
mongoose.set('useCreateIndex', true);
mongoose.set('useFindAndModify', false);
mongoose.Promise = global.Promise;
const db = mongoose.connection;
export default db;
-19
View File
@@ -1,19 +0,0 @@
export const UNPUBLISHED = 'UNPUBLISHED';
export const PUBLISHED = 'PUBLISHED';
export const CANCELLED = 'CANCELLED';
export const RUNNING = 'RUNNING';
export const INTERRUPTED = 'INTERRUPTED';
export const FINISHED = 'FINISHED';
export const ARCHIVED = 'ARCHIVED';
export const EventStateEnum = [
UNPUBLISHED,
PUBLISHED,
CANCELLED,
RUNNING,
INTERRUPTED,
FINISHED,
ARCHIVED,
];
export default EventStateEnum;
-45
View File
@@ -1,45 +0,0 @@
import * as Sentry from '@sentry/node';
class ClientError extends Error {
constructor(args) {
super(args);
Sentry.configureScope((scope) => {
scope.setLevel('debug');
});
Sentry.captureException(this);
}
}
class ServerError extends Error {
constructor(args) {
super(args);
Sentry.configureScope((scope) => {
scope.setLevel('error');
});
Sentry.captureException(this);
}
}
export class AuthentificationError extends ClientError {
code = 401
message = 'Autentification not found, you have to be authentificated to perform this action'
}
export class DatabaseError extends ClientError {
code = 404
message = `Ressource not found : ${this.message}`
}
export class WrongArgumentsError extends ClientError {
code = 400
message = `Wrong arguments : ${this.message}`
}
export class ServiceUnavailableError extends ServerError {
code = 503
message = `At least one service is unresponding ${this.message}`
}
-8
View File
@@ -1,8 +0,0 @@
{
"errors": [
{
"code": 401,
"message": "Wait, you're not supposed to be here, go through the gate as everyone else"
}
]
}
-22
View File
@@ -1,22 +0,0 @@
/* eslint-disable no-console */
import * as Sentry from '@sentry/node';
import db from './db';
import app from './app';
// Bind server success and error to sentry
db.on('error', (err) => {
Sentry.configureScope((scope) => {
scope.setLevel('error');
});
Sentry.captureException(err);
});
db.once('open', () => {
Sentry.configureScope((scope) => {
scope.setLevel('info');
});
Sentry.captureMessage('Connected to the DB.');
});
app.listen(process.env.PORT, () => {
console.log(`Listening on port ${process.env.PORT}`);
});
-104
View File
@@ -1,104 +0,0 @@
import mongoose, { Schema } from 'mongoose';
import Plotter from './plotter';
import Formula from './formula';
import {
UNPUBLISHED,
EventStateEnum,
} from '../enums/EventState';
const { ObjectId } = Schema.Types;
const eventSchema = new Schema({
state: {
type: String,
enum: EventStateEnum,
default: UNPUBLISHED,
},
name: {
type: String,
required: true,
},
hostId: {
type: String,
required: true,
},
description: {
type: String,
},
startDatetime: {
type: Number,
required: true,
},
finishDatetime: {
type: Number,
required: true,
},
formulaId: {
type: ObjectId,
ref: Formula.modelName,
},
plotterId: {
type: ObjectId,
ref: Plotter.modelName,
},
rules: [{
position: {
type: Number,
required: true,
},
title: {
type: String,
required: true,
},
description: {
type: String,
},
}],
prizes: [{
rank: {
type: Number,
required: true,
},
amount: {
type: Number,
required: true,
},
additional: [{
condition: String,
amount: {
type: Number,
required: true,
},
asset: {
type: String,
required: true,
},
}],
}],
participants: [{
teamId: {
type: String,
required: true,
},
botId: String,
releaseId: String,
}],
});
eventSchema.pre('find', function populate() {
this.populate('formulaId').populate('plotterId');
});
eventSchema.post('save', (doc, next) => {
doc.populate('formulaId').populate('plotterId').execPopulate().then(() => {
next();
});
});
eventSchema.post('findOneAndUpdate', (doc, next) => {
doc.populate('formulaId').populate('plotterId').execPopulate().then(() => {
next();
});
});
const Event = mongoose.model('Event', eventSchema);
export default Event;
-20
View File
@@ -1,20 +0,0 @@
import mongoose, { Schema } from 'mongoose';
const formulaSchema = new Schema({
ownerId: {
type: String,
required: true,
},
isTemplate: {
type: Boolean,
default: false,
},
name: {
type: String,
required: true,
},
});
const Formula = mongoose.model('Formula', formulaSchema);
export default Formula;
-9
View File
@@ -1,9 +0,0 @@
import Plotter from './plotter';
import Event from './event';
import Formula from './formula';
export {
Event,
Plotter,
Formula,
};
-32
View File
@@ -1,32 +0,0 @@
import mongoose, { Schema } from 'mongoose';
const plotterSchema = new Schema({
ownerId: {
type: String,
required: true,
},
isTemplate: {
type: Boolean,
default: false,
},
name: {
type: String,
required: true,
},
host: {
type: String,
required: true,
},
repo: {
type: String,
required: true,
},
moduleName: {
type: String,
required: true,
},
});
const Plotter = mongoose.model('Plotter', plotterSchema);
export default Plotter;
-13
View File
@@ -1,13 +0,0 @@
import {
GraphQLSchema,
} from 'graphql';
import Mutation from './mutations';
import RootQuery from './queries';
const Schema = new GraphQLSchema({
query: RootQuery,
mutation: Mutation,
});
export default Schema;
@@ -1,39 +0,0 @@
import {
GraphQLNonNull,
GraphQLID,
} from 'graphql';
import { AuthentificationError } from '../../errors';
import { EventType } from '../types';
import { Event } from '../../models';
import EventStateEnum from '../types/enum/EventState';
const args = {
eventId: { type: new GraphQLNonNull(GraphQLID) },
state: { type: EventStateEnum },
};
const resolve = (parent, { eventId: _id, state }, { userId: hostId }) => {
if (!hostId) {
throw new AuthentificationError();
}
return new Promise((res, rej) => {
Event.findOneAndUpdate({ _id, hostId }, { state }, { new: true }, (err, modifiedEvent) => {
if (err) {
rej(err);
return;
}
res(modifiedEvent);
});
});
};
const mutation = {
changeEventState: {
type: EventType,
args,
resolve,
},
};
export default mutation;
@@ -1,37 +0,0 @@
import { AuthentificationError } from '../../errors';
import { EventType } from '../types';
import { Event } from '../../models';
import { EventInputType } from '../types/input';
export const args = {
event: { type: EventInputType },
};
const resolve = (parent, { event }, { userId: hostId }) => {
if (!hostId) {
throw new AuthentificationError();
}
event.hostId = hostId;
const newEvent = new Event(event);
return new Promise((res, rej) => {
newEvent.save((err) => {
if (err) {
rej(err);
return;
}
res(newEvent);
});
});
};
const mutation = {
createEvent: {
type: EventType,
args,
resolve,
},
};
export default mutation;
@@ -1,37 +0,0 @@
import { AuthentificationError } from '../../errors';
import { FormulaType } from '../types';
import { Formula } from '../../models';
import { FormulaInputType } from '../types/input';
const args = {
formula: { type: FormulaInputType },
};
const resolve = (parent, { formula }, { userId: ownerId }) => {
if (!ownerId) {
throw new AuthentificationError();
}
formula.ownerId = ownerId;
const newFormula = new Formula(formula);
return new Promise((res, rej) => {
newFormula.save((err) => {
if (err) {
rej(err);
return;
}
res(newFormula);
});
});
};
const mutation = {
createFormula: {
type: FormulaType,
args,
resolve,
},
};
export default mutation;
@@ -1,37 +0,0 @@
import { AuthentificationError } from '../../errors';
import { PlotterType } from '../types';
import { Plotter } from '../../models';
import { PlotterInputType } from '../types/input';
const args = {
plotter: { type: PlotterInputType },
};
const resolve = (parent, { plotter }, { userId: ownerId }) => {
if (!ownerId) {
throw new AuthentificationError();
}
plotter.ownerId = ownerId;
const newPlotter = new Plotter(plotter);
return new Promise((res, reject) => {
newPlotter.save((err) => {
if (err) {
reject(err);
return;
}
res(newPlotter);
});
});
};
const mutation = {
createPlotter: {
type: PlotterType,
args,
resolve,
},
};
export default mutation;
-39
View File
@@ -1,39 +0,0 @@
import {
GraphQLNonNull,
GraphQLID,
} from 'graphql';
import { AuthentificationError } from '../../errors';
import { EventType } from '../types';
import { Event } from '../../models';
import { EventInputType } from '../types/input';
const args = {
eventId: { type: new GraphQLNonNull(GraphQLID) },
event: { type: EventInputType },
};
const resolve = (parent, { eventId: _id, event }, { userId: hostId }) => {
if (!hostId) {
throw new AuthentificationError();
}
return new Promise((res, rej) => {
Event.findOneAndUpdate({ _id, hostId }, event, { new: true }, (err, modifiedEvent) => {
if (err) {
rej(err);
return;
}
res(modifiedEvent);
});
});
};
const mutation = {
editEvent: {
type: EventType,
args,
resolve,
},
};
export default mutation;
@@ -1,83 +0,0 @@
import {
GraphQLNonNull,
GraphQLID,
} from 'graphql';
import axios from 'axios';
import {
AuthentificationError,
WrongArgumentsError,
ServiceUnavailableError,
} from '../../errors';
import { EventType } from '../types';
import { Event } from '../../models';
import { ParticipantInputType } from '../types/input';
const args = {
eventId: { type: new GraphQLNonNull(GraphQLID) },
participant: { type: ParticipantInputType },
};
const resolve = (parent,
{ eventId: _id, participant: { teamId, botId, releaseId } },
{ userId, authorization }) => {
if (!userId) {
throw new AuthentificationError();
}
return new Promise((res, rej) => {
axios({
url: process.env.GATEWAY_ENDPOINT,
method: 'post',
data: {
query: `
{
teams_TeamsByRole{
id
}
}
`,
},
headers: { authorization },
}).then(
(result) => {
if (!result.data.data.teamsByRole.some(team => team.id === teamId)) {
rej(new WrongArgumentsError('You are not eligible to edit this team'));
return;
}
Event.findOne({ _id }).exec((err, event) => {
if (err) {
rej(err);
return;
}
const participantIndex = event.participant
.findIndex(participant => participant.teamId === teamId);
event.participants[participantIndex].botId = botId
|| event.participants[participantIndex].botId;
event.participants[participantIndex].releaseId = releaseId
|| event.participants[participantIndex].releaseId;
event.save((error) => {
if (error) {
rej(error);
return;
}
res(event);
});
});
},
(error) => {
rej(new ServiceUnavailableError(error));
},
);
});
};
const mutation = {
editParticipant: {
type: EventType,
args,
resolve,
},
};
export default mutation;
@@ -1,85 +0,0 @@
import 'dotenv/config';
import {
GraphQLNonNull,
GraphQLID,
} from 'graphql';
import axios from 'axios';
import {
AuthentificationError,
WrongArgumentsError,
ServiceUnavailableError,
} from '../../errors';
import { EventType } from '../types';
import { Event } from '../../models';
import { ParticipantInputType } from '../types/input';
const args = {
eventId: { type: new GraphQLNonNull(GraphQLID) },
participant: { type: ParticipantInputType },
};
const resolve = (parent,
{ eventId: _id, participant: { teamId, botId, releaseId } },
{ userId, authorization }) => {
if (!userId) {
throw new AuthentificationError();
}
return new Promise((res, rej) => {
axios({
url: process.env.GATEWAY_ENDPOINT,
method: 'post',
data: {
query: `
{
teams_TeamsByRole{
id
}
}
`,
},
headers: { authorization },
}).then(
(result) => {
if (!result.data.data.teamsByRole.some(team => team.id === teamId)) {
rej(new WrongArgumentsError('You are not eligible to register this team'));
return;
}
Event.findOne({ _id }).exec((err, event) => {
if (err) {
rej(err);
return;
}
if (event.participants.some(participant => participant.teamId === teamId)) {
rej(new WrongArgumentsError('You are already registred'));
return;
}
event.participants.push({
teamId,
botId,
releaseId,
});
event.save((error) => {
if (error) {
rej(error);
return;
}
res(event);
});
});
},
(error) => {
rej(new ServiceUnavailableError(error));
},
);
});
};
const mutation = {
registerToEvent: {
type: EventType,
args,
resolve,
},
};
export default mutation;
-26
View File
@@ -1,26 +0,0 @@
import {
GraphQLObjectType,
} from 'graphql';
import CreateEventMutation from './CreateEvent';
import EditEventMutation from './EditEvent';
import RegisterToEventMutation from './RegisterToEvent';
import EditParticipantMutation from './EditParticipant';
import CreateFormulaMutation from './CreateFormula';
import CreatePlotterMutation from './CreatePlotter';
import ChangeEventStateMutation from './ChangeEventState';
const Mutation = new GraphQLObjectType({
name: 'Mutation',
fields: Object.assign(
CreateEventMutation,
EditEventMutation,
RegisterToEventMutation,
EditParticipantMutation,
CreateFormulaMutation,
CreatePlotterMutation,
ChangeEventStateMutation,
),
});
export default Mutation;
-35
View File
@@ -1,35 +0,0 @@
import {
GraphQLNonNull,
GraphQLID,
} from 'graphql';
import { DatabaseError } from '../../errors';
import { EventType } from '../types';
import { Event } from '../../models';
const args = {
eventId: { type: new GraphQLNonNull(GraphQLID) },
};
const resolve = (parent, { eventId: _id }) => new Promise((res, rej) => {
Event.findOne({ _id }).exec((err, event) => {
if (err) {
rej(err);
return;
}
if (!event) {
rej(new DatabaseError('None of the events respond to that id'));
return;
}
res(event);
});
});
const query = {
event: {
type: EventType,
args,
resolve,
},
};
export default query;
-37
View File
@@ -1,37 +0,0 @@
import {
GraphQLInt,
GraphQLList,
} from 'graphql';
import { EventType } from '../types';
import { Event } from '../../models';
import { UNPUBLISHED, ARCHIVED } from '../../enums/EventState';
const args = {
minDate: { type: GraphQLInt },
maxDate: { type: GraphQLInt },
};
const resolve = (parent, { minDate, maxDate }) => Event.find(
Object.assign(
{ state: { $nin: [UNPUBLISHED, ARCHIVED] } },
minDate || maxDate
? {
startDatetime:
Object.assign(
minDate ? { $gte: minDate } : {},
maxDate ? { $lte: maxDate } : {},
),
}
: {},
),
);
const query = {
events: {
type: new GraphQLList(EventType),
args,
resolve,
},
};
export default query;
-39
View File
@@ -1,39 +0,0 @@
import {
GraphQLInt,
GraphQLList,
GraphQLString,
} from 'graphql';
import { EventType } from '../types';
import { Event } from '../../models';
import { UNPUBLISHED, ARCHIVED } from '../../enums/EventState';
const args = {
hostId: { type: GraphQLString },
minDate: { type: GraphQLInt },
maxDate: { type: GraphQLInt },
};
const resolve = (parent, { hostId, minDate, maxDate }, context) => Event.find(
Object.assign(
hostId ? { hostId, state: { $nin: [UNPUBLISHED, ARCHIVED] } } : { hostId: context.userId },
minDate || maxDate
? {
startDatetime:
Object.assign(
minDate ? { $gte: minDate } : {},
maxDate ? { $lte: maxDate } : {},
),
}
: {},
),
);
const query = {
eventsByHost: {
type: new GraphQLList(EventType),
args,
resolve,
},
};
export default query;
-44
View File
@@ -1,44 +0,0 @@
import {
GraphQLInt,
GraphQLList,
GraphQLString,
GraphQLNonNull,
} from 'graphql';
import { EventType } from '../types';
import { Event } from '../../models';
import { UNPUBLISHED, ARCHIVED } from '../../enums/EventState';
const args = {
teamId: { type: new GraphQLNonNull(GraphQLString) },
minDate: { type: GraphQLInt },
maxDate: { type: GraphQLInt },
};
const resolve = (parent, { teamId, minDate, maxDate }) => Event.find(
Object.assign(
{
participants: { $elemMatch: { teamId } },
state: { $nin: [UNPUBLISHED, ARCHIVED] },
},
minDate || maxDate
? {
startDatetime:
Object.assign(
minDate ? { $gte: minDate } : {},
maxDate ? { $lte: maxDate } : {},
),
}
: {},
),
);
const query = {
eventsByTeam: {
type: new GraphQLList(EventType),
args,
resolve,
},
};
export default query;
-19
View File
@@ -1,19 +0,0 @@
import {
GraphQLList,
} from 'graphql';
import { FormulaType } from '../types';
import { Formula } from '../../models';
const args = {};
const resolve = () => Formula.find();
const query = {
formulas: {
type: new GraphQLList(FormulaType),
args,
resolve,
},
};
export default query;
-19
View File
@@ -1,19 +0,0 @@
import {
GraphQLList,
} from 'graphql';
import { PlotterType } from '../types';
import { Plotter } from '../../models';
const args = {};
const resolve = () => Plotter.find();
const query = {
plotters: {
type: new GraphQLList(PlotterType),
args,
resolve,
},
};
export default query;
-24
View File
@@ -1,24 +0,0 @@
import {
GraphQLObjectType,
} from 'graphql';
import EventQuery from './Event';
import EventsQuery from './Events';
import EventsByHostQuery from './EventsByHost';
import EventsByTeamQuery from './EventsByTeam';
import FormulasQuery from './Formulas';
import PlottersQuery from './Plotters';
const RootQuery = new GraphQLObjectType({
name: 'RootQueryType',
fields: Object.assign(
EventQuery,
EventsQuery,
EventsByHostQuery,
EventsByTeamQuery,
FormulasQuery,
PlottersQuery,
),
});
export default RootQuery;
@@ -1,18 +0,0 @@
import {
GraphQLObjectType,
GraphQLNonNull,
GraphQLString,
GraphQLInt,
} from 'graphql';
const AdditionalPrizeType = new GraphQLObjectType({
name: 'AdditionalPrize',
description: 'Non algo complementary prize',
fields: () => ({
condition: { type: GraphQLString },
amount: { type: new GraphQLNonNull(GraphQLInt) },
asset: { type: new GraphQLNonNull(GraphQLString) },
}),
});
export default AdditionalPrizeType;
-61
View File
@@ -1,61 +0,0 @@
import {
GraphQLObjectType,
GraphQLInt,
GraphQLString,
GraphQLList,
GraphQLID,
} from 'graphql';
import {
FormulaType,
PlotterType,
RuleType,
ParticipantType,
PrizeType,
} from './index';
import EventStateEnumType from './enum/EventState';
const EventType = new GraphQLObjectType({
name: 'Event',
description: 'Everything you need to know about an event',
fields: () => ({
id: { type: GraphQLID },
state: { type: EventStateEnumType },
name: { type: GraphQLString },
hostId: { type: GraphQLString },
description: { type: GraphQLString },
startDatetime: { type: GraphQLInt },
finishDatetime: { type: GraphQLInt },
formula: {
type: FormulaType,
resolve(parent) {
return parent.formulaId;
},
},
plotter: {
type: PlotterType,
resolve(parent) {
return parent.plotterId;
},
},
rules: {
type: new GraphQLList(RuleType),
resolve(parent) {
return parent.rules;
},
},
participants: {
type: new GraphQLList(ParticipantType),
resolve(parent) {
return parent.participants;
},
},
prizes: {
type: new GraphQLList(PrizeType),
resolve(parent) {
return parent.prizes;
},
},
}),
});
export default EventType;
-18
View File
@@ -1,18 +0,0 @@
import {
GraphQLObjectType,
GraphQLString,
GraphQLBoolean,
} from 'graphql';
const FormulaType = new GraphQLObjectType({
name: 'Formula',
description: 'For now it\'s simplay a named field',
fields: () => ({
id: { type: GraphQLString },
ownerId: { type: GraphQLString },
isTemplate: { type: GraphQLBoolean },
name: { type: GraphQLString },
}),
});
export default FormulaType;
-16
View File
@@ -1,16 +0,0 @@
import {
GraphQLObjectType,
GraphQLString,
} from 'graphql';
const ParticipantType = new GraphQLObjectType({
name: 'Participant',
description: 'Informations about the participant of an event',
fields: () => ({
teamId: { type: GraphQLString },
botId: { type: GraphQLString },
releaseId: { type: GraphQLString },
}),
});
export default ParticipantType;
-21
View File
@@ -1,21 +0,0 @@
import {
GraphQLObjectType,
GraphQLString,
GraphQLBoolean,
} from 'graphql';
const PlotterType = new GraphQLObjectType({
name: 'Plotter',
description: 'Will soon change in order to use contained plotter objects',
fields: () => ({
id: { type: GraphQLString },
ownerId: { type: GraphQLString },
isTemplate: { type: GraphQLBoolean },
name: { type: GraphQLString },
host: { type: GraphQLString },
repo: { type: GraphQLString },
moduleName: { type: GraphQLString },
}),
});
export default PlotterType;
-24
View File
@@ -1,24 +0,0 @@
import {
GraphQLObjectType,
GraphQLList,
GraphQLInt,
GraphQLNonNull,
} from 'graphql';
import { AdditionalPrizeType } from './index';
const PrizeType = new GraphQLObjectType({
name: 'Prize',
description: 'Prize, by default in algos',
fields: () => ({
rank: { type: new GraphQLNonNull(GraphQLInt) },
amount: { type: new GraphQLNonNull(GraphQLInt) },
additional: {
type: new GraphQLList(AdditionalPrizeType),
resolve(parent) {
return parent.additional;
},
},
}),
});
export default PrizeType;
-17
View File
@@ -1,17 +0,0 @@
import {
GraphQLObjectType,
GraphQLInt,
GraphQLString,
} from 'graphql';
const RuleType = new GraphQLObjectType({
name: 'Rule',
description: 'Textual rules of an event',
fields: () => ({
position: { type: GraphQLInt },
title: { type: GraphQLString },
description: { type: GraphQLString },
}),
});
export default RuleType;
@@ -1,19 +0,0 @@
import {
GraphQLEnumType,
} from 'graphql';
import { EventStateEnum } from '../../../enums/EventState';
const values = {};
EventStateEnum.forEach((EventState) => {
values[EventState] = { value: EventState };
});
const EventStateEnumType = new GraphQLEnumType({
name: 'EventStateEnum',
values,
});
export {
EventStateEnumType as default,
};
-17
View File
@@ -1,17 +0,0 @@
import PlotterType from './Plotter';
import RuleType from './Rule';
import ParticipantType from './Participant';
import AdditionalPrizeType from './AdditionalPrize';
import PrizeType from './Prize';
import FormulaType from './Formula';
import EventType from './Event';
export {
PlotterType,
RuleType,
ParticipantType,
AdditionalPrizeType,
PrizeType,
FormulaType,
EventType,
};
@@ -1,18 +0,0 @@
import {
GraphQLInputObjectType,
GraphQLNonNull,
GraphQLString,
GraphQLInt,
} from 'graphql';
const Type = new GraphQLInputObjectType({
name: 'AdditionalPrizeInput',
description: 'Payload for formula input',
fields: () => ({
condition: { type: GraphQLString },
amount: { type: new GraphQLNonNull(GraphQLInt) },
asset: { type: new GraphQLNonNull(GraphQLString) },
}),
});
export default Type;
-25
View File
@@ -1,25 +0,0 @@
import {
GraphQLString,
GraphQLInt,
GraphQLInputObjectType,
GraphQLList,
} from 'graphql';
import InputPrizeType from './Prize';
import InputRuleType from './Rule';
const Type = new GraphQLInputObjectType({
name: 'EventInput',
description: 'Payload for event input',
fields: () => ({
name: { type: GraphQLString },
description: { type: GraphQLString },
startDatetime: { type: GraphQLInt },
finishDatetime: { type: GraphQLInt },
formulaId: { type: GraphQLString },
plotterId: { type: GraphQLString },
prizes: { type: new GraphQLList(InputPrizeType) },
rules: { type: new GraphQLList(InputRuleType) },
}),
});
export default Type;
-15
View File
@@ -1,15 +0,0 @@
import {
GraphQLNonNull,
GraphQLString,
GraphQLInputObjectType,
} from 'graphql';
const Type = new GraphQLInputObjectType({
name: 'FormulaInput',
description: 'Payload for formula input',
fields: () => ({
name: { type: new GraphQLNonNull(GraphQLString) },
}),
});
export default Type;
@@ -1,17 +0,0 @@
import {
GraphQLInputObjectType,
GraphQLString,
GraphQLNonNull,
} from 'graphql';
const Type = new GraphQLInputObjectType({
name: 'ParticipantInput',
description: 'Payload for formula input',
fields: () => ({
teamId: { type: new GraphQLNonNull(GraphQLString) },
botId: { type: GraphQLString },
releaseId: { type: GraphQLString },
}),
});
export default Type;
-18
View File
@@ -1,18 +0,0 @@
import {
GraphQLNonNull,
GraphQLString,
GraphQLInputObjectType,
} from 'graphql';
const Type = new GraphQLInputObjectType({
name: 'PlotterInput',
description: 'Payload for plotter input',
fields: () => ({
name: { type: new GraphQLNonNull(GraphQLString) },
host: { type: GraphQLString },
repo: { type: GraphQLString },
moduleName: { type: GraphQLString },
}),
});
export default Type;
-21
View File
@@ -1,21 +0,0 @@
import {
GraphQLInputObjectType,
GraphQLList,
GraphQLInt,
GraphQLNonNull,
} from 'graphql';
import InputAdditionalPrizeType from './AdditionalPrize';
const Type = new GraphQLInputObjectType({
name: 'PrizeInput',
description: 'Payload for formula input',
fields: () => ({
rank: { type: new GraphQLNonNull(GraphQLInt) },
amount: { type: new GraphQLNonNull(GraphQLInt) },
additional: {
type: new GraphQLList(InputAdditionalPrizeType),
},
}),
});
export default Type;
-18
View File
@@ -1,18 +0,0 @@
import {
GraphQLNonNull,
GraphQLString,
GraphQLInt,
GraphQLInputObjectType,
} from 'graphql';
const Type = new GraphQLInputObjectType({
name: 'RuleInput',
description: 'Payload for rule input',
fields: () => ({
position: { type: GraphQLInt },
title: { type: new GraphQLNonNull(GraphQLString) },
description: { type: GraphQLString },
}),
});
export default Type;
-17
View File
@@ -1,17 +0,0 @@
import PlotterInputType from './Plotter';
import RuleInputType from './Rule';
import PrizeInputType from './Prize';
import FormulaInputType from './Formula';
import EventInputType from './Event';
import AdditionalPrizeInputType from './AdditionalPrize';
import ParticipantInputType from './Participant';
export {
PlotterInputType,
RuleInputType,
PrizeInputType,
FormulaInputType,
EventInputType,
AdditionalPrizeInputType,
ParticipantInputType,
};
-19
View File
@@ -1,19 +0,0 @@
export const capitalize = string => (string).charAt(0).toUpperCase() + (string).slice(1);
export const slugify = text => text.toString().toLowerCase()
.replace(/\s+/g, '-')
.replace(/[^\w-]+/g, '')
.replace(/--+/g, '-')
.replace(/^-+/, '')
.replace(/-+$/, '');
export const epoch = () => Math.round(new Date().getTime() / 1000);
export const isBetween = (value, valA, valB) => {
const min = valA < valB ? valA : valB;
const max = valA > valB ? valA : valB;
if (value >= min && value <= max) {
return true;
}
return false;
};
@@ -35,10 +35,16 @@ class Basic extends React.Component {
/>
<TextField
label='Name'
value={event.name}
label='Title'
value={event.title}
className={classes.inputField}
onChange={newVal => edit('name', newVal.target.value)}
onChange={newVal => edit('title', newVal.target.value)}
/>
<TextField
label='Subtitle'
value={event.subtitle}
className={classes.inputField}
onChange={newVal => edit('subtitle', newVal.target.value)}
/>
<TextField
multiline
@@ -9,9 +9,9 @@ import {
} from '@material-ui/core';
import { Mutation } from 'react-apollo';
import { getOptionsCalls } from '../../../../../GraphQL/Calls/index';
import { getOptionsCalls } from '../../../../../../GraphQL/Calls/index';
class NewFormula extends React.Component {
class New extends React.Component {
constructor() {
super();
this.state = { name: '' };
@@ -19,10 +19,11 @@ class NewFormula extends React.Component {
render() {
const { name } = this.state;
const { closeDialogs } = this.props;
return (
<Dialog
open={true}
onClose={() => this.props.closeDialogs()}
onClose={() => closeDialogs()}
aria-labelledby='createFormula-dialog-title'
>
<DialogTitle id='createFormula-dialog-title'>
@@ -42,39 +43,36 @@ class NewFormula extends React.Component {
query: getOptionsCalls.EVENTS_FORMULAS,
data: { events_Formulas: formulas.concat([data.events_CreateFormula]) },
});
this.props.closeDialogs();
closeDialogs();
}
}
>
{createFormula => (
<div className='container'>
<form
onSubmit={(e) => {
e.preventDefault();
createFormula({
variables: {
formula: { name },
},
});
}}
>
<TextField
label='Name'
value={name}
onChange={e => this.setState({ name: e.target.value })}
fullWidth
/>
<Button type='submit' variant='contained' color='secondary'>Create a new formula</Button>
</form>
</div>
<form
onSubmit={(e) => {
e.preventDefault();
createFormula({
variables: {
formula: { name },
},
});
}}
>
<TextField
label='Name'
value={name}
onChange={e => this.setState({ name: e.target.value })}
fullWidth
/>
<Button type='submit' variant='contained' color='secondary'>Create a new formula</Button>
</form>
)}
</Mutation>
<Button onClick={() => closeDialogs()} variant='contained' color='primary'>Close</Button>
</DialogContent>
</Dialog>
);
}
}
export default NewFormula;
export default New;
@@ -0,0 +1,5 @@
import New from './New';
export {
New,
};
@@ -0,0 +1,108 @@
import React from 'react';
import {
Dialog,
DialogTitle,
DialogContent,
DialogContentText,
Button,
TextField,
} from '@material-ui/core';
import { Mutation } from 'react-apollo';
import { getOptionsCalls } from '../../../../../../GraphQL/Calls/index';
class New extends React.Component {
constructor() {
super();
this.state = {
name: '',
host: '',
repo: '',
moduleName: '',
};
}
render() {
const {
name, host, repo, moduleName,
} = this.state;
const { closeDialogs } = this.props;
return (
<Dialog
open={true}
onClose={() => closeDialogs()}
aria-labelledby='createPlotter-dialog-title'
>
<DialogTitle id='createPlotter-dialog-title'>
Create a new plotter
</DialogTitle>
<DialogContent>
<DialogContentText>
At least for now, all the plotters are publically available, creating it here will let you select it in the select element.
</DialogContentText>
<Mutation mutation={getOptionsCalls.EVENTS_CREATEPLOTTER}
update={(store, { data }) => {
const { events_Plotters: plotters } = store.readQuery({
query: getOptionsCalls.EVENTS_PLOTTERS,
});
store.writeQuery({
query: getOptionsCalls.EVENTS_PLOTTERS,
data: { events_Plotters: plotters.concat([data.events_CreatePlotter]) },
});
closeDialogs();
}
}
>
{createPlotter => (
<form
onSubmit={(e) => {
e.preventDefault();
createPlotter({
variables: {
plotter: {
name,
host,
repo,
moduleName,
},
},
});
}}
>
<TextField
label='Name'
value={name}
onChange={e => this.setState({ name: e.target.value })}
fullWidth
/>
<TextField
label='Host'
value={host}
onChange={e => this.setState({ host: e.target.value })}
fullWidth
/>
<TextField
label='Repository'
value={repo}
onChange={e => this.setState({ repo: e.target.value })}
fullWidth
/>
<TextField
label='Module Name'
value={moduleName}
onChange={e => this.setState({ moduleName: e.target.value })}
fullWidth
/>
<Button type='submit' variant='contained' color='secondary'>Create a new plotter</Button>
</form>
)}
</Mutation>
<Button onClick={() => closeDialogs()} variant='contained' color='primary'>Close</Button>
</DialogContent>
</Dialog>
);
}
}
export default New;
@@ -0,0 +1,5 @@
import New from './New';
export {
New,
};
@@ -0,0 +1,80 @@
import React from 'react';
import {
Paper,
Grid,
Typography,
} from '@material-ui/core';
import {
SortableContainer,
SortableElement,
SortableHandle,
} from 'react-sortable-hoc';
const DragHandle = SortableHandle(() => <div className='dragHandle' />);
const SortableItem = SortableElement(({ value, deletePrize }) => (
<div className='sortableListItem'>
<Grid container spacing={16}>
<Grid item>
<DragHandle />
</Grid>
<Grid item xs={12} sm container>
<Grid item xs container direction="column" spacing={16}>
<Typography gutterBottom variant="subtitle1">
{value.fromRank}{value.toRank}{value.additional}{value.amount}{value.asset}
</Typography>
<Typography color="textSecondary">
</Typography>
</Grid>
<Grid item>
<Typography style={{ cursor: 'pointer' }} onClick={() => deletePrize(value.position)} >Remove</Typography>
</Grid>
</Grid>
</Grid>
</div>
));
const SortableList = SortableContainer(({ items, deletePrize }) => (
<div className='sortableList'>
{items.map((value, index) => (
<SortableItem key={`prize-${index}`} index={index} value={value} deletePrize={deleteId => deletePrize(deleteId)} />
))}
</div>
));
class List extends React.Component {
onSortEnd = ({ oldIndex, newIndex }) => {
let newPrizes = this.props.prizes.slice(0);
newPrizes.splice(newIndex, 0, newPrizes.splice(oldIndex, 1)[0]);
newPrizes = newPrizes.map((prize, index) => {
prize.position = index;
return prize;
});
this.props.edit(newPrizes);
}
deletePrize = (deletedIndex) => {
let newPrizes = this.props.prizes.slice(0);
newPrizes.splice(deletedIndex, 1);
newPrizes = newPrizes.map((prize, index) => {
prize.position = index;
return prize;
});
this.props.edit(newPrizes);
}
render() {
return (
<Paper>
<SortableList
items={this.props.prizes}
onSortEnd={this.onSortEnd}
useDragHandle={true}
deletePrize={deleteId => this.deletePrize(deleteId)}
/>
</Paper>
);
}
}
export default List;
@@ -0,0 +1,106 @@
import React from 'react';
import {
Dialog,
DialogTitle,
DialogContent,
DialogContentText,
Button,
TextField,
} from '@material-ui/core';
class New extends React.Component {
constructor() {
super();
this.state = {
additional: '',
amount: 0,
asset: '',
};
}
render() {
const {
fromRank, toRank, additional, amount, asset,
} = this.state;
const { addPrize, closeDialogs } = this.props;
return (
<Dialog
open={true}
onClose={() => closeDialogs()}
aria-labelledby='addPrize-dialog-title'
>
<DialogContent>
<DialogContentText>
Prizes are define textually only. In case of infringement, contact us.
</DialogContentText>
<form
onSubmit={(e) => {
e.preventDefault();
addPrize({
fromRank,
toRank,
additional,
amount,
asset,
});
}}
>
<DialogTitle>
Conditions :
</DialogTitle>
<DialogContentText>
Examples :
If you want to make a price for the best bot only, you set both from and to rank to 1.
If you want the rest of the top 10 to get a price, you add a new price with from rank set to 2 and to rank set to 10.
Caution :
- Leaving &quot;from rank&quot; empty considers it to 0.
- Leaving &quot;to rank&quot; empty considers it as infinite
- Prizes are define in an additive manner, meaning that if a team qualifies for two prices, it gets both.
- Additional allows you to write addionnal textual condition, like &quot;positive ROI only&quot; for example.
</DialogContentText>
<TextField
label='From rank'
value={fromRank}
onChange={e => this.setState({ fromRank: e.target.value })}
type="number"
/>
<TextField
label='To rank'
value={toRank}
onChange={e => this.setState({ toRank: e.target.value })}
type="number"
/>
<TextField
label='Additional'
value={additional}
onChange={e => this.setState({ additional: e.target.value })}
fullWidth
/>
<DialogContentText>
Pool :
</DialogContentText>
<DialogContentText>
Here you define the pool, the amount is a number whereas asset is a text. For example 1BTC, 200$, or whatever.
</DialogContentText>
<TextField
label='Amount'
value={amount}
onChange={e => this.setState({ amount: e.target.value })}
type="number"
/>
<TextField
label='Asset'
value={asset}
onChange={e => this.setState({ asset: e.target.value })}
/>
<Button type='submit' variant='contained' color='secondary'>Create a new prize</Button>
</form>
<Button onClick={() => closeDialogs()} variant='contained' color='primary'>Close</Button>
</DialogContent>
</Dialog>
);
}
}
export default New;
@@ -0,0 +1,7 @@
import List from './List';
import New from './New';
export {
List,
New,
};
@@ -0,0 +1,81 @@
import React from 'react';
import {
Paper,
Grid,
Typography,
} from '@material-ui/core';
import {
SortableContainer,
SortableElement,
SortableHandle,
} from 'react-sortable-hoc';
const DragHandle = SortableHandle(() => <div className='dragHandle' />);
const SortableItem = SortableElement(({ value, deleteRule }) => (
<div className='sortableListItem'>
<Grid container spacing={16}>
<Grid item>
<DragHandle />
</Grid>
<Grid item xs={12} sm container>
<Grid item xs container direction="column" spacing={16}>
<Typography gutterBottom variant="subtitle1">
{value.title}
</Typography>
<Typography color="textSecondary">
{value.description}
</Typography>
</Grid>
<Grid item>
<Typography style={{ cursor: 'pointer' }} onClick={() => deleteRule(value.position)} >Remove</Typography>
</Grid>
</Grid>
</Grid>
</div>
));
const SortableList = SortableContainer(({ items, deleteRule }) => (
<div className='sortableList'>
{items.map((value, index) => (
<SortableItem key={`rule-${index}`} index={index} value={value} deleteRule={deleteId => deleteRule(deleteId)} />
))}
</div>
));
class List extends React.Component {
onSortEnd = ({ oldIndex, newIndex }) => {
let newRules = this.props.rules.slice(0);
newRules.splice(newIndex, 0, newRules.splice(oldIndex, 1)[0]);
newRules = newRules.map((rule, index) => {
rule.position = index;
return rule;
});
this.props.edit(newRules);
}
deleteRule = (deletedIndex) => {
let newRules = this.props.rules.slice(0);
newRules.splice(deletedIndex, 1);
newRules = newRules.map((rule, index) => {
rule.position = index;
return rule;
});
this.props.edit(newRules);
}
render() {
return (
<Paper>
<SortableList
items={this.props.rules}
onSortEnd={this.onSortEnd}
useDragHandle={true}
deleteRule={deleteId => this.deleteRule(deleteId)}
/>
</Paper>
);
}
}
export default List;
@@ -0,0 +1,68 @@
import React from 'react';
import {
Dialog,
DialogTitle,
DialogContent,
DialogContentText,
Button,
TextField,
} from '@material-ui/core';
class New extends React.Component {
constructor() {
super();
this.state = {
title: '',
description: '',
};
}
render() {
const {
title, description,
} = this.state;
const { addRule, closeDialogs } = this.props;
return (
<Dialog
open={true}
onClose={() => closeDialogs()}
aria-labelledby='addRule-dialog-title'
>
<DialogTitle id='addRule-dialog-title'>
Create a new rule
</DialogTitle>
<DialogContent>
<DialogContentText>
Rules are define textually only. In case of infringement, contact us.
</DialogContentText>
<form
onSubmit={(e) => {
e.preventDefault();
addRule(
title,
description,
);
}}
>
<TextField
label='Title'
value={title}
onChange={e => this.setState({ title: e.target.value })}
fullWidth
/>
<TextField
label='Description'
value={description}
onChange={e => this.setState({ description: e.target.value })}
fullWidth
/>
<Button type='submit' variant='contained' color='secondary'>Create a new rule</Button>
</form>
<Button onClick={() => closeDialogs()} variant='contained' color='primary'>Close</Button>
</DialogContent>
</Dialog>
);
}
}
export default New;
@@ -0,0 +1,7 @@
import List from './List';
import New from './New';
export {
List,
New,
};
@@ -17,8 +17,11 @@ import styles from '../../styles';
import { getOptionsCalls } from '../../../../../GraphQL/Calls/index';
import NewPlotter from './NewPlotter';
import NewFormula from './NewFormula';
import { List as RulesList, New as NewRule } from './Rules';
import { List as PrizesList, New as NewPrize } from './Prizes';
import { New as NewPlotter } from './Plotter';
import { New as NewFormula } from './Formula';
class Technical extends React.Component {
constructor(props) {
@@ -26,16 +29,39 @@ class Technical extends React.Component {
this.state = {
isNewFormulaOpen: false,
isNewPlotterOpen: false,
isNewRuleOpen: false,
isNewPrizeOpen: false,
};
}
addRule = (title, description) => {
this.props.edit('rules', [...this.props.event.rules, {
title,
description,
position: this.props.event.rules.length,
}]);
this.closeDialogs();
}
addPrize = (prize) => {
this.props.edit('prizes', [...this.props.event.prizes, prize]);
this.closeDialogs();
}
closeDialogs = () => {
this.setState({ isNewFormulaOpen: false, isNewPlotterOpen: false });
this.setState({
isNewFormulaOpen: false,
isNewPlotterOpen: false,
isNewRuleOpen: false,
isNewPrizeOpen: false,
});
}
render() {
const { classes, event, edit } = this.props;
const { isNewPlotterOpen, isNewFormulaOpen } = this.state;
const {
isNewPlotterOpen, isNewFormulaOpen, isNewRuleOpen, isNewPrizeOpen,
} = this.state;
return (
<React.Fragment>
<Typography className={classes.typography} variant='body1' gutterBottom align='left'>
@@ -127,6 +153,33 @@ class Technical extends React.Component {
To create a new plotter, click here
</FormHelperText>
</FormControl>
<FormControl className={classes.inputField}>
<Typography variant='h5'>
Define the rules of your event.
</Typography>
<RulesList rules={event.rules} edit={newVal => edit('rules', newVal)} />
{ isNewRuleOpen
? <NewRule closeDialogs={() => this.closeDialogs()} addRule={(title, description) => this.addRule(title, description)} />
: ''}
<FormHelperText className={classes.clickable} onClick={() => { this.setState({ isNewRuleOpen: true }); }} >
To add a new rule, click here
</FormHelperText>
</FormControl>
<FormControl className={classes.inputField}>
<Typography variant='h5'>
Define the prizes of your event.
</Typography>
<PrizesList prizes={event.prizes} edit={newVal => edit('prizes', newVal)} />
{ isNewPrizeOpen
? <NewPrize closeDialogs={() => this.closeDialogs()} addPrize={prize => this.addPrize(prize)} />
: ''}
<FormHelperText className={classes.clickable} onClick={() => { this.setState({ isNewPrizeOpen: true }); }} >
To add a new prize, click here
</FormHelperText>
</FormControl>
<Grid container justify='center' >
<Grid item>
<Button className={classes.bottomButton} type='submit' variant='contained' color='secondary'>
@@ -42,12 +42,15 @@ class Create extends React.Component {
super(props);
this.state = {
value: 0,
name: '',
title: '',
subtitle: '',
description: '',
startDatetime: DateTime.local().plus({ days: 1 }).startOf('day'),
finishDatetime: DateTime.local().plus({ days: 8 }).startOf('day'),
formulaId: '',
plotterId: '',
prizes: [],
rules: [],
};
}
@@ -61,18 +64,21 @@ class Create extends React.Component {
render() {
const {
name,
title,
subtitle,
description,
startDatetime,
finishDatetime,
value,
formulaId,
plotterId,
prizes,
rules,
} = this.state;
const { classes } = this.props;
return (
<React.Fragment>
<BannerTopBar backgroundUrl='https://aacorporatesitedevelop.azurewebsites.net/img/photos/events.jpg' />
<BannerTopBar backgroundUrl='https://superalgos.org/img/photos/events.jpg' />
<Mutation mutation={hostedEventsCalls.EVENTS_CREATEEVENT}
update={(store, { data }) => {
this.props.history.push(`/events/edit/${data.events_CreateEvent.id}`);
@@ -114,51 +120,57 @@ class Create extends React.Component {
/>
</Tabs>
</AppBar>
<Paper className={classes.paperRoot}>
<Typography className={classes.typography} variant='headline' gutterBottom>
Create a new event
</Typography>
<form
onSubmit={(e) => {
e.preventDefault();
hostEvent({
variables: {
event: {
name,
<div className='container'>
<Paper className={classes.paperRoot}>
<Typography className={classes.typography} variant='h5' gutterBottom>
Create a new event
</Typography>
<form
onSubmit={(e) => {
e.preventDefault();
hostEvent({
variables: {
event: {
title,
subtitle,
description,
startDatetime: startDatetime.valueOf() / 1000,
finishDatetime: finishDatetime.valueOf() / 1000,
formulaId,
plotterId,
},
},
});
}}
>
{value === 0 && <TabContainer>
<Basic
event={{
title,
subtitle,
description,
startDatetime: startDatetime.valueOf() / 1000,
finishDatetime: finishDatetime.valueOf() / 1000,
startDatetime,
finishDatetime,
}}
edit={(newType, newVal) => this.handleEventChange(newType, newVal)}
/>
</TabContainer>}
{value === 1 && <TabContainer>
<Technical
event={{
formulaId,
plotterId,
},
},
});
}}
>
{value === 0 && <TabContainer>
<Basic
event={{
name,
description,
startDatetime,
finishDatetime,
}}
edit={(newType, newVal) => this.handleEventChange(newType, newVal)}
/>
</TabContainer>}
{value === 1 && <TabContainer>
<Technical
event={{
formulaId,
plotterId,
}}
edit={(newType, newVal) => this.handleEventChange(newType, newVal)}
/>
</TabContainer>}
{value === 2 && <TabContainer><TeamsServer /></TabContainer>}
{value === 3 && <TabContainer><PresentationPage /></TabContainer>}
</form>
</Paper>
prizes,
rules,
}}
edit={(newType, newVal) => this.handleEventChange(newType, newVal)}
/>
</TabContainer>}
{value === 2 && <TabContainer><TeamsServer /></TabContainer>}
{value === 3 && <TabContainer><PresentationPage /></TabContainer>}
</form>
</Paper>
</div>
</div>
)}
</Mutation>
@@ -13,14 +13,6 @@ const styles = theme => ({
clickable: {
cursor: 'pointer',
},
card: {
flexGrow: 1,
padding: 20,
marginTop: 20,
marginBottom: 20,
marginLeft: 400,
marginRight: 400,
},
buttonList: {
margin: theme.spacing.unit,
float: 'right',
@@ -32,11 +24,10 @@ const styles = theme => ({
marginTop: 20,
},
paperRoot: {
width: '50%',
flexGrow: 1,
padding: 10,
marginLeft: '25%',
marginTop: '2%',
marginTop: 25,
marginBottom: 25,
},
inputField: {
width: '80%',
+115
View File
@@ -0,0 +1,115 @@
import React from 'react';
import {
TextField,
Button,
FormGroup,
Typography,
Grid,
} from '@material-ui/core';
import {
ChevronLeft,
ChevronRight,
} from '@material-ui/icons';
import { DateTimePicker } from 'material-ui-pickers';
import { withStyles } from '@material-ui/core/styles';
import styles from '../styles';
class Basic extends React.Component {
render() {
const { classes, event, edit } = this.props;
return (
<React.Fragment>
<Typography className={classes.typography} variant='body1' gutterBottom align='left'>
These are the basic information you need to input in order to create an event.
There might be some heavy changes in the near future as the application is still at a very early stage.
</Typography>
<TextField
label='Public id'
value='Your public ID will be generated automatically'
className={classes.inputField}
disabled
/>
<TextField
label='Title'
value={event.title}
className={classes.inputField}
onChange={newVal => edit('title', newVal.target.value)}
/>
<TextField
label='Subtitle'
value={event.subtitle}
className={classes.inputField}
onChange={newVal => edit('subtitle', newVal.target.value)}
/>
<TextField
multiline
label='Description'
value={event.description}
className={classes.inputField}
onChange={newVal => edit('description', newVal.target.value)}
/>
<Typography className={classes.typography} variant='body1' gutterBottom align='left'>
The dates are purely indicative, as it is important for you to make sure everything is
ready before manually triggering the beginning and end of the event.
If you are confident use the scheduler to start it for you(incoming).
</Typography>
<FormGroup row className={classes.inputField}>
<Grid container justify='space-around' >
<Grid item>
<DateTimePicker
autoOk
disablePast
format="DD' at 'HH:mm"
ampm={false}
showTabs={false}
leftArrowIcon={<ChevronLeft />}
rightArrowIcon={<ChevronRight />}
value={event.startDatetime}
helperText='Competition start date'
onChange={newVal => edit('startDatetime', newVal)}
/>
</Grid>
<Grid item>
<DateTimePicker
autoOk
disablePast
format="DD' at 'HH:mm"
ampm={false}
showTabs={false}
leftArrowIcon={<ChevronLeft />}
rightArrowIcon={<ChevronRight />}
value={event.finishDatetime}
helperText='Competition finishing date'
onChange={newVal => edit('finishDatetime', newVal)}
/>
</Grid>
</Grid>
</FormGroup>
<Grid container justify='center' >
<Grid item>
<Button
className={classes.bottomButton}
variant='contained'
color='secondary'
onClick={() => edit('value', 1)}
>
Go to technical tab
</Button>
<Button className={classes.bottomButton} type='submit' variant='contained' color='secondary'>
Or Create event
</Button>
</Grid>
</Grid>
</React.Fragment>
);
}
}
export default withStyles(styles)(Basic);
@@ -0,0 +1,27 @@
import React from 'react';
import { Typography } from '@material-ui/core';
import { withStyles } from '@material-ui/core/styles';
import styles from '../styles';
class PresentationPage extends React.Component {
render() {
const { classes } = this.props;
return (
<React.Fragment>
<Typography
className={classes.title}
variant='h4'
align='center'
color='textPrimary'
gutterBottom
>
PresentationPage
</Typography>
</React.Fragment>
);
}
}
export default withStyles(styles)(PresentationPage);
@@ -0,0 +1,27 @@
import React from 'react';
import { Typography } from '@material-ui/core';
import { withStyles } from '@material-ui/core/styles';
import styles from '../styles';
class TeamsServer extends React.Component {
render() {
const { classes } = this.props;
return (
<React.Fragment>
<Typography
className={classes.title}
variant='h4'
align='center'
color='textPrimary'
gutterBottom
>
TeamsServer
</Typography>
</React.Fragment>
);
}
}
export default withStyles(styles)(TeamsServer);
@@ -0,0 +1,78 @@
import React from 'react';
import {
Dialog,
DialogTitle,
DialogContent,
DialogContentText,
Button,
TextField,
} from '@material-ui/core';
import { Mutation } from 'react-apollo';
import { getOptionsCalls } from '../../../../../../GraphQL/Calls/index';
class New extends React.Component {
constructor() {
super();
this.state = { name: '' };
}
render() {
const { name } = this.state;
const { closeDialogs } = this.props;
return (
<Dialog
open={true}
onClose={() => closeDialogs()}
aria-labelledby='createFormula-dialog-title'
>
<DialogTitle id='createFormula-dialog-title'>
Create a new formula
</DialogTitle>
<DialogContent>
<DialogContentText>
At least for now, all the formulas are publically available, creating it here will let you select it in the select element.
</DialogContentText>
<Mutation mutation={getOptionsCalls.EVENTS_CREATEFORMULA}
update={(store, { data }) => {
const { events_Formulas: formulas } = store.readQuery({
query: getOptionsCalls.EVENTS_FORMULAS,
});
store.writeQuery({
query: getOptionsCalls.EVENTS_FORMULAS,
data: { events_Formulas: formulas.concat([data.events_CreateFormula]) },
});
closeDialogs();
}
}
>
{createFormula => (
<form
onSubmit={(e) => {
e.preventDefault();
createFormula({
variables: {
formula: { name },
},
});
}}
>
<TextField
label='Name'
value={name}
onChange={e => this.setState({ name: e.target.value })}
fullWidth
/>
<Button type='submit' variant='contained' color='secondary'>Create a new formula</Button>
</form>
)}
</Mutation>
<Button onClick={() => closeDialogs()} variant='contained' color='primary'>Close</Button>
</DialogContent>
</Dialog>
);
}
}
export default New;
@@ -0,0 +1,5 @@
import New from './New';
export {
New,
};
@@ -0,0 +1,108 @@
import React from 'react';
import {
Dialog,
DialogTitle,
DialogContent,
DialogContentText,
Button,
TextField,
} from '@material-ui/core';
import { Mutation } from 'react-apollo';
import { getOptionsCalls } from '../../../../../../GraphQL/Calls/index';
class New extends React.Component {
constructor() {
super();
this.state = {
name: '',
host: '',
repo: '',
moduleName: '',
};
}
render() {
const {
name, host, repo, moduleName,
} = this.state;
const { closeDialogs } = this.props;
return (
<Dialog
open={true}
onClose={() => closeDialogs()}
aria-labelledby='createPlotter-dialog-title'
>
<DialogTitle id='createPlotter-dialog-title'>
Create a new plotter
</DialogTitle>
<DialogContent>
<DialogContentText>
At least for now, all the plotters are publically available, creating it here will let you select it in the select element.
</DialogContentText>
<Mutation mutation={getOptionsCalls.EVENTS_CREATEPLOTTER}
update={(store, { data }) => {
const { events_Plotters: plotters } = store.readQuery({
query: getOptionsCalls.EVENTS_PLOTTERS,
});
store.writeQuery({
query: getOptionsCalls.EVENTS_PLOTTERS,
data: { events_Plotters: plotters.concat([data.events_CreatePlotter]) },
});
closeDialogs();
}
}
>
{createPlotter => (
<form
onSubmit={(e) => {
e.preventDefault();
createPlotter({
variables: {
plotter: {
name,
host,
repo,
moduleName,
},
},
});
}}
>
<TextField
label='Name'
value={name}
onChange={e => this.setState({ name: e.target.value })}
fullWidth
/>
<TextField
label='Host'
value={host}
onChange={e => this.setState({ host: e.target.value })}
fullWidth
/>
<TextField
label='Repository'
value={repo}
onChange={e => this.setState({ repo: e.target.value })}
fullWidth
/>
<TextField
label='Module Name'
value={moduleName}
onChange={e => this.setState({ moduleName: e.target.value })}
fullWidth
/>
<Button type='submit' variant='contained' color='secondary'>Create a new plotter</Button>
</form>
)}
</Mutation>
<Button onClick={() => closeDialogs()} variant='contained' color='primary'>Close</Button>
</DialogContent>
</Dialog>
);
}
}
export default New;
@@ -0,0 +1,5 @@
import New from './New';
export {
New,
};
@@ -0,0 +1,80 @@
import React from 'react';
import {
Paper,
Grid,
Typography,
} from '@material-ui/core';
import {
SortableContainer,
SortableElement,
SortableHandle,
} from 'react-sortable-hoc';
const DragHandle = SortableHandle(() => <div className='dragHandle' />);
const SortableItem = SortableElement(({ value, deletePrize }) => (
<div className='sortableListItem'>
<Grid container spacing={16}>
<Grid item>
<DragHandle />
</Grid>
<Grid item xs={12} sm container>
<Grid item xs container direction="column" spacing={16}>
<Typography gutterBottom variant="subtitle1">
{value.fromRank}{value.toRank}{value.additional}{value.amount}{value.asset}
</Typography>
<Typography color="textSecondary">
</Typography>
</Grid>
<Grid item>
<Typography style={{ cursor: 'pointer' }} onClick={() => deletePrize(value.position)} >Remove</Typography>
</Grid>
</Grid>
</Grid>
</div>
));
const SortableList = SortableContainer(({ items, deletePrize }) => (
<div className='sortableList'>
{items.map((value, index) => (
<SortableItem key={`prize-${index}`} index={index} value={value} deletePrize={deleteId => deletePrize(deleteId)} />
))}
</div>
));
class List extends React.Component {
onSortEnd = ({ oldIndex, newIndex }) => {
let newPrizes = this.props.prizes.slice(0);
newPrizes.splice(newIndex, 0, newPrizes.splice(oldIndex, 1)[0]);
newPrizes = newPrizes.map((prize, index) => {
prize.position = index;
return prize;
});
this.props.edit(newPrizes);
}
deletePrize = (deletedIndex) => {
let newPrizes = this.props.prizes.slice(0);
newPrizes.splice(deletedIndex, 1);
newPrizes = newPrizes.map((prize, index) => {
prize.position = index;
return prize;
});
this.props.edit(newPrizes);
}
render() {
return (
<Paper>
<SortableList
items={this.props.prizes}
onSortEnd={this.onSortEnd}
useDragHandle={true}
deletePrize={deleteId => this.deletePrize(deleteId)}
/>
</Paper>
);
}
}
export default List;
@@ -0,0 +1,106 @@
import React from 'react';
import {
Dialog,
DialogTitle,
DialogContent,
DialogContentText,
Button,
TextField,
} from '@material-ui/core';
class New extends React.Component {
constructor() {
super();
this.state = {
additional: '',
amount: 0,
asset: '',
};
}
render() {
const {
fromRank, toRank, additional, amount, asset,
} = this.state;
const { addPrize, closeDialogs } = this.props;
return (
<Dialog
open={true}
onClose={() => closeDialogs()}
aria-labelledby='addPrize-dialog-title'
>
<DialogContent>
<DialogContentText>
Prizes are define textually only. In case of infringement, contact us.
</DialogContentText>
<form
onSubmit={(e) => {
e.preventDefault();
addPrize({
fromRank,
toRank,
additional,
amount,
asset,
});
}}
>
<DialogTitle>
Conditions :
</DialogTitle>
<DialogContentText>
Examples :
If you want to make a price for the best bot only, you set both from and to rank to 1.
If you want the rest of the top 10 to get a price, you add a new price with from rank set to 2 and to rank set to 10.
Caution :
- Leaving &quot;from rank&quot; empty considers it to 0.
- Leaving &quot;to rank&quot; empty considers it as infinite
- Prizes are define in an additive manner, meaning that if a team qualifies for two prices, it gets both.
- Additional allows you to write addionnal textual condition, like &quot;positive ROI only&quot; for example.
</DialogContentText>
<TextField
label='From rank'
value={fromRank}
onChange={e => this.setState({ fromRank: e.target.value })}
type="number"
/>
<TextField
label='To rank'
value={toRank}
onChange={e => this.setState({ toRank: e.target.value })}
type="number"
/>
<TextField
label='Additional'
value={additional}
onChange={e => this.setState({ additional: e.target.value })}
fullWidth
/>
<DialogContentText>
Pool :
</DialogContentText>
<DialogContentText>
Here you define the pool, the amount is a number whereas asset is a text. For example 1BTC, 200$, or whatever.
</DialogContentText>
<TextField
label='Amount'
value={amount}
onChange={e => this.setState({ amount: e.target.value })}
type="number"
/>
<TextField
label='Asset'
value={asset}
onChange={e => this.setState({ asset: e.target.value })}
/>
<Button type='submit' variant='contained' color='secondary'>Create a new prize</Button>
</form>
<Button onClick={() => closeDialogs()} variant='contained' color='primary'>Close</Button>
</DialogContent>
</Dialog>
);
}
}
export default New;
@@ -0,0 +1,7 @@
import List from './List';
import New from './New';
export {
List,
New,
};
@@ -0,0 +1,81 @@
import React from 'react';
import {
Paper,
Grid,
Typography,
} from '@material-ui/core';
import {
SortableContainer,
SortableElement,
SortableHandle,
} from 'react-sortable-hoc';
const DragHandle = SortableHandle(() => <div className='dragHandle' />);
const SortableItem = SortableElement(({ value, deleteRule }) => (
<div className='sortableListItem'>
<Grid container spacing={16}>
<Grid item>
<DragHandle />
</Grid>
<Grid item xs={12} sm container>
<Grid item xs container direction="column" spacing={16}>
<Typography gutterBottom variant="subtitle1">
{value.title}
</Typography>
<Typography color="textSecondary">
{value.description}
</Typography>
</Grid>
<Grid item>
<Typography style={{ cursor: 'pointer' }} onClick={() => deleteRule(value.position)} >Remove</Typography>
</Grid>
</Grid>
</Grid>
</div>
));
const SortableList = SortableContainer(({ items, deleteRule }) => (
<div className='sortableList'>
{items.map((value, index) => (
<SortableItem key={`rule-${index}`} index={index} value={value} deleteRule={deleteId => deleteRule(deleteId)} />
))}
</div>
));
class List extends React.Component {
onSortEnd = ({ oldIndex, newIndex }) => {
let newRules = this.props.rules.slice(0);
newRules.splice(newIndex, 0, newRules.splice(oldIndex, 1)[0]);
newRules = newRules.map((rule, index) => {
rule.position = index;
return rule;
});
this.props.edit(newRules);
}
deleteRule = (deletedIndex) => {
let newRules = this.props.rules.slice(0);
newRules.splice(deletedIndex, 1);
newRules = newRules.map((rule, index) => {
rule.position = index;
return rule;
});
this.props.edit(newRules);
}
render() {
return (
<Paper>
<SortableList
items={this.props.rules}
onSortEnd={this.onSortEnd}
useDragHandle={true}
deleteRule={deleteId => this.deleteRule(deleteId)}
/>
</Paper>
);
}
}
export default List;
@@ -0,0 +1,68 @@
import React from 'react';
import {
Dialog,
DialogTitle,
DialogContent,
DialogContentText,
Button,
TextField,
} from '@material-ui/core';
class New extends React.Component {
constructor() {
super();
this.state = {
title: '',
description: '',
};
}
render() {
const {
title, description,
} = this.state;
const { addRule, closeDialogs } = this.props;
return (
<Dialog
open={true}
onClose={() => closeDialogs()}
aria-labelledby='addRule-dialog-title'
>
<DialogTitle id='addRule-dialog-title'>
Create a new rule
</DialogTitle>
<DialogContent>
<DialogContentText>
Rules are define textually only. In case of infringement, contact us.
</DialogContentText>
<form
onSubmit={(e) => {
e.preventDefault();
addRule(
title,
description,
);
}}
>
<TextField
label='Title'
value={title}
onChange={e => this.setState({ title: e.target.value })}
fullWidth
/>
<TextField
label='Description'
value={description}
onChange={e => this.setState({ description: e.target.value })}
fullWidth
/>
<Button type='submit' variant='contained' color='secondary'>Create a new rule</Button>
</form>
<Button onClick={() => closeDialogs()} variant='contained' color='primary'>Close</Button>
</DialogContent>
</Dialog>
);
}
}
export default New;
@@ -0,0 +1,7 @@
import List from './List';
import New from './New';
export {
List,
New,
};
@@ -0,0 +1,195 @@
import React from 'react';
import { Query } from 'react-apollo';
import {
Typography,
FormControl,
InputLabel,
Input,
Select,
FormHelperText,
MenuItem,
Grid,
Button,
} from '@material-ui/core';
import { withStyles } from '@material-ui/core/styles';
import styles from '../../styles';
import { getOptionsCalls } from '../../../../../GraphQL/Calls/index';
import { List as RulesList, New as NewRule } from './Rules';
import { List as PrizesList, New as NewPrize } from './Prizes';
import { New as NewPlotter } from './Plotter';
import { New as NewFormula } from './Formula';
class Technical extends React.Component {
constructor(props) {
super(props);
this.state = {
isNewFormulaOpen: false,
isNewPlotterOpen: false,
isNewRuleOpen: false,
isNewPrizeOpen: false,
};
}
addRule = (title, description) => {
this.props.edit('rules', [...this.props.event.rules, {
title,
description,
position: this.props.event.rules.length,
}]);
this.closeDialogs();
}
addPrize = (prize) => {
this.props.edit('prizes', [...this.props.event.prizes, prize]);
this.closeDialogs();
}
closeDialogs = () => {
this.setState({
isNewFormulaOpen: false,
isNewPlotterOpen: false,
isNewRuleOpen: false,
isNewPrizeOpen: false,
});
}
render() {
const { classes, event, edit } = this.props;
const {
isNewPlotterOpen, isNewFormulaOpen, isNewRuleOpen, isNewPrizeOpen,
} = this.state;
return (
<React.Fragment>
<Typography className={classes.typography} variant='body1' gutterBottom align='left'>
Select the formula and the plotter you want to use, you can also create your own with the corresponding button.
</Typography>
<FormControl className={classes.inputField}>
<InputLabel shrink htmlFor='select'>
Select the formula
</InputLabel>
<Query query={getOptionsCalls.EVENTS_FORMULAS} >
{({ loading, error, data }) => {
if (loading) {
return (
<Select
value='loading'
input={<Input />}
displayEmpty
className={classes.selectEmpty}
disabled
>
<MenuItem key='1' value='loading'>Loading possibilities...</MenuItem>
</Select>
);
}
if (error) return `Error! ${error.message}`;
const selects = data.events_Formulas.map((formula, index) => (
<MenuItem key={index} value={formula.id}>{formula.name}</MenuItem>
));
return (
<React.Fragment>
<Select
value={event.formulaId}
input={<Input />}
displayEmpty
className={classes.selectEmpty}
onChange={newVal => edit('formulaId', newVal.target.value)}
>
{selects}
</Select>
{ isNewFormulaOpen ? <NewFormula closeDialogs={() => this.closeDialogs()} /> : ''}
</React.Fragment>
);
}}
</Query>
<FormHelperText className={classes.clickable} onClick={() => { this.setState({ isNewFormulaOpen: true }); }}>
To create a new formula, click here
</FormHelperText>
</FormControl>
<FormControl className={classes.inputField}>
<InputLabel shrink htmlFor='select'>
Select the Plotter
</InputLabel>
<Query query={getOptionsCalls.EVENTS_PLOTTERS} >
{({ loading, error, data }) => {
if (loading) {
return (
<Select
value='loading'
input={<Input />}
displayEmpty
className={classes.selectEmpty}
disabled
>
<MenuItem key='1' value='loading'>Loading possibilities...</MenuItem>
</Select>
);
}
if (error) return `Error! ${error.message}`;
const selects = data.events_Plotters.map((plotter, index) => (
<MenuItem key={index} value={plotter.id}>{plotter.name}</MenuItem>
));
return (
<React.Fragment>
<Select
value={event.plotterId}
input={<Input />}
displayEmpty
className={classes.selectEmpty}
onChange={newVal => edit('plotterId', newVal.target.value)}
>
{selects}
</Select>
{ isNewPlotterOpen ? <NewPlotter closeDialogs={() => this.closeDialogs()} /> : ''}
</React.Fragment>
);
}}
</Query>
<FormHelperText className={classes.clickable} onClick={() => { this.setState({ isNewPlotterOpen: true }); }} >
To create a new plotter, click here
</FormHelperText>
</FormControl>
<FormControl className={classes.inputField}>
<Typography variant='h5'>
Define the rules of your event.
</Typography>
<RulesList rules={event.rules} edit={newVal => edit('rules', newVal)} />
{ isNewRuleOpen
? <NewRule closeDialogs={() => this.closeDialogs()} addRule={(title, description) => this.addRule(title, description)} />
: ''}
<FormHelperText className={classes.clickable} onClick={() => { this.setState({ isNewRuleOpen: true }); }} >
To add a new rule, click here
</FormHelperText>
</FormControl>
<FormControl className={classes.inputField}>
<Typography variant='h5'>
Define the prizes of your event.
</Typography>
<PrizesList prizes={event.prizes} edit={newVal => edit('prizes', newVal)} />
{ isNewPrizeOpen
? <NewPrize closeDialogs={() => this.closeDialogs()} addPrize={prize => this.addPrize(prize)} />
: ''}
<FormHelperText className={classes.clickable} onClick={() => { this.setState({ isNewPrizeOpen: true }); }} >
To add a new prize, click here
</FormHelperText>
</FormControl>
<Grid container justify='center' >
<Grid item>
<Button className={classes.bottomButton} type='submit' variant='contained' color='secondary'>
Create the event
</Button>
</Grid>
</Grid>
</React.Fragment>
);
}
}
export default withStyles(styles)(Technical);
+11
View File
@@ -0,0 +1,11 @@
import Basic from './Basic';
import PresentationPage from './PresentationPage';
import TeamsServer from './TeamsServer';
import Technical from './Technical';
export {
Basic,
PresentationPage,
TeamsServer,
Technical,
};
Loaded 100 of 129 files, more files were not shown because too many files have changed in this diff. Show more