Skip to content

Commit

Permalink
adding some features in dashboard and removing user access for deleti…
Browse files Browse the repository at this point in the history
…ng reports
  • Loading branch information
aliasadolahi74 committed May 7, 2022
1 parent cc65c46 commit b5613c2
Show file tree
Hide file tree
Showing 12 changed files with 64 additions and 171 deletions.
8 changes: 0 additions & 8 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ function App() {
<Route path={`${dir}/admin`} component={AdminPanel} />
<Route path={`${dir}/not-found`} component={NotFound} />
<Route path={`${dir}/login`} component={Login} />
<<<<<<< HEAD

=======
>>>>>>> 56f99646e54e4149e299b6afa1c0573d508a1d4c
<Redirect from={`${dir}/`} exact to={`${dir}/login`} />
<Redirect to={`${dir}/not-found`} />
</Switch>
Expand All @@ -57,11 +53,7 @@ function App() {
}
return (
<MuiThemeProvider theme={theme}>
<<<<<<< HEAD
<div className='App'>{routes}</div>
=======
<div className="App">{routes}</div>
>>>>>>> 56f99646e54e4149e299b6afa1c0573d508a1d4c
</MuiThemeProvider>
);
}
Expand Down
6 changes: 5 additions & 1 deletion src/components/adminPanel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import qs from "qs";
import SMSServiceSettings from "./smsServiceSettings";

const dir = process.env.REACT_APP_CUSTOM_DIR;
const panelURL = process.env.REACT_APP_PANEL_URL;

class AdminPanel extends Component {
state = {
Expand Down Expand Up @@ -65,8 +66,11 @@ class AdminPanel extends Component {
{
id: "6",
title: "خروج",
link: `${dir}/admin/logout`,
fontAwesomeIcon: "fa-sign-out-alt",
action: () => {
localStorage.clear();
window.location.href = panelURL;
},
},
],
};
Expand Down
13 changes: 0 additions & 13 deletions src/components/common/textarea.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const TextArea = ({
<label htmlFor={name}>{label}</label>
<textarea
autoFocus={autoFocus ? true : false}
<<<<<<< HEAD
className='form-control'
id={name}
name={name}
Expand All @@ -25,18 +24,6 @@ const TextArea = ({
/>
{error && (
<div className='alert alert-danger mt-2'>
=======
className="form-control"
id={name}
name={name}
onChange={onChange}
rows="3"
value={value}
placeholder={`${label} را وارد کنید`}
/>
{error && (
<div className="alert alert-danger mt-2">
>>>>>>> 56f99646e54e4149e299b6afa1c0573d508a1d4c
<small>{error}</small>
</div>
)}
Expand Down
6 changes: 6 additions & 0 deletions src/components/dashboard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ class Dashboard extends Component {
</div>
)}

{!authData.isAdmin && (data !== undefined || data.length !== 0) ? (
<h4 style={{ width: "100%", textAlign: "center" }}>
خلاصه وضعیت سیستم های شما بر اساس آخرین داده های دریافتی
</h4>
) : null}

<div className='dashboard-table-container'>
<StatisticsTable data={data} columns={columns} title='' />
</div>
Expand Down
29 changes: 16 additions & 13 deletions src/components/device.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,19 +124,22 @@ class Device extends Component {
return { name: item.name, label: item.label };
});
columns.push({ name: "datetime", label: "زمان" });
columns.push({
name: "deleteButton",
label: "",
content: (item) => (
<button
onClick={() => this.handleDeleteButtonClick(item)}
className='btn btn-danger'
style={{ fontSize: 12 }}
>
<i className='fa fa-trash '></i>
</button>
),
});
if (authData.isAdmin) {
columns.push({
name: "deleteButton",
label: "",
content: (item) => (
<button
onClick={() => this.handleDeleteButtonClick(item)}
className='btn btn-danger'
style={{ fontSize: 12 }}
>
<i className='fa fa-trash '></i>
</button>
),
});
}

return columns;
};

Expand Down
25 changes: 0 additions & 25 deletions src/components/hardwareModule.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,8 @@ const HardwareModule = (props) => {
const { hardwareModule, onStartClick, onStopClick } = props;

return (
<<<<<<< HEAD
<div className='hardware-button-container mb-4'>
<span className='label mb-2'>{hardwareModule.label}</span>
=======
<div className="hardware-button-container mb-4">
<span className="label mb-2">{hardwareModule.label}</span>
>>>>>>> 56f99646e54e4149e299b6afa1c0573d508a1d4c
<div>{getButtons(hardwareModule, onStartClick, onStopClick)}</div>
</div>
);
Expand All @@ -20,23 +15,6 @@ const getButtons = (hardwareModule, onStartClick, onStopClick) => {
if (hardwareModule.name === "Door") {
return (
<React.Fragment>
<<<<<<< HEAD
=======
<button
onClick={() => {
onStartClick(hardwareModule);
}}
className="btn btn-success"
>
{hardwareModule["on_text"]}
</button>
<span></span>
</React.Fragment>
);
} else {
return (
<React.Fragment>
>>>>>>> 56f99646e54e4149e299b6afa1c0573d508a1d4c
<button
onClick={() => {
onStartClick(hardwareModule);
Expand All @@ -59,7 +37,6 @@ const getButtons = (hardwareModule, onStartClick, onStopClick) => {
>
{hardwareModule["on_text"]}
</button>
<<<<<<< HEAD
{hardwareModule["off_text"] !== "" ? (
<button
onClick={() => {
Expand All @@ -70,8 +47,6 @@ const getButtons = (hardwareModule, onStartClick, onStopClick) => {
{hardwareModule["off_text"]}
</button>
) : null}
=======
>>>>>>> 56f99646e54e4149e299b6afa1c0573d508a1d4c
</React.Fragment>
);
}
Expand Down
18 changes: 0 additions & 18 deletions src/components/login.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ class Login extends Component {
return null;
} else {
return (
<<<<<<< HEAD
<div className='background'>
<div className='login-page-container'>
<div className='container-fluid p-5 h-100 w-100 main-section'>
Expand All @@ -37,23 +36,6 @@ class Login extends Component {
تاسیسات الکتریکی
</h4>
<p className='about-us-text'>
=======
<div className="background">
<div className="login-page-container">
<div className="container-fluid p-5 h-100 w-100 main-section">
<div className="d-flex justify-content-center align-items-center flex-column login-form-container">
<a href={websiteURL}>
<img src={icon} className="tmb-logo" alt="logo" />
</a>
<LoginForm />
</div>
<div className="d-flex w-100 flex-column align-items-center justify-content-center about-us-container">
<div className="content p-5 w-100 h-100 d-flex justify-content-center">
<h4 className="mb-4 nowrap">
سامانه تله‌متری شرکت طراحان مدار باختر
</h4>
<p className="about-us-text">
>>>>>>> 56f99646e54e4149e299b6afa1c0573d508a1d4c
شرکت طراحان مدار باختر در سال ۱۳۹۴ با هدف تولید و بروزآوری
محصولات مورد نیاز صنایع «در حوزه‌های برق، الکترونیک،
مخابرات، کنترل و ابزار دقیق» و توسعه اقتصاد دانش‌محور و
Expand Down
46 changes: 1 addition & 45 deletions src/components/newDeviceForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ const dir = process.env.REACT_APP_CUSTOM_DIR;

class NewDeviceForm extends Form {
state = {
<<<<<<< HEAD
data: {
deviceID: "",
deviceName: "",
Expand All @@ -22,9 +21,6 @@ class NewDeviceForm extends Form {
installationDatetime: "",
type: "",
},
=======
data: { deviceID: "", deviceName: "", phoneNumber: "", address: "" },
>>>>>>> 56f99646e54e4149e299b6afa1c0573d508a1d4c
errors: {},
hardwareList: [],
authData: { username: authData.username, token: authData.token },
Expand All @@ -46,14 +42,7 @@ class NewDeviceForm extends Form {
"string.empty": "وارد کردن نام دستگاه الزامی است",
"string.length": "اندازه شماره سیم کارت باید ۱۱ رقم باشد",
}),
address: Joi.string()
.regex(/^[، آابپتثجچحخدذرزژسشصضطظعغفقکگلمنوهیئج+\d]+$/s)
.allow("", null)
.messages({
"string.pattern.base":
"محل نصب باید فارسی باشد. استفاده از کارکترهایی بجز - و ، غیرمجاز است",
}),
<<<<<<< HEAD
address: Joi.string().allow("", null),

description: Joi.string()
.regex(
Expand Down Expand Up @@ -81,8 +70,6 @@ class NewDeviceForm extends Form {
.messages({
"string.pattern.base": "تاریخ نصب دارای کارکتر غیرمجاز است",
}),
=======
>>>>>>> 56f99646e54e4149e299b6afa1c0573d508a1d4c
};

async componentDidMount() {
Expand Down Expand Up @@ -159,27 +146,9 @@ class NewDeviceForm extends Form {
const { data, errors, hardwareList } = this.state;
return (
<React.Fragment>
<<<<<<< HEAD
<form onSubmit={this.handleSubmit} className='d-flex flex-column px-4'>
<div className='w-75 newDeviceFormInputContainer'>
<div className='w-75'>
=======
<form onSubmit={this.handleSubmit} className="d-flex flex-column px-4">
<div className="w-75 newDeviceFormInputContainer">
<div className="w-75">
<Input
autoFocus
name="deviceID"
type="text"
value={data.deviceID}
onChange={this.handleChange}
label="شناسه دستگاه"
error={errors.deviceID}
/>
</div>

<div className="w-75">
>>>>>>> 56f99646e54e4149e299b6afa1c0573d508a1d4c
<Input
autoFocus
name='deviceID'
Expand Down Expand Up @@ -213,7 +182,6 @@ class NewDeviceForm extends Form {
/>
</div>

<<<<<<< HEAD
<div className='w-75'>
<Input
name='address'
Expand Down Expand Up @@ -257,18 +225,6 @@ class NewDeviceForm extends Form {
error={errors.type}
/>
</div>
=======
<div className="w-75">
<Input
name="address"
type="text"
value={data.address}
onChange={this.handleChange}
label="محل نصب"
error={errors.address}
/>
</div>
>>>>>>> 56f99646e54e4149e299b6afa1c0573d508a1d4c
</div>

<div className='form-group'>
Expand Down
53 changes: 36 additions & 17 deletions src/components/sidebar-menu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,53 @@ class SidebarMenu extends Component {
const { items } = this.props;
const websiteURL = process.env.REACT_APP_WEBSITE;
return (
<aside className="sidebar">
<div className="title">
<aside className='sidebar'>
<div className='title'>
<a href={websiteURL}>
<img src={icon} alt="logo" />
<img src={icon} alt='logo' />
</a>
</div>
<nav className="menu">
<nav className='menu'>
<ul>
{items.map((item) => {
return (
<li
key={item.id}
onClick={() => {
this.handleMenuItemClick(item);
if (item.action) {
item.action();
} else {
this.handleMenuItemClick(item);
}
}}
>
<NavLink
to={item.link}
isActive={(match) => {
if (!match || item.link === "#") {
return false;
}
return true;
}}
>
<i className={"fa menu-icon " + item.fontAwesomeIcon}></i>
{item.title}
</NavLink>
{item.action ? (
<NavLink
to={"#"}
isActive={(match) => {
if (!match || item.link === "#") {
return false;
}
return true;
}}
>
<i className={"fa menu-icon " + item.fontAwesomeIcon}></i>
{item.title}
</NavLink>
) : (
<NavLink
to={item.link}
isActive={(match) => {
if (!match || item.link === "#") {
return false;
}
return true;
}}
>
<i className={"fa menu-icon " + item.fontAwesomeIcon}></i>
{item.title}
</NavLink>
)}
</li>
);
})}
Expand Down
Loading

0 comments on commit b5613c2

Please sign in to comment.