Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v2.2.6 (#46) #48

Merged
merged 1 commit into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Rec-to-NWB YAML Generator",
"version": "2.2.5",
"version": "2.2.6",
"description": "Create YAML File for Spyglass",
"keywords": [
"electron",
Expand Down
13 changes: 10 additions & 3 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
titleCase,
showCustomValidityError,
stringToInteger,
isProduction,
useMount,
} from './utils';
import {
Expand Down Expand Up @@ -652,7 +653,9 @@ const generateYMLFile = (e) => {

if (isValid && isFormValid) {
const yAMLForm = convertObjectToYAMLString(form);
createYAMLFile('metaData.yml', yAMLForm);
const fileNameDate = form.subject.date_of_birth.substring(0,10).replaceAll('-', '');
const subjectId = formData.subject.subject_id.toLocaleLowerCase();
createYAMLFile(`${fileNameDate}_${subjectId}_metadata.yml`, yAMLForm);
return;
}

Expand Down Expand Up @@ -845,7 +848,7 @@ useEffect(() => {

return <>
<div className="home-region">
<a href="/">
<a href={isProduction() ? '/rec_to_nwb_yaml_creator' : '/'}>
<img src={logo} alt="Loren Frank Lab logo"/>
</a>
</div>
Expand Down Expand Up @@ -934,7 +937,8 @@ useEffect(() => {
inputPlaceholder="No experimenter"
defaultValue={formData.experimenter_name}
title="Experimenter Name"
placeholder="LastName, FirstName or LastName, FirstName MiddleInitial. or LastName, FirstName MiddleName"
placeholder="LastName, FirstName"
listPlaceHolder="LastName, FirstName"
updateFormData={updateFormData}
metaData={{
nameValue: 'experimenter_name',
Expand Down Expand Up @@ -1955,6 +1959,9 @@ useEffect(() => {
index,
})
}
metaData={{
index,
}}
onMapInput={onMapInput}
/>
</div>
Expand Down
6 changes: 5 additions & 1 deletion src/element/ListElement.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const ListElement = (prop) => {
metaData,
required,
inputPlaceholder,
listPlaceHolder,
updateFormData,
step,
readOnly,
Expand Down Expand Up @@ -64,6 +65,7 @@ const ListElement = (prop) => {
const listData = useRef();

const valueToAdd = useRef('');
const textPlaceHolder = listPlaceHolder ? listPlaceHolder : `Type ${title}`;

return (
<label className="container" htmlFor={id}>
Expand All @@ -83,7 +85,7 @@ const ListElement = (prop) => {
<input
name={name}
type={type}
placeholder={`Type ${title}`}
placeholder={textPlaceHolder}
ref={valueToAdd}
step={step}
onKeyPress={e => addListItemViaEnterKey(e, valueToAdd)}
Expand All @@ -102,6 +104,7 @@ ListElement.propType = {
type: PropTypes.string.isRequired,
name: PropTypes.string.isRequired,
placeholder: PropTypes.string,
listPlaceHolder: PropTypes.string,
required: PropTypes.bool,
readOnly: PropTypes.bool,
inputPlaceholder: PropTypes.string,
Expand All @@ -119,6 +122,7 @@ ListElement.defaultProps = {
readOnly: false,
metaData: {},
inputPlaceholder: '',
listPlaceHolder: null,
step: 'any',
required: false,
};
Expand Down
5 changes: 3 additions & 2 deletions src/ntrode/ChannelMap.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import InfoIcon from './../element/InfoIcon';
* @returns Virtual DOM of the map for ntrode_electrode_group_channel_map
*/
const ChannelMap = (prop) => {
const { nTrodeItems, onBlur, onMapInput, electrodeGroupId, updateFormArray } =
const { nTrodeItems, onBlur, onMapInput, electrodeGroupId, updateFormArray, metaData } =
prop;

const getOptions = (options, mapValue, mapValues) => {
Expand Down Expand Up @@ -67,7 +67,7 @@ const ChannelMap = (prop) => {
updateFormArray={updateFormArray}
metaData={{
nameValue: 'bad_channels',
index,
index: metaData.index,
keyValue: 'ntrode_electrode_group_channel_map',
}}
onChange={updateFormArray}
Expand Down Expand Up @@ -139,6 +139,7 @@ ChannelMap.propType = {
onBlur: PropTypes.func,
updateFormArray: PropTypes.func,
onMapInput: PropTypes.func,
metaData: PropTypes.instanceOf(Object),
};

export default ChannelMap;
13 changes: 13 additions & 0 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,16 @@
.trim()
.replace(/[^a-z0-9]/gi, '');
};


/**
* Checks if running in Production
*
* @returns True if running in Production, false otherwise
*/
export const isProduction = () => {
// It is better to use node.js. But that requires adding a package.
// See - https://stackoverflow.com/a/70989566/178550. This is sufficient for
// now but can be updated if the need arises
return window.location.href.includes('https://lorenfranklab.github.io');

Check failure

Code scanning / CodeQL

Incomplete URL substring sanitization High

'
https://lorenfranklab.github.io
' can be anywhere in the URL, and arbitrary hosts may come before or after it.
};