diff --git a/README.md b/README.md
index 7c94ef502..66dfbfcff 100644
--- a/README.md
+++ b/README.md
@@ -41,6 +41,14 @@ To avoid injection attacks, ASP.NET Core defaults to only accepting forwarded he
- Data for Remotely will be saved in `/var/www/remotely/` within two files: appsettings.json and Remotely.db.
- These files will persist through teardown and setup of new Remotely containers.
- If upgrading from a non-Docker version of Remotely, overwrite these files with the ones from your previous installation.
+ - In that case, please note that you may need to change _SQLite_ parameter in your non-Docker appsettings.json. You may have something like:
+ ```
+ "SQLite": "DataSource=Remotely.db",
+ ```
+ but this should be changed to reflect the new Remotely.db location (relative to the container):
+ ```
+ "SQLite": "DataSource=/remotely-data/Remotely.db",
+ ```
- Use Caddy as a reverse proxy if you want to expose the site to the internet.
- If this is the first run, create your account by clicking the `Register` button on the main page.
- This account will be both the server admin and organization admin.
diff --git a/Server/API/RemoteControlController.cs b/Server/API/RemoteControlController.cs
index a93dcb04a..1f82b5de3 100644
--- a/Server/API/RemoteControlController.cs
+++ b/Server/API/RemoteControlController.cs
@@ -151,7 +151,8 @@ await _serviceHub.Clients.Client(serviceConnectionId).SendAsync("RemoteControl",
accessKey,
HttpContext.Connection.Id,
string.Empty,
- orgName);
+ orgName,
+ orgID);
var waitResult = await session.WaitForSessionReady(TimeSpan.FromSeconds(30));
if (!waitResult)
diff --git a/Server/Components/Scripts/RunScript.razor b/Server/Components/Scripts/RunScript.razor
index 5838fe681..1cffdfdba 100644
--- a/Server/Components/Scripts/RunScript.razor
+++ b/Server/Components/Scripts/RunScript.razor
@@ -15,7 +15,7 @@
Show only mine
- Show only mine
-
Show only mine
- ChildItems { get; } = new();
public SavedScript Script { get; init; }
}
diff --git a/Server/Pages/ScriptsPage.razor b/Server/Pages/ScriptsPage.razor
index aa09be595..885f5e4a8 100644
--- a/Server/Pages/ScriptsPage.razor
+++ b/Server/Pages/ScriptsPage.razor
@@ -32,7 +32,9 @@
@code {
- private IEnumerable? _filteredScriptNodes;
+ private readonly List _treeNodes = new();
+ private IEnumerable _allScripts = Enumerable.Empty();
+
private bool _showOnlyMyScripts = true;
[Parameter]
@@ -43,34 +45,24 @@
get => _showOnlyMyScripts;
set
{
- _filteredScriptNodes = null;
_showOnlyMyScripts = value;
+ _treeNodes.Clear();
}
}
- public List TreeNodes { get; } = new();
- public IEnumerable FilteredScriptNodes
+ public IEnumerable TreeNodes
{
get
{
- if (_filteredScriptNodes?.Any() == true)
+ if (_treeNodes?.Any() == true)
{
- return _filteredScriptNodes;
+ return _treeNodes;
}
- if (ShowOnlyMyScripts)
- {
- _filteredScriptNodes = TreeNodes.Where(x =>
- x.Script.CreatorId == User.Id);
- }
- else
- {
- _filteredScriptNodes = TreeNodes.Where(x =>
- x.Script.IsPublic || x.Script.CreatorId == User.Id);
- }
+ RefreshTreeNodes();
- return _filteredScriptNodes;
+ return _treeNodes;
}
}
@@ -85,31 +77,9 @@
public async Task RefreshScripts()
{
- TreeNodes.Clear();
- _filteredScriptNodes = null;
-
- var allScripts = await DataService.GetSavedScriptsWithoutContent(User.Id, User.OrganizationID);
-
- foreach (var script in allScripts)
- {
- var root = BuildFolderPath(script.FolderPath);
- root.Add(new ScriptTreeNode()
- {
- Name = script.Name,
- Script = script,
- ItemType = TreeItemType.Item
- });
- }
+ _treeNodes.Clear();
- TreeNodes.Sort((a, b) =>
- {
- if (a.ItemType != b.ItemType)
- {
- return Comparer.Default.Compare(a.ItemType, b.ItemType);
- }
-
- return Comparer.Default.Compare(a.Name, b.Name);
- });
+ _allScripts = await DataService.GetSavedScriptsWithoutContent(User.Id, User.OrganizationID);
}
protected override async Task OnInitializedAsync()
@@ -119,13 +89,14 @@
}
- private List BuildFolderPath(string folderPath)
+ private void CreateTreeNode(SavedScript script)
{
- var root = TreeNodes;
+ var root = _treeNodes;
+ ScriptTreeNode? targetParent = null;
- if (!string.IsNullOrWhiteSpace(folderPath))
+ if (!string.IsNullOrWhiteSpace(script.FolderPath))
{
- var paths = folderPath.Split("/", StringSplitOptions.RemoveEmptyEntries);
+ var paths = script.FolderPath.Split("/", StringSplitOptions.RemoveEmptyEntries);
for (var i = 0; i < paths.Length; i++)
{
var existingParent = root.Find(x => x.Name == paths[i]);
@@ -135,18 +106,58 @@
var newItem = new ScriptTreeNode()
{
Name = paths[i],
- ItemType = TreeItemType.Folder
+ ItemType = TreeItemType.Folder,
+ ParentNode = existingParent
};
root.Add(newItem);
root = newItem.ChildItems;
+ targetParent = newItem;
}
else
{
root = existingParent.ChildItems;
+ targetParent = existingParent;
}
}
}
- return root;
+ var scriptNode = new ScriptTreeNode()
+ {
+ Name = script.Name,
+ Script = script,
+ ItemType = TreeItemType.Item,
+ ParentNode = targetParent
+ };
+
+ root.Add(scriptNode);
+ }
+
+ private void RefreshTreeNodes()
+ {
+ _treeNodes.Clear();
+
+ foreach (var script in _allScripts)
+ {
+ var showScript = ShowOnlyMyScripts ?
+ script.CreatorId == User.Id :
+ script.CreatorId == User.Id || script.IsPublic;
+
+ if (!showScript)
+ {
+ continue;
+ }
+
+ CreateTreeNode(script);
+ }
+
+ _treeNodes.Sort((a, b) =>
+ {
+ if (a.ItemType != b.ItemType)
+ {
+ return Comparer.Default.Compare(a.ItemType, b.ItemType);
+ }
+
+ return Comparer.Default.Compare(a.Name, b.Name);
+ });
}
}
diff --git a/Server/Services/DataService.cs b/Server/Services/DataService.cs
index 423b4d06f..8c8c7f5a8 100644
--- a/Server/Services/DataService.cs
+++ b/Server/Services/DataService.cs
@@ -655,12 +655,12 @@ public async Task ClearLogs(string currentUserName)
{
if (currentUser.IsServerAdmin)
{
- dbContext.EventLogs.RemoveRange(dbContext.EventLogs);
+ await dbContext.EventLogs.ExecuteDeleteAsync();
}
else
{
var eventLogs = dbContext.EventLogs.Where(x => x.OrganizationID == currentUser.OrganizationID);
- dbContext.EventLogs.RemoveRange(eventLogs);
+ await eventLogs.ExecuteDeleteAsync();
}
await dbContext.SaveChangesAsync();