Skip to content

Commit

Permalink
Add loading project file to controller editora
Browse files Browse the repository at this point in the history
  • Loading branch information
keyroll-99 committed May 28, 2024
1 parent f022fce commit 650ad9d
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 14 deletions.
17 changes: 10 additions & 7 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,16 @@ Good to have - 30-60 days
- [X] Simple view where the user can drag and drop boxes
- [X] Nav menu
- [X] Creating project
- [ ] Users can connect boxes
- [ ] Run project
- [ ] Adding controller
- [ ] Adding service
- [ ] Add a way to create a simple CRUD
- [ ] Add logic statement
- [ ] Add loop statement
- [ ] Configuration endpoint class
- [ ] Save to file
- [ ] Load from file
- [ ] Users can connect boxes
- [ ] Run project
- [ ] Adding controller
- [ ] Adding service
- [ ] Add a way to create a simple CRUD
- [ ] Add logic statement
- [ ] Add loop statement

Nice to have - 30 days
- [ ] Tools
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Fiona.IDE.ProjectManager.Exceptions;

public class ProjectFileNotFoundException(string @namespace): Exception($"Project with namespace {@namespace} not found")
{

}
1 change: 1 addition & 0 deletions ide/src/Fiona.IDE.ProjectManager/IProjectManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public interface IProjectManager
Task<string> CreateProject(string path, string name);
Task LoadProject(string path);
IEnumerable<ProjectFile> GetFiles();
ProjectFile GetProjectFileByNamespace(string @namespace);
Task CreateFileAsync(string name, string folderPath);

}
Expand Down
8 changes: 8 additions & 0 deletions ide/src/Fiona.IDE.ProjectManager/Models/Dependency.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Fiona.IDE.ProjectManager.Models;

internal sealed class Dependency(string name, string type)
{
public string Name { get; } = name;
public string Type { get; } = type;

}
12 changes: 7 additions & 5 deletions ide/src/Fiona.IDE.ProjectManager/Models/ProjectFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ public sealed class ProjectFile
{
public string Path { get; }
public string Name { get; }
public static string Extension = "fn";
public string Namespace => Path.Replace(System.IO.Path.DirectorySeparatorChar.ToString(), ".");
public string Namespace { get; }
public const string Extension = "fn";


[JsonConstructor]
private ProjectFile(string path)
{
Path = path;
Name = path.Split(System.IO.Path.DirectorySeparatorChar).Last();

Namespace = path.Replace(System.IO.Path.DirectorySeparatorChar.ToString(), ".").Split(":").Last().Replace(".fn", "")[1..];
}

internal static ProjectFile Create(string path)
Expand All @@ -27,6 +27,8 @@ internal static ProjectFile Create(string path)
}
File.Create(path);



return new ProjectFile(path);
}
}
Expand Down
2 changes: 2 additions & 0 deletions ide/src/Fiona.IDE.ProjectManager/ProjectManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ public async Task LoadProject(string path)

public IEnumerable<ProjectFile> GetFiles()
=> Project?.ProjectFileUrl ?? Enumerable.Empty<ProjectFile>() ;
public ProjectFile GetProjectFileByNamespace(string @namespace)
=> Project?.ProjectFileUrl.FirstOrDefault(x => x.Namespace == @namespace) ?? throw new ProjectFileNotFoundException(@namespace);

Check warning on line 42 in ide/src/Fiona.IDE.ProjectManager/ProjectManager.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference argument for parameter 'source' in 'ProjectFile? Enumerable.FirstOrDefault<ProjectFile>(IEnumerable<ProjectFile> source, Func<ProjectFile, bool> predicate)'.

public Task CreateFileAsync(string name, string folderPath)
{
Expand Down
10 changes: 8 additions & 2 deletions ide/src/Fiona.IDE/Components/Pages/Project/Index.razor
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
@using Blazor.Diagrams.Core.Geometry
@using Blazor.Diagrams.Components
@using Fiona.IDE.ProjectManager
@using Fiona.IDE.ProjectManager.Models
@inject NavigationManager NavManager


<div>
<div class="configuration">
<button @onclick="AddEndpoint">add endpoint</button>

</div>

<div class="diagram-container">
Expand All @@ -24,6 +26,8 @@
[Parameter]
public string? @namespace { get; init; } = default;

private ProjectFile CurrentFile { get; set; }

Check warning on line 29 in ide/src/Fiona.IDE/Components/Pages/Project/Index.razor

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'CurrentFile' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 29 in ide/src/Fiona.IDE/Components/Pages/Project/Index.razor

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'CurrentFile' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

private BlazorDiagram Diagram { get; set; } = null!;


Expand All @@ -34,7 +38,9 @@
NavManager.NavigateTo("/");
}

var options = new BlazorDiagramOptions
CurrentFile = ProjectManager.GetProjectFileByNamespace(@namespace!);

BlazorDiagramOptions options = new BlazorDiagramOptions
{
AllowMultiSelection = true,
Zoom =
Expand Down

0 comments on commit 650ad9d

Please sign in to comment.