Skip to content

Commit

Permalink
[ICAT] - Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
marcus-oscarsson committed Oct 3, 2024
1 parent f0c2468 commit 0871150
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 73 deletions.
7 changes: 6 additions & 1 deletion ui/src/actions/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ import { fetchAvailableWorkflows } from '../api/workflow';
import { fetchAvailableTasks, fetchQueueState } from '../api/queue';

import { showErrorPanel, applicationFetched } from './general';
import { fetchLoginInfo, sendLogIn, sendSignOut, sendSSOLogIn } from '../api/login';
import {
fetchLoginInfo,
sendLogIn,
sendSignOut,
sendSSOLogIn,
} from '../api/login';
import { fetchDetectorInfo } from '../api/detector';
import { fetchSampleChangerInitialState } from '../api/sampleChanger';
import { fetchHarvesterInitialState } from '../api/harvester';
Expand Down
50 changes: 24 additions & 26 deletions ui/src/components/LoginForm/SelectProposal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class SelectProposal extends React.Component {
this.props.handleHide();
}

selectProposal() {
handleSelectProposal() {
this.props.selectProposal(this.state.pNumber);
}

Expand All @@ -38,10 +38,10 @@ class SelectProposal extends React.Component {
return `${session.code}-${session.number}`;
}

onSessionSelected(session) {
handleOnSessionSelected(session) {
this.setState({
proposal: this.getProposalBySession(session),
session: session,
session,
pId: session.session_id,
pNumber: session.session_id,
});
Expand All @@ -50,25 +50,25 @@ class SelectProposal extends React.Component {
handleChange(event) {
const filteredSessions = this.state.sessions.filter((s) => {
return (
s.title.indexOf(event.target.value) !== -1 ||
s.number.indexOf(event.target.value) !== -1 ||
s.code.indexOf(event.target.value) !== -1
s.title.includes(event.target.value) ||
s.number.includes(event.target.value) ||
s.code.includes(event.target.value)
);
});

this.setState({
filter: event.target.value,
filteredSessions: filteredSessions,
filteredSessions,
});
}

render() {
/** sort by start date */
let sortedlist = this.state.filteredSessions.sort((a, b) =>
const sortedlist = this.state.filteredSessions.sort((a, b) =>
a.actual_start_date < b.actual_start_date ? 1 : -1,
);

const session = this.state.session;
const { session } = this.state;

const scheduledSessions = sortedlist.filter(
(s) => s.is_scheduled_beamline && s.is_scheduled_time,
Expand All @@ -87,15 +87,13 @@ class SelectProposal extends React.Component {
<Modal.Title>Select a session</Modal.Title>
</Modal.Header>
<Modal.Body>
<>
<Form.Control
type="text"
id="search_session"
placeholder="Search"
value={this.state.filter}
onChange={this.handleChange.bind(this)}
/>
</>
<Form.Control
type="text"
id="search_session"
placeholder="Search"
value={this.state.filter}
onChange={this.handleChange.bind(this)}
/>
<br />

<Tabs defaultActiveKey="scheduled" id="scheduled-tab">
Expand All @@ -109,8 +107,8 @@ class SelectProposal extends React.Component {
selectedSessionId={this.state.pId}
filter={this.state.filter}
params={{ showBeamline: false }}
onSessionSelected={this.onSessionSelected}
></SessionTable>
onSessionSelected={this.handleOnSessionSelected}
/>
</div>
</Tab>
<Tab
Expand All @@ -123,8 +121,8 @@ class SelectProposal extends React.Component {
selectedSessionId={this.state.pId}
filter={this.state.filter}
params={{ showBeamline: true }}
onSessionSelected={this.onSessionSelected}
></SessionTable>
onSessionSelected={this.handleOnSessionSelected}
/>
</div>
</Tab>
</Tabs>
Expand All @@ -137,7 +135,7 @@ class SelectProposal extends React.Component {
variant="warning"
className="float-end"
disabled={this.state.pNumber === null}
onClick={this.selectProposal}
onClick={this.handleSelectProposal}
>
Reschedule
</Button>
Expand All @@ -147,7 +145,7 @@ class SelectProposal extends React.Component {
variant="danger"
className="float-end"
disabled // {this.state.pNumber === null}
onClick={this.selectProposal}
onClick={this.handleSelectProposal}
>
Move here
</Button>
Expand All @@ -163,11 +161,11 @@ class SelectProposal extends React.Component {
(session && session.is_scheduled_beamline === false) ||
session.is_scheduled_time === false
}
onClick={this.selectProposal}
onClick={this.handleSelectProposal}
>
{this.state.proposal === null
? 'Select Proposal'
: 'Select ' + this.state.proposal}
: `Select ${this.state.proposal}`}
</Button>
</Modal.Footer>
</Modal>
Expand Down
64 changes: 32 additions & 32 deletions ui/src/components/LoginForm/SessionTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ const getDateComponent = (startDate, startTime) => {
*/
const getScheduledDateComponent = (session, startDate, startTime) => {
if (session.is_rescheduled) {
return <del className={styles.time}>{getDateComponent(startDate, startTime)}</del>;
return (
<del className={styles.time}>
{getDateComponent(startDate, startTime)}
</del>
);
}
return getDateComponent(startDate, startTime);
};
Expand All @@ -53,7 +57,7 @@ const getLinkBySession = (session) => {
].map((item) => {
return (
<p key={item.url}>
<a href={item.url} className="p-1" target="_blank" rel="noreferrer">
<a href={item.url} className="p-1" target="_blank" rel="noreferrer">
<LuExternalLink /> {item.title}
</a>
</p>
Expand All @@ -77,12 +81,12 @@ export default function SessionTable(props) {
<tr>
<th />
{props.params.showBeamline && <th>Beamline</th>}
<th>Title</th>
<th>Start</th>
<th>End</th>
<th>Portal</th>
<th>User</th>
<th>Logbook</th>
<th>Title</th>
<th>Start</th>
<th>End</th>
<th>Portal</th>
<th>User</th>
<th>Logbook</th>
</tr>
</thead>
<tbody>
Expand All @@ -104,34 +108,30 @@ export default function SessionTable(props) {
{props.params.showBeamline && <td>{session.beamline_name}</td>}
<td>{session.title}</td>
<td>

{getScheduledDateComponent(
session,
session.start_date,
session.start_time,
{getScheduledDateComponent(
session,
session.start_date,
session.start_time,
)}
<br />
{session.is_rescheduled &&
getDateComponent(
session.actual_start_date,
session.actual_start_time,
)}
<br />
{session.is_rescheduled &&
getDateComponent(
session.actual_start_date,
session.actual_start_time,
)}

</td>
<td>

{getScheduledDateComponent(
session,
session.end_date,
session.end_time,
{getScheduledDateComponent(
session,
session.end_date,
session.end_time,
)}
<br />
{session.is_rescheduled &&
getDateComponent(
session.actual_end_date,
session.actual_end_time,
)}
<br />
{session.is_rescheduled &&
getDateComponent(
session.actual_end_date,
session.actual_end_time,
)}

</td>
<td>{getLinkBySession(session)[0]}</td>
<td>{getLinkBySession(session)[1]}</td>
Expand Down
2 changes: 1 addition & 1 deletion ui/src/components/SSXChip/SSXChipControl.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default class SSXChipControl extends React.Component {
cell_count: 0,
numRows: 0,
numCols: 0,
selection: triggerEvent.props.selection
selection: triggerEvent.props.selection,
},
type: 'ssx_chip_collection',
},
Expand Down
16 changes: 8 additions & 8 deletions ui/src/components/SampleView/utils.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
export function downloadImage(blob, download_name) {
const url = window.URL.createObjectURL(new Blob([blob]));
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', download_name);
document.body.append(link);
link.click();
link.remove();
URL.revokeObjectURL(url);
const url = window.URL.createObjectURL(new Blob([blob]));
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', download_name);
document.body.append(link);
link.click();
link.remove();
URL.revokeObjectURL(url);
}
8 changes: 3 additions & 5 deletions ui/src/containers/SampleListViewContainer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ class SampleListViewContainer extends React.Component {
}

getSynchronizationDropDownList() {
if (this.props.loginData.limsName.length == 1) {
if (this.props.loginData.limsName.length === 1) {
return (
<TooltipTrigger
id="sync-samples-tooltip"
Expand All @@ -635,10 +635,7 @@ class SampleListViewContainer extends React.Component {
variant="outline-secondary"
onClick={this.syncSamples}
>
<i
className="fas fa-sync-alt"
style={{ marginRight: '0.5em' }}
/>
<i className="fas fa-sync-alt" style={{ marginRight: '0.5em' }} />
{this.props.loginData.limsName}
</Button>
</TooltipTrigger>
Expand All @@ -653,6 +650,7 @@ class SampleListViewContainer extends React.Component {
<Dropdown.Menu>
{this.props.loginData.limsName.map((lims) => (
<TooltipTrigger
key={lims.name}
tooltipContent={`Synchronise sample list with ${this.props.loginData.limsName[0].name}`}
>
<Dropdown.Item
Expand Down

0 comments on commit 0871150

Please sign in to comment.