diff --git a/.gitignore b/.gitignore index 1079980a3..40a41b816 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ coverage # misc xrank_data +maps .DS_Store .env .env.local diff --git a/index.js b/index.js index 38827c799..431015e33 100644 --- a/index.js +++ b/index.js @@ -5,6 +5,7 @@ const express = require('express') const cors = require('cors') const Placement = require('./models/placement') const Player = require('./models/player') +const Maplist = require('./models/maplist') //const User = require('./models/user') const jwt = require('jsonwebtoken') const path = require('path') @@ -78,6 +79,15 @@ const typeDefs = gql` placements: [Placement!]! } + type Maplist { + name: String! + sz: [String!]! + tc: [String!]! + rm: [String!]! + cb: [String!]! + + } + type Token { value: String! } @@ -97,6 +107,7 @@ const typeDefs = gql` weaponPlacementStats(weapon: String!): [Int!]! playerInfo(uid: String!): PlayerWithPlacements! searchForPlayers(name: String! exact: Boolean): [Placement]! + maplists: [Maplist!]! } type Mutation { @@ -363,6 +374,16 @@ const resolvers = { uids.push(p.unique_id) return true }) + }, + maplists: (root, args) => { + return Maplist + .find({}) + .sort({ order: "asc" }) + .catch(e => { + throw new UserInputError(e.message, { + invalidArgs: args, + }) + }) } } } diff --git a/models/maplist.js b/models/maplist.js new file mode 100644 index 000000000..89cd134d0 --- /dev/null +++ b/models/maplist.js @@ -0,0 +1,11 @@ +const mongoose = require('mongoose') + +const maplistSchema = new mongoose.Schema({ + name: {type: String, required: true}, + sz: {type: [String], required: true}, + tc: {type: [String], required: true}, + rm: {type: [String], required: true}, + cb: {type: [String], required: true} +}) + +module.exports = mongoose.model('Maplist', maplistSchema) \ No newline at end of file diff --git a/react-ui/src/App.js b/react-ui/src/App.js index b8c6971da..f8c038030 100644 --- a/react-ui/src/App.js +++ b/react-ui/src/App.js @@ -1,15 +1,16 @@ import React, { useState } from 'react' import { Container } from 'semantic-ui-react' -import Footer from './components/Footer' -import MainMenu from './components/MainMenu' -import NotFound from './components/NotFound' -import { BrowserRouter as Router, Route, Switch } from 'react-router-dom' +import Footer from './components/Misc/Footer' +import MainMenu from './components/Misc/MainMenu' +import NotFound from './components/Misc/NotFound' +import { BrowserRouter as Router, Route, Switch, Redirect } from 'react-router-dom' -import WeaponLeaderboardSelector from './components/WeaponLeaderboardSelector' -import XSearch from './components/XSearch' -import InfoPlayer from './components/InfoPlayer' -import InfoWeapon from './components/InfoWeapon' +import WeaponLeaderboardSelector from './components/XLeaderboard/WeaponLeaderboardSelector' +import XSearch from './components/XSearch/XSearch' +import InfoPlayer from './components/XSearch/InfoPlayer' +import InfoWeapon from './components/XSearch/InfoWeapon' import ScrollToTop from './utils/ScrollToTop' +import MapListGenerator from './components/Tools/MapListGenerator' const App = () => { const [menuSelection, setMenuSelection] = useState('home') @@ -21,7 +22,7 @@ const App = () => {
-
This is home.
} /> + } /> } /> } /> @@ -30,6 +31,9 @@ const App = () => { } /> + + + } /> } /> } />
diff --git a/react-ui/src/components/Footer.js b/react-ui/src/components/Misc/Footer.js similarity index 100% rename from react-ui/src/components/Footer.js rename to react-ui/src/components/Misc/Footer.js diff --git a/react-ui/src/components/MainMenu.js b/react-ui/src/components/Misc/MainMenu.js similarity index 82% rename from react-ui/src/components/MainMenu.js rename to react-ui/src/components/Misc/MainMenu.js index 49165b373..3df5a6bad 100644 --- a/react-ui/src/components/MainMenu.js +++ b/react-ui/src/components/Misc/MainMenu.js @@ -1,7 +1,7 @@ import React, { useState } from 'react' import { Menu, Segment } from 'semantic-ui-react' import { withRouter } from 'react-router-dom' -import { memCakes } from '../utils/lists' +import { memCakes } from '../../utils/lists' const MainMenu = withRouter(({ history, menuSelection, setMenuSelection }) => { const [memCakePic, setMemCakePic] = useState(memCakes[Math.floor(Math.random()*memCakes.length)]) @@ -12,23 +12,23 @@ const MainMenu = withRouter(({ history, menuSelection, setMenuSelection }) => { mem cake logo setMemCakePic(memCakes[Math.floor(Math.random()*memCakes.length)])}/> { - history.push('/') - setMenuSelection('home') + history.push('/maps') + setMenuSelection('maplists') }} /> - { history.push('/xsearch') }} - /> { history.push('/xleaderboard') }} /> + { history.push('/xsearch') }} + /> ) diff --git a/react-ui/src/components/NotFound.js b/react-ui/src/components/Misc/NotFound.js similarity index 77% rename from react-ui/src/components/NotFound.js rename to react-ui/src/components/Misc/NotFound.js index 639356e8a..cf71aa0c1 100644 --- a/react-ui/src/components/NotFound.js +++ b/react-ui/src/components/Misc/NotFound.js @@ -1,13 +1,13 @@ import React from 'react' import { Header } from 'semantic-ui-react' -import bridge from './img/s1Maps/bridge.png' -import depot from './img/s1Maps/depot.png' -import heights from './img/s1Maps/heights.png' -import mahi from './img/s1Maps/mahi.png' -import museum from './img/s1Maps/museum.png' -import rig from './img/s1Maps/rig.png' -import underpass from './img/s1Maps/underpass.png' +import bridge from '../img/s1Maps/bridge.png' +import depot from '../img/s1Maps/depot.png' +import heights from '../img/s1Maps/heights.png' +import mahi from '../img/s1Maps/mahi.png' +import museum from '../img/s1Maps/museum.png' +import rig from '../img/s1Maps/rig.png' +import underpass from '../img/s1Maps/underpass.png' const NotFound = () => { const maps = [ diff --git a/react-ui/src/components/Tools/MapListGenerator.js b/react-ui/src/components/Tools/MapListGenerator.js new file mode 100644 index 000000000..cb2df0c57 --- /dev/null +++ b/react-ui/src/components/Tools/MapListGenerator.js @@ -0,0 +1,176 @@ +import React, { useEffect, useState } from 'react' +import { TextArea, Loader, Checkbox, Form, Header, List, Image, Divider, Icon, Grid, Input, Button } from 'semantic-ui-react' +import { useQuery } from 'react-apollo-hooks' +import { maplists } from '../../graphql/queries/maplists' +import szIcon from '../img/modeIcons/sz.png' +import tcIcon from '../img/modeIcons/tc.png' +import rmIcon from '../img/modeIcons/rm.png' +import cbIcon from '../img/modeIcons/cb.png' +//