1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/web/ synced 2025-03-09 00:00:01 +01:00

cosmetic code changes

This commit is contained in:
Steffen Vogel 2021-03-08 16:05:33 +01:00
parent facd4f137e
commit 74c16e3ae2
9 changed files with 76 additions and 56 deletions

View file

@ -169,14 +169,16 @@ class CustomTable extends Component {
<OverlayTrigger
key={1}
placement={'bottom'}
overlay={<Tooltip id={`tooltip-${"export"}`}> Export </Tooltip>} >
overlay={<Tooltip id={`tooltip-${"export"}`}> Export </Tooltip>}
>
<Button
variant='table-control-button'
onClick={() => child.props.onExport(index)}
disabled={child.props.onExport == null}>
<Icon icon='download' />
</Button>
</OverlayTrigger>);
</OverlayTrigger>
);
}
if (child.props.duplicateButton) {
@ -191,7 +193,8 @@ class CustomTable extends Component {
disabled={child.props.onDuplicate == null}>
<Icon icon='copy' />
</Button>
</OverlayTrigger>);
</OverlayTrigger>
);
}
if (child.props.addRemoveFilesButton) {
@ -206,7 +209,8 @@ class CustomTable extends Component {
disabled={child.props.onAddRemove == null}>
<Icon icon='file' />
</Button>
</OverlayTrigger>);
</OverlayTrigger>
);
}
if (child.props.downloadAllButton) {
@ -246,8 +250,6 @@ class CustomTable extends Component {
}
}
return cell;
} // addCell
@ -312,26 +314,24 @@ class CustomTable extends Component {
</thead>
<tbody>
{
this.state.rows.map((row, rowIndex) => (
this.state.rows.map((row, rowIndex) =>
<tr key={rowIndex}>
{
row.map((cell, cellIndex) => {
let isCellInlineEditable = children[cellIndex].props.inlineEditable === true;
let tabIndex = isCellInlineEditable ? 0 : -1;
let evtHdls = isCellInlineEditable ? {
onCellClick: (event) => this.onClick(event, rowIndex, cellIndex),
onCellFocus: () => this.onCellFocus({ cell: cellIndex, row: rowIndex }),
onCellBlur: () => this.cellLostFocus()
} : {
onCellClick: () => { },
onCellFocus: () => { },
onCellBlur: () => { }
};
onCellClick: () => { },
onCellFocus: () => { },
onCellBlur: () => { }
};
return (<td
return <td
key={cellIndex}
tabIndex={tabIndex}
onClick={evtHdls.onCellClick}
@ -344,17 +344,18 @@ class CustomTable extends Component {
value={cell}
onChange={(event) => children[cellIndex].props.onInlineChange(event, rowIndex, cellIndex)}
ref={ref => { this.activeInput = ref; }} />
) : (
<span>
{cell.map((element, elementIndex) => (
: <span>
{
cell.map((element, elementIndex) =>
<span key={elementIndex}>{element}</span>
))}
</span>
)}
</td>)
)
}
</span>
}
</td>
})
}
</tr>))
</tr>)
}
</tbody>
</Table>

View file

@ -37,8 +37,6 @@ class EditOwnUserDialog extends React.Component {
}
}
onClose(canceled) {
if (canceled === false) {
if (this.valid) {
@ -49,8 +47,6 @@ class EditOwnUserDialog extends React.Component {
}
}
handleChange(e) {
this.setState({ [e.target.id]: e.target.value });
@ -65,26 +61,24 @@ class EditOwnUserDialog extends React.Component {
username = false;
}
if(this.state.mail === ''){
if (this.state.mail === '') {
mail = false;
}
if(this.state.password === ''){
if (this.state.password === '') {
pw = false;
}
if(this.state.oldPassword === ''){
if (this.state.oldPassword === '') {
oldPassword = false;
}
if(this.state.confirmpassword === ''){
if (this.state.confirmpassword === '') {
confirmpassword = false;
}
// form is valid if the following condition is met
this.valid = username || mail || (oldPassword && pw && confirmpassword);
}
resetState() {

View file

@ -60,7 +60,6 @@ class EditUserDialog extends React.Component {
var confirmpassword = true;
var oldPW = true;
if (this.state.username === '') {
username = false;
}

View file

@ -26,7 +26,7 @@ class LoginComplete extends React.Component {
constructor(props) {
console.log("LoginComplete constructor");
super(props);
AppDispatcher.dispatch({
type: 'users/extlogin',
});
@ -42,8 +42,6 @@ class LoginComplete extends React.Component {
this.startTimer = this.startTimer.bind(this);
this.countDown = this.countDown.bind(this);
this.stopTimer = this.stopTimer.bind(this);
}
componentDidMount() {
@ -51,7 +49,6 @@ class LoginComplete extends React.Component {
this.setState({secondsToWait: 5});
}
static getStores(){
return [LoginStore]
}
@ -104,4 +101,4 @@ class LoginComplete extends React.Component {
}
let fluxContainerConverter = require('../common/FluxContainerConverter');
export default Container.create(fluxContainerConverter.convert(LoginComplete));
export default Container.create(fluxContainerConverter.convert(LoginComplete));

View file

@ -32,7 +32,7 @@ class Login extends Component {
constructor(props) {
super(props);
// load config in case the user goes directly to /login
// Load config in case the user goes directly to /login
// otherwise it will be loaded in app constructor
AppDispatcher.dispatch({
type: 'config/load',

View file

@ -54,7 +54,6 @@ class NewUserDialog extends React.Component {
let mail = this.state.mail !== '';
this.valid = username && password && role && mail;
}
resetState() {

View file

@ -46,7 +46,6 @@ class User extends Component {
}
componentDidMount() {
let currentUserID = JSON.parse(localStorage.getItem("currentUser")).id;
AppDispatcher.dispatch({
@ -54,12 +53,13 @@ class User extends Component {
data: parseInt(currentUserID, 10),
token: this.state.token
});
}
closeEditModal(data) {
this.setState({
editModal: false
});
this.setState({ editModal: false });
let updatedData = {}
updatedData.id = this.state.currentUser.id;
let updatedUser = this.state.currentUser;
@ -87,8 +87,7 @@ class User extends Component {
}
if (hasChanged || pwChanged) {
if(hasChanged){
if (hasChanged){
this.setState({currentUser: updatedUser})
}
@ -103,9 +102,12 @@ class User extends Component {
}
}
getHumanRoleName(role_key) {
const HUMAN_ROLE_NAMES = {Admin: 'Administrator', User: 'User', Guest: 'Guest'};
const HUMAN_ROLE_NAMES = {
Admin: 'Administrator',
User: 'User',
Guest: 'Guest'
};
return HUMAN_ROLE_NAMES.hasOwnProperty(role_key)? HUMAN_ROLE_NAMES[role_key] : '';
}

View file

@ -50,7 +50,6 @@ class UsersStore extends ArrayStore {
return super.reduce(state, action);
}
}
}
export default new UsersStore();

View file

@ -129,7 +129,6 @@ class Users extends Component {
}
render() {
const buttonStyle = {
marginLeft: '10px',
};
@ -153,17 +152,47 @@ class Users extends Component {
</h1>
<Table data={this.state.users}>
<TableColumn title='Username' width='150' dataKey='username' />
<TableColumn title='ID' width='150' dataKey='id' />
<TableColumn title='E-mail' dataKey='mail' />
<TableColumn title='Role' dataKey='role' modifier={(role) => this.getHumanRoleName(role)} />
<TableColumn title='Active' dataKey='active' modifier={(active) => this.modifyActiveColumn(active)} />
<TableColumn width='200' editButton deleteButton onEdit={index => this.setState({ editModal: true, modalData: this.state.users[index] })} onDelete={index => this.setState({ deleteModal: true, modalData: this.state.users[index] })} />
<TableColumn
title='Username'
width='150'
dataKey='username'
/>
<TableColumn
title='ID'
width='150'
dataKey='id'
/>
<TableColumn
title='E-mail'
dataKey='mail'
/>
<TableColumn
title='Role'
dataKey='role'
modifier={(role) => this.getHumanRoleName(role)}
/>
<TableColumn
title='Active'
dataKey='active'
modifier={(active) => this.modifyActiveColumn(active)}
/>
<TableColumn
width='200'
editButton
deleteButton
onEdit={index => this.setState({
editModal: true,
modalData: this.state.users[index]
})}
onDelete={index => this.setState({
deleteModal: true,
modalData: this.state.users[index]
})}
/>
</Table>
<NewUserDialog show={this.state.newModal} onClose={(data) => this.closeNewModal(data)} />
<EditUserDialog show={this.state.editModal} onClose={(data) => this.closeEditModal(data)} user={this.state.modalData} />
<DeleteDialog title="user" name={this.state.modalData.username} show={this.state.deleteModal} onClose={(e) => this.closeDeleteModal(e)} />
</div>
);