Skip to content

Commit 812e689

Browse files
authored
Merge pull request #696 from MetaCell/feature/netpyne-122
netpyne-122 Add default directory for save action
2 parents 54401ae + 0480a62 commit 812e689

2 files changed

Lines changed: 26 additions & 4 deletions

File tree

netpyne_ui/netpyne_geppetto.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -819,13 +819,17 @@ def checkFileExists(self, path):
819819
path = Path(path or '')
820820
return path.exists()
821821

822-
def getDirList(self, dir=None, onlyDirs=False, filterFiles=False, subDir=None):
823-
# Get Current dir
822+
def getFullPath(self, dir, subDir):
824823
if dir is None or dir == '':
825824
base = constants.NETPYNE_WORKDIR_PATH
826825
if subDir:
827-
base = os.path.join(base, subDir)
826+
base = os.path.join(base, subDir)
828827
dir = os.path.join(os.getcwd(), base)
828+
return dir
829+
830+
def getDirList(self, dir=None, onlyDirs=False, filterFiles=False, subDir=None):
831+
# Get Current dir
832+
dir = self.getFullPath(dir, subDir)
829833
dir_list = []
830834
file_list = []
831835
for f in sorted(os.listdir(str(dir)), key=str.lower):

webapp/components/topbar/dialogs/OverwriteModel.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,35 @@ const saveOptions = [
3232
},
3333
];
3434

35+
const DEFAULT_DIR = "uploads";
36+
3537
const OverwriteModel = (props) => {
38+
const updateFullPath = (value) => {
39+
if (value && value.startsWith('/')) { // We know we will be in a UNIX like env.
40+
return value
41+
}
42+
Utils
43+
.evalPythonMessage('netpyne_geppetto.getFullPath', [null, value])
44+
.then((fullpath) => {
45+
setDstPath(`${fullpath}/`)
46+
})
47+
return DEFAULT_DIR
48+
}
49+
3650
const srcPath = useSelector((state) => state.general.modelPath);
3751
const [explorerDialogOpen, setExplorerDialogOpen] = React.useState(false);
3852
const [openOverwriteDialog, setOpenOverwriteDialog] = React.useState(false);
3953
const [isDirectoryValid, setIsDirectoryValid] = React.useState(false);
4054
const [explorerParameter, setExplorerParameter] = React.useState('srcPath');
41-
const [dstPath, setDstPath] = React.useState(srcPath);
55+
const [dstPath, setDstPath] = React.useState(srcPath ? srcPath: DEFAULT_DIR);
4256
const [options, setOptions] = React.useState({
4357
exportNetParamsAsPython: false,
4458
exportSimConfigAsPython: false
4559
});
4660
const dispatch = useDispatch();
4761

62+
updateFullPath(dstPath);
63+
4864
const getDirAndModuleFromPath = (fullpath) => {
4965
const fileName = fullpath.replace(/^.*[\\/]/, '');
5066
const moduleName = fileName.replace(/\.[^/.]+$/, '');
@@ -128,6 +144,8 @@ const OverwriteModel = (props) => {
128144
// We cleanup on close
129145
React.useEffect(() => { return () => props.onRequestClose() }, []);
130146

147+
148+
131149
return (
132150
<>
133151
<ActionValidationDialog

0 commit comments

Comments
 (0)