├── .env ├── .gitignore ├── LICENSE ├── Makefile ├── README.md ├── README_.md ├── dist ├── dist.go └── dist_gen.go ├── jsconfig.json ├── package.json ├── public ├── _redirects ├── favicon.ico ├── index.html ├── manifest.json └── robots.txt ├── src ├── App.js ├── components │ ├── Album │ │ ├── index.js │ │ └── styles.scss │ ├── AppBar │ │ ├── index.js │ │ └── styles.scss │ ├── ArticleBox │ │ ├── index.js │ │ └── styles.scss │ ├── Checkout │ │ ├── index.js │ │ └── styles.scss │ ├── DrawerMenu │ │ ├── index.js │ │ └── styles.scss │ ├── File │ │ ├── index.js │ │ └── styles.scss │ ├── FileSelector │ │ ├── index.js │ │ └── styles.scss │ ├── FileUploader │ │ └── index.js │ ├── GalleryBox │ │ ├── index.js │ │ └── styles.scss │ ├── PhotoBox │ │ ├── index.js │ │ └── styles.scss │ ├── ProjectBox │ │ ├── index.js │ │ └── styles.scss │ ├── Selector │ │ ├── index.js │ │ └── styles.scss │ ├── SiteBox │ │ ├── index.js │ │ └── styles.scss │ ├── Sorter │ │ └── index.js │ ├── Track │ │ ├── index.js │ │ └── styles.scss │ ├── Video │ │ ├── index.js │ │ └── styles.scss │ └── VideoGroup │ │ ├── index.js │ │ └── styles.scss ├── index.js ├── pages │ ├── dashboard │ │ ├── About │ │ │ ├── index.js │ │ │ └── styles.scss │ │ ├── Access │ │ │ ├── index.js │ │ │ └── styles.scss │ │ ├── Album │ │ │ ├── index.js │ │ │ └── styles.scss │ │ ├── Albums │ │ │ ├── index.js │ │ │ └── styles.scss │ │ ├── Articles │ │ │ ├── index.js │ │ │ └── styles.scss │ │ ├── Contact │ │ │ └── index.js │ │ ├── EditArticle │ │ │ ├── index.js │ │ │ └── styles.scss │ │ ├── EditGallery │ │ │ ├── index.js │ │ │ └── styles.scss │ │ ├── EditPhoto │ │ │ ├── index.js │ │ │ └── styles.scss │ │ ├── EditProject │ │ │ └── index.js │ │ ├── Galleries │ │ │ ├── index.js │ │ │ └── styles.scss │ │ ├── Modules │ │ │ ├── index.js │ │ │ └── styles.scss │ │ ├── MyAccount │ │ │ ├── index.js │ │ │ └── styles.scss │ │ ├── MySites │ │ │ ├── index.js │ │ │ └── styles.scss │ │ ├── Overview │ │ │ └── index.js │ │ ├── Photos │ │ │ ├── index.js │ │ │ └── styles.scss │ │ ├── Projects │ │ │ ├── index.js │ │ │ └── styles.scss │ │ ├── Settings │ │ │ ├── index.js │ │ │ └── styles.scss │ │ ├── SiteEditor │ │ │ ├── index.js │ │ │ └── styles.scss │ │ ├── Storage │ │ │ ├── index.js │ │ │ └── styles.scss │ │ ├── Track │ │ │ ├── index.js │ │ │ └── styles.scss │ │ ├── Video │ │ │ └── index.js │ │ ├── VideoGroup │ │ │ ├── index.js │ │ │ └── styles.scss │ │ ├── VideoGroups │ │ │ ├── index.js │ │ │ └── styles.scss │ │ └── index.js │ ├── homepage │ │ ├── Authentication │ │ │ ├── index.js │ │ │ └── styles.scss │ │ ├── Home │ │ │ ├── index.js │ │ │ └── styles.scss │ │ └── index.js │ └── index.js ├── serviceWorker.js ├── services │ └── client.js ├── strings.js ├── styles │ ├── fonts.scss │ └── styles.scss └── utils │ ├── index.js │ └── token.js └── yarn.lock /.env: -------------------------------------------------------------------------------- 1 | REACT_APP_DEV_ENDPOINT=http://localhost:8000/admin 2 | 3 | REACT_APP_PROD_ENDPOINT=https://backpulseapi.aureleoules.com/admin 4 | 5 | NODE_PATH=src/ 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | 4 | .idea/ 5 | *.iml 6 | 7 | # dependencies 8 | /node_modules 9 | /.pnp 10 | .pnp.js 11 | 12 | # testing 13 | /coverage 14 | 15 | # production 16 | /build 17 | 18 | # misc 19 | .DS_Store 20 | .env.local 21 | .env.development.local 22 | .env.test.local 23 | .env.production.local 24 | 25 | npm-debug.log* 26 | yarn-debug.log* 27 | yarn-error.log* 28 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Backpulse 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: default generate 2 | 3 | default: generate 4 | 5 | generate: 6 | rm -rf dist/dist_gen.go 7 | go generate ./dist/dist.go 8 | gofmt -s -w dist 9 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![forthebadge](https://forthebadge.com/images/badges/made-with-javascript.svg)](https://forthebadge.com) 2 | [![forthebadge](https://forthebadge.com/images/badges/powered-by-netflix.svg)](https://forthebadge.com) 3 | 4 | [![Donate](https://img.shields.io/badge/Donate-Crypto-blue.svg)](https://commerce.coinbase.com/checkout/b4d64264-dda8-41d0-9f15-0843f969fa79) 5 | [![Donate](https://img.shields.io/badge/Donate-Patreon-orange.svg)](https://www.patreon.com/backpulse) 6 | [![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.me/aureleoules) 7 | [![Netlify Status](https://api.netlify.com/api/v1/badges/bed0c1f7-2fcc-4040-9da3-33e86689eb11/deploy-status)](https://dashboard.backpulse.io) 8 | 9 | ![Backpulse](https://files.backpulse.io/backpulse.png#cache2 "Backpulse.io") 10 | 11 | # Backpulse dashboard 12 | Backpulse is an API Based / Headless CMS. 13 | Your site's content is accessible directly via our RESTful API, on any web framework and any device. 14 | 15 | ## Installation 16 | ```bash 17 | git clone https://github.com/backpulse/dashboard.git 18 | cd dashboard 19 | yarn install 20 | ``` 21 | 22 | ## Development 23 | To develop Backpulse locally, make sure to run [backpulse/core](https://github.com/backpulse/core) on port `8000`. 24 | Then, open a dev server using `yarn start`. 25 | _For more informations:_ [React README](https://github.com/backpulse/dashboard/blob/master/README_.md) 26 | 27 | ## Contributing 28 | Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. 29 | 30 | ## License 31 | [MIT](https://github.com/backpulse/dashboard/blob/master/LICENSE) © [Aurèle Oulès](https://www.aureleoules.com) -------------------------------------------------------------------------------- /README_.md: -------------------------------------------------------------------------------- 1 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). 2 | 3 | ## Available Scripts 4 | 5 | In the project directory, you can run: 6 | 7 | ### `npm start` 8 | 9 | Runs the app in the development mode.
10 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser. 11 | 12 | The page will reload if you make edits.
13 | You will also see any lint errors in the console. 14 | 15 | ### `npm test` 16 | 17 | Launches the test runner in the interactive watch mode.
18 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. 19 | 20 | ### `npm run build` 21 | 22 | Builds the app for production to the `build` folder.
23 | It correctly bundles React in production mode and optimizes the build for the best performance. 24 | 25 | The build is minified and the filenames include the hashes.
26 | Your app is ready to be deployed! 27 | 28 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. 29 | 30 | ### `npm run eject` 31 | 32 | **Note: this is a one-way operation. Once you `eject`, you can’t go back!** 33 | 34 | If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. 35 | 36 | Instead, it will copy all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. 37 | 38 | You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. 39 | 40 | ## Learn More 41 | 42 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). 43 | 44 | To learn React, check out the [React documentation](https://reactjs.org/). 45 | 46 | ### Code Splitting 47 | 48 | This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting 49 | 50 | ### Analyzing the Bundle Size 51 | 52 | This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size 53 | 54 | ### Making a Progressive Web App 55 | 56 | This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app 57 | 58 | ### Advanced Configuration 59 | 60 | This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration 61 | 62 | ### Deployment 63 | 64 | This section has moved here: https://facebook.github.io/create-react-app/docs/deployment 65 | 66 | ### `npm run build` fails to minify 67 | 68 | This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify 69 | -------------------------------------------------------------------------------- /dist/dist.go: -------------------------------------------------------------------------------- 1 | package dist 2 | 3 | //go:generate go-bindata -fs -nomemcopy -pkg=dist -prefix=../build -debug=false -o=dist_gen.go ../build/... 4 | -------------------------------------------------------------------------------- /jsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "CommonJS", 4 | "baseUrl": "." 5 | } 6 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "backpulse", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@material-ui/core": "^3.9.0", 7 | "@material-ui/icons": "^3.0.2", 8 | "axios": "^0.18.0", 9 | "dayjs": "^1.8.0", 10 | "highlight.js": "^9.15.6", 11 | "node-sass": "^4.11.0", 12 | "notistack": "^0.5.1", 13 | "react": "^16.7.0", 14 | "react-beautiful-dnd": "^10.0.4", 15 | "react-dom": "^16.7.0", 16 | "react-markdown": "aureleoules/react-markdown", 17 | "react-masonry-component": "^6.2.1", 18 | "react-router": "^4.3.1", 19 | "react-router-dom": "^4.3.1", 20 | "react-scripts": "2.1.3", 21 | "react-select": "^2.3.0", 22 | "react-stripe-elements": "^2.0.2", 23 | "react-text-mask": "^5.4.3", 24 | "react-youtube": "^7.9.0" 25 | }, 26 | "scripts": { 27 | "start": "react-scripts start", 28 | "build": "react-scripts build", 29 | "test": "react-scripts test", 30 | "eject": "react-scripts eject" 31 | }, 32 | "eslintConfig": { 33 | "extends": "react-app" 34 | }, 35 | "browserslist": [ 36 | ">0.2%", 37 | "not dead", 38 | "not ie <= 11", 39 | "not op_mini all" 40 | ] 41 | } 42 | -------------------------------------------------------------------------------- /public/_redirects: -------------------------------------------------------------------------------- 1 | /* /index.html 200 -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backpulse/dashboard/02ac7a964f938124c23f9bac59e750b5fa220abe/public/favicon.ico -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 10 | 11 | 12 | Backpulse 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "Backpulse", 3 | "name": "Backpulse", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | } 10 | ], 11 | "start_url": ".", 12 | "display": "standalone", 13 | "theme_color": "#000000", 14 | "background_color": "#ffffff" 15 | } 16 | -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | User-agent: * 2 | Disallow: / -------------------------------------------------------------------------------- /src/App.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | import { 4 | BrowserRouter as Router, 5 | Route, 6 | Redirect 7 | } from 'react-router-dom'; 8 | 9 | import { 10 | MuiThemeProvider, 11 | createMuiTheme 12 | } from '@material-ui/core/styles'; 13 | 14 | import { getJWT, getUser, removeJWT } from 'utils/token'; 15 | import { SnackbarProvider } from 'notistack'; 16 | 17 | import { 18 | MySites, 19 | SiteEditor, 20 | Projects, 21 | Contact, 22 | About, 23 | Settings, 24 | Overview, 25 | Galleries, 26 | EditProject, 27 | EditGallery, 28 | MyAccount, 29 | Access, 30 | Modules, 31 | Articles, 32 | EditArticle, 33 | VideoGroups, 34 | VideoGroup, 35 | Video, 36 | Albums, 37 | Album, 38 | Track, 39 | Storage, 40 | Photos, 41 | EditPhoto 42 | } from 'pages/dashboard'; 43 | 44 | import { 45 | Authentication 46 | } from 'pages/homepage'; 47 | 48 | import {getTheme} from 'utils'; 49 | 50 | const theme = createMuiTheme({ 51 | typography: { 52 | useNextVariants: true, 53 | }, 54 | palette: { 55 | primary: { 56 | main: "#00ad9f", 57 | contrastText: "#e3e3e3" 58 | }, 59 | secondary: { 60 | main: "#0e1e25", 61 | contrastText: "#e3e3e3" 62 | }, 63 | text: { 64 | primary: "#e3e3e3", 65 | secondary: "#e3e3e3" 66 | }, 67 | background: { 68 | paper: "#0e1e25" 69 | }, 70 | type: "dark" 71 | } 72 | }); 73 | 74 | const themeLight = createMuiTheme({ 75 | typography: { 76 | useNextVariants: true, 77 | }, 78 | palette: { 79 | primary: { 80 | main: "#0e1e25", 81 | 82 | }, 83 | secondary: { 84 | main: "#00ad9f", 85 | }, 86 | type: "light" 87 | }, 88 | }); 89 | 90 | 91 | class App extends React.Component { 92 | 93 | constructor(props) { 94 | super(props); 95 | this.switch = React.createRef(); 96 | } 97 | 98 | requireAuth = Component => { 99 | if(getJWT()) { 100 | return Component; 101 | } 102 | return ; 103 | } 104 | 105 | noAuth = Component => { 106 | if(!getJWT()) { 107 | return Component; 108 | } 109 | return 110 | } 111 | 112 | componentWillMount() { 113 | window.__MUI_USE_NEXT_TYPOGRAPHY_VARIANTS__ = true; 114 | 115 | const user = getUser(); 116 | if(user) { 117 | if(Date.parse(user.exp) - Date.now() < 0) { 118 | removeJWT(); 119 | window.location = "/login"; 120 | } 121 | } 122 | } 123 | 124 | updateTheme = () => { 125 | this.forceUpdate(); 126 | } 127 | 128 | render() { 129 | return ( 130 | 131 |
132 | 133 |
134 | 135 | 136 | 137 | this.noAuth()} /> 138 | this.noAuth()} /> 139 | {!getJWT() && }/>} 140 | 141 | 142 | {getJWT() && 143 | }/> 144 | this.requireAuth()}/> 145 | ( 146 | 147 | this.requireAuth()}/> 148 | this.requireAuth()}/> 149 | 150 | this.requireAuth()}/> 151 | this.requireAuth()}/> 152 | this.requireAuth( this.forceUpdate}/>)}/> 153 | 154 | this.requireAuth()}/> 155 | this.requireAuth()}/> 156 | 157 | this.requireAuth()}/> 158 | this.requireAuth()}/> 159 | this.requireAuth( 182 | )}/> 183 | } 184 | 185 | 186 |
187 |
188 |
189 | ) 190 | } 191 | } 192 | 193 | export default App; -------------------------------------------------------------------------------- /src/components/Album/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import './styles.scss'; 3 | import dayjs from 'dayjs'; 4 | import Typography from '@material-ui/core/Typography'; 5 | 6 | import Card from '@material-ui/core/Card'; 7 | import CardHeader from '@material-ui/core/CardHeader'; 8 | import CardActions from '@material-ui/core/CardActions'; 9 | import IconButton from '@material-ui/core/IconButton'; 10 | import EditIcon from '@material-ui/icons/Edit'; 11 | import DeleteIcon from '@material-ui/icons/Delete'; 12 | import Tooltip from '@material-ui/core/Tooltip'; 13 | import CardMedia from '@material-ui/core/CardMedia'; 14 | import strings from 'strings'; 15 | 16 | class Album extends React.Component { 17 | render() { 18 | return ( 19 | 20 | {this.props.data.title || strings.NO_NAME}} 22 | subheader={ {dayjs(this.props.data.updated_at).format("DD/MM/YYYY HH:mm")}} 23 | /> 24 | {this.props.data.cover && } 28 | 29 | {/* 30 | 31 | 32 | 33 | */} 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | ); 47 | } 48 | } 49 | 50 | export default Album; -------------------------------------------------------------------------------- /src/components/Album/styles.scss: -------------------------------------------------------------------------------- 1 | .album { 2 | width: 350px; 3 | min-height: 150px; 4 | 5 | position: relative; 6 | 7 | 8 | .media { 9 | height: 0; 10 | padding-top: 56.25%; 11 | } 12 | 13 | .bottom { 14 | height: 50px; 15 | position: relative; 16 | bottom: 0px; 17 | left: 5px; 18 | font-size: 12px; 19 | opacity: 0.8; 20 | display: flex; 21 | align-items: center; 22 | 23 | svg { 24 | margin-left: 5px; 25 | } 26 | 27 | span.updated-at { 28 | margin-left: 6px; 29 | } 30 | .open-button { 31 | margin-left: auto; 32 | margin-right: 20px; 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /src/components/AppBar/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import Bar from '@material-ui/core/AppBar'; 3 | import Toolbar from '@material-ui/core/Toolbar'; 4 | 5 | import Menu from '@material-ui/core/Menu'; 6 | import MenuItem from '@material-ui/core/MenuItem'; 7 | import AccountCircle from '@material-ui/icons/AccountCircle'; 8 | import IconButton from '@material-ui/core/IconButton'; 9 | import MenuIcon from '@material-ui/icons/Menu'; 10 | 11 | import Typography from '@material-ui/core/Typography'; 12 | 13 | import './styles.scss'; 14 | 15 | import strings from 'strings'; 16 | import {Link} from 'react-router-dom'; 17 | 18 | import {signOut} from 'utils/token'; 19 | 20 | import {getTheme, toggleTheme} from 'utils'; 21 | 22 | class AppBar extends React.Component { 23 | 24 | constructor(props) { 25 | super(props); 26 | this.state = { 27 | anchorEl: null, 28 | open: false 29 | } 30 | console.log(props); 31 | } 32 | 33 | handleMenu = event => { 34 | this.setState({ anchorEl: event.currentTarget, open: true }); 35 | }; 36 | 37 | handleClose = () => { 38 | this.setState({ anchorEl: null, open: false }); 39 | }; 40 | 41 | handleDrawerToggle = () => { 42 | window.dispatchEvent(new Event("menu-toggle")); 43 | } 44 | 45 | render() { 46 | return ( 47 | 48 | 49 | 50 | {!this.props.noMenu && 55 | 56 | } 57 | 58 | {this.props.title || "Backpulse"} 59 | 60 |
61 | 66 | 67 | 68 | 82 | 83 | {strings.MENU_MY_SITES} 84 | 85 | 86 | {strings.MENU_MY_ACCOUNT} 87 | 88 | { 89 | toggleTheme(); 90 | this.props.updateTheme() 91 | this.handleClose(); 92 | }}>{getTheme() === "light" ? strings.DARK_THEME : strings.LIGHT_THEME} 93 | {strings.MENU_LOGOUT} 94 | 95 |
96 |
97 |
98 |
99 | ); 100 | } 101 | } 102 | 103 | export default AppBar; -------------------------------------------------------------------------------- /src/components/AppBar/styles.scss: -------------------------------------------------------------------------------- 1 | .app-bar { 2 | z-index: 1201 !important; 3 | background-color: #00ad9f; 4 | } 5 | 6 | .toolbar { 7 | min-height: 64px; 8 | } 9 | 10 | .right { 11 | position: absolute !important; 12 | right: 15px; 13 | } 14 | -------------------------------------------------------------------------------- /src/components/ArticleBox/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import Typography from '@material-ui/core/Typography'; 3 | 4 | import './styles.scss'; 5 | 6 | import dayjs from 'dayjs'; 7 | 8 | import Card from '@material-ui/core/Card'; 9 | import CardHeader from '@material-ui/core/CardHeader'; 10 | import CardActions from '@material-ui/core/CardActions'; 11 | import IconButton from '@material-ui/core/IconButton'; 12 | import EditIcon from '@material-ui/icons/Edit'; 13 | import DeleteIcon from '@material-ui/icons/Delete'; 14 | import Tooltip from '@material-ui/core/Tooltip'; 15 | import strings from 'strings'; 16 | 17 | class ArticleBox extends React.Component { 18 | render() { 19 | return ( 20 | 21 | {this.props.article.title}} 23 | subheader={ {dayjs(this.props.article.updated_at).format("DD/MM/YYYY HH:mm")}} 24 | /> 25 | 26 | {/* 27 | 28 | 29 | 30 | */} 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | ); 44 | } 45 | } 46 | 47 | export default ArticleBox; -------------------------------------------------------------------------------- /src/components/ArticleBox/styles.scss: -------------------------------------------------------------------------------- 1 | .articlebox { 2 | width: 350px; 3 | min-height: 150px; 4 | 5 | // display: flex; 6 | // align-items: center; 7 | // justify-content: center; 8 | margin: 15px 0; 9 | position: relative; 10 | @media screen and (max-width: 600px) { 11 | width: 100%; 12 | margin-left: 0; 13 | } 14 | 15 | .articlebox-content { 16 | height: 100px; 17 | position: relative; 18 | display: flex; 19 | align-items: center; 20 | justify-content: center; 21 | cursor: pointer; 22 | .type-icon { 23 | svg { 24 | position: absolute; 25 | margin-left: -30px; 26 | margin-top: 0px; 27 | } 28 | } 29 | 30 | .divider { 31 | width: 350px; 32 | position: absolute; 33 | left: 0; 34 | bottom: 0px; 35 | } 36 | } 37 | 38 | .bottom { 39 | height: 50px; 40 | position: relative; 41 | bottom: 0px; 42 | left: 5px; 43 | font-size: 12px; 44 | opacity: 0.8; 45 | display: flex; 46 | align-items: center; 47 | 48 | svg { 49 | margin-left: 5px; 50 | } 51 | 52 | span.updated-at { 53 | margin-left: 6px; 54 | } 55 | .open-button { 56 | margin-left: auto; 57 | margin-right: 20px; 58 | } 59 | } 60 | } -------------------------------------------------------------------------------- /src/components/Checkout/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import {injectStripe, CardElement} from 'react-stripe-elements'; 3 | 4 | import MaskedInput from 'react-text-mask'; 5 | import TextField from '@material-ui/core/TextField'; 6 | import Grid from '@material-ui/core/Grid'; 7 | import Button from '@material-ui/core/Button'; 8 | 9 | import {getTheme} from 'utils'; 10 | 11 | import strings from 'strings'; 12 | import './styles.scss'; 13 | 14 | import client from 'services/client'; 15 | 16 | function ZIP(props) { 17 | const { inputRef, ...other } = props; 18 | return ( 19 | { 21 | inputRef(ref ? ref.inputElement : null); 22 | }} 23 | {...other} 24 | mask={[/\d/, /\d/, /\d/,/\d/, /\d/, /\d/, /\d/, /\d/, /\d/]} 25 | /> 26 | ) 27 | } 28 | 29 | class CheckoutForm extends React.Component { 30 | constructor(props) { 31 | super(props); 32 | this.state = { 33 | name: this.props.lastUser.fullname, 34 | address: this.props.lastUser.address, 35 | zip: this.props.lastUser.zip, 36 | city: this.props.lastUser.city, 37 | state: this.props.lastUser.state, 38 | country: this.props.lastUser.country, 39 | 40 | paid: false 41 | } 42 | this.submit = this.submit.bind(this); 43 | } 44 | 45 | async submit(ev) { 46 | ev.preventDefault(); 47 | this.setState({paid: true}, async () => { 48 | const {token} = await this.props.stripe.createToken({name: this.state.name, }); 49 | 50 | if(token) { 51 | try { 52 | this.setState({paid: true}); 53 | const response = await client.post('/account/charge', { 54 | name: this.state.name, 55 | address: this.state.address, 56 | city: this.state.city, 57 | state: this.state.state, 58 | zip: this.state.zip, 59 | country: this.state.country, 60 | token 61 | }); 62 | if(response.data.status === "success") { 63 | this.props.onSuccess(); 64 | } 65 | } catch (err) { 66 | this.setState({paid: false}); 67 | if(err) throw err; 68 | } 69 | } else { 70 | this.setState({paid: false}); 71 | } 72 | }); 73 | 74 | } 75 | 76 | handleChange = (value, e) => { 77 | this.setState({ 78 | [value]: e.target.value 79 | }); 80 | } 81 | 82 | render() { 83 | const colorText = getTheme() === "dark" ? "#e3e3e3" : "#000"; 84 | const style = { 85 | base: { 86 | color: colorText, 87 | fontSize: '18px', 88 | fontFamily: '"Open Sans", sans-serif', 89 | fontSmoothing: 'antialiased', 90 | '::placeholder': { 91 | color: '#CFD7DF', 92 | }, 93 | }, 94 | invalid: { 95 | color: colorText, 96 | ':focus': { 97 | color: 'white', 98 | }, 99 | }, 100 | }; 101 | 102 | return ( 103 |
104 |
105 | this.handleChange('name', e)} 111 | fullWidth 112 | /> 113 | 121 | this.handleChange('country', e)} 127 | value={this.state.country} 128 | fullWidth 129 | /> 130 | this.handleChange('address', e)} 135 | value={this.state.address} 136 | fullWidth 137 | /> 138 |
139 | 140 | this.handleChange('city', e)} 145 | value={this.state.city} 146 | fullWidth 147 | /> 148 | 149 | 150 | this.handleChange('state', e)} 154 | label={strings.STATE} 155 | value={this.state.state} 156 | fullWidth 157 | /> 158 | 159 | 160 | this.handleChange('zip', e)} 164 | label={strings.POSTAL_CODE} 165 | value={this.state.zip} 166 | fullWidth 167 | InputProps={{ 168 | inputComponent: ZIP 169 | }} 170 | /> 171 | 172 |
173 | 174 | 175 |
176 | 177 | 180 | 181 | 182 | 185 | 186 |
187 | 188 |
189 | ); 190 | } 191 | } 192 | 193 | export default injectStripe(CheckoutForm); -------------------------------------------------------------------------------- /src/components/Checkout/styles.scss: -------------------------------------------------------------------------------- 1 | .card-number-input { 2 | margin-top: 15px; 3 | margin-block-end: 15px; 4 | } -------------------------------------------------------------------------------- /src/components/DrawerMenu/styles.scss: -------------------------------------------------------------------------------- 1 | .root { 2 | flex-grow: 1; 3 | height: 440px; 4 | z-index: 1; 5 | overflow: hidden; 6 | position: relative; 7 | display: flex; 8 | } 9 | 10 | .dark { 11 | .drawer-paper { 12 | >div { 13 | background-color: #0e1e25 !important; 14 | } 15 | 16 | .list-item { 17 | background-color: #0e1e25; 18 | color: #e3e3e3; 19 | 20 | svg { 21 | fill: #e3e3e3; 22 | } 23 | } 24 | 25 | .route-text { 26 | span { 27 | color: #e3e3e3; 28 | } 29 | } 30 | } 31 | } 32 | 33 | .light { 34 | .drawer-paper { 35 | >div { 36 | background-color: white !important; 37 | } 38 | 39 | .list-item { 40 | background-color: white; 41 | color: #0e1e25 !important; 42 | 43 | svg { 44 | fill: #0e1e25; 45 | } 46 | } 47 | .route-text { 48 | span { 49 | color: #0e1e25; 50 | } 51 | } 52 | } 53 | } 54 | 55 | .drawer-paper { 56 | position: relative; 57 | width: 240px; 58 | 59 | div+div { 60 | width: 240px !important; 61 | } 62 | .progress-container { 63 | // width: 50px!important; 64 | text-align: center; 65 | margin-top: 50px; 66 | } 67 | } 68 | 69 | .MuiListItem-root-91 { 70 | padding-top: 13px !important; 71 | padding-bottom: 13px !important; 72 | } 73 | 74 | .signout-icon { 75 | g { 76 | path { 77 | fill: #fafafa 78 | } 79 | } 80 | } 81 | 82 | .list-item { 83 | padding-left: 24px !important; 84 | padding-right: 24px !important; 85 | 86 | &.active { 87 | background-color: rgba(0, 0, 0, 0.09); 88 | 89 | div { 90 | background-color: rgba(0, 0, 0, 0); 91 | } 92 | } 93 | } 94 | 95 | .toolbar { 96 | background: #00ad9f; 97 | display: flex; 98 | align-items: center; 99 | // justify-content: center; 100 | h1 { 101 | margin: 0 auto; 102 | font-size: 1.75em; 103 | color: white; 104 | } 105 | } -------------------------------------------------------------------------------- /src/components/File/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import Typography from '@material-ui/core/Typography'; 3 | 4 | import './styles.scss'; 5 | 6 | import dayjs from 'dayjs'; 7 | 8 | import Card from '@material-ui/core/Card'; 9 | import CardHeader from '@material-ui/core/CardHeader'; 10 | import CardActions from '@material-ui/core/CardActions'; 11 | import IconButton from '@material-ui/core/IconButton'; 12 | import EditIcon from '@material-ui/icons/Edit'; 13 | import DeleteIcon from '@material-ui/icons/Delete'; 14 | import Tooltip from '@material-ui/core/Tooltip'; 15 | import strings from 'strings'; 16 | import CardMedia from '@material-ui/core/CardMedia'; 17 | import LinkIcon from '@material-ui/icons/Link'; 18 | import {copy} from 'utils'; 19 | 20 | class File extends React.Component { 21 | 22 | copyLink = () => copy(this.props.data.url); 23 | 24 | render() { 25 | return ( 26 | 27 | {this.props.data.name}} 29 | subheader={ {dayjs(this.props.data.created_at).format("DD/MM/YYYY HH:mm")}} 30 | /> 31 | {this.props.data.type.startsWith("image") && } 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | ); 54 | } 55 | } 56 | 57 | export default File; -------------------------------------------------------------------------------- /src/components/File/styles.scss: -------------------------------------------------------------------------------- 1 | .filebox { 2 | width: 350px; 3 | min-height: 150px; 4 | position: relative; 5 | margin: 10px; 6 | height: fit-content; 7 | 8 | @media screen and (max-width: 600px) { 9 | width: 100%; 10 | } 11 | 12 | .media { 13 | height: 0; 14 | // background-size: contain; 15 | padding-top: 56.25%; 16 | } 17 | 18 | .filebox-content { 19 | height: 100px; 20 | position: relative; 21 | display: flex; 22 | align-items: center; 23 | justify-content: center; 24 | cursor: pointer; 25 | .type-icon { 26 | svg { 27 | position: absolute; 28 | margin-left: -30px; 29 | margin-top: 0px; 30 | } 31 | } 32 | 33 | .divider { 34 | width: 350px; 35 | position: absolute; 36 | left: 0; 37 | bottom: 0px; 38 | } 39 | } 40 | 41 | .bottom { 42 | height: 50px; 43 | position: relative; 44 | bottom: 0px; 45 | left: 5px; 46 | font-size: 12px; 47 | opacity: 0.8; 48 | display: flex; 49 | align-items: center; 50 | 51 | svg { 52 | margin-left: 5px; 53 | } 54 | 55 | span.updated-at { 56 | margin-left: 6px; 57 | } 58 | .open-button { 59 | margin-left: auto; 60 | margin-right: 20px; 61 | } 62 | } 63 | } -------------------------------------------------------------------------------- /src/components/FileSelector/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import CircularProgress from '@material-ui/core/CircularProgress'; 3 | import Dialog from '@material-ui/core/Dialog'; 4 | import DialogActions from '@material-ui/core/DialogActions'; 5 | import DialogContent from '@material-ui/core/DialogContent'; 6 | import DialogTitle from '@material-ui/core/DialogTitle'; 7 | 8 | import Button from '@material-ui/core/Button'; 9 | import client from 'services/client'; 10 | 11 | import strings from 'strings'; 12 | import GridList from '@material-ui/core/GridList'; 13 | import GridListTile from '@material-ui/core/GridListTile'; 14 | import GridListTileBar from '@material-ui/core/GridListTileBar'; 15 | import IconButton from '@material-ui/core/IconButton'; 16 | import CheckCircle from '@material-ui/icons/Check'; 17 | import Clear from '@material-ui/icons/Clear'; 18 | import {withRouter} from 'react-router'; 19 | 20 | import dayjs from 'dayjs'; 21 | import relativeTime from 'dayjs/plugin/relativeTime' 22 | import './styles.scss'; 23 | dayjs.extend(relativeTime); 24 | 25 | 26 | class FileSelector extends React.Component { 27 | 28 | constructor(props) { 29 | super(props); 30 | this.state = { 31 | files: [], 32 | fetched: false, 33 | selected: { 34 | id: "" 35 | } 36 | } 37 | } 38 | 39 | fetchFiles = () => { 40 | this.setState({fetched: false}); 41 | client.get('/files/' + this.props.match.params.name).then(response => { 42 | let files = response.data.payload || []; 43 | files = this.filterFiles(files); 44 | this.setState({files, fetched: true}); 45 | }) 46 | } 47 | 48 | filterFiles = files => { 49 | const filter = this.props.accept || "image"; 50 | const filtered = [] 51 | files.forEach(file => { 52 | if(file.type.startsWith(filter)) filtered.push(file); 53 | }); 54 | return filtered; 55 | } 56 | 57 | 58 | componentWillMount() { 59 | this.fetchFiles(); 60 | } 61 | 62 | selectImage = file => { 63 | if(file.id === this.state.selected.id) { 64 | this.setState({selected: {id: ""}}); 65 | return 66 | } 67 | this.setState({selected: file}); 68 | } 69 | 70 | goToStorage = () => { 71 | this.props.history.push('/site/' + this.props.match.params.name + '/storage'); 72 | } 73 | 74 | render() { 75 | return ( 76 | 83 | {strings.SELECT_FILE} 84 | 85 | {!this.state.fetched && } 86 | {this.state.files.length < 1 && 87 | 90 | } 91 | 92 | {this.state.files.length > 0 && 93 | this.state.files.map((file, i) => ( 94 | this.selectImage(file)} 102 | key={i}> 103 | 104 | {file.type.startsWith("image") && {file.name}} 105 | {dayjs(file.created_at).fromNow()}} 108 | actionIcon={ 109 | this.selectImage(file)}> 110 | {this.state.selected.id === file.id ? : } 111 | 112 | } 113 | /> 114 | 115 | )) 116 | } 117 | 118 | 119 | 120 | 121 | {this.state.files.length > 0 && } 124 | 127 | 130 | 131 | 132 | ) 133 | } 134 | } 135 | 136 | export default withRouter(FileSelector); -------------------------------------------------------------------------------- /src/components/FileSelector/styles.scss: -------------------------------------------------------------------------------- 1 | .file-selector { 2 | .disabled { 3 | opacity: 0.25; 4 | } 5 | 6 | .file-is-any { 7 | height: 70px!important; 8 | } 9 | } -------------------------------------------------------------------------------- /src/components/FileUploader/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import CircularProgress from '@material-ui/core/CircularProgress'; 3 | import Dialog from '@material-ui/core/Dialog'; 4 | import DialogActions from '@material-ui/core/DialogActions'; 5 | import DialogContent from '@material-ui/core/DialogContent'; 6 | import DialogContentText from '@material-ui/core/DialogContentText'; 7 | import DialogTitle from '@material-ui/core/DialogTitle'; 8 | 9 | import Button from '@material-ui/core/Button'; 10 | import Typography from '@material-ui/core/Typography'; 11 | import client from 'services/client'; 12 | 13 | import async from 'async'; 14 | import strings from 'strings'; 15 | class FileUploader extends React.Component { 16 | 17 | constructor(props) { 18 | super(props); 19 | this.state = { 20 | publishing: false, 21 | files: [], 22 | completed: 0 23 | } 24 | } 25 | 26 | componentWillReceiveProps() { 27 | /* Reset */ 28 | this.setState({ 29 | files: [], 30 | completed: 0 31 | }); 32 | } 33 | 34 | upload = (file, cb) => { 35 | const formData = new FormData(); 36 | 37 | if(this.props.isStorage) { 38 | formData.append("file", file, file.name); 39 | client.post('/files/' + this.props.siteName, formData, {headers: {"Content-Type": "multipart/form-data"}}).then(response => cb(response.data)).catch(err => { 40 | if(err) { 41 | this.setState({publishing: false, error: err.message}); 42 | } 43 | }) 44 | } else if(this.props.isPhoto) { 45 | formData.append("image", file, file.name); 46 | client.post("/photos/" + this.props.siteName + "/" + this.props.photoID, formData, { 47 | headers: { 48 | 'Content-Type': 'multipart/form-data' 49 | } 50 | }).then(response => { 51 | cb(response.data); 52 | }).catch(err => { 53 | if(err) { 54 | this.setState({publishing: false, error: err.message}); 55 | } 56 | }); 57 | } else { 58 | formData.append("image", file, file.name); 59 | formData.append("is_gallery", this.props.isGallery); 60 | formData.append("is_project", this.props.isProject); 61 | formData.append("gallery_id", this.props.galleryID); 62 | formData.append("project_id", this.props.projectID); 63 | 64 | client.post("/photos/" + this.props.siteName, formData, { 65 | headers: { 66 | 'Content-Type': 'multipart/form-data' 67 | } 68 | }).then(response => { 69 | cb(response.data); 70 | }).catch(err => { 71 | if(err) { 72 | this.setState({publishing: false, error: err.message}); 73 | } 74 | }); 75 | } 76 | 77 | } 78 | 79 | handleSubmit = () => { 80 | const files = document.getElementById("fileInput").files; 81 | this.setState({publishing: true}); 82 | 83 | let completed = 0; 84 | const uploadedPictures = []; 85 | async.eachSeries(files, (file, next) => { 86 | this.upload(file, data => { 87 | uploadedPictures.push(data); 88 | console.log(uploadedPictures); 89 | completed++; 90 | this.setState({completed}); 91 | next(); 92 | }); 93 | }, () => { 94 | this.setState({publishing: false}, () => { 95 | console.log(uploadedPictures); 96 | this.props.onDone(uploadedPictures); 97 | }); 98 | }); 99 | } 100 | 101 | handleImageSelect = () => { 102 | const fileInput = document.getElementById("fileInput"); 103 | 104 | fileInput.addEventListener("change", () => { 105 | const files = fileInput.files; 106 | 107 | if(this.props.max) { 108 | if(files.length > this.props.max) { 109 | alert(strings.TOO_MANY_PICTURES); 110 | fileInput.value = ""; 111 | } 112 | } 113 | this.setState({canPublish: files.length > 0, files}) 114 | }); 115 | 116 | fileInput.click(); 117 | } 118 | 119 | render() { 120 | return ( 121 | 126 | {strings.IMPORT_FILES} 127 | 128 | 129 | 130 | {this.props.max > 1 ? strings.IMPORT_FILES_DESCRIPTION : strings.IMPORT_FILE} 131 | 132 | 133 |
134 | 135 | 136 | {this.props.max && this.state.files < 1 && {this.props.max} max} 137 | {this.state.files.length > 0 && {this.state.files.length} {strings.FILES}} 138 |
139 | {this.state.publishing && ( 140 |
141 | 142 | {this.state.completed} / {this.state.files.length} 143 |
144 | )} 145 |
146 | 147 | 150 | 153 | 154 | 155 |
156 | ) 157 | } 158 | } 159 | 160 | export default FileUploader; -------------------------------------------------------------------------------- /src/components/GalleryBox/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import Typography from '@material-ui/core/Typography'; 3 | 4 | import './styles.scss'; 5 | 6 | import dayjs from 'dayjs'; 7 | 8 | import Card from '@material-ui/core/Card'; 9 | import CardHeader from '@material-ui/core/CardHeader'; 10 | import CardActions from '@material-ui/core/CardActions'; 11 | import IconButton from '@material-ui/core/IconButton'; 12 | import EditIcon from '@material-ui/icons/Edit'; 13 | import DeleteIcon from '@material-ui/icons/Delete'; 14 | import Tooltip from '@material-ui/core/Tooltip'; 15 | import strings from 'strings'; 16 | import HomeIcon from '@material-ui/icons/Home'; 17 | 18 | class GalleryBox extends React.Component { 19 | render() { 20 | return ( 21 | 22 | {this.props.data.title}} 24 | subheader={ {dayjs(this.props.data.updated_at).format("DD/MM/YYYY HH:mm")}} 25 | /> 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | ); 45 | } 46 | } 47 | 48 | export default GalleryBox; -------------------------------------------------------------------------------- /src/components/GalleryBox/styles.scss: -------------------------------------------------------------------------------- 1 | .gallerybox { 2 | width: 350px; 3 | min-height: 150px; 4 | position: relative; 5 | 6 | @media screen and (max-width: 600px) { 7 | width: 100%; 8 | } 9 | 10 | 11 | .gallerybox-content { 12 | height: 100px; 13 | position: relative; 14 | display: flex; 15 | align-items: center; 16 | justify-content: center; 17 | cursor: pointer; 18 | .type-icon { 19 | svg { 20 | position: absolute; 21 | margin-left: -30px; 22 | margin-top: 0px; 23 | } 24 | } 25 | 26 | .divider { 27 | width: 350px; 28 | position: absolute; 29 | left: 0; 30 | bottom: 0px; 31 | } 32 | } 33 | 34 | .bottom { 35 | height: 50px; 36 | position: relative; 37 | bottom: 0px; 38 | left: 5px; 39 | font-size: 12px; 40 | opacity: 0.8; 41 | display: flex; 42 | align-items: center; 43 | 44 | svg { 45 | margin-left: 5px; 46 | } 47 | 48 | span.updated-at { 49 | margin-left: 6px; 50 | } 51 | .open-button { 52 | margin-left: auto; 53 | margin-right: 20px; 54 | } 55 | } 56 | } -------------------------------------------------------------------------------- /src/components/PhotoBox/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import Card from '@material-ui/core/Card'; 3 | import CardMedia from '@material-ui/core/CardMedia'; 4 | import CardActions from '@material-ui/core/CardActions'; 5 | import IconButton from '@material-ui/core/IconButton'; 6 | import EditIcon from '@material-ui/icons/Edit'; 7 | import DeleteIcon from '@material-ui/icons/Delete'; 8 | import Tooltip from '@material-ui/core/Tooltip'; 9 | import CardHeader from '@material-ui/core/CardHeader'; 10 | 11 | import strings from 'strings'; 12 | 13 | import './styles.scss'; 14 | 15 | class PhotoBox extends React.Component { 16 | render() { 17 | return ( 18 | 19 | 20 | {this.props.data.url && } 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | ) 38 | } 39 | } 40 | 41 | export default PhotoBox; -------------------------------------------------------------------------------- /src/components/PhotoBox/styles.scss: -------------------------------------------------------------------------------- 1 | .photobox{ 2 | width: 400px; 3 | 4 | @media screen and(max-width: 600px) { 5 | width: 100%; 6 | } 7 | } 8 | .photobox-preview-media { 9 | padding-top: 56.25%; 10 | } -------------------------------------------------------------------------------- /src/components/ProjectBox/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import Typography from '@material-ui/core/Typography'; 3 | 4 | import './styles.scss'; 5 | 6 | import dayjs from 'dayjs'; 7 | 8 | import Card from '@material-ui/core/Card'; 9 | import CardHeader from '@material-ui/core/CardHeader'; 10 | import CardActions from '@material-ui/core/CardActions'; 11 | import IconButton from '@material-ui/core/IconButton'; 12 | import EditIcon from '@material-ui/icons/Edit'; 13 | import DeleteIcon from '@material-ui/icons/Delete'; 14 | import Tooltip from '@material-ui/core/Tooltip'; 15 | import strings from 'strings'; 16 | 17 | class ProjectBox extends React.Component { 18 | render() { 19 | return ( 20 | 21 | {this.props.project.title}} 23 | subheader={ {dayjs(this.props.project.updated_at).format("DD/MM/YYYY HH:mm")}} 24 | /> 25 | 26 | {/* 27 | 28 | 29 | 30 | */} 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | ); 44 | } 45 | } 46 | 47 | export default ProjectBox; -------------------------------------------------------------------------------- /src/components/ProjectBox/styles.scss: -------------------------------------------------------------------------------- 1 | .projectbox { 2 | width: 350px; 3 | min-height: 150px; 4 | 5 | // display: flex; 6 | // align-items: center; 7 | // justify-content: center; 8 | margin: 15px; 9 | position: relative; 10 | 11 | 12 | .projectbox-content { 13 | height: 100px; 14 | position: relative; 15 | display: flex; 16 | align-items: center; 17 | justify-content: center; 18 | cursor: pointer; 19 | .type-icon { 20 | svg { 21 | position: absolute; 22 | margin-left: -30px; 23 | margin-top: 0px; 24 | } 25 | } 26 | 27 | .divider { 28 | width: 350px; 29 | position: absolute; 30 | left: 0; 31 | bottom: 0px; 32 | } 33 | } 34 | 35 | .bottom { 36 | height: 50px; 37 | position: relative; 38 | bottom: 0px; 39 | left: 5px; 40 | font-size: 12px; 41 | opacity: 0.8; 42 | display: flex; 43 | align-items: center; 44 | 45 | svg { 46 | margin-left: 5px; 47 | } 48 | 49 | span.updated-at { 50 | margin-left: 6px; 51 | } 52 | .open-button { 53 | margin-left: auto; 54 | margin-right: 20px; 55 | } 56 | } 57 | } -------------------------------------------------------------------------------- /src/components/Selector/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | import Typography from '@material-ui/core/Typography'; 4 | import TextField from '@material-ui/core/TextField'; 5 | import MenuItem from '@material-ui/core/MenuItem'; 6 | import Paper from '@material-ui/core/Paper'; 7 | import { withStyles } from '@material-ui/core/styles'; 8 | import { emphasize } from '@material-ui/core/styles/colorManipulator'; 9 | import Select from 'react-select'; 10 | 11 | import './styles.scss'; 12 | 13 | const styles = theme => ({ 14 | root: { 15 | flexGrow: 1, 16 | height: 250, 17 | }, 18 | input: { 19 | display: 'flex', 20 | padding: "5px 0", 21 | }, 22 | valueContainer: { 23 | display: 'flex', 24 | flexWrap: 'wrap', 25 | flex: 1, 26 | alignItems: 'center', 27 | overflow: 'hidden', 28 | }, 29 | chip: { 30 | margin: `${theme.spacing.unit / 2}px ${theme.spacing.unit / 4}px`, 31 | }, 32 | chipFocused: { 33 | backgroundColor: emphasize( 34 | theme.palette.type === 'light' ? theme.palette.grey[300] : theme.palette.grey[700], 35 | 0.08, 36 | ), 37 | }, 38 | noOptionsMessage: { 39 | padding: `${theme.spacing.unit}px ${theme.spacing.unit * 2}px`, 40 | }, 41 | singleValue: { 42 | fontSize: 16, 43 | }, 44 | placeholder: { 45 | position: 'absolute', 46 | left: 2, 47 | fontSize: 16, 48 | }, 49 | paper: { 50 | position: 'absolute', 51 | zIndex: 1, 52 | marginTop: theme.spacing.unit, 53 | left: 0, 54 | right: 0, 55 | }, 56 | divider: { 57 | height: theme.spacing.unit * 2, 58 | }, 59 | }); 60 | 61 | function NoOptionsMessage(props) { 62 | return ( 63 | 68 | {props.children} 69 | 70 | ); 71 | } 72 | 73 | function inputComponent({ inputRef, ...props }) { 74 | return
; 75 | } 76 | 77 | function Control(props) { 78 | return ( 79 | 93 | ); 94 | } 95 | 96 | function Option(props) { 97 | return ( 98 | 107 | {props.children} 108 | 109 | ); 110 | } 111 | 112 | function Placeholder(props) { 113 | return ( 114 | 119 | {props.children} 120 | 121 | ); 122 | } 123 | 124 | function SingleValue(props) { 125 | return ( 126 | 127 | {props.children} 128 | 129 | ); 130 | } 131 | 132 | function ValueContainer(props) { 133 | return
{props.children}
; 134 | } 135 | 136 | function Menu(props) { 137 | return ( 138 | 139 | {props.children} 140 | 141 | ); 142 | } 143 | 144 | const components = { 145 | Control, 146 | Menu, 147 | NoOptionsMessage, 148 | Option, 149 | Placeholder, 150 | SingleValue, 151 | ValueContainer, 152 | }; 153 | 154 | class Selector extends React.Component { 155 | render() { 156 | const { classes, theme } = this.props; 157 | 158 | const selectStyles = { 159 | input: base => ({ 160 | ...base, 161 | color: theme.palette.text.primary, 162 | '& input': { 163 | font: 'inherit', 164 | }, 165 | }), 166 | }; 167 | return ( 168 | 162 | 163 | {strings.NONE} 164 | 165 | {this.state.galleries.map((g, i) => ( 166 | 167 | {g.title} 168 | 169 | ))} 170 | 171 | 172 | { 179 | this.setState({content: e.target.value}) 180 | }} 181 | margin="normal" 182 | rows={10} 183 | rowsMax={100} 184 | fullWidth 185 | /> 186 | {/* */} 187 | this.setState({url: e.target.value})} 191 | margin="normal" 192 | fullWidth 193 | InputProps={{ 194 | endAdornment: 195 | 196 | 197 | 198 | , 199 | }} 200 | /> 201 | 210 | photography 211 | 214 | {this.state.error && 215 | {this.state.errorMsg} 216 | } 217 | } 218 |
219 | ) 220 | } 221 | } 222 | 223 | export default withRouter(EditPhoto); -------------------------------------------------------------------------------- /src/pages/dashboard/EditPhoto/styles.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backpulse/dashboard/02ac7a964f938124c23f9bac59e750b5fa220abe/src/pages/dashboard/EditPhoto/styles.scss -------------------------------------------------------------------------------- /src/pages/dashboard/Galleries/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import Fab from '@material-ui/core/Fab'; 3 | import AddIcon from '@material-ui/icons/Add'; 4 | import {withRouter}from 'react-router'; 5 | 6 | import Button from '@material-ui/core/Button'; 7 | import FormHelperText from '@material-ui/core/FormHelperText'; 8 | import TextField from '@material-ui/core/TextField'; 9 | import DialogContent from '@material-ui/core/DialogContent'; 10 | import FormControl from '@material-ui/core/FormControl'; 11 | import strings from 'strings'; 12 | 13 | import Dialog from '@material-ui/core/Dialog'; 14 | import DialogTitle from '@material-ui/core/DialogTitle'; 15 | import DialogContentText from '@material-ui/core/DialogContentText'; 16 | import DialogActions from '@material-ui/core/DialogActions'; 17 | import client from 'services/client'; 18 | 19 | import CircularProgress from '@material-ui/core/CircularProgress'; 20 | 21 | import GalleryBox from 'components/GalleryBox'; 22 | 23 | import './styles.scss'; 24 | 25 | import Sorter from '../../../components/Sorter'; 26 | 27 | import {sortByIndex} from 'utils'; 28 | 29 | class Galleries extends React.Component { 30 | 31 | constructor(props) { 32 | super(props); 33 | this.state = { 34 | galleries : [], 35 | fetched: false, 36 | titles: [], 37 | descriptions: [], 38 | languages: [], 39 | photos: [], 40 | editGalleryDialog: false, 41 | newGalleryDialog: false, 42 | galleryName: "", 43 | importDialog: false, 44 | confirmDelete: false, 45 | nameHasError: false, 46 | error: false, 47 | errorMsg: "", 48 | galleryToDelete: {}, 49 | 50 | loading: false 51 | } 52 | } 53 | 54 | componentDidMount() { 55 | this.fetchGalleries(); 56 | } 57 | 58 | componentWillReceiveProps() { 59 | this.fetchGalleries(); 60 | } 61 | 62 | 63 | fetchGalleries = () => { 64 | client.get('/galleries/' + this.props.match.params.name).then(response => { 65 | const galleries = response.data.payload || []; 66 | sortByIndex(galleries); 67 | this.setState({galleries, fetched: true}); 68 | }).catch(err => { 69 | if(err) throw err; 70 | }); 71 | } 72 | 73 | handleCreateGallery = () => { 74 | this.setState({ galleryName: "",newGalleryDialog: true, error: false, errorMsg: "", nameHasError: false}); 75 | } 76 | 77 | checkError = err => { 78 | const errType = err.data.message; 79 | switch(errType) { 80 | case "name_too_short": { 81 | this.setState({ 82 | nameHasError: true, 83 | errorMsg: strings.NAME_TOO_SHORT, 84 | error: true 85 | }); 86 | break; 87 | } 88 | case "name_too_long": { 89 | this.setState({ 90 | nameHasError: true, 91 | errorMsg: strings.NAME_TOO_LONG, 92 | error: true 93 | }); 94 | break; 95 | } 96 | default: 97 | break 98 | } 99 | } 100 | 101 | handleCloseNewGalleryDialog = () => this.setState({ 102 | newGalleryDialog: false 103 | }); 104 | 105 | createGallery = e => { 106 | e.preventDefault(); 107 | client.post('/galleries/'+this.props.match.params.name + '/' + this.state.galleryName).then(response => { 108 | this.fetchGalleries(); 109 | this.handleCloseNewGalleryDialog(); 110 | }).catch(err => { 111 | this.checkError(err); 112 | if(err) throw err; 113 | }) 114 | } 115 | 116 | editGallery = gallery => { 117 | this.props.history.push('/site/' + this.props.match.params.name + '/galleries/' + gallery.id); 118 | } 119 | 120 | handleNameChange = e => this.setState({ 121 | galleryName: e.target.value 122 | }); 123 | 124 | onDragEnd = galleries => { 125 | this.setState({galleries}); 126 | client.put('/galleries/' + this.props.match.params.name + '/indexes', galleries).then(response => { 127 | console.log(response.data); 128 | }).catch(err => { 129 | if(err) throw err; 130 | }); 131 | } 132 | 133 | closeConfirmDelete = () => this.setState({ 134 | confirmDelete: false 135 | }); 136 | 137 | confirmDelete = gallery => this.setState({ 138 | confirmDelete: true, 139 | galleryToDelete: gallery 140 | }); 141 | 142 | deleteGallery = () => { 143 | client.delete('/gallery/' + this.state.galleryToDelete.id).then(response => { 144 | this.closeConfirmDelete(); 145 | this.fetchGalleries(); 146 | }).catch(err => { 147 | if(err) throw err; 148 | }); 149 | } 150 | 151 | onDefaultSet = gallery => { 152 | client.put('/galleries/' + this.props.match.params.name + '/default/' + gallery.id).then(response => { 153 | console.log(response.data); 154 | this.fetchGalleries(); 155 | }).catch(err => { 156 | if(err) throw err; 157 | }); 158 | } 159 | 160 | render() { 161 | return ( 162 |
163 | 164 | 165 | {strings.NEW_GALLERY} 166 | 167 |
168 |

{strings.DRAWER_GALLERIES}

169 |
170 | {!this.state.fetched && } 171 | {this.state.galleries.length < 1 && this.state.fetched && } 175 | 176 | {this.state.galleries.length > 0 && 177 | this.editGallery(g)} 186 | onDelete={g => this.confirmDelete(g)} 187 | onDefaultSet={g => this.onDefaultSet(g)} 188 | /> 189 | } 190 | 191 | 196 |
197 | {strings.NEW_GALLERY} 198 | 199 | 200 | {strings.NEW_GALLERY_DESCRIPTION} 201 | 202 | 203 | 213 | 214 | {this.state.error && 215 | {this.state.errorMsg} 216 | } 217 | 218 | 219 | 220 | 223 | 226 | 227 |
228 |
229 | 230 | 234 | {strings.DELETE_GALLERY} 235 | 236 | 237 | {strings.CONFIRM_DELETE_GALLERY_DESCRIPTION} 238 | 239 | 240 | 241 | 244 | 247 | 248 | 249 |
250 | ) 251 | } 252 | } 253 | 254 | export default withRouter(Galleries); -------------------------------------------------------------------------------- /src/pages/dashboard/Galleries/styles.scss: -------------------------------------------------------------------------------- 1 | .page.dashboard-galleries { 2 | .galleries-container { 3 | display: flex; 4 | flex-direction: column; 5 | flex-wrap: wrap; 6 | margin-left: -12px; 7 | margin-top: -15px; 8 | @media screen and (max-width: 600px) { 9 | position: relative; 10 | } 11 | } 12 | } 13 | 14 | 15 | 16 | input[type="file"] { 17 | display: none; 18 | } 19 | 20 | .dialog-gallery-edit { 21 | .gallery-photos-container { 22 | margin-left: -10px; 23 | } 24 | } -------------------------------------------------------------------------------- /src/pages/dashboard/Modules/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | import './styles.scss'; 4 | import strings from 'strings'; 5 | 6 | import {withRouter} from 'react-router'; 7 | import AddIcon from '@material-ui/icons/Add'; 8 | 9 | import client from 'services/client'; 10 | import List from '@material-ui/core/List'; 11 | import ListItem from '@material-ui/core/ListItem'; 12 | import ListItemSecondaryAction from '@material-ui/core/ListItemSecondaryAction'; 13 | import ListItemText from '@material-ui/core/ListItemText'; 14 | import IconButton from '@material-ui/core/IconButton'; 15 | import DeleteIcon from '@material-ui/icons/Delete'; 16 | 17 | import Grid from '@material-ui/core/Grid'; 18 | import ExtensionIcon from '@material-ui/icons/Extension'; 19 | import ListItemIcon from '@material-ui/core/ListItemIcon'; 20 | 21 | import Dialog from '@material-ui/core/Dialog'; 22 | import DialogContent from '@material-ui/core/DialogContent'; 23 | import DialogTitle from '@material-ui/core/DialogTitle'; 24 | import DialogContentText from '@material-ui/core/DialogContentText'; 25 | import DialogActions from '@material-ui/core/DialogActions'; 26 | import Select from '@material-ui/core/Select'; 27 | import FormControl from '@material-ui/core/FormControl'; 28 | import FormHelperText from '@material-ui/core/FormHelperText'; 29 | import MenuItem from '@material-ui/core/MenuItem'; 30 | 31 | import CircularProgress from '@material-ui/core/CircularProgress'; 32 | import Button from '@material-ui/core/Button'; 33 | 34 | class Modules extends React.Component { 35 | 36 | constructor(props) { 37 | super(props); 38 | this.state = { 39 | modules: [], 40 | fetched: false, 41 | 42 | open: false, 43 | confirm: false, 44 | 45 | moduleToAdd: "" 46 | } 47 | 48 | this.modules = ["projects", "galleries", "articles", "videos", "music"]; 49 | } 50 | 51 | fetchModules = () => { 52 | client.get('/sites/' + this.props.match.params.name + '/modules').then(response => { 53 | const modules = response.data.payload; 54 | this.setState({modules, fetched: true}); 55 | console.log(modules); 56 | }).catch(err => { 57 | if(err) throw err; 58 | }); 59 | } 60 | 61 | componentDidMount() { 62 | this.fetchModules(); 63 | } 64 | 65 | getModuleName = m => { 66 | if(m === "galleries") return strings.MODULE_GALLERIES; 67 | if(m === "projects") return strings.MODULE_PROJECTS; 68 | if(m === "articles") return strings.MODULE_ARTICLES; 69 | if(m === "videos") return strings.MODULE_VIDEOS; 70 | if(m === "music") return strings.MODULE_MUSIC; 71 | } 72 | 73 | openModuleSelector = () => this.setState({ 74 | open: true 75 | }); 76 | 77 | closeModuleSelector = () => this.setState({ 78 | open: false 79 | }); 80 | 81 | getModules = () => { 82 | const modules = this.modules; 83 | 84 | const availableModules = []; 85 | 86 | for(let i = 0; i < modules.length; i++) { 87 | let exists = false; 88 | for(let j = 0; j < this.state.modules.length; j++) { 89 | if(modules[i] === this.state.modules[j]) { 90 | exists = true; 91 | } 92 | } 93 | if (!exists) { 94 | availableModules.push(modules[i]); 95 | } 96 | } 97 | return availableModules; 98 | } 99 | 100 | onSelect = e => { 101 | const m = e.target.value; 102 | this.setState({ 103 | moduleToAdd: m 104 | }); 105 | } 106 | 107 | addModule = e => { 108 | e.preventDefault(); 109 | client.post('/sites/' + this.props.match.params.name + '/modules/' + this.state.moduleToAdd).then(response => { 110 | window.location.reload(); 111 | }).catch(err => { 112 | if(err) throw err; 113 | }); 114 | } 115 | 116 | confirmRemove = m => this.setState({ 117 | confirm: true, 118 | moduleToDelete: m 119 | }); 120 | 121 | closeConfirm = () => this.setState({ 122 | confirm: false 123 | }); 124 | 125 | removeModule = () => { 126 | client.delete('/sites/' + this.props.match.params.name + '/modules/' + this.state.moduleToDelete).then(response => { 127 | window.location.reload(); 128 | }).catch(err => { 129 | if(err) throw err 130 | }); 131 | } 132 | 133 | render() { 134 | return ( 135 |
136 |

{strings.DRAWER_MODULES}

137 | 141 | {!this.state.fetched && } 142 | 143 | {this.state.fetched && 144 | 145 | {this.state.modules.map((m, i) => ( 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | this.confirmRemove(m)}> 154 | 155 | 156 | 157 | 158 | ))} 159 | 160 | } 161 | 162 | 163 | 167 | {strings.REMOVE_MODULE} 168 | 169 | 170 | {strings.REMOVE_MODULE_DESCRIPTION} 171 | 172 | 173 | 174 | 177 | 180 | 181 | 182 | 183 | 187 |
188 | {strings.ADD_MODULE} 189 | 190 | 191 | {strings.ADD_MODULE_DESCRIPTION} 192 | 193 | 194 | 201 | 202 | {this.state.error && 203 | {this.state.errorMsg} 204 | } 205 | 206 | 207 | 208 | 211 | 214 | 215 |
216 |
217 |
218 | ) 219 | } 220 | 221 | } 222 | export default withRouter(Modules); -------------------------------------------------------------------------------- /src/pages/dashboard/Modules/styles.scss: -------------------------------------------------------------------------------- 1 | .page.dashboard-modules { 2 | .add-module-btn { 3 | margin-top: 15px; 4 | } 5 | } -------------------------------------------------------------------------------- /src/pages/dashboard/MyAccount/styles.scss: -------------------------------------------------------------------------------- 1 | .page.my-account { 2 | padding-left: 20%!important; 3 | padding-right: 20%!important; 4 | 5 | @media screen and (max-width: 700px) { 6 | padding-left: 5% !important; 7 | padding-right: 5% !important; 8 | } 9 | 10 | h1 { 11 | margin-bottom: 25px; 12 | } 13 | h2 { 14 | margin-bottom: -15px; 15 | 16 | } 17 | 18 | .group { 19 | margin-bottom: 25px; 20 | .divider { 21 | margin-top: 25px; 22 | } 23 | button { 24 | margin-top: 15px; 25 | } 26 | .warning-text { 27 | margin-top: 15px; 28 | } 29 | } 30 | 31 | } 32 | 33 | .dark { 34 | .page.my-account { 35 | h2 { 36 | color: #00ad9f!important; 37 | } 38 | } 39 | } 40 | 41 | 42 | .inline-grid { 43 | display: flex; 44 | justify-content: space-between; 45 | } -------------------------------------------------------------------------------- /src/pages/dashboard/MySites/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | import './styles.scss'; 4 | 5 | import client from 'services/client'; 6 | 7 | import Fab from '@material-ui/core/Fab'; 8 | import AddIcon from '@material-ui/icons/Add'; 9 | 10 | import Dialog from '@material-ui/core/Dialog'; 11 | import DialogContent from '@material-ui/core/DialogContent'; 12 | import Button from '@material-ui/core/Button'; 13 | import DialogTitle from '@material-ui/core/DialogTitle'; 14 | import DialogContentText from '@material-ui/core/DialogContentText'; 15 | import DialogActions from '@material-ui/core/DialogActions'; 16 | import TextField from '@material-ui/core/TextField'; 17 | import FormControl from '@material-ui/core/FormControl'; 18 | import FormHelperText from '@material-ui/core/FormHelperText'; 19 | 20 | import CircularProgress from '@material-ui/core/CircularProgress'; 21 | 22 | 23 | import strings from 'strings'; 24 | import SiteBox from 'components/SiteBox'; 25 | 26 | import AppBar from 'components/AppBar'; 27 | 28 | class MySites extends React.Component { 29 | 30 | constructor(props) { 31 | super(props); 32 | this.state = { 33 | newSiteDialog: false, 34 | siteName: "", 35 | siteType: "", 36 | sites: [], 37 | 38 | nameHasError: false, 39 | error: false, 40 | errorMsg: "", 41 | fetched: false 42 | } 43 | } 44 | 45 | fetchSites = () => { 46 | client.get('/sites').then(response => { 47 | const sites = response.data.payload || []; 48 | this.setState({sites, fetched: true}); 49 | }).catch(err => { 50 | if(err) throw err; 51 | }); 52 | } 53 | 54 | componentDidMount() { 55 | this.fetchSites(); 56 | } 57 | 58 | 59 | handleNewSite = () => { 60 | this.setState({newSiteDialog: true, errorMsg: "", error: false, nameHasError: false, siteName: "", siteType: ""}) 61 | }; 62 | handleNewSiteDialogClose = () => this.setState({newSiteDialog: false}); 63 | 64 | handleTypeChange = e => { 65 | this.setState({siteType: e.target.value}); 66 | } 67 | 68 | handleNameChange = e => { 69 | this.setState({ 70 | siteName: e.target.value, 71 | error: false, 72 | errorMsg: "", 73 | nameHasError: false 74 | }); 75 | } 76 | 77 | onKeyDown = e => { 78 | if(e.keyCode === 32) e.preventDefault(); 79 | } 80 | 81 | createSite = e => { 82 | e.preventDefault(); 83 | client.post('/sites', { 84 | name: this.state.siteName, 85 | type: this.state.siteType 86 | }).then(response => { 87 | this.fetchSites(); 88 | this.handleNewSiteDialogClose(); 89 | }).catch(err => { 90 | this.checkError(err); 91 | if(err) throw err; 92 | }); 93 | } 94 | 95 | checkError = err => { 96 | const errType = err.data.message; 97 | switch(errType) { 98 | case "name_too_short": { 99 | this.setState({ 100 | nameHasError: true, 101 | errorMsg: strings.NAME_TOO_SHORT, 102 | error: true 103 | }); 104 | break; 105 | } 106 | case "name_too_long": { 107 | this.setState({ 108 | nameHasError: true, 109 | errorMsg: strings.NAME_TOO_LONG, 110 | error: true 111 | }); 112 | break; 113 | } 114 | case "site_exists": { 115 | this.setState({ 116 | nameHasError: true, 117 | errorMsg: strings.SITE_EXISTS, 118 | error: true 119 | }); 120 | break; 121 | } 122 | case "incorrect_characters": { 123 | this.setState({ 124 | nameHasError: true, 125 | errorMsg: strings.SITE_NAME_INCORRECT, 126 | error: true 127 | }); 128 | break; 129 | } 130 | default: 131 | break 132 | } 133 | } 134 | 135 | favoriteSite = site => { 136 | const sites = this.state.sites; 137 | sites.forEach((s, i) => { 138 | if(s.name === site.name) { 139 | sites[i].favorite = !sites[i].favorite; 140 | } 141 | }); 142 | this.setState({sites}); 143 | client.put('/sites/favorite/' + site.name).then(response => { 144 | this.fetchSites(); 145 | }).catch(err => { 146 | if(err) throw err; 147 | }); 148 | } 149 | 150 | render() { 151 | return ( 152 |
153 | 154 | 155 | 156 | {strings.MY_SITES_ADD_SITE} 157 | 158 | 159 |

{strings.MENU_MY_SITES}

160 | {!this.state.fetched && } 161 | 162 | {this.state.sites.length < 1 && this.state.fetched && } 166 |
167 | {this.state.sites.map((site, i) => ( 168 | this.openSite(site)} 170 | favorite={() => this.favoriteSite(site)} 171 | key={i} 172 | site={site}/> 173 | ))} 174 |
175 | 176 | 181 |
182 | {strings.NEW_SITE_TITLE} 183 | 184 | 185 | {strings.NEW_SITE_DESCRIPTION} 186 | 187 | 188 | 198 | 199 | {this.state.error && 200 | {this.state.errorMsg} 201 | } 202 | 203 | 204 | 205 | 208 | 211 | 212 |
213 |
214 |
215 | ); 216 | } 217 | } 218 | 219 | export default MySites; -------------------------------------------------------------------------------- /src/pages/dashboard/MySites/styles.scss: -------------------------------------------------------------------------------- 1 | .page.dashboard-my-sites { 2 | padding-left: 10%!important; 3 | padding-right: 10%!important; 4 | 5 | .new-site-button { 6 | margin-top: 15px; 7 | } 8 | 9 | @media screen and (max-width: 750px) { 10 | padding-left: 5%!important; 11 | padding-right: 5%!important; 12 | .sites-container { 13 | justify-content: center; 14 | .sitebox { 15 | width: 100%; 16 | } 17 | } 18 | 19 | } 20 | 21 | .sites-container { 22 | display: flex; 23 | flex-direction: row; 24 | flex-wrap: wrap; 25 | margin-left: -12px 26 | } 27 | } -------------------------------------------------------------------------------- /src/pages/dashboard/Overview/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | import client from 'services/client'; 4 | 5 | import {withRouter}from 'react-router'; 6 | import CircularProgress from '@material-ui/core/CircularProgress'; 7 | 8 | class Overview extends React.Component { 9 | 10 | constructor(props) { 11 | super(props); 12 | this.state = { 13 | fetched: false, 14 | display_name: "", 15 | name: "", 16 | total_size: 0, 17 | files: 0, 18 | galleries: 0, 19 | articles: 0, 20 | projects: 0, 21 | videogroups: 0, 22 | albums: 0, 23 | collaborators: [], 24 | 25 | } 26 | } 27 | 28 | fetchOverview = () => { 29 | this.setState({fetched: false}); 30 | client.get('/sites/' + this.props.match.params.name + '/overview').then(response => { 31 | const overview = response.data.payload; 32 | this.setState({...overview, fetched: true}); 33 | }).then(err => { 34 | if(err) throw err; 35 | }); 36 | } 37 | 38 | componentDidMount() { 39 | this.fetchOverview(); 40 | } 41 | 42 | render() { 43 | return ( 44 |
45 |

{this.state.display_name}

46 | {!this.state.fetched && } 47 |
48 | ); 49 | } 50 | } 51 | 52 | export default withRouter(Overview); -------------------------------------------------------------------------------- /src/pages/dashboard/Photos/styles.scss: -------------------------------------------------------------------------------- 1 | .dashboard-photos { 2 | padding-bottom: 25px; 3 | .photos-container { 4 | .draggable { 5 | margin: 20px 0; 6 | } 7 | } 8 | } -------------------------------------------------------------------------------- /src/pages/dashboard/Projects/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import Fab from '@material-ui/core/Fab'; 3 | import AddIcon from '@material-ui/icons/Add'; 4 | import {withRouter}from 'react-router'; 5 | 6 | import Button from '@material-ui/core/Button'; 7 | import CircularProgress from '@material-ui/core/CircularProgress'; 8 | 9 | import ProjectBox from 'components/ProjectBox'; 10 | 11 | import strings from 'strings'; 12 | 13 | import client from 'services/client'; 14 | 15 | import './styles.scss'; 16 | 17 | class Projects extends React.Component { 18 | 19 | constructor(props) { 20 | super(props); 21 | this.state = { 22 | projects: [], 23 | fetched: false 24 | } 25 | } 26 | 27 | componentWillReceiveProps() { 28 | this.fetchProjects(); 29 | } 30 | 31 | componentDidMount() { 32 | this.fetchProjects(); 33 | } 34 | 35 | fetchProjects = () => { 36 | this.setState({fetched: false}); 37 | client.get('/projects/'+ this.props.match.params.name).then(response => { 38 | const projects = response.data.payload || []; 39 | this.setState({projects, fetched: true}); 40 | }).catch(err => { 41 | if(err) throw err; 42 | }); 43 | } 44 | 45 | editProject = project => { 46 | this.props.history.push('/site/' + this.props.match.params.name + '/projects/edit/' + project.id); 47 | } 48 | 49 | handleNewProject = () => { 50 | this.props.history.push('/site/' + this.props.match.params.name + '/projects/new'); 51 | } 52 | 53 | render() { 54 | return ( 55 |
56 | 57 | 58 | {strings.PROJECTS_NEW_PROJECT} 59 | 60 |
61 |

{strings.DRAWER_PROJECTS}

62 |
63 | {!this.state.fetched && } 64 | {this.state.projects.length < 1 && this.state.fetched && } 68 |
69 | {this.state.projects.map((project, i) => { 70 | return this.editProject(project)} project={project}/>; 71 | })} 72 |
73 |
74 | ); 75 | } 76 | } 77 | 78 | export default withRouter(Projects); -------------------------------------------------------------------------------- /src/pages/dashboard/Projects/styles.scss: -------------------------------------------------------------------------------- 1 | .page.dashboard-projects { 2 | .projects-container { 3 | display: flex; 4 | flex-direction: row; 5 | flex-wrap: wrap; 6 | margin-left: -12px 7 | } 8 | } 9 | 10 | .dialog-content { 11 | padding-top: 15px!important; 12 | @media screen and(max-width: 960px) { 13 | margin-left: 0px; 14 | } 15 | margin-left: 50px; 16 | 17 | .url-input { 18 | width: calc(100% + 8px); 19 | } 20 | } 21 | .topbar { 22 | position: relative!important; 23 | } 24 | 25 | .remove-button { 26 | cursor: pointer; 27 | } 28 | .no-padding { 29 | padding-right: 0px!important 30 | } -------------------------------------------------------------------------------- /src/pages/dashboard/Settings/styles.scss: -------------------------------------------------------------------------------- 1 | .page.dashboard-settings { 2 | h5 { 3 | margin-top: 15px; 4 | } 5 | hr { 6 | margin-top: 15px; 7 | } 8 | 9 | .red-text { 10 | color: #e74c3c!important; 11 | } 12 | 13 | .margin { 14 | margin-top: 15px; 15 | } 16 | } 17 | 18 | .dark { 19 | .page.dashboard-settings { 20 | h2.primary { 21 | color: #00ad9f!important; 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /src/pages/dashboard/SiteEditor/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | import {withRouter} from 'react-router'; 4 | 5 | import './styles.scss'; 6 | 7 | import client from 'services/client'; 8 | import DrawerMenu from 'components/DrawerMenu'; 9 | import AppBar from 'components/AppBar'; 10 | 11 | class SiteEditor extends React.Component { 12 | 13 | constructor(props) { 14 | super(props); 15 | this.state = { 16 | site: {} 17 | } 18 | } 19 | 20 | fetchSite = () => { 21 | client.get('/sites/' + this.props.match.params.name).then(response => { 22 | const site = response.data.payload || {}; 23 | this.setState({site}); 24 | }).catch(err => { 25 | if(err) throw err; 26 | }); 27 | } 28 | 29 | componentDidMount() { 30 | this.fetchSite(); 31 | } 32 | 33 | render() { 34 | return ( 35 |
36 | 37 | 38 |
39 | ); 40 | } 41 | } 42 | 43 | export default withRouter(SiteEditor); -------------------------------------------------------------------------------- /src/pages/dashboard/SiteEditor/styles.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backpulse/dashboard/02ac7a964f938124c23f9bac59e750b5fa220abe/src/pages/dashboard/SiteEditor/styles.scss -------------------------------------------------------------------------------- /src/pages/dashboard/Storage/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | import strings from 'strings'; 4 | import {withRouter} from 'react-router'; 5 | import CircularProgress from '@material-ui/core/CircularProgress'; 6 | import AddIcon from '@material-ui/icons/Add'; 7 | import Fab from '@material-ui/core/Fab'; 8 | import FileUploader from 'components/FileUploader'; 9 | import File from 'components/File'; 10 | 11 | import client from 'services/client'; 12 | import './styles.scss'; 13 | import Masonry from 'react-masonry-component'; 14 | 15 | import Dialog from '@material-ui/core/Dialog'; 16 | import DialogContent from '@material-ui/core/DialogContent'; 17 | import DialogTitle from '@material-ui/core/DialogTitle'; 18 | import DialogContentText from '@material-ui/core/DialogContentText'; 19 | import DialogActions from '@material-ui/core/DialogActions'; 20 | import Button from '@material-ui/core/Button'; 21 | import FormControl from '@material-ui/core/FormControl'; 22 | import TextField from '@material-ui/core/TextField'; 23 | 24 | class Storage extends React.Component { 25 | 26 | constructor(props) { 27 | super(props); 28 | this.state = { 29 | files: [], 30 | importFiles: false, 31 | confirmDelete: false, 32 | editFile: false, 33 | newFilename: "" 34 | } 35 | } 36 | 37 | componentDidMount() { 38 | this.fetchFiles(); 39 | } 40 | 41 | fetchFiles = () => { 42 | this.setState({fetched: false}); 43 | client.get('/files/' + this.props.match.params.name).then(response => { 44 | const files = response.data.payload || []; 45 | files.reverse(); 46 | this.setState({files, fetched: true}); 47 | console.log(files); 48 | }).catch(err => { 49 | if(err) throw err; 50 | }); 51 | } 52 | 53 | importFiles = () => this.setState({ 54 | importFiles: true 55 | }) 56 | 57 | closeImport = () => this.setState({ 58 | importFiles: false 59 | }); 60 | 61 | onUploadDone = data => { 62 | console.log(data); 63 | this.fetchFiles(); 64 | this.closeImport(); 65 | } 66 | 67 | closeConfirm = () => this.setState({ 68 | confirmDelete: false 69 | }) 70 | 71 | removeFile = () => { 72 | client.delete('/files/' + this.props.match.params.name + '/' + [this.state.fileToDelete.id]).then(response => { 73 | console.log(response.data); 74 | this.closeConfirm(); 75 | this.fetchFiles(); 76 | }).catch(err => { 77 | if(err) throw err; 78 | }); 79 | } 80 | 81 | closeEdit = () => this.setState({ 82 | editFile: false 83 | }); 84 | 85 | editFile = e => { 86 | e.preventDefault(); 87 | client.put('/files/' + this.props.match.params.name + '/' + this.state.fileToEdit.id + '/' + this.state.newFilename).then(response => { 88 | this.fetchFiles(); 89 | this.closeEdit(); 90 | }).catch(err => { 91 | if(err) throw err; 92 | }); 93 | } 94 | 95 | render() { 96 | return ( 97 |
98 |

{strings.DRAWER_STORAGE}

99 | {!this.state.fetched && } 100 | 101 | 102 | {strings.IMPORT_FILE} 103 | 104 | 105 | 106 | {this.state.files.map((file, i) => ( 107 | this.setState({ 109 | fileToDelete: file, 110 | confirmDelete: true 111 | })} 112 | onEdit={() => this.setState({ 113 | fileToEdit: file, 114 | editFile: true, 115 | newFilename: file.name 116 | })} 117 | data={file} 118 | key={i} 119 | /> 120 | ))} 121 | 122 | 123 | 131 | 132 | 136 |
137 | {strings.EDIT_FILENAME} 138 | 139 | 140 | this.setState({ 143 | newFilename: e.target.value 144 | })} 145 | autoFocus 146 | value={this.state.newFilename} 147 | margin="dense" 148 | label={strings.FILE_NAME} 149 | fullWidth 150 | /> 151 | 152 | 153 | 154 | 155 | 158 | 161 | 162 |
163 |
164 | 165 | 170 | {strings.REMOVE_FILE} 171 | 172 | 173 | {strings.REMOVE_FILE_DESC} 174 | 175 | 176 | 177 | 180 | 183 | 184 | 185 |
186 | ); 187 | } 188 | } 189 | 190 | export default withRouter(Storage); -------------------------------------------------------------------------------- /src/pages/dashboard/Storage/styles.scss: -------------------------------------------------------------------------------- 1 | .page.dashboard-storage { 2 | .files-container { 3 | display: flex; 4 | flex-direction: row; 5 | flex-wrap: wrap; 6 | margin-left: -12px; 7 | @media screen and(max-width: 960px) { 8 | margin-left: -22px; 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /src/pages/dashboard/Track/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | import {withRouter} from 'react-router'; 4 | 5 | import client from 'services/client'; 6 | import TextField from '@material-ui/core/TextField'; 7 | import Button from '@material-ui/core/Button'; 8 | import strings from 'strings'; 9 | import CircularProgress from '@material-ui/core/CircularProgress'; 10 | 11 | import Grid from '@material-ui/core/Grid'; 12 | import FileSelector from 'components/FileSelector'; 13 | import InputAdornment from '@material-ui/core/InputAdornment'; 14 | import StorageIcon from '@material-ui/icons/Storage'; 15 | import IconButton from '@material-ui/core/IconButton'; 16 | import './styles.scss'; 17 | 18 | class Track extends React.Component { 19 | 20 | constructor(props) { 21 | super(props); 22 | this.state = { 23 | fetched: false, 24 | url: "", 25 | title: "", 26 | image: "", 27 | description: "", 28 | 29 | fileSelector: false, 30 | audioSelector: false 31 | } 32 | } 33 | 34 | fetchTrack = () => { 35 | client.get('/tracks/' + this.props.match.params.name + '/' + this.props.match.params.id).then(response => { 36 | const track = response.data.payload; 37 | this.setState({...track, fetched: true}); 38 | }).catch(err => { 39 | if(err) throw err; 40 | }); 41 | } 42 | 43 | componentDidMount() { 44 | this.fetchTrack(); 45 | } 46 | 47 | saveTrack = e => { 48 | e.preventDefault(); 49 | client.put('/tracks/' + this.props.match.params.name + '/' + this.props.match.params.id, { 50 | title: this.state.title, 51 | content: this.state.content, 52 | url: this.state.url, 53 | image: this.state.image, 54 | }).then(response => { 55 | console.log(response.data); 56 | }).catch(err => { 57 | if(err) throw err; 58 | }); 59 | } 60 | 61 | onImageSelected = file => { 62 | this.setState({image: file.url}); 63 | this.closeFileSelector(); 64 | } 65 | 66 | onAudioSelected = file => { 67 | this.setState({url: file.url}); 68 | this.closeAudioSelector(); 69 | } 70 | 71 | closeFileSelector = () => this.setState({ 72 | fileSelector: false 73 | }); 74 | 75 | openFileSelector = () => this.setState({ 76 | fileSelector: true 77 | }); 78 | 79 | closeAudioSelector = () => this.setState({ 80 | audioSelector: false 81 | }); 82 | 83 | openAudioSelector = () => this.setState({ 84 | audioSelector: true 85 | }); 86 | 87 | render() { 88 | return ( 89 |
90 |

{strings.EDIT_TRACK}

91 | {!this.state.fetched && } 92 | 93 | 99 | 105 | 106 |
107 | {this.state.fetched && 108 | 109 | this.setState({ 115 | title: e.target.value 116 | })} 117 | margin="normal" 118 | fullWidth 119 | required 120 | /> 121 | this.setState({ 128 | content: e.target.value 129 | })} 130 | margin="normal" 131 | fullWidth 132 | /> 133 | this.setState({url: e.target.value})} 137 | margin="normal" 138 | fullWidth 139 | required 140 | InputProps={{ 141 | endAdornment: 142 | 143 | 144 | 145 | , 146 | }} 147 | /> 148 | this.setState({image: e.target.value})} 152 | margin="normal" 153 | fullWidth 154 | InputProps={{ 155 | endAdornment: 156 | 157 | 158 | 159 | , 160 | }} 161 | /> 162 | {this.state.image.length > 2 && cover} 163 | 164 | 165 | 171 | 172 | 173 | } 174 |
175 |
176 | ); 177 | } 178 | } 179 | 180 | export default withRouter(Track); -------------------------------------------------------------------------------- /src/pages/dashboard/Track/styles.scss: -------------------------------------------------------------------------------- 1 | .page.dashboard-track { 2 | img { 3 | width: 300px; 4 | } 5 | } -------------------------------------------------------------------------------- /src/pages/dashboard/Video/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | import {withRouter} from 'react-router'; 4 | 5 | import client from 'services/client'; 6 | import TextField from '@material-ui/core/TextField'; 7 | import Button from '@material-ui/core/Button'; 8 | import strings from 'strings'; 9 | import CircularProgress from '@material-ui/core/CircularProgress'; 10 | import {youtubeParser} from 'utils'; 11 | 12 | import Grid from '@material-ui/core/Grid'; 13 | 14 | class Video extends React.Component { 15 | 16 | constructor(props) { 17 | super(props); 18 | this.state = { 19 | fetched: false, 20 | youtube_url: "", 21 | title: "", 22 | content: "" 23 | } 24 | } 25 | 26 | fetchVideo = () => { 27 | client.get('/videos/' + this.props.match.params.name + '/' + this.props.match.params.videoid).then(response => { 28 | console.log(response.data); 29 | const video = response.data.payload; 30 | this.setState({...video, fetched: true}); 31 | }).catch(err => { 32 | if(err) throw err; 33 | }); 34 | } 35 | 36 | componentDidMount() { 37 | this.fetchVideo(); 38 | } 39 | 40 | saveVideo = () => { 41 | client.put('/videos/' + this.props.match.params.name + '/' + this.props.match.params.videoid, { 42 | content: this.state.content, 43 | title: this.state.title, 44 | youtube_url: this.state.youtube_url 45 | }).then(response => { 46 | console.log(response.data); 47 | }).catch(err => { 48 | if(err) throw err; 49 | }); 50 | } 51 | 52 | render() { 53 | return ( 54 |
55 |

{strings.EDIT_VIDEO}

56 | {!this.state.fetched && } 57 | {this.state.fetched && 58 | 59 | this.setState({ 65 | youtube_url: e.target.value 66 | })} 67 | margin="normal" 68 | fullWidth 69 | /> 70 | this.setState({ 76 | title: e.target.value 77 | })} 78 | margin="normal" 79 | fullWidth 80 | /> 81 | this.setState({ 88 | content: e.target.value 89 | })} 90 | margin="normal" 91 | fullWidth 92 | /> 93 | thumbnail 94 | 95 | 96 | 102 | 103 | 104 | } 105 |
106 | ); 107 | } 108 | } 109 | 110 | export default withRouter(Video); -------------------------------------------------------------------------------- /src/pages/dashboard/VideoGroup/styles.scss: -------------------------------------------------------------------------------- 1 | .page.dashboard-videogroup { 2 | 3 | .videos-container { 4 | display: flex; 5 | flex-direction: column; 6 | flex-wrap: wrap; 7 | margin-left: -12px 8 | } 9 | } 10 | 11 | .edit-group-dialog { 12 | img { 13 | max-width: 50%; 14 | } 15 | } -------------------------------------------------------------------------------- /src/pages/dashboard/VideoGroups/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | import Fab from '@material-ui/core/Fab'; 4 | import AddIcon from '@material-ui/icons/Add'; 5 | 6 | 7 | import Button from '@material-ui/core/Button'; 8 | import TextField from '@material-ui/core/TextField'; 9 | import Dialog from '@material-ui/core/Dialog'; 10 | import DialogActions from '@material-ui/core/DialogActions'; 11 | import DialogContent from '@material-ui/core/DialogContent'; 12 | import DialogContentText from '@material-ui/core/DialogContentText'; 13 | import DialogTitle from '@material-ui/core/DialogTitle'; 14 | 15 | import {withRouter} from 'react-router'; 16 | 17 | import client from 'services/client'; 18 | 19 | import strings from 'strings'; 20 | 21 | import VideoGroup from '../../../components/VideoGroup'; 22 | 23 | import './styles.scss'; 24 | import CircularProgress from '@material-ui/core/CircularProgress'; 25 | import {sortByIndex} from 'utils'; 26 | 27 | import Sorter from 'components/Sorter'; 28 | 29 | class Videos extends React.Component { 30 | 31 | constructor(props) { 32 | super(props); 33 | this.state = { 34 | videos: [], 35 | fetched: false, 36 | groups: [], 37 | title: "", 38 | addVideoGroup: false, 39 | confirmDelete: false 40 | } 41 | } 42 | 43 | fetchVideoGroups = () => { 44 | this.setState({fetched: false}); 45 | client.get('/videogroups/' + this.props.match.params.name).then(response => { 46 | const groups = response.data.payload || []; 47 | sortByIndex(groups); 48 | this.setState({groups, fetched: true}); 49 | }).catch(err => { 50 | if(err) throw err; 51 | }); 52 | } 53 | 54 | openAddVideoGroup = () => this.setState({ 55 | addVideoGroup: true 56 | }); 57 | 58 | handleClose = () => this.setState({ 59 | addVideoGroup: false 60 | }); 61 | 62 | addVideoGroup = e => { 63 | e.preventDefault(); 64 | client.post('/videogroups/' + this.props.match.params.name, { 65 | title: this.state.title 66 | }).then(response => { 67 | this.fetchVideoGroups(); 68 | this.handleClose(); 69 | this.setState({ 70 | title: "" 71 | }) 72 | console.log(response.data); 73 | }).catch(err => { 74 | if(err) throw err; 75 | }); 76 | } 77 | 78 | componentWillMount() { 79 | this.fetchVideoGroups(); 80 | } 81 | 82 | closeConfirm = () => this.setState({ 83 | confirmDelete: false 84 | }); 85 | 86 | 87 | editGroup = group => { 88 | this.props.history.push('/site/' + this.props.match.params.name + '/videogroups/' + group.id); 89 | } 90 | 91 | deleteGroup = () => { 92 | client.delete('/videogroups/' + this.props.match.params.name + '/' + this.state.groupToDelete.id).then(response => { 93 | console.log(response.data); 94 | this.fetchVideoGroups(); 95 | this.closeConfirm(); 96 | 97 | }).catch(err => { 98 | if(err) throw err; 99 | }); 100 | } 101 | 102 | onDragEnd = groups => { 103 | this.setState({groups}); 104 | client.put('/videogroups/' + this.props.match.params.name + '/indexes', groups).then(response => { 105 | console.log(response.data); 106 | }).catch(err => { 107 | if(err) throw err; 108 | }); 109 | } 110 | 111 | render() { 112 | return ( 113 |
114 |
115 |

{strings.VIDEO_GROUPS}

116 |
117 | {!this.state.fetched && } 118 | 119 | 120 | {strings.ADD_VIDEO_GROUP} 121 | 122 | {this.state.groups.length < 1 && this.state.fetched && } 126 | 127 | this.editGroup(g)} 135 | onDelete={g => this.setState({ 136 | confirmDelete: true, 137 | groupToDelete: g, 138 | })} 139 | /> 140 | 141 | 146 |
147 | {strings.ADD_VIDEO_GROUP} 148 | 149 | 150 | {strings.ADD_VIDEO_GROUP_DESC} 151 | 152 | this.setState({ 157 | title: e.target.value 158 | })} 159 | label={strings.TITLE} 160 | fullWidth 161 | /> 162 | 163 | 164 | 167 | 170 | 171 |
172 |
173 | 174 | 178 | {strings.DELETE_VIDEO_GROUP} 179 | 180 | 181 | {strings.DELETE_VIDEO_GROUP_DESC} 182 | 183 | 184 | 185 | 188 | 191 | 192 | 193 |
194 | ); 195 | } 196 | } 197 | 198 | export default withRouter(Videos); -------------------------------------------------------------------------------- /src/pages/dashboard/VideoGroups/styles.scss: -------------------------------------------------------------------------------- 1 | .page.dashboard-videogroups { 2 | .groups-container { 3 | display: flex; 4 | flex-direction: column; 5 | flex-wrap: wrap; 6 | margin-left: -12px 7 | } 8 | } -------------------------------------------------------------------------------- /src/pages/dashboard/index.js: -------------------------------------------------------------------------------- 1 | import About from './About'; 2 | import Contact from './Contact'; 3 | import Projects from './Projects'; 4 | import MySites from './MySites'; 5 | import SiteEditor from './SiteEditor'; 6 | import Settings from './Settings'; 7 | import Overview from './Overview'; 8 | import Galleries from './Galleries'; 9 | import EditProject from './EditProject'; 10 | import EditGallery from './EditGallery'; 11 | import MyAccount from './MyAccount'; 12 | import Access from './Access'; 13 | import Modules from './Modules'; 14 | import Articles from './Articles'; 15 | import EditArticle from './EditArticle'; 16 | import VideoGroups from './VideoGroups'; 17 | import VideoGroup from './VideoGroup'; 18 | import Video from './Video'; 19 | import Albums from './Albums'; 20 | import Storage from './Storage'; 21 | import Album from './Album'; 22 | import Track from './Track'; 23 | import Photos from './Photos'; 24 | import EditPhoto from './EditPhoto'; 25 | 26 | export { 27 | MySites, 28 | About, 29 | Contact, 30 | Projects, 31 | SiteEditor, 32 | Settings, 33 | Overview, 34 | Galleries, 35 | EditProject, 36 | EditGallery, 37 | MyAccount, 38 | Access, 39 | Modules, 40 | Articles, 41 | EditArticle, 42 | VideoGroups, 43 | VideoGroup, 44 | Video, 45 | Albums, 46 | Album, 47 | Track, 48 | Storage, 49 | Photos, 50 | EditPhoto 51 | } -------------------------------------------------------------------------------- /src/pages/homepage/Authentication/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | import './styles.scss'; 4 | 5 | import strings from 'strings'; 6 | 7 | import Paper from '@material-ui/core/Paper'; 8 | import TextField from '@material-ui/core/TextField'; 9 | import FormControl from '@material-ui/core/FormControl'; 10 | import Button from '@material-ui/core/Button'; 11 | import FormHelperText from '@material-ui/core/FormHelperText'; 12 | 13 | import client from 'services/client'; 14 | import { saveJWT } from '../../../utils/token'; 15 | import CircularProgress from '@material-ui/core/CircularProgress'; 16 | 17 | class Authentication extends React.Component { 18 | 19 | constructor(props) { 20 | super(props); 21 | this.state = { 22 | email: "", 23 | password: "", 24 | 25 | errorMsg: "", 26 | error: false, 27 | emailHasError: false, 28 | passHasError: false, 29 | 30 | authenticating: false 31 | } 32 | } 33 | 34 | onSubmit = e => { 35 | e.preventDefault(); 36 | 37 | this.setState({authenticating: true}); 38 | client.post(this.props.type === "login" ? "/users/authenticate" : "/users", { 39 | email: this.state.email, 40 | password: this.state.password 41 | }).then(response => { 42 | saveJWT(response.data.payload); 43 | window.location = "/"; 44 | }).catch(err => { 45 | this.checkError(err); 46 | this.setState({authenticating: false}); 47 | if(err) throw err; 48 | }); 49 | } 50 | 51 | checkError = err => { 52 | console.log(err); 53 | const errType = err.data.message; 54 | switch (errType) { 55 | case "password_too_short": 56 | this.setState({ 57 | errorMsg: strings.PASSWORD_TOO_SHORT, 58 | passHasError: true, 59 | emailHasError: false, 60 | error: true 61 | }); 62 | break; 63 | case "password_too_long": 64 | this.setState({ 65 | errorMsg: strings.PASSWORD_TOO_LONG, 66 | passHasError: true, 67 | emailHasError: false, 68 | error: true 69 | }); 70 | break; 71 | 72 | case "email_exists": 73 | this.setState({ 74 | errorMsg: strings.EMAIL_EXISTS, 75 | emailHasError: true, 76 | passHasError: false, 77 | error: true 78 | }); 79 | break; 80 | 81 | case "auth_fail": 82 | this.setState({ 83 | errorMsg: strings.AUTHENTICATION_FAIL, 84 | emailHasError: true, 85 | passHasError: true, 86 | error: true 87 | }); 88 | break; 89 | default: 90 | break; 91 | } 92 | } 93 | 94 | render() { 95 | return ( 96 |
97 |
98 |

{this.props.type === "login" ? strings.AUTHENTICATION_LOGIN_TO_BACKPULSE : strings.AUTHENICATION_CREATE_BACKPULSE_ACCOUNT}

99 | 100 |
101 | 102 | this.setState({ 111 | email: e.target.value 112 | })} 113 | /> 114 | 115 | 116 | this.setState({ 124 | password: e.target.value 125 | })} 126 | /> 127 | 128 | {this.state.error && 129 | {this.state.errorMsg} 130 | } 131 | 132 | 136 | 137 |
138 | {this.props.type === "login" && 139 | {strings.NOT_REGISTERED_YET} 140 | } 141 | {this.props.type !== "login" && 142 | {strings.ALREADY_REGISTERED} 143 | } 144 |
145 |
146 |
147 | ); 148 | } 149 | } 150 | 151 | export default Authentication; -------------------------------------------------------------------------------- /src/pages/homepage/Authentication/styles.scss: -------------------------------------------------------------------------------- 1 | .homepage.homepage-authentication { 2 | min-height: 100vh; 3 | background: #0e1e25; 4 | 5 | color: white; 6 | 7 | display: flex; 8 | justify-content: center; 9 | 10 | 11 | h1 { 12 | font-size: 36px; 13 | font-weight: 300; 14 | line-height: 48px; 15 | margin-bottom: 52px; 16 | text-align: center; 17 | margin-top: 150px; 18 | } 19 | 20 | .form { 21 | padding: 32px 40px 40px; 22 | width: 70%; 23 | margin: 0 auto; 24 | position: relative; 25 | 26 | input { 27 | color: #0e1e25!important; 28 | } 29 | 30 | p { 31 | position: absolute; 32 | margin-top: 0; 33 | } 34 | 35 | button { 36 | margin-top: 20px; 37 | } 38 | 39 | a { 40 | font-size: 12px; 41 | color: #0e1e25; 42 | bottom: 7px; 43 | position: absolute; 44 | } 45 | } 46 | } -------------------------------------------------------------------------------- /src/pages/homepage/Home/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | import './styles.scss'; 4 | 5 | class Home extends React.Component { 6 | render() { 7 | return ( 8 |
9 | Homepage home 10 |
11 | ); 12 | } 13 | } 14 | 15 | export default Home; -------------------------------------------------------------------------------- /src/pages/homepage/Home/styles.scss: -------------------------------------------------------------------------------- 1 | .homepage.homepage-home { 2 | min-height: 100vh; 3 | // background: #0e1e25; 4 | } -------------------------------------------------------------------------------- /src/pages/homepage/index.js: -------------------------------------------------------------------------------- 1 | import Home from './Home'; 2 | import Authentication from './Authentication'; 3 | 4 | export { 5 | Home, 6 | Authentication 7 | }; -------------------------------------------------------------------------------- /src/pages/index.js: -------------------------------------------------------------------------------- 1 | import About from './About'; 2 | import Contact from './Contact'; 3 | import Projects from './Projects'; 4 | import MySites from './MySites'; 5 | import SiteEditor from './SiteEditor'; 6 | import Settings from './Settings'; 7 | import Overview from './Overview'; 8 | import Galleries from './Galleries'; 9 | import EditProject from './EditProject'; 10 | import EditGallery from './EditGallery'; 11 | 12 | export { 13 | MySites, 14 | About, 15 | Contact, 16 | Projects, 17 | SiteEditor, 18 | Settings, 19 | Overview, 20 | Galleries, 21 | EditProject, 22 | EditGallery 23 | } -------------------------------------------------------------------------------- /src/serviceWorker.js: -------------------------------------------------------------------------------- 1 | // This optional code is used to register a service worker. 2 | // register() is not called by default. 3 | 4 | // This lets the app load faster on subsequent visits in production, and gives 5 | // it offline capabilities. However, it also means that developers (and users) 6 | // will only see deployed updates on subsequent visits to a page, after all the 7 | // existing tabs open on the page have been closed, since previously cached 8 | // resources are updated in the background. 9 | 10 | // To learn more about the benefits of this model and instructions on how to 11 | // opt-in, read http://bit.ly/CRA-PWA 12 | 13 | const isLocalhost = Boolean( 14 | window.location.hostname === 'localhost' || 15 | // [::1] is the IPv6 localhost address. 16 | window.location.hostname === '[::1]' || 17 | // 127.0.0.1/8 is considered localhost for IPv4. 18 | window.location.hostname.match( 19 | /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/ 20 | ) 21 | ); 22 | 23 | export function register(config) { 24 | if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) { 25 | // The URL constructor is available in all browsers that support SW. 26 | const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href); 27 | if (publicUrl.origin !== window.location.origin) { 28 | // Our service worker won't work if PUBLIC_URL is on a different origin 29 | // from what our page is served on. This might happen if a CDN is used to 30 | // serve assets; see https://github.com/facebook/create-react-app/issues/2374 31 | return; 32 | } 33 | 34 | window.addEventListener('load', () => { 35 | const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`; 36 | 37 | if (isLocalhost) { 38 | // This is running on localhost. Let's check if a service worker still exists or not. 39 | checkValidServiceWorker(swUrl, config); 40 | 41 | // Add some additional logging to localhost, pointing developers to the 42 | // service worker/PWA documentation. 43 | navigator.serviceWorker.ready.then(() => { 44 | console.log( 45 | 'This web app is being served cache-first by a service ' + 46 | 'worker. To learn more, visit http://bit.ly/CRA-PWA' 47 | ); 48 | }); 49 | } else { 50 | // Is not localhost. Just register service worker 51 | registerValidSW(swUrl, config); 52 | } 53 | }); 54 | } 55 | } 56 | 57 | function registerValidSW(swUrl, config) { 58 | navigator.serviceWorker 59 | .register(swUrl) 60 | .then(registration => { 61 | registration.onupdatefound = () => { 62 | const installingWorker = registration.installing; 63 | if (installingWorker == null) { 64 | return; 65 | } 66 | installingWorker.onstatechange = () => { 67 | if (installingWorker.state === 'installed') { 68 | if (navigator.serviceWorker.controller) { 69 | // At this point, the updated precached content has been fetched, 70 | // but the previous service worker will still serve the older 71 | // content until all client tabs are closed. 72 | console.log( 73 | 'New content is available and will be used when all ' + 74 | 'tabs for this page are closed. See http://bit.ly/CRA-PWA.' 75 | ); 76 | 77 | // Execute callback 78 | if (config && config.onUpdate) { 79 | config.onUpdate(registration); 80 | } 81 | } else { 82 | // At this point, everything has been precached. 83 | // It's the perfect time to display a 84 | // "Content is cached for offline use." message. 85 | console.log('Content is cached for offline use.'); 86 | 87 | // Execute callback 88 | if (config && config.onSuccess) { 89 | config.onSuccess(registration); 90 | } 91 | } 92 | } 93 | }; 94 | }; 95 | }) 96 | .catch(error => { 97 | console.error('Error during service worker registration:', error); 98 | }); 99 | } 100 | 101 | function checkValidServiceWorker(swUrl, config) { 102 | // Check if the service worker can be found. If it can't reload the page. 103 | fetch(swUrl) 104 | .then(response => { 105 | // Ensure service worker exists, and that we really are getting a JS file. 106 | const contentType = response.headers.get('content-type'); 107 | if ( 108 | response.status === 404 || 109 | (contentType != null && contentType.indexOf('javascript') === -1) 110 | ) { 111 | // No service worker found. Probably a different app. Reload the page. 112 | navigator.serviceWorker.ready.then(registration => { 113 | registration.unregister().then(() => { 114 | window.location.reload(); 115 | }); 116 | }); 117 | } else { 118 | // Service worker found. Proceed as normal. 119 | registerValidSW(swUrl, config); 120 | } 121 | }) 122 | .catch(() => { 123 | console.log( 124 | 'No internet connection found. App is running in offline mode.' 125 | ); 126 | }); 127 | } 128 | 129 | export function unregister() { 130 | if ('serviceWorker' in navigator) { 131 | navigator.serviceWorker.ready.then(registration => { 132 | registration.unregister(); 133 | }); 134 | } 135 | } 136 | -------------------------------------------------------------------------------- /src/services/client.js: -------------------------------------------------------------------------------- 1 | import axios from 'axios'; 2 | import {getLanguage} from 'utils'; 3 | import {getJWT} from 'utils/token'; 4 | 5 | const httpClient = axios.create({ 6 | baseURL: process.env.NODE_ENV === "development" ? process.env.REACT_APP_DEV_ENDPOINT : process.env.REACT_APP_PROD_ENDPOINT, 7 | headers: { 8 | "Language": getLanguage(), 9 | "Authorization": getJWT() 10 | } 11 | }); 12 | 13 | httpClient.interceptors.response.use((response) => { 14 | return response; 15 | }, function (error) { 16 | return Promise.reject(error.response); 17 | }); 18 | 19 | export default httpClient; -------------------------------------------------------------------------------- /src/styles/fonts.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backpulse/dashboard/02ac7a964f938124c23f9bac59e750b5fa220abe/src/styles/fonts.scss -------------------------------------------------------------------------------- /src/styles/styles.scss: -------------------------------------------------------------------------------- 1 | body, html, #root,.app,.app-container { 2 | height: 100%; 3 | margin: 0; 4 | padding: 0; 5 | font-family: -apple-system,system-ui,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif 6 | } 7 | 8 | .page { 9 | button[type="submit"] { 10 | margin-bottom: 15px; 11 | } 12 | } 13 | 14 | .app { 15 | div.page { 16 | padding-top: 85px; 17 | padding-left: 275px; 18 | padding-right: 25px; 19 | min-height: calc(100% - 85px); 20 | 21 | @media screen and(max-width: 960px) { 22 | padding-left: 25px; 23 | } 24 | 25 | h1 { 26 | font-size: 36px; 27 | font-weight: 300; 28 | line-height: 48px; 29 | } 30 | } 31 | } 32 | 33 | .pointer { 34 | cursor: pointer; 35 | } 36 | 37 | .dark { 38 | input,textarea { 39 | color: white!important; 40 | } 41 | div.page { 42 | background-color: #0e1e25fa; 43 | } 44 | h1,h2,h3,h4,h5 { 45 | color: #e3e3e3!important; 46 | } 47 | } 48 | 49 | .light { 50 | div.page { 51 | } 52 | h1 { 53 | color: #0e1e25; 54 | } 55 | } 56 | 57 | 58 | .c-div { 59 | @media screen and (max-width: 600px) { 60 | width: 100%; 61 | } 62 | 63 | width: fit-content; 64 | } 65 | 66 | h1,h2,h3,h4,h5 { 67 | font-weight: 300; 68 | line-height: 48px; 69 | } 70 | 71 | h1 { 72 | font-size: 36px; 73 | } 74 | 75 | h2 { 76 | font-size: 30px; 77 | } 78 | 79 | h1,h2,h3,p { 80 | margin: 0; 81 | } 82 | 83 | a { 84 | text-decoration: none!important; 85 | // color: rgba(0, 0, 0, 0.87)!important; 86 | } 87 | 88 | .hide-desktop { 89 | @media screen and (min-width: 960px) { 90 | display: none!important; 91 | } 92 | } 93 | 94 | .fab { 95 | position: fixed!important; 96 | bottom: 15px; 97 | right: 15px; 98 | z-index: 99; 99 | } 100 | 101 | .divider { 102 | border-color: #eef1f6; 103 | border-bottom-style: solid; 104 | border-bottom-width: 1px; 105 | } 106 | 107 | .menu-appbar { 108 | *:focus {outline:0;} 109 | } 110 | 111 | .MuiTypography-body1-50 { 112 | line-height: 1.75!important; 113 | } 114 | 115 | .overflow-hidden { 116 | textarea { 117 | overflow: hidden!important; 118 | } 119 | } 120 | 121 | .button-danger { 122 | color: white!important; 123 | background-color: #f44336!important; 124 | 125 | &:disabled { 126 | opacity: 0.6; 127 | } 128 | } 129 | .button-danger-outlined { 130 | border-color: #f44336!important; 131 | color: #f44336!important; 132 | } 133 | 134 | .value-container { 135 | display: flex!important; 136 | flex-wrap: wrap!important; 137 | flex: 1!important; 138 | align-items: center!important; 139 | overflow: hidden!important; 140 | } 141 | 142 | .select-placeholder { 143 | position: absolute!important; 144 | left: 2px!important; 145 | font-size: 16px!important; 146 | } 147 | 148 | .select-menu { 149 | position: absolute!important; 150 | z-index: 1!important; 151 | margin-top: 8px!important; 152 | left: 0!important; 153 | right: 0!important; 154 | } 155 | 156 | .select-input { 157 | flex: 1!important; 158 | padding: 0!important; 159 | } 160 | 161 | .title-div { 162 | display: flex; 163 | margin-bottom: 15px; 164 | align-items: center; 165 | h1 { 166 | display: inline-block!important; 167 | margin-right: 15px; 168 | } 169 | } 170 | 171 | .margin-10 { 172 | margin: 10px; 173 | } 174 | 175 | .progress { 176 | margin-top: 6px; 177 | position: absolute; 178 | 179 | .circular { 180 | margin-top: 24px!important; 181 | position: absolute; 182 | } 183 | } 184 | 185 | 186 | .red-text { 187 | color: #e74c3c!important; 188 | } 189 | 190 | .draggable { 191 | margin: 10px; 192 | } 193 | 194 | .fit-content { 195 | width: fit-content; 196 | } -------------------------------------------------------------------------------- /src/utils/index.js: -------------------------------------------------------------------------------- 1 | export const copy = text => { 2 | const el = document.createElement('textarea'); 3 | el.id = "dummy"; 4 | el.value = text; 5 | document.body.appendChild(el); 6 | el.select(); 7 | document.execCommand('copy'); 8 | document.body.removeChild(el); 9 | } 10 | 11 | export const getTheme = () => { 12 | const theme = localStorage.getItem("theme"); 13 | if (theme === "light") return "light"; 14 | return "dark"; 15 | } 16 | 17 | export const toggleTheme = () => { 18 | const theme = getTheme(); 19 | if (theme === "dark") { 20 | localStorage.setItem("theme", "light"); 21 | } else { 22 | localStorage.setItem("theme", "dark"); 23 | } 24 | } 25 | 26 | export const getLanguage = () => { 27 | const navigatorLang = navigator.language.substr(0, 2); 28 | let lang = localStorage.getItem("language") || navigatorLang; 29 | if (lang !== "fr" && lang !== "en") { 30 | lang = "en"; 31 | } 32 | return lang; 33 | } 34 | 35 | export const setLanguage = lang => { 36 | localStorage.setItem("language", lang); 37 | window.dispatchEvent(new CustomEvent("language"), { 38 | detail: { 39 | language: lang 40 | } 41 | }); 42 | } 43 | 44 | export function validateEmail(email) { 45 | var re = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; 46 | return re.test(String(email).toLowerCase()); 47 | } 48 | 49 | export function toTitleCase(str) { 50 | return str.replace( 51 | /\w\S*/g, 52 | function(txt) { 53 | return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase(); 54 | } 55 | ); 56 | } 57 | 58 | export const reorder = (list, startIndex, endIndex) => { 59 | const result = Array.from(list); 60 | const [removed] = result.splice(startIndex, 1); 61 | result.splice(endIndex, 0, removed); 62 | return result; 63 | }; 64 | 65 | export const sortByIndex = array => { 66 | return array.sort(function(a, b){return a.index - b.index}); 67 | } 68 | 69 | export const youtubeParser = url => { 70 | const regExp = /^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#&?]*).*/; 71 | const match = url.match(regExp); 72 | return (match&&match[7].length===11)? match[7] : false; 73 | } -------------------------------------------------------------------------------- /src/utils/token.js: -------------------------------------------------------------------------------- 1 | export function saveJWT(token) { 2 | localStorage.setItem("JWT", "Bearer " + token); 3 | } 4 | 5 | export function getJWT() { 6 | return localStorage.getItem("JWT"); 7 | } 8 | 9 | export function removeJWT() { 10 | localStorage.setItem("JWT", ""); 11 | } 12 | 13 | export function signOut() { 14 | removeJWT(); 15 | window.location = "https://backpulse.io"; 16 | } 17 | 18 | export function getUser() { 19 | const token = getJWT(); 20 | if(token) { 21 | var base64Url = token.split('.')[1]; 22 | var base64 = base64Url.replace('-', '+').replace('_', '/'); 23 | return JSON.parse(window.atob(base64)); 24 | } 25 | } --------------------------------------------------------------------------------