Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
restmount committed Oct 29, 2016
0 parents commit 07c6028
Show file tree
Hide file tree
Showing 84 changed files with 3,422 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets" : ["es2015", "react", "stage-2"],
}
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# http://editorconfig.org
root = true

[*]
indent_style = tab
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
10 changes: 10 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"parser": "babel-eslint",
"env": {
"browser": true,
"node": true
},
"rules": {
"quotes": "off"
}
}
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules
public/admin/assets/css/bundle.css
public/admin/assets/js/bundle.js
public/admin/assets/images
public/themes
public/uploads
7 changes: 7 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
admin
node_modules
public/admin/assets/css/bundle.css
public/admin/assets/js/bundle.js
public/admin/assets/images
public/themes
public/uploads
22 changes: 22 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

MIT License

Copyright (c) 2016 cezerin

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
## Files structure

```
public
uploads
categories
{id}
file.png
products
{id}
file.png
brands
{id}
file.png
files
file.png
admin
themes
config
api
server
admin
client
store
server
```
70 changes: 70 additions & 0 deletions admin/client/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import React from 'react'
import ReactDOM from 'react-dom'
import { Router, Route, browserHistory, IndexRoute } from 'react-router'
import { createStore, applyMiddleware } from 'redux'
import { Provider } from 'react-redux'
import thunkMiddleware from 'redux-thunk'
import { syncHistoryWithStore, routerReducer, routerMiddleware, push } from 'react-router-redux'

import settings from 'lib/settings'
import messages from 'src/locale'
import reducers from 'src/rootReducer'

import layoutLogin from 'layout/login'
import layoutShared from 'layout/shared'
import layoutHome from 'layout/home'
import layoutNotFound from 'layout/404'
import layoutProducts from 'layout/products'
import layoutProductsEdit from 'layout/products/edit'
import layoutProductsCategories from 'layout/products/categories'

const routerMiddlewareConst = routerMiddleware(browserHistory);
const store = createStore(reducers, applyMiddleware(thunkMiddleware, routerMiddlewareConst));
const history = syncHistoryWithStore(browserHistory, store)



function checkLogged(nextState, replace) {
if(localStorage.getItem('token')) {
replace({
pathname: '/admin',
state: { nextPathname: nextState.location.pathname }
})
}
}

function checkToken(nextState, replace){
if(nextState.location.pathname !== settings.admin.pages.login && !localStorage.getItem('token')) {
replace({
pathname: settings.admin.pages.login,
state: { nextPathname: nextState.location.pathname }
})
}
}

function removeToken(nextState, replace){
localStorage.removeItem('token');
location.replace(settings.admin.pages.login);
}


var appElement = document.getElementById('app');
ReactDOM.render(
<Provider store={store}>
<Router history={history}>
<Route path="/admin" onEnter={checkToken}>
<Route path="login" component={layoutLogin} onEnter={checkLogged} />
<Route path="logout" component={layoutNotFound} onEnter={removeToken} />
<Route component={layoutShared}>
<IndexRoute component={layoutHome} />
<Route path="orders" component={layoutNotFound} />
<Route path="cusomers" component={layoutNotFound} />
<Route path="products" component={layoutProducts} />
<Route path="product/:url" component={layoutNotFound} />
<Route path="products/categories" component={layoutProductsCategories} />
<Route path="*" component={layoutNotFound} />
</Route>
</Route>
</Router>
</Provider>
, appElement)
7 changes: 7 additions & 0 deletions admin/client/layout/404.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import React from 'react'

export default () => (
<div>
Page not found!
</div>
)
17 changes: 17 additions & 0 deletions admin/client/layout/home.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from 'react'

import FontIcon from 'material-ui/FontIcon';

export const Layout = () => (
<div>
<FontIcon className="material-icons">attach_file</FontIcon>
<FontIcon className="material-icons">add_a_photo</FontIcon>
<FontIcon className="material-icons">delete</FontIcon>
<FontIcon className="material-icons">done</FontIcon>
<FontIcon className="material-icons">search</FontIcon>
<FontIcon className="material-icons">content_copy</FontIcon>
<FontIcon className="material-icons">clear</FontIcon>
</div>
)

export default Layout
25 changes: 25 additions & 0 deletions admin/client/layout/login.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import React from 'react'
import Login from 'modules/app/login'

// import {deepPurple500} from 'material-ui/styles/colors';
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider';
import getMuiTheme from 'material-ui/styles/getMuiTheme';

const muiTheme = getMuiTheme({
palette: {
// textColor: deepPurple500,
},
appBar: {
//height: 50,
},
});

export default () => (
<MuiThemeProvider muiTheme={muiTheme}>
<div className="row col-full-height center-xs middle-xs">
<div className="col-xs-10 col-sm-6 col-md-5 col-lg-4">
<Login />
</div>
</div>
</MuiThemeProvider>
)
14 changes: 14 additions & 0 deletions admin/client/layout/products/categories/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React from 'react'
import CategoryEdit from 'modules/product-categories/edit';
import Categories from 'modules/product-categories/list';

export default () => (
<div className="row row--no-gutter col-full-height">
<div className="col-xs-3 col--no-gutter scroll col-categories">
<Categories showAll={false} showTrash={false} showAdd={true} />
</div>
<div className="col-xs-9 col--no-gutter scroll">
<CategoryEdit />
</div>
</div>
)
Empty file.
23 changes: 23 additions & 0 deletions admin/client/layout/products/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React from 'react'
import { Link } from 'react-router'
import ProductsList from 'modules/products/list';
import Categories from 'modules/product-categories/list';
import FloatingActionButton from 'material-ui/FloatingActionButton';
import FontIcon from 'material-ui/FontIcon';
import Subheader from 'material-ui/Subheader';

export default () => (
<div className="row row--no-gutter col-full-height">
<div className="col-xs-3 col--no-gutter scroll col-categories">
<Categories showAll={true} showTrash={true} showAdd={false}/>
</div>
<div className="col-xs-9 col--no-gutter scroll">
<ProductsList />
<Link to="/admin/product/add">
<FloatingActionButton secondary={false} style={{position: 'fixed', right: '25px', bottom: '15px'}}>
<FontIcon className="material-icons">add</FontIcon>
</FloatingActionButton>
</Link>
</div>
</div>
)
Empty file added admin/client/layout/recover.js
Empty file.
36 changes: 36 additions & 0 deletions admin/client/layout/shared.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import React from 'react'
import Head from 'modules/app/head'

// import {deepPurple500} from 'material-ui/styles/colors';
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider';
import getMuiTheme from 'material-ui/styles/getMuiTheme';

import injectTapEventPlugin from 'react-tap-event-plugin';
injectTapEventPlugin();

const muiTheme = getMuiTheme({
palette: {
// textColor: deepPurple500,
},
appBar: {
//height: 50,
},
});

const Layout = ({ children }) => (
<MuiThemeProvider muiTheme={muiTheme}>
<div id="container">
<div id="headContainer">
<Head />
</div>
<div id="bodyContainer">
{children}
</div>
</div>
</MuiThemeProvider>
)

Layout.propTypes = {
children: React.PropTypes.element.isRequired
}
export default Layout
12 changes: 12 additions & 0 deletions admin/client/lib/api/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import api from 'cezerin-client'
import settings from 'lib/settings'

let token = localStorage.getItem('token');
if(token) {
api.init(
settings.api.url.base,
settings.api.language.default,
token);
}

export default api;
12 changes: 12 additions & 0 deletions admin/client/lib/settings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
var yaml = require('js-yaml');
var settings = null;

var request = new XMLHttpRequest();
request.open('GET', '/admin/assets/js/config/settings.yml', false);
request.send();

if (request.status === 200) {
settings = yaml.safeLoad(request.responseText);
}

export default settings
72 changes: 72 additions & 0 deletions admin/client/locale/en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
{
"trash": "Trash",
"slug": "Slug",
"active": "Active",
"draft": "Draft",
"description": "Description",
"metaDescription": "Meta Description",
"pageTitle": "Page title",
"learnMore": "LEARN MORE",

"actions": {
"cancel": "Cancel",
"save": "Save",
"add": "Add",
"delete": "Delete",
"remove": "Remove",
"moveHere": "Move here",
"moveTo": "Move to...",
"moveUp": "Move Up",
"moveDown": "Move Down",
"done": "Done",
"upload": "Upload",
"discardDraft": "Discard draft"
},

"messages": {
"saving": "Saving...",
"saved": "Saved",
"loading": "Loading...",
"uploading": "Uploading...",
"uploadComplete": "Upload complete",
"deleteConfirmation": "Are you sure you want to delete this item?"
},

"help": {
"dropHere": "Drop file here to upload",
"slug": "The “slug” is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens."
},

"errors": {
"required": "This field is required.",
"email": "Please enter a valid email address.",
"url": "Please enter a valid URL.",
"number": "Please enter a valid number.",
"urlTaken": "URL is taken or contains a reserved word"
},

"login": {
"title": "Login",
"email": "Email",
"password": "Password",
"loginButton": "Login",
"recoveyButton": "Forgot password?",
"error": "Invalid login or password"
},

"products": {
"title": "Products",
"name": "Product name"
},

"productCategories": {
"titleAdd": "Add new category",
"titleEdit": "Edit category",
"name": "Category name",
"all": "All Products",
"root": "Root",
"title": "Categories",
"aboutDelete": "Will delete category {name} with all childs and move products to Archive."
}

}
Loading

0 comments on commit 07c6028

Please sign in to comment.