From feaa7112b4892e44f46ac145fbfd66a23c67217a Mon Sep 17 00:00:00 2001
From: Jan Lemmer <jan.lemmer@fst.tu-darmstadt.de>
Date: Tue, 9 Nov 2021 09:34:41 +0100
Subject: [PATCH] Correct a Bug, Closes #63

---
 +PlotID/@userDLG/userDLG.m |  2 +-
 +PlotID/Publish.m          | 21 ++++++++++++---------
 .gitignore                 |  1 +
 3 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/+PlotID/@userDLG/userDLG.m b/+PlotID/@userDLG/userDLG.m
index d053ced..3ec2b4b 100644
--- a/+PlotID/@userDLG/userDLG.m
+++ b/+PlotID/@userDLG/userDLG.m
@@ -51,7 +51,7 @@ classdef userDLG
             end
        end
        
-       function [] = error(message)
+       function [] = error(obj,message)
             %error handles critical errors
             %   critical errors will always result in a matlab error 
             
diff --git a/+PlotID/Publish.m b/+PlotID/Publish.m
index 1dddfef..34917d3 100644
--- a/+PlotID/Publish.m
+++ b/+PlotID/Publish.m
@@ -24,6 +24,7 @@ arguments
    options.Location {mustBeMember(options.Location ,{'local','server','manual','CI-Test'})} = 'local' % storage path
    options.Method {mustBeMember(options.Method ,{'individual','centralized'})} = 'individual'
    options.ParentFolder (1,:) {mustBeText} = 'export'
+   options.ConfigFileName (1,:) {mustBeText} = 'config.json' %individual config names possible
    options.CopyUserFCN (1,1) {mustBeNumericOrLogical} = true
    options.CSV (1,1) {mustBeNumericOrLogical} = false
    options.ShowMessages(1,1) {mustBeNumericOrLogical} = true
@@ -42,8 +43,8 @@ if numel(figure) > 1
 end
 
 %get ID from Figure
-
 ID = figure.Tag;
+
 if isempty(ID)  
    % no ID found, User dialog for Folder name 
    ID = inputdlg(['No ID defined- ' newline,...
@@ -54,8 +55,8 @@ if isempty(ID)
    warning(msg);
 end
 
-dlgObj = PlotID.userDLG(ID,options); % Error and MSG handeling    
-
+% Error and MSG handeling
+dlgObj = PlotID.userDLG(ID,options); 
 
 %% read config file
 try 
@@ -63,9 +64,6 @@ try
    config = jsondecode(txt);
 catch
    dlgObj.configError = true; 
-   msg = ['Error while reading the config file' newline,...
-       ' publishing on server not possible'];
-   dlgObj.softError(msg);
 end
 
 %% storage location
@@ -79,7 +77,12 @@ switch options.Location
             storPath = fullfile(scriptLocation,options.ParentFolder);
         end
     case 'server' %from config File
-         storPath = config.ServerPath;
+        if dlgObj.configError
+            msg = ['Error while reading the config file' newline,...
+                ' publishing on server not possible'];         
+            dlgObj.error(msg);
+        end
+        storPath = config.ServerPath;
     case 'manual' %UI
         storPath = uigetdir();
     case 'CI-Test'
@@ -88,7 +91,7 @@ end
 
 folderName = ['.',char(ID)]; %hidden folder
 
-%% Create Data-Directory
+%% Create data directory
 if isfolder(fullfile(storPath,folderName))
    dlgObj.error(['Folder ',folderName, ' exists - Plot was already published ']);
 elseif mkdir(fullfile(storPath,folderName))
@@ -97,7 +100,7 @@ else
 end
 disp(['publishing of ', ID, ' started']);
 
-%% Create a Copy of the script and user functions(optional)
+%% Create a copy of the script and user functions(optional)
 % script
 [~, status, msg] = PlotID.createFileCopy({scriptPath},folderName,storPath,ID, 'script');
 dlgObj.scriptPublished =status;
diff --git a/.gitignore b/.gitignore
index 708bea6..32ea249 100644
--- a/.gitignore
+++ b/.gitignore
@@ -37,6 +37,7 @@ testdata_2.h5
 testdata2.h5
 test_data.mat
 export/*
+unused*/*
 
 # Octave session info
 octave-workspace
-- 
GitLab