Initial Commit Rework

This commit is contained in:
Qstick
2017-09-03 22:20:56 -04:00
parent 74a4cc048c
commit 95051cbd63
2483 changed files with 101351 additions and 111396 deletions

View File

@@ -0,0 +1,139 @@
import PropTypes from 'prop-types';
import React, { Component } from 'react';
import { icons } from 'Helpers/Props';
import Alert from 'Components/Alert';
import Link from 'Components/Link/Link';
import LoadingIndicator from 'Components/Loading/LoadingIndicator';
import Table from 'Components/Table/Table';
import PageContent from 'Components/Page/PageContent';
import PageContentBodyConnector from 'Components/Page/PageContentBodyConnector';
import PageToolbar from 'Components/Page/Toolbar/PageToolbar';
import PageToolbarSection from 'Components/Page/Toolbar/PageToolbarSection';
import PageToolbarSeparator from 'Components/Page/Toolbar/PageToolbarSeparator';
import PageToolbarButton from 'Components/Page/Toolbar/PageToolbarButton';
import TableBody from 'Components/Table/TableBody';
import LogsNavMenu from '../LogsNavMenu';
import LogFilesTableRow from './LogFilesTableRow';
const columns = [
{
name: 'filename',
label: 'Filename',
isVisible: true
},
{
name: 'lastWriteTime',
label: 'Last Write Time',
isVisible: true
},
{
name: 'download',
isVisible: true
}
];
class LogFiles extends Component {
//
// Render
render() {
const {
isFetching,
items,
deleteFilesExecuting,
currentLogView,
location,
onRefreshPress,
onDeleteFilesPress,
...otherProps
} = this.props;
return (
<PageContent title="Log Files">
<PageToolbar>
<PageToolbarSection>
<LogsNavMenu current={currentLogView} />
<PageToolbarSeparator />
<PageToolbarButton
label="Refresh"
iconName={icons.REFRESH}
spinningName={icons.REFRESH}
isSpinning={isFetching}
onPress={onRefreshPress}
/>
<PageToolbarButton
label="Clear"
iconName={icons.CLEAR}
isSpinning={deleteFilesExecuting}
onPress={onDeleteFilesPress}
/>
</PageToolbarSection>
</PageToolbar>
<PageContentBodyConnector>
<Alert>
<div>
Log files are located in: {location}
</div>
{
currentLogView === 'Log Files' &&
<div>
The log level defaults to 'Info' and can be changed in <Link to="/settings/general">General Settings</Link>
</div>
}
</Alert>
{
isFetching &&
<LoadingIndicator />
}
{
!isFetching && !!items.length &&
<div>
<Table
columns={columns}
{...otherProps}
>
<TableBody>
{
items.map((item) => {
return (
<LogFilesTableRow
key={item.id}
{...item}
/>
);
})
}
</TableBody>
</Table>
</div>
}
{
!isFetching && !items.length &&
<div>No log files</div>
}
</PageContentBodyConnector>
</PageContent>
);
}
}
LogFiles.propTypes = {
isFetching: PropTypes.bool.isRequired,
items: PropTypes.array.isRequired,
deleteFilesExecuting: PropTypes.bool.isRequired,
currentLogView: PropTypes.string.isRequired,
location: PropTypes.string.isRequired,
onRefreshPress: PropTypes.func.isRequired,
onDeleteFilesPress: PropTypes.func.isRequired
};
export default LogFiles;

View File

@@ -0,0 +1,93 @@
import _ from 'lodash';
import PropTypes from 'prop-types';
import React, { Component } from 'react';
import { connect } from 'react-redux';
import { createSelector } from 'reselect';
import combinePath from 'Utilities/String/combinePath';
import createCommandsSelector from 'Store/Selectors/createCommandsSelector';
import { executeCommand } from 'Store/Actions/commandActions';
import { fetchLogFiles } from 'Store/Actions/systemActions';
import * as commandNames from 'Commands/commandNames';
import LogFiles from './LogFiles';
function createMapStateToProps() {
return createSelector(
(state) => state.system.logFiles,
(state) => state.system.status.item,
createCommandsSelector(),
(logFiles, status, commands) => {
const {
isFetching,
items
} = logFiles;
const {
appData,
isWindows
} = status;
const deleteFilesExecuting = _.some(commands, { name: commandNames.DELETE_LOG_FILES });
return {
isFetching,
items,
deleteFilesExecuting,
currentLogView: 'Log Files',
location: combinePath(isWindows, appData, ['logs'])
};
}
);
}
const mapDispatchToProps = {
fetchLogFiles,
executeCommand
};
class LogFilesConnector extends Component {
//
// Lifecycle
componentDidMount() {
this.props.fetchLogFiles();
}
componentDidUpdate(prevProps) {
if (prevProps.deleteFilesExecuting && !this.props.deleteFilesExecuting) {
this.props.fetchLogFiles();
}
}
//
// Listeners
onRefreshPress = () => {
this.props.fetchLogFiles();
}
onDeleteFilesPress = () => {
this.props.executeCommand({ name: commandNames.DELETE_LOG_FILES });
}
//
// Render
render() {
return (
<LogFiles
onRefreshPress={this.onRefreshPress}
onDeleteFilesPress={this.onDeleteFilesPress}
{...this.props}
/>
);
}
}
LogFilesConnector.propTypes = {
deleteFilesExecuting: PropTypes.bool.isRequired,
fetchLogFiles: PropTypes.func.isRequired,
executeCommand: PropTypes.func.isRequired
};
export default connect(createMapStateToProps, mapDispatchToProps)(LogFilesConnector);

View File

@@ -0,0 +1,5 @@
.download {
composes: cell from 'Components/Table/Cells/TableRowCell.css';
width: 100px;
}

View File

@@ -0,0 +1,50 @@
import PropTypes from 'prop-types';
import React, { Component } from 'react';
import Link from 'Components/Link/Link';
import RelativeDateCellConnector from 'Components/Table/Cells/RelativeDateCellConnector';
import TableRow from 'Components/Table/TableRow';
import TableRowCell from 'Components/Table/Cells/TableRowCell';
import styles from './LogFilesTableRow.css';
class LogFilesTableRow extends Component {
//
// Render
render() {
const {
filename,
lastWriteTime,
downloadUrl
} = this.props;
return (
<TableRow>
<TableRowCell>{filename}</TableRowCell>
<RelativeDateCellConnector
date={lastWriteTime}
/>
<TableRowCell className={styles.download}>
<Link
to={downloadUrl}
target="_blank"
noRouter={true}
>
Download
</Link>
</TableRowCell>
</TableRow>
);
}
}
LogFilesTableRow.propTypes = {
filename: PropTypes.string.isRequired,
lastWriteTime: PropTypes.string.isRequired,
downloadUrl: PropTypes.string.isRequired
};
export default LogFilesTableRow;