reactjs
This commit is contained in:
parent
8fc0b4bb05
commit
bc2fbbda68
@ -5,4 +5,5 @@ RedirectMatch 404 /\.git
|
|||||||
|
|
||||||
RewriteEngine On
|
RewriteEngine On
|
||||||
RewriteRule ^api/(.*)?$ index.php?api=$1&$2 [L,QSA]
|
RewriteRule ^api/(.*)?$ index.php?api=$1&$2 [L,QSA]
|
||||||
|
RewriteRule ^admin(/(.*)?)?$ index.php?site=admin&$1 [L,QSA]
|
||||||
RewriteRule ^((?!((js|css|img|fonts|api|docs)($|/)))(.*)?)$ index.php?site=$1&$2 [L,QSA]
|
RewriteRule ^((?!((js|css|img|fonts|api|docs)($|/)))(.*)?)$ index.php?site=$1&$2 [L,QSA]
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="JavaScriptSettings">
|
<component name="JavaScriptSettings">
|
||||||
<option name="languageLevel" value="ES6" />
|
<option name="languageLevel" value="JSX" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
3
admin/.babelrc
Normal file
3
admin/.babelrc
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"presets": ["@babel/preset-env", "@babel/preset-react"]
|
||||||
|
}
|
23
admin/.gitignore
vendored
Normal file
23
admin/.gitignore
vendored
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
||||||
|
|
||||||
|
# dependencies
|
||||||
|
/node_modules
|
||||||
|
/.pnp
|
||||||
|
.pnp.js
|
||||||
|
|
||||||
|
# testing
|
||||||
|
/coverage
|
||||||
|
|
||||||
|
# production
|
||||||
|
/build
|
||||||
|
|
||||||
|
# misc
|
||||||
|
.DS_Store
|
||||||
|
.env.local
|
||||||
|
.env.development.local
|
||||||
|
.env.test.local
|
||||||
|
.env.production.local
|
||||||
|
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
68
admin/README.md
Normal file
68
admin/README.md
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
|
||||||
|
|
||||||
|
## Available Scripts
|
||||||
|
|
||||||
|
In the project directory, you can run:
|
||||||
|
|
||||||
|
### `npm start`
|
||||||
|
|
||||||
|
Runs the app in the development mode.<br />
|
||||||
|
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
|
||||||
|
|
||||||
|
The page will reload if you make edits.<br />
|
||||||
|
You will also see any lint errors in the console.
|
||||||
|
|
||||||
|
### `npm test`
|
||||||
|
|
||||||
|
Launches the test runner in the interactive watch mode.<br />
|
||||||
|
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
|
||||||
|
|
||||||
|
### `npm run build`
|
||||||
|
|
||||||
|
Builds the app for production to the `build` folder.<br />
|
||||||
|
It correctly bundles React in production mode and optimizes the build for the best performance.
|
||||||
|
|
||||||
|
The build is minified and the filenames include the hashes.<br />
|
||||||
|
Your app is ready to be deployed!
|
||||||
|
|
||||||
|
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
|
||||||
|
|
||||||
|
### `npm run eject`
|
||||||
|
|
||||||
|
**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
## Learn More
|
||||||
|
|
||||||
|
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
|
||||||
|
|
||||||
|
To learn React, check out the [React documentation](https://reactjs.org/).
|
||||||
|
|
||||||
|
### Code Splitting
|
||||||
|
|
||||||
|
This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting
|
||||||
|
|
||||||
|
### Analyzing the Bundle Size
|
||||||
|
|
||||||
|
This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size
|
||||||
|
|
||||||
|
### Making a Progressive Web App
|
||||||
|
|
||||||
|
This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app
|
||||||
|
|
||||||
|
### Advanced Configuration
|
||||||
|
|
||||||
|
This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration
|
||||||
|
|
||||||
|
### Deployment
|
||||||
|
|
||||||
|
This section has moved here: https://facebook.github.io/create-react-app/docs/deployment
|
||||||
|
|
||||||
|
### `npm run build` fails to minify
|
||||||
|
|
||||||
|
This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify
|
4147
admin/dist/main.js
vendored
Normal file
4147
admin/dist/main.js
vendored
Normal file
File diff suppressed because one or more lines are too long
16739
admin/package-lock.json
generated
Normal file
16739
admin/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
41
admin/package.json
Normal file
41
admin/package.json
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
{
|
||||||
|
"name": "admin",
|
||||||
|
"version": "0.1.0",
|
||||||
|
"private": true,
|
||||||
|
"dependencies": {
|
||||||
|
"@testing-library/jest-dom": "^4.2.4",
|
||||||
|
"@testing-library/react": "^9.5.0",
|
||||||
|
"@testing-library/user-event": "^7.2.1",
|
||||||
|
"adminlte-reactjs": "^1.0.6",
|
||||||
|
"react": "^16.13.1",
|
||||||
|
"react-dom": "^16.13.1",
|
||||||
|
"react-scripts": "3.4.1"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"build": "webpack --mode development && cp dist/main.js ../js/admin.min.js"
|
||||||
|
},
|
||||||
|
"eslintConfig": {
|
||||||
|
"extends": "react-app"
|
||||||
|
},
|
||||||
|
"browserslist": {
|
||||||
|
"production": [
|
||||||
|
">0.2%",
|
||||||
|
"not dead",
|
||||||
|
"not op_mini all"
|
||||||
|
],
|
||||||
|
"development": [
|
||||||
|
"last 1 chrome version",
|
||||||
|
"last 1 firefox version",
|
||||||
|
"last 1 safari version"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@babel/core": "^7.10.2",
|
||||||
|
"@babel/preset-env": "^7.10.2",
|
||||||
|
"@babel/preset-react": "^7.10.1",
|
||||||
|
"babel-loader": "^8.1.0",
|
||||||
|
"babel-polyfill": "^6.26.0",
|
||||||
|
"webpack": "^4.43.0",
|
||||||
|
"webpack-cli": "^3.3.11"
|
||||||
|
}
|
||||||
|
}
|
20
admin/src/api.js
Normal file
20
admin/src/api.js
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
import 'babel-polyfill';
|
||||||
|
|
||||||
|
export default class API {
|
||||||
|
constructor() {
|
||||||
|
this.user = {};
|
||||||
|
this.baseUrl = "http://localhost"
|
||||||
|
}
|
||||||
|
|
||||||
|
async fetchUser() {
|
||||||
|
let response = await fetch(this.baseUrl + "/api/user/fetch");
|
||||||
|
let data = await response.json()
|
||||||
|
this.user = data["users"][0];
|
||||||
|
return data && data.success && data.hasOwnProperty("logoutIn");
|
||||||
|
}
|
||||||
|
|
||||||
|
async logout() {
|
||||||
|
let response = await fetch(this.baseUrl + "/api/user/logout");
|
||||||
|
return await response.json();
|
||||||
|
}
|
||||||
|
};
|
42
admin/src/dialog.js
Normal file
42
admin/src/dialog.js
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
import React from "react";
|
||||||
|
|
||||||
|
export default class Dialog extends React.Component {
|
||||||
|
|
||||||
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
this.state = { hidden: !!props.hidden };
|
||||||
|
}
|
||||||
|
|
||||||
|
onClose() {
|
||||||
|
this.setState({ hidden: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
|
||||||
|
console.log("Rendering dialog with:", this.props);
|
||||||
|
|
||||||
|
let classes = "modal fade";
|
||||||
|
if (!this.state.hidden) {
|
||||||
|
classes *= " show";
|
||||||
|
}
|
||||||
|
|
||||||
|
return <div className={classes} id="modal-default" style={{paddingRight: "12px"}} aria-modal="true" onClick={() => this.onClose()}>
|
||||||
|
<div className="modal-dialog" onClick={(e) => e.stopPropagation()}>
|
||||||
|
<div className="modal-content">
|
||||||
|
<div className="modal-header">
|
||||||
|
<h4 className="modal-title">{this.props.title}</h4>
|
||||||
|
<button type="button" className="close" data-dismiss="modal" aria-label="Close" onClick={() => this.onClose()}>
|
||||||
|
<span aria-hidden="true">×</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div className="modal-body">
|
||||||
|
<p>{this.props.message}</p>
|
||||||
|
</div>
|
||||||
|
<div className="modal-footer justify-content-between">
|
||||||
|
<button type="button" className="btn btn-default" data-dismiss="modal" onClick={() => this.onClose()}>Close</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
}
|
59
admin/src/header.js
Normal file
59
admin/src/header.js
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
import * as React from "react";
|
||||||
|
import Icon from "./icon";
|
||||||
|
|
||||||
|
export default class Header extends React.Component {
|
||||||
|
render() {
|
||||||
|
|
||||||
|
let notificationCount = 0;
|
||||||
|
let notificationText = "";
|
||||||
|
|
||||||
|
return <nav className={"main-header navbar navbar-expand navbar-white navbar-light"}>
|
||||||
|
|
||||||
|
{/*Left navbar links */}
|
||||||
|
<ul className={"navbar-nav"}>
|
||||||
|
<li className={"nav-item"}>
|
||||||
|
<a href={"#"} className={"nav-link"} data-widget={"pushmenu"} role={"button"}>
|
||||||
|
<Icon icon={"bars"}/>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li className={"nav-item d-none d-sm-inline-block"}>
|
||||||
|
<a href={"#"} className={"nav-link"}>
|
||||||
|
Home
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
{/* SEARCH FORM */}
|
||||||
|
<form className={"form-inline ml-3"}>
|
||||||
|
<div className={"input-group input-group-sm"}>
|
||||||
|
<input className={"form-control form-control-navbar"} type={"search"} placeholder={"Search"} aria-label={"Search"} />
|
||||||
|
<div className={"input-group-append"}>
|
||||||
|
<button className={"btn btn-navbar"} type={"submit"}>
|
||||||
|
<Icon icon={"search"}/>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
{/* Right navbar links */}
|
||||||
|
<ul className={"navbar-nav ml-auto"}>
|
||||||
|
{/* Notifications Dropdown Menu */}
|
||||||
|
<li className={"nav-item dropdown"}>
|
||||||
|
<a href={"#"} className={"nav-link"} data-toggle={"dropdown"}>
|
||||||
|
<Icon class={"bell"} type={"far"} />
|
||||||
|
<span className={"badge badge-warning navbar-badge"}>
|
||||||
|
{notificationCount}
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
|
<div className={"dropdown-menu dropdown-menu-lg dropdown-menu-right"}>
|
||||||
|
<span className={"dropdown-item dropdown-header"}>
|
||||||
|
{notificationText}
|
||||||
|
</span>
|
||||||
|
<div className={"dropdown-divider"} />
|
||||||
|
<a href={"#"} className={"dropdown-item dropdown-footer"}>See All Notifications</a>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
}
|
||||||
|
}
|
20
admin/src/icon.js
Normal file
20
admin/src/icon.js
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
import * as React from "react";
|
||||||
|
|
||||||
|
export default function Icon(props) {
|
||||||
|
|
||||||
|
let classes = props.classes || [];
|
||||||
|
classes = Array.isArray(classes) ? classes : classes.toString().split(" ");
|
||||||
|
let type = props.type || "fas";
|
||||||
|
let icon = props.icon;
|
||||||
|
|
||||||
|
classes.push("fa");
|
||||||
|
classes.push(type + "-" + icon);
|
||||||
|
|
||||||
|
if (icon === "spinner") {
|
||||||
|
classes.push("fa-spin");
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<i className={classes.join(" ")} />
|
||||||
|
);
|
||||||
|
}
|
7
admin/src/include/adminlte.min.js
vendored
Normal file
7
admin/src/include/adminlte.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
77
admin/src/include/index.css
Normal file
77
admin/src/include/index.css
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
.main-header {
|
||||||
|
transition: all 0.3s;
|
||||||
|
margin-left: 75px;
|
||||||
|
border-bottom: 1px solid #dee2e6;
|
||||||
|
padding: 0.7rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navbar-badge {
|
||||||
|
font-size: .6rem;
|
||||||
|
font-weight: 300;
|
||||||
|
padding: 2px 4px;
|
||||||
|
position: absolute;
|
||||||
|
right: 3px;
|
||||||
|
top: 7px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navbar-white {
|
||||||
|
background-color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.main-wrapper:not(.sidebar-collapsed) .main-header {
|
||||||
|
transition: all 0.3s;
|
||||||
|
margin-left: 250px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.main-sidebar {
|
||||||
|
background-color: #343a40;
|
||||||
|
width: 250px;
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
height: 100vh;
|
||||||
|
z-index: 999;
|
||||||
|
color: #fff;
|
||||||
|
transition: all 0.3s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.main-sidebar.collapsed {
|
||||||
|
margin-left: 0;
|
||||||
|
width: 4.6rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hide-collapsed {
|
||||||
|
transition: all 0.2s linear;
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.main-sidebar.collapsed .hide-collapsed {
|
||||||
|
opacity: 0;
|
||||||
|
font-size: 0;
|
||||||
|
margin-left: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.main-content {
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.main-wrapper {
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dropdown-menu-lg {
|
||||||
|
max-width: 300px;
|
||||||
|
min-width: 280px;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.brand-link {
|
||||||
|
display: block;
|
||||||
|
font-size: 1.5rem;
|
||||||
|
line-height: 2;
|
||||||
|
padding: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.show {
|
||||||
|
display: block !important;
|
||||||
|
}
|
78
admin/src/index.js
Normal file
78
admin/src/index.js
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import ReactDOM from 'react-dom';
|
||||||
|
import './include/index.css';
|
||||||
|
import './include/adminlte.min.css';
|
||||||
|
// import './include/adminlte.min.js';
|
||||||
|
import API from './api.js';
|
||||||
|
import Header from './header.js';
|
||||||
|
import Sidebar from './sidebar.js';
|
||||||
|
import UserOverview from './users.js';
|
||||||
|
import Overview from './overview.js'
|
||||||
|
import Icon from "./icon";
|
||||||
|
import Dialog from "./dialog";
|
||||||
|
|
||||||
|
class AdminDashboard extends React.Component {
|
||||||
|
|
||||||
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
this.api = new API();
|
||||||
|
this.state = {
|
||||||
|
currentView: "dashboard",
|
||||||
|
loaded: false,
|
||||||
|
dialog: { hidden: true }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
onChangeView(view) {
|
||||||
|
console.log("changing view to: " + view);
|
||||||
|
this.setState({ ...this.state, currentView: view || "dashboard" });
|
||||||
|
}
|
||||||
|
|
||||||
|
showDialog(props) {
|
||||||
|
props = props || { hidden: true };
|
||||||
|
if (!props.hasOwnProperty("hidden")) props.hidden = false;
|
||||||
|
this.setState({ ...this.state, dialog: props });
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
|
||||||
|
if (!this.state.loaded) {
|
||||||
|
this.api.fetchUser().then(Success => {
|
||||||
|
if (!Success) {
|
||||||
|
document.location = "/admin";
|
||||||
|
} else {
|
||||||
|
this.setState({...this.state, loaded: true});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return <b>Loading… <Icon icon={"spinner"} /></b>
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("Rendering mainview with:", this.state.dialog);
|
||||||
|
const dialog = <Dialog {...this.state.dialog}/>
|
||||||
|
const content = this.createContent();
|
||||||
|
|
||||||
|
return <div className={"wrapper"}>
|
||||||
|
<Header />
|
||||||
|
<Sidebar currentView={this.state.currentView} onChangeView={this.onChangeView.bind(this)} showDialog={this.showDialog.bind(this)} api={this.api} />
|
||||||
|
<div className={"content-wrapper p-2"}>
|
||||||
|
<section className={"content"}>
|
||||||
|
{content}
|
||||||
|
{dialog}
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
|
||||||
|
createContent() {
|
||||||
|
if (this.state.currentView === "users") {
|
||||||
|
return <UserOverview />
|
||||||
|
} else {
|
||||||
|
return <Overview />
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ReactDOM.render(
|
||||||
|
<AdminDashboard />,
|
||||||
|
document.getElementById('root')
|
||||||
|
);
|
7
admin/src/overview.js
Normal file
7
admin/src/overview.js
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
import * as React from "react";
|
||||||
|
|
||||||
|
export default class Overview extends React.Component {
|
||||||
|
render() {
|
||||||
|
return <div>Overview</div>
|
||||||
|
}
|
||||||
|
}
|
95
admin/src/sidebar.js
Normal file
95
admin/src/sidebar.js
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import Icon from "./icon";
|
||||||
|
|
||||||
|
export default class Sidebar extends React.Component {
|
||||||
|
|
||||||
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
this.parent = {
|
||||||
|
onChangeView: props.onChangeView || function() { },
|
||||||
|
showDialog: props.showDialog || function() {},
|
||||||
|
api: props.api
|
||||||
|
}
|
||||||
|
this.state = { currentView: props.currentView, }
|
||||||
|
}
|
||||||
|
|
||||||
|
onChangeView(view) {
|
||||||
|
this.setState({ ...this.state, currentView: view });
|
||||||
|
this.parent.onChangeView(view);
|
||||||
|
}
|
||||||
|
|
||||||
|
onLogout() {
|
||||||
|
this.parent.api.logout().then(obj => {
|
||||||
|
if (obj.success) {
|
||||||
|
document.location = "/admin";
|
||||||
|
} else {
|
||||||
|
this.parent.showDialog({message: "Error logging out: " + obj.msg, title: "Error logging out"});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
|
||||||
|
const menuItems = {
|
||||||
|
"dashboard": {
|
||||||
|
"name": "Dashboard",
|
||||||
|
"icon": "tachometer-alt"
|
||||||
|
},
|
||||||
|
"users": {
|
||||||
|
"name": "Users",
|
||||||
|
"icon": "users"
|
||||||
|
},
|
||||||
|
"settings": {
|
||||||
|
"name": "Settings",
|
||||||
|
"icon": "tools"
|
||||||
|
},
|
||||||
|
"help": {
|
||||||
|
"name": "Help",
|
||||||
|
"icon": "question-circle"
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
let li = [];
|
||||||
|
for (let id in menuItems) {
|
||||||
|
let obj = menuItems[id];
|
||||||
|
let active = this.state.currentView === id ? " active" : "";
|
||||||
|
li.push(<li key={id} className={"nav-item"}>
|
||||||
|
<a href={"#"} onClick={() => this.onChangeView(id)} className={"nav-link" + active}>
|
||||||
|
<Icon icon={obj.icon} /><p>{obj.name}</p>
|
||||||
|
</a>
|
||||||
|
</li>);
|
||||||
|
}
|
||||||
|
|
||||||
|
li.push(<li key={"logout"} className={"nav-item"}>
|
||||||
|
<a href={"#"} onClick={() => this.onLogout()} className={"nav-link"}>
|
||||||
|
<Icon icon={"arrow-left"} classes={"nav-icon"} />
|
||||||
|
<p>Logout</p>
|
||||||
|
</a>
|
||||||
|
</li>);
|
||||||
|
|
||||||
|
return <aside className={"main-sidebar sidebar-dark-primary elevation-4"}>
|
||||||
|
<a href={"#"} onClick={() => this.onChangeView("dashboard") } className={"brand-link"}>
|
||||||
|
<img src={"/img/web_base_logo.png"} alt={"WebBase Logo"} className={"brand-image img-circle elevation-3"} style={{"opacity": ".8"}} />
|
||||||
|
<span className={"brand-text font-weight-light"}>WebBase</span>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
{/* Sidebar */}
|
||||||
|
<div className={"sidebar"}>
|
||||||
|
|
||||||
|
<div className={"mt-2"}>
|
||||||
|
Logged in as: {this.parent.api.user.name}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr />
|
||||||
|
|
||||||
|
{/* Sidebar Menu */}
|
||||||
|
<nav className={"mt-2"}>
|
||||||
|
<ul className={"nav nav-pills nav-sidebar flex-column"} data-widget={"treeview"} role={"menu"} data-accordion={"false"}>
|
||||||
|
{li}
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
</aside>
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
7
admin/src/users.js
Normal file
7
admin/src/users.js
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
import * as React from "react";
|
||||||
|
|
||||||
|
export default class UserOverview extends React.Component {
|
||||||
|
render() {
|
||||||
|
return <div>UserOverview</div>
|
||||||
|
}
|
||||||
|
}
|
18
admin/webpack.config.js
Normal file
18
admin/webpack.config.js
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
module.exports = {
|
||||||
|
mode: 'development',
|
||||||
|
module: {
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
test: /\.(js|jsx)$/,
|
||||||
|
exclude: /node_modules/,
|
||||||
|
use: {
|
||||||
|
loader: "babel-loader"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: /\.css$/,
|
||||||
|
use: ['style-loader', 'css-loader']
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
};
|
@ -72,7 +72,7 @@ class Fetch extends Request {
|
|||||||
$groupId = intval($row["groupId"]);
|
$groupId = intval($row["groupId"]);
|
||||||
$groupName = $row["groupName"];
|
$groupName = $row["groupName"];
|
||||||
if (!isset($this->result["users"][$userId])) {
|
if (!isset($this->result["users"][$userId])) {
|
||||||
$this->result["users"][$userId] = array(
|
$this->result["users"][] = array(
|
||||||
"uid" => $userId,
|
"uid" => $userId,
|
||||||
"name" => $row["name"],
|
"name" => $row["name"],
|
||||||
"email" => $row["email"],
|
"email" => $row["email"],
|
||||||
|
@ -17,6 +17,10 @@ class Logout extends Request {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->lastError = "CUSTOM ERROR MESSAGE";
|
||||||
|
$this->success = false;
|
||||||
|
return false;
|
||||||
|
|
||||||
$this->success = $this->user->logout();
|
$this->success = $this->user->logout();
|
||||||
$this->lastError = $this->user->getSQL()->getLastError();
|
$this->lastError = $this->user->getSQL()->getLastError();
|
||||||
return $this->success;
|
return $this->success;
|
||||||
|
@ -29,12 +29,12 @@ namespace Documents\Admin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected function initSources() {
|
protected function initSources() {
|
||||||
$this->loadJQuery();
|
// $this->loadJQuery();
|
||||||
$this->loadFontawesome();
|
// $this->loadFontawesome();
|
||||||
$this->addJS(Script::CORE);
|
// $this->addJS(Script::CORE);
|
||||||
$this->addCSS(Link::CORE);
|
// $this->addCSS(Link::CORE);
|
||||||
$this->addJS(Script::ADMIN);
|
// $this->addJS(Script::ADMIN);
|
||||||
$this->addCSS(Link::ADMIN);
|
// $this->addCSS(Link::ADMIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function initMetas() {
|
protected function initMetas() {
|
||||||
|
@ -6,4 +6,8 @@ abstract class StaticView {
|
|||||||
|
|
||||||
public abstract function getCode();
|
public abstract function getCode();
|
||||||
|
|
||||||
|
public function __toString() {
|
||||||
|
return $this->getCode();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -230,10 +230,10 @@ class AdminDashboardBody extends Body {
|
|||||||
parent::loadView();
|
parent::loadView();
|
||||||
|
|
||||||
$head = $this->getDocument()->getHead();
|
$head = $this->getDocument()->getHead();
|
||||||
$head->addJS(Script::BOOTSTRAP);
|
// $head->addJS("/js/admin.min.js");
|
||||||
$head->loadAdminlte();
|
// $head->loadAdminlte();
|
||||||
|
|
||||||
$this->notifications = $this->getNotifications();
|
// $this->notifications = $this->getNotifications();
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getContent() {
|
private function getContent() {
|
||||||
@ -253,10 +253,14 @@ class AdminDashboardBody extends Body {
|
|||||||
public function getCode() {
|
public function getCode() {
|
||||||
$html = parent::getCode();
|
$html = parent::getCode();
|
||||||
|
|
||||||
|
// $this->getDocument()->getHead()->addJS("/js/admin.min.js");
|
||||||
|
|
||||||
|
/*
|
||||||
$header = $this->getHeader();
|
$header = $this->getHeader();
|
||||||
$sidebar = $this->getSidebar();
|
$sidebar = $this->getSidebar();
|
||||||
$content = $this->getContent();
|
$content = $this->getContent();
|
||||||
|
|
||||||
|
|
||||||
$html .=
|
$html .=
|
||||||
"<!-- LICENSE: /docs/LICENSE_ADMINLTE -->
|
"<!-- LICENSE: /docs/LICENSE_ADMINLTE -->
|
||||||
<body class=\"hold-transition sidebar-mini layout-fixed\">
|
<body class=\"hold-transition sidebar-mini layout-fixed\">
|
||||||
@ -266,7 +270,10 @@ class AdminDashboardBody extends Body {
|
|||||||
$content
|
$content
|
||||||
</div>
|
</div>
|
||||||
</body>";
|
</body>";
|
||||||
|
*/
|
||||||
|
|
||||||
|
$script = new Script(Script::MIME_TEXT_JAVASCRIPT, "/js/admin.min.js");
|
||||||
|
$html .= "<body id=\"root\">$script</body>";
|
||||||
return $html;
|
return $html;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
namespace Views;
|
namespace Views;
|
||||||
|
|
||||||
use Elements\Body;
|
use Elements\Body;
|
||||||
|
use Elements\Link;
|
||||||
|
use Elements\Script;
|
||||||
|
|
||||||
class LoginBody extends Body {
|
class LoginBody extends Body {
|
||||||
|
|
||||||
@ -12,7 +14,14 @@ class LoginBody extends Body {
|
|||||||
|
|
||||||
public function loadView() {
|
public function loadView() {
|
||||||
parent::loadView();
|
parent::loadView();
|
||||||
$this->getDocument()->getHead()->loadBootstrap();
|
$head = $this->getDocument()->getHead();
|
||||||
|
$head->loadBootstrap();
|
||||||
|
$head->loadJQuery();
|
||||||
|
$head->loadFontawesome();
|
||||||
|
$head->addJS(Script::CORE);
|
||||||
|
$head->addCSS(Link::CORE);
|
||||||
|
$head->addJS(Script::ADMIN);
|
||||||
|
$head->addCSS(Link::ADMIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCode() {
|
public function getCode() {
|
||||||
|
Loading…
Reference in New Issue
Block a user