Skip to content

Commit 92707c9

Browse files
committed
Added some more export options
- Option to exclude scripts - Option to exclude DOM - Option to exclude Images - Option to exclude Themes
1 parent 2c4ad4c commit 92707c9

File tree

4 files changed

+152
-59
lines changed

4 files changed

+152
-59
lines changed

CompanionFiles/Skyline DataMiner/Documents/Low Code App Editor/Install.xml

+18
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,12 @@ namespace Install_1.DOM
375375
{
376376
Log("Installing DOM items");
377377
378+
if(!Directory.Exists(context.AppContentPath + DOM_FOLDERPATH))
379+
{
380+
Log("No DOM Modules found, skipping this step.");
381+
return;
382+
}
383+
378384
foreach (var exportedDomJson in Directory.GetFiles(context.AppContentPath + DOM_FOLDERPATH, "*.json"))
379385
{
380386
Log("Installing " + exportedDomJson);
@@ -492,6 +498,12 @@ namespace Install_1.Images
492498
{
493499
Log("Low Code App Images Installation");
494500
501+
if (!Directory.Exists(context.AppContentPath + Images_FOLDERPATH))
502+
{
503+
Log("No Images found, skipping this step.");
504+
return;
505+
}
506+
495507
// Check if images folder exists
496508
if (!Directory.Exists(Images_Directory))
497509
{
@@ -841,6 +853,12 @@ namespace Install_1.Themes
841853
{
842854
Log("Low Code App Themes Installation");
843855
856+
if (!File.Exists(context.AppContentPath + Themes_Context_PATH))
857+
{
858+
Log("No Themes found, skipping this step.");
859+
return;
860+
}
861+
844862
var appThemesContent = File.ReadAllText(context.AppContentPath + Themes_Context_PATH);
845863
var appThemes = JObject.Parse(appThemesContent)["Themes"] as JArray;
846864

Low Code App Editor_1/Controllers/ExportController.cs

+80-31
Original file line numberDiff line numberDiff line change
@@ -82,48 +82,85 @@ private static string ExportPackage(IEngine engine, IEnumerable<App> apps, Expor
8282
// Add the app as CompanionFiles
8383
AddAppToArchive(zip, app, options);
8484

85-
engine.GenerateInformation($"Adding Scripts");
85+
if (options.ExcludeScripts)
86+
{
87+
engine.GenerateInformation("Skipping Automation Scripts");
88+
}
89+
else
90+
{
91+
engine.GenerateInformation($"Adding Scripts");
8692

87-
// Add the scripts used in the App
88-
var scripts = AddScriptsToArchive(zip, app);
93+
// Add the scripts used in the App
94+
var scripts = AddScriptsToArchive(zip, app);
8995

90-
engine.GenerateInformation($"Adding Script dependencies");
96+
engine.GenerateInformation($"Adding Script dependencies");
9197

92-
// Add script dependencies
93-
var appReferences = AddDependenciesToArchive(zip, app, scripts);
94-
foreach (var pair in appReferences)
95-
{
96-
if (!scriptReferences.ContainsKey(pair.Key))
98+
// Add script dependencies
99+
var appReferences = AddDependenciesToArchive(zip, app, scripts);
100+
foreach (var pair in appReferences)
97101
{
98-
scriptReferences.Add(pair.Key, pair.Value);
99-
}
100-
else
101-
{
102-
scriptReferences[pair.Key].AddRange(pair.Value);
102+
if (!scriptReferences.ContainsKey(pair.Key))
103+
{
104+
scriptReferences.Add(pair.Key, pair.Value);
105+
}
106+
else
107+
{
108+
scriptReferences[pair.Key].AddRange(pair.Value);
109+
}
103110
}
104111
}
105112

106-
// Add Dom definitions
107-
domModuleIds.AddRangeUnique(app.LatestVersion.GetUsedDomModules());
113+
if (!options.ExcludeDom)
114+
{
115+
// Add Dom definitions
116+
domModuleIds.AddRangeUnique(app.LatestVersion.GetUsedDomModules());
117+
}
108118

109-
// Add Images to companion files
110-
images.AddRangeUnique(app.LatestVersion.GetUsedImages());
119+
if (!options.ExcludeImages)
120+
{
121+
// Add Images to companion files
122+
images.AddRangeUnique(app.LatestVersion.GetUsedImages());
123+
}
111124

112-
// Add Theme
113-
themes.AddRangeUnique(app.LatestVersion.GetUsedThemes());
125+
if (!options.ExcludeThemes)
126+
{
127+
// Add Theme
128+
themes.AddRangeUnique(app.LatestVersion.GetUsedThemes());
129+
}
114130
}
115131

116132
// Add DOM modules
117-
engine.GenerateInformation($"Adding DOM modules");
118-
AddDomToArchive(engine, zip, domModuleIds, options);
133+
if (options.ExcludeDom)
134+
{
135+
engine.GenerateInformation($"Skipping DOM modules");
136+
}
137+
else
138+
{
139+
engine.GenerateInformation($"Adding DOM modules");
140+
AddDomToArchive(engine, zip, domModuleIds, options);
141+
}
119142

120-
// Add Images
121-
engine.GenerateInformation($"Adding Images");
122-
AddImagesToArchive(zip, images);
143+
if (options.ExcludeImages)
144+
{
145+
engine.GenerateInformation($"Skipping Images");
146+
}
147+
else
148+
{
149+
// Add Images
150+
engine.GenerateInformation($"Adding Images");
151+
AddImagesToArchive(zip, images);
152+
}
123153

124-
// Add Themes
125-
engine.GenerateInformation($"Adding Themes");
126-
AddThemesToArchive(zip, themes);
154+
if (options.ExcludeThemes)
155+
{
156+
engine.GenerateInformation($"Skipping Themes");
157+
}
158+
else
159+
{
160+
// Add Themes
161+
engine.GenerateInformation($"Adding Themes");
162+
AddThemesToArchive(zip, themes);
163+
}
127164

128165
engine.GenerateInformation($"Adding Installer code");
129166

@@ -275,7 +312,7 @@ private static void AddThemesToArchive(ZipArchive zip, List<DMADashboardTheme> t
275312
usedThemesArray.Clear();
276313

277314
// Add the ones needed for the package to the cloned
278-
foreach(var theme in themes)
315+
foreach (var theme in themes)
279316
{
280317
var usedTheme = allThemes.First(t => t["Name"].Value<string>() == theme.Name);
281318
usedThemesArray.Add(usedTheme);
@@ -293,17 +330,29 @@ public class ExportOptions
293330

294331
public bool ExportPackage { get; } = true;
295332

333+
public bool OverwritePreviousVersions { get; set; }
334+
335+
public bool ExcludeScripts { get; set; }
336+
337+
public bool ExcludeDom { get; set; }
338+
296339
public bool ExportDomInstances { get; set; }
297340

298-
public bool OverwritePreviousVersions { get; set; }
341+
public bool ExcludeImages { get; set; }
342+
343+
public bool ExcludeThemes { get; set; }
299344

300345
public static ExportOptions FromDialog(ExportDialog dialog)
301346
{
302347
return new ExportOptions
303348
{
304349
IncludeVersions = dialog.ExportVersions.IsChecked,
305-
ExportDomInstances = dialog.ExportDomInstances.IsChecked,
306350
OverwritePreviousVersions = dialog.OverwritePreviousVersions.IsChecked,
351+
ExcludeScripts = dialog.ExcludeScripts.IsChecked,
352+
ExcludeDom = dialog.ExcludeDom.IsChecked,
353+
ExportDomInstances = dialog.ExportDomInstances.IsChecked,
354+
ExcludeImages = dialog.ExcludeImages.IsChecked,
355+
ExcludeThemes = dialog.ExcludeThemes.IsChecked,
307356
};
308357
}
309358
}

Low Code App Editor_1/Low Code App Editor_1.cs

+9
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,15 @@ private void InitExport(IEngine engine)
177177
{
178178
controller.ShowDialog(overview);
179179
};
180+
export.ExcludeDom.UnChecked += (sender, e) =>
181+
{
182+
export.ExportDomInstances.IsEnabled = true;
183+
};
184+
export.ExcludeDom.Checked += (sender, e) =>
185+
{
186+
export.ExportDomInstances.IsChecked = false;
187+
export.ExportDomInstances.IsEnabled = false;
188+
};
180189
export.ExportButton.Pressed += (sender, e) =>
181190
{
182191
var selection = export.Apps.CheckedOptions;
+45-28
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,57 @@
11
namespace Low_Code_App_Editor_1.UI
22
{
3-
using System;
4-
using Skyline.DataMiner.Automation;
5-
using Skyline.DataMiner.Utils.InteractiveAutomationScript;
3+
using System;
64

7-
public class ExportDialog : Dialog<GridPanel>
8-
{
9-
public ExportDialog(IEngine engine) : base(engine)
10-
{
11-
Title = "Select apps to export";
5+
using Skyline.DataMiner.Automation;
6+
using Skyline.DataMiner.Utils.InteractiveAutomationScript;
127

13-
Panel.Add(Apps, 0, 0);
14-
Panel.Add(new Label("Include Version History:"), 1, 0);
15-
Panel.Add(ExportVersions, 1, 1);
16-
Panel.Add(new Label("Export Dom Instances:"), 3, 0);
17-
Panel.Add(ExportDomInstances, 3, 1);
18-
Panel.Add(new Label("Overwrite Previous Versions:"), 4, 0);
19-
Panel.Add(OverwritePreviousVersions, 4, 1);
20-
Panel.Add(new WhiteSpace(), 5, 0);
21-
Panel.Add(BackButton, 6, 0);
22-
Panel.Add(ExportButton, 6, 1);
23-
Panel.Add(Status, 7, 0, 1, 3);
24-
}
8+
public class ExportDialog : Dialog<GridPanel>
9+
{
10+
public ExportDialog(IEngine engine) : base(engine)
11+
{
12+
Title = "Select apps to export";
2513

26-
public ICheckBoxList Apps { get; } = new CheckBoxList();
14+
Panel.Add(Apps, 0, 0);
15+
Panel.Add(new Label("Include Version History:"), 1, 0);
16+
Panel.Add(ExportVersions, 1, 1);
17+
Panel.Add(new Label("Overwrite Previous Versions:"), 2, 0);
18+
Panel.Add(OverwritePreviousVersions, 2, 1);
19+
Panel.Add(new Label("Exclude Scripts:"), 3, 0);
20+
Panel.Add(ExcludeScripts, 3, 1);
21+
Panel.Add(new Label("Exclude DOM:"), 4, 0);
22+
Panel.Add(ExcludeDom, 4, 1);
23+
Panel.Add(new Label("Export DOM Instances:"), 5, 0);
24+
Panel.Add(ExportDomInstances, 5, 1);
25+
Panel.Add(new Label("Exclude Images:"), 6, 0);
26+
Panel.Add(ExcludeImages, 6, 1);
27+
Panel.Add(new Label("Exclude Themes:"), 7, 0);
28+
Panel.Add(ExcludeThemes, 7, 1);
29+
Panel.Add(new WhiteSpace(), 8, 0);
30+
Panel.Add(BackButton, 9, 0);
31+
Panel.Add(ExportButton, 10, 1);
32+
Panel.Add(Status, 11, 0, 1, 3);
33+
}
2734

28-
public ICheckBox ExportVersions { get; } = new CheckBox();
35+
public ICheckBoxList Apps { get; } = new CheckBoxList();
2936

30-
public ICheckBox ExportDomInstances { get; } = new CheckBox();
37+
public ICheckBox ExportVersions { get; } = new CheckBox();
3138

32-
public ICheckBox OverwritePreviousVersions { get; } = new CheckBox();
39+
public ICheckBox OverwritePreviousVersions { get; } = new CheckBox();
3340

34-
public IButton BackButton { get; } = new Button("Back");
41+
public ICheckBox ExcludeScripts { get; } = new CheckBox();
3542

36-
public IButton ExportButton { get; } = new Button("Export");
43+
public ICheckBox ExcludeDom { get; } = new CheckBox();
3744

38-
public ILabel Status { get; } = new Label(String.Empty);
39-
}
45+
public ICheckBox ExportDomInstances { get; } = new CheckBox();
46+
47+
public ICheckBox ExcludeImages { get; } = new CheckBox();
48+
49+
public ICheckBox ExcludeThemes { get; } = new CheckBox();
50+
51+
public IButton BackButton { get; } = new Button("Back");
52+
53+
public IButton ExportButton { get; } = new Button("Export");
54+
55+
public ILabel Status { get; } = new Label(String.Empty);
56+
}
4057
}

0 commit comments

Comments
 (0)