Skip to content

Commit d00cd42

Browse files
authored
feat: snapshots streaming
* fix: snapshot files orginization * fit: logs chunk writer basic implementation * feat: snapshot create request * feat: uploader basic implementation and chunk refactor * fix: refactored snapshot manager and chunk manager * fix: optimised snapshot upload for stream and bulk upload * fix: streamin chunks to backend * feat: snapshot upload and streaming * fix: code refactoring and dublication removed * feat: snapshot UI update, refactoring * fix: network error refactor, snapshot UI fixes * fix: statuses fix for snapshots and flow * fix: screenshot upload with multipart form data * feat: payload for screenshot upload request * feat: stop streaming * feat: UI improvements for snapshots view * feat: jahro settings added snapshoting mode * fix: datetime to Univarsal Time * fix: snapshot card, project settings loading * fix: project settings optimisation, UI fixes * feat: dedub for logs with count field * fix: minor fixes for mobile * fix: scroll for logs item height recalculation * fix: logs in scrollview optimisation * fix: snapshot statuses and errors fix. console open button default position * fix: proper release of managers * feat: config system refactor * fix: UI improvements * feat: refresh snapshots and minor bug fixes * fix: open button positioning in mobile devices * fix: default host to localhost * fix: minor UI fixes * fix: minor fixes for logs height * fix: logs cleanup * feat: new version
1 parent 8d7757a commit d00cd42

File tree

119 files changed

+9498
-3238
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

119 files changed

+9498
-3238
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
/[Ll]ogs/
1111
/[Uu]ser[Ss]ettings/
1212

13+
*.DS_Store
14+
1315
# MemoryCaptures can get excessive in size.
1416
# They also could contain extremely sensitive data
1517
/[Mm]emoryCaptures/
@@ -70,3 +72,4 @@ crashlytics-build.properties
7072
# Temporary auto-generated Android Assets
7173
/[Aa]ssets/[Ss]treamingAssets/aa.meta
7274
/[Aa]ssets/[Ss]treamingAssets/aa/*
75+

Editor/JahroInstallManager.cs

Lines changed: 25 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,53 @@
1-
using System;
2-
using System.Diagnostics;
31
using System.IO;
2+
using JahroConsole.Core.Context;
43
using JahroConsole.Core.Data;
5-
using JahroConsole.Editor;
64
using UnityEditor;
75
using UnityEngine;
86

9-
namespace JahroConsole.Core.Registry
7+
namespace JahroConsole.Editor
108
{
119

1210
[InitializeOnLoad]
13-
internal class JahroInstallManager : AssetPostprocessor
11+
internal class JahroInstallManager
1412
{
15-
16-
private const string BaseFolder = "Assets/Jahro";
17-
private const string ResourcesFolder = "Assets/Jahro/Resources";
18-
1913
static JahroInstallManager()
2014
{
15+
#if UNITY_EDITOR
16+
EditorApplication.projectChanged += onProjectChanged;
17+
#endif
2118
}
2219

23-
static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths, bool didDomainReload)
20+
private static void onProjectChanged()
2421
{
25-
if (didDomainReload)
22+
bool isSettingsFileExists = JahroProjectSettings.isSettingsFileExists();
23+
ValidateSettingsFile(JahroProjectSettings.Load());
24+
if (!isSettingsFileExists && Application.isPlaying == false)
2625
{
27-
bool isSettingsFileExists = JahroProjectSettings.isSettingsFileExists();
28-
var settings = JahroProjectSettings.LoadOrCreate();
29-
ValidateSettingsFile(settings);
30-
if (!isSettingsFileExists)
31-
{
32-
JahroEditorView.isFreshInstall = !isSettingsFileExists;
33-
JahroEditorView.ShowWindow();
34-
}
26+
JahroEditorView.isFreshInstall = true;
27+
JahroEditorView.ShowWindow();
3528
}
3629
}
3730

38-
public static void ValidateSettingsFile(JahroProjectSettings settings)
31+
private static JahroProjectSettings ValidateSettingsFile(JahroProjectSettings settings)
3932
{
4033
#if UNITY_EDITOR
41-
EnsureFolderExists(BaseFolder);
42-
EnsureFolderExists(ResourcesFolder);
34+
string assetPath = $"{JahroConfig.ProjectResourcesFolder}/{JahroConfig.ProjectSettingFile}.asset";
35+
if (settings == null)
36+
{
37+
settings = JahroProjectSettings.CreateDefault();
38+
}
4339

44-
string assetPath = $"{ResourcesFolder}/{FileManager.ProjectSettingFile}.asset";
40+
EnsureFolderExists(JahroConfig.ProjectBaseFolder);
41+
EnsureFolderExists(JahroConfig.ProjectResourcesFolder);
4542

46-
if (!AssetExists<JahroProjectSettings>(assetPath))
43+
if (AssetDatabase.LoadAssetAtPath<JahroProjectSettings>(assetPath) == null)
4744
{
48-
CreateAsset(settings, assetPath);
45+
AssetDatabase.CreateAsset(settings, assetPath);
46+
AssetDatabase.SaveAssets();
47+
AssetDatabase.Refresh();
4948
}
5049
#endif
50+
return settings;
5151
}
5252

5353
private static void EnsureFolderExists(string folderPath)
@@ -61,17 +61,5 @@ private static void EnsureFolderExists(string folderPath)
6161
AssetDatabase.SaveAssets();
6262
}
6363
}
64-
65-
private static bool AssetExists<T>(string assetPath) where T : UnityEngine.Object
66-
{
67-
return AssetDatabase.LoadAssetAtPath<T>(assetPath) != null;
68-
}
69-
70-
private static void CreateAsset<T>(T asset, string assetPath) where T : UnityEngine.Object
71-
{
72-
AssetDatabase.CreateAsset(asset, assetPath);
73-
AssetDatabase.SaveAssets();
74-
AssetDatabase.Refresh();
75-
}
7664
}
7765
}

Editor/View/JahroEditorView.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,15 @@ public static void ShowWindow()
3737
JahroEditorView wnd = GetWindow<JahroEditorView>(false, "Jahro Settings", true);
3838
wnd.titleContent = new GUIContent("Jahro Settings");
3939
wnd.minSize = new Vector2(300, 300);
40+
Vector2 size = new Vector2(EditorGUIUtility.GetMainWindowPosition().width, EditorGUIUtility.GetMainWindowPosition().height);
41+
size = size * 0.5f;
42+
wnd.position = new Rect(EditorGUIUtility.GetMainWindowPosition().center - size * 0.5f, size);
4043
}
4144

4245
public void CreateGUI()
4346
{
47+
_projectSettings = JahroProjectSettings.Load();
48+
4449
VisualElement root = rootVisualElement;
4550
m_VisualTreeAsset.CloneTree(rootVisualElement);
4651

@@ -66,9 +71,6 @@ public void CreateGUI()
6671

6772
_welcomeView.OnValidationSuccess += OnAPIKeyValidated;
6873
_settingsView.OnResetApiKey += ResetApiKey;
69-
70-
_projectSettings = JahroProjectSettings.LoadOrCreate();
71-
7274
_projectSettings.OnSettingsChanged += SaveProjectSettings;
7375

7476
SetWindowMode(WindowMode.LOADING);
@@ -104,6 +106,7 @@ await VersionChecker.Send(isFreshInstall,
104106
(error) =>
105107
{
106108
_errorLoadingLabel.text = "Error checking version: " + error.message;
109+
Debug.LogError("Error checking version: " + error.message);
107110
}
108111
);
109112
}
@@ -129,6 +132,8 @@ private async void CheckAndValidateAPIKey()
129132
return;
130133
}
131134

135+
SetWindowMode(WindowMode.WELCOME);
136+
132137
try
133138
{
134139
await KeyValidator.Send(savedApiKey, (response) =>
@@ -138,6 +143,7 @@ await KeyValidator.Send(savedApiKey, (response) =>
138143
{
139144
_apiKeyValidation = response;
140145
_welcomeView.ShowError(response.message);
146+
Debug.LogError("Error validating API key: " + response.message);
141147
});
142148

143149
if (_apiKeyValidation != null && _apiKeyValidation.success)

Editor/View/JahroEditorView.uxml

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,20 @@
1919
<ui:Label text="Loading..." />
2020
<ui:Label text="Loading..." name="ErrorLabel" class="error-text" />
2121
</ui:VisualElement>
22-
<ui:VisualElement name="WelcomeBlock" style="flex-grow: 0; align-content: center; justify-content: center; align-items: center; flex-shrink: 10; padding-top: 32px; padding-right: 32px; padding-bottom: 32px; padding-left: 32px; align-self: stretch; display: none;">
23-
<ui:ScrollView vertical-scroller-visibility="Auto" name="ScrollView" horizontal-scroller-visibility="Hidden" style="flex-grow: 0; flex-shrink: 1; align-self: stretch;">
24-
<ui:VisualElement name="WelcomeBlock" style="flex-grow: 0; align-content: stretch; justify-content: space-between; align-items: stretch; flex-shrink: 1; padding-top: 0; padding-right: 0; padding-bottom: 0; padding-left: 0; align-self: stretch; display: flex;">
22+
<ui:VisualElement name="WelcomeBlock" style="flex-grow: 1; align-content: center; justify-content: center; align-items: center; flex-shrink: 0; padding-top: 32px; padding-right: 32px; padding-bottom: 32px; padding-left: 32px; align-self: stretch; display: none;">
23+
<ui:ScrollView vertical-scroller-visibility="Auto" name="ScrollView" horizontal-scroller-visibility="Hidden" style="flex-grow: 1; flex-shrink: 0; align-self: stretch;">
24+
<ui:VisualElement name="WelcomeBlock" style="flex-grow: 1; align-content: stretch; justify-content: space-between; align-items: stretch; flex-shrink: 0; padding-top: 0; padding-right: 0; padding-bottom: 0; padding-left: 0; align-self: stretch; display: flex;">
2525
<ui:Label text="Welcome to Jahro" name="Title" class="h1" />
2626
<ui:Label text="enter your API key to begin" name="Subtitle" class="h2" />
27-
<ui:VisualElement style="flex-grow: 0; margin-top: 32px; align-self: stretch;">
27+
<ui:VisualElement style="flex-grow: 0; margin-top: 32px; align-self: stretch; flex-shrink: 1;">
2828
<ui:Label text="Project API Key" class="text-category" />
2929
<ui:VisualElement name="apikey-input" style="flex-grow: 0; flex-direction: row; margin-bottom: 0; justify-content: center; align-items: center; align-content: flex-start;">
3030
<ui:TextField label="Text Field" placeholder-text="Enter your API key" name="key-input" hide-placeholder-on-focus="false" password="false" style="flex-grow: 1; min-width: 200px; flex-shrink: 0; margin-top: 4px;" />
3131
<ui:Button text="Submit" name="ValidateKey" class="btn-primary" style="flex-shrink: 1; flex-grow: 0; width: 100px; height: 36px; margin-top: 5px; margin-bottom: 0; padding-top: 0; padding-bottom: 0; padding-right: 0; padding-left: 0; margin-right: 0; margin-left: 0; align-self: auto; align-content: auto; align-items: stretch; justify-content: center; -unity-font-style: bold;" />
3232
</ui:VisualElement>
3333
<ui:Label text="Error Message" name="KeyErrorLabel" class="text-subline error-text" style="padding-top: 6px;" />
34-
<ui:VisualElement style="flex-basis: 20px; flex-direction: row; align-items: center;">
35-
<ui:Label text="You can find the API key here in the" enable-rich-text="true" class="text-subline" style="padding-top: 0; -unity-text-align: middle-left;" />
34+
<ui:VisualElement style="flex-basis: 20px; flex-direction: row; align-items: center; flex-grow: 1; flex-shrink: 0; flex-wrap: wrap; padding-top: 4px;">
35+
<ui:Label text="You can find the API key here in the" enable-rich-text="true" class="text-subline" style="padding-top: 0; -unity-text-align: middle-left; white-space: normal;" />
3636
<ui:Button text="Project API Keys page" display-tooltip-when-elided="true" name="ProjectPageLink" class="footer-button" style="-unity-text-align: middle-left; align-items: flex-start; margin-left: 0; padding-left: 2px; padding-right: 2px;" />
3737
</ui:VisualElement>
3838
</ui:VisualElement>
@@ -41,11 +41,12 @@
4141
</ui:VisualElement>
4242
<ui:VisualElement name="SettingsBlock" style="flex-grow: 1; align-content: center; justify-content: flex-start; align-items: stretch; flex-shrink: 0; padding-top: 32px; padding-right: 32px; padding-bottom: 32px; padding-left: 32px; align-self: auto; display: flex; flex-basis: 100%;">
4343
<ui:VisualElement name="TabView" style="flex-grow: 1; max-width: none; flex-basis: 100%;">
44-
<ui:VisualElement name="TabsControl" class="tab-header" style="height: 40px; flex-direction: row; justify-content: center; flex-shrink: 0; flex-basis: 40px; margin-bottom: 16px;">
45-
<ui:Button text="Account" display-tooltip-when-elided="true" name="AccountTab" class="tab-button" />
46-
<ui:Button text="Settings" display-tooltip-when-elided="true" name="SettingTab" class="tab-button" />
44+
<ui:VisualElement name="TabsControl" class="tab-header" style="height: auto; flex-direction: row; justify-content: center; flex-shrink: 0; flex-basis: auto; margin-bottom: 0; flex-wrap: wrap; flex-grow: 0; align-items: stretch; padding-top: 0; padding-bottom: 0; padding-right: 0; padding-left: 0;">
45+
<ui:Button text="Account" display-tooltip-when-elided="true" name="AccountTab" class="tab-button" style="max-height: 36px; min-height: 36px; height: 36px; margin-top: 4px; margin-bottom: 4px;" />
46+
<ui:Button text="Snapshots Settings" display-tooltip-when-elided="true" name="SnapshotsTab" class="tab-button" style="height: 40px; max-height: 40px; min-height: 40px; margin-top: 4px; margin-bottom: 4px;" />
47+
<ui:Button text="General Settings" display-tooltip-when-elided="true" name="SettingTab" class="tab-button" style="height: 40px; min-height: 40px; max-height: 40px; margin-top: 4px; margin-bottom: 4px;" />
4748
</ui:VisualElement>
48-
<ui:VisualElement style="flex-grow: 1;">
49+
<ui:VisualElement style="flex-grow: 100; margin-top: 16px;">
4950
<ui:VisualElement name="AccountContainer" style="flex-grow: 1; display: none;">
5051
<ui:ScrollView>
5152
<ui:VisualElement name="VisualElement" style="flex-grow: 1; flex-shrink: 0; justify-content: space-between; align-self: stretch; align-content: stretch; height: 100%; flex-basis: auto;">
@@ -81,7 +82,7 @@
8182
</ui:VisualElement>
8283
</ui:ScrollView>
8384
</ui:VisualElement>
84-
<ui:VisualElement name="SettingsContainer" style="display: flex; flex-grow: 1;">
85+
<ui:VisualElement name="SettingsContainer" style="display: none; flex-grow: 1;">
8586
<ui:ScrollView horizontal-scroller-visibility="Hidden" name="ScrollView" style="margin-top: 8px; margin-bottom: 8px;">
8687
<ui:VisualElement name="SettingsItem" style="flex-grow: 1; flex-direction: row; justify-content: space-between; flex-wrap: nowrap; flex-shrink: 0; flex-basis: auto; padding-top: 8px; padding-bottom: 8px;">
8788
<ui:VisualElement name="VisualElement" style="flex-grow: 1; margin-left: 0;">
@@ -103,7 +104,7 @@
103104
<ui:Label text="Launch Key" name="Title" class="settings-item-title" style="margin-top: 2px; margin-bottom: 2px;" />
104105
<ui:Label text="Set the key to open the Jahro window during play mode." name="Description" class="settings-item-description" />
105106
</ui:VisualElement>
106-
<uie:EnumField value="Center" name="LaunchKeyPicker" style="min-width: auto; flex-grow: 1;" />
107+
<uie:EnumField value="Center" name="LaunchKeyPicker" style="min-width: 150px; flex-grow: 1; min-height: 40px; max-height: 40px; margin-top: 3px; margin-bottom: 3px;" />
107108
</ui:VisualElement>
108109
<ui:VisualElement name="SettingsItem" style="flex-grow: 1; flex-direction: row; justify-content: space-between; flex-wrap: nowrap; flex-shrink: 0; flex-basis: auto; padding-top: 8px; padding-bottom: 8px;">
109110
<ui:VisualElement name="VisualElement" style="flex-grow: 1; margin-left: 0;">
@@ -119,21 +120,27 @@
119120
</ui:VisualElement>
120121
<ui:Toggle name="MobileTapAreaToggle" style="min-width: auto; justify-content: flex-end; align-content: flex-end; align-self: auto; align-items: stretch; flex-direction: row;" />
121122
</ui:VisualElement>
122-
<ui:VisualElement name="SettingsItem" style="flex-grow: 1; flex-direction: row; justify-content: space-between; flex-wrap: nowrap; flex-shrink: 0; flex-basis: auto; padding-top: 8px; padding-bottom: 8px;">
123-
<ui:VisualElement name="VisualElement" style="flex-grow: 1; margin-left: 0;">
124-
<ui:Label text="Duplicate Jahro.Log to Console" name="Title" class="settings-item-title" style="margin-top: 2px; margin-bottom: 2px;" />
125-
<ui:Label text="Show Jahro.Log() messages in Unity Console too." name="Description" class="settings-item-description" />
126-
</ui:VisualElement>
127-
<ui:Toggle name="DublicateLogsToggle" style="min-width: auto; justify-content: flex-end; align-content: flex-end; align-self: auto; align-items: stretch; flex-direction: row;" />
128-
</ui:VisualElement>
129123
<ui:VisualElement name="Separator" style="flex-grow: 1; border-top-width: 0; border-left-color: rgba(0, 0, 0, 0.6); border-right-color: rgba(0, 0, 0, 0.6); border-top-color: rgba(0, 0, 0, 0.6); border-bottom-color: rgba(0, 0, 0, 0.6); background-color: rgb(75, 75, 75); height: 2px; margin-top: 8px; margin-bottom: 4px;" />
130124
<ui:VisualElement name="SettingsItem" style="flex-grow: 1; flex-direction: row; justify-content: space-between; flex-wrap: wrap; flex-shrink: 0; flex-basis: auto; padding-top: 8px; padding-bottom: 8px;">
131125
<ui:VisualElement name="VisualElement" style="flex-grow: 1; margin-left: 0; min-width: 150px;">
132126
<ui:Label text="Assemblies" name="Title" class="settings-item-title" style="margin-top: 2px; margin-bottom: 2px;" />
133127
<ui:Label text="Select assemblies where Jahro looks for Commands and Watchers." name="Description" class="settings-item-description" />
134128
</ui:VisualElement>
135-
<uie:MaskField name="AssembliesPicker" style="min-width: auto; flex-grow: 1;" />
129+
<uie:MaskField name="AssembliesPicker" style="min-width: 150px; flex-grow: 1; min-height: 40px; max-height: 40px; margin-top: 3px; margin-bottom: 3px;" />
130+
</ui:VisualElement>
131+
<ui:VisualElement name="Separator" style="flex-grow: 1; border-top-width: 0; border-left-color: rgba(0, 0, 0, 0.6); border-right-color: rgba(0, 0, 0, 0.6); border-top-color: rgba(0, 0, 0, 0.6); border-bottom-color: rgba(0, 0, 0, 0.6); background-color: rgb(75, 75, 75); height: 2px; margin-top: 8px; margin-bottom: 4px;" />
132+
</ui:ScrollView>
133+
</ui:VisualElement>
134+
<ui:VisualElement name="SnapshotsContainer" style="display: flex; flex-grow: 1;">
135+
<ui:ScrollView horizontal-scroller-visibility="Hidden" name="ScrollView" style="margin-top: 8px; margin-bottom: 8px;">
136+
<ui:VisualElement name="SettingsItem" style="flex-grow: 1; flex-direction: row; justify-content: space-between; flex-wrap: wrap; flex-shrink: 0; flex-basis: auto; padding-top: 8px; padding-bottom: 8px; align-items: flex-end;">
137+
<ui:VisualElement name="VisualElement" style="flex-grow: 1; margin-left: 0;">
138+
<ui:Label text="Snapshots Mode" name="Title" class="settings-item-title" style="margin-top: 2px; margin-bottom: 2px; padding-bottom: 8px;" />
139+
<ui:Label text="&lt;color=white&gt;&lt;b&gt;Recording&lt;/b&gt;&lt;/color&gt;&#10;Snapshots are stored on the device only. Nothing is uploaded to Jahro.&#10;&#10;&lt;color=white&gt;&lt;b&gt;Streaming - Except Editor&lt;/b&gt;&lt;/color&gt;&#10;Auto-upload for devices; Editor snapshots stay local&#10;&#10;&lt;color=white&gt;&lt;b&gt;Streaming - All&lt;/b&gt;&lt;/color&gt;&#10;Auto-upload snapshots to Jahro for every platform" name="Description" double-click-selects-word="false" class="settings-item-description" />
140+
</ui:VisualElement>
141+
<uie:EnumField value="Center" name="SnapshotsModePicker" style="min-width: 150px; flex-grow: 1; max-height: 40px; min-height: 40px; margin-top: 3px; margin-bottom: 3px;" />
136142
</ui:VisualElement>
143+
<ui:VisualElement name="Separator" style="flex-grow: 1; border-top-width: 0; border-left-color: rgba(0, 0, 0, 0.6); border-right-color: rgba(0, 0, 0, 0.6); border-top-color: rgba(0, 0, 0, 0.6); border-bottom-color: rgba(0, 0, 0, 0.6); background-color: rgb(75, 75, 75); height: 2px; margin-top: 8px; margin-bottom: 4px;" />
137144
</ui:ScrollView>
138145
</ui:VisualElement>
139146
</ui:VisualElement>

0 commit comments

Comments
 (0)