Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamo new homepage implementation #14879

Merged
merged 33 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
0cddb6c
initial WIP
dnenov Dec 19, 2023
d84d2c8
initial changes
dnenov Jan 9, 2024
1e105d3
moved loading to frontend
dnenov Jan 14, 2024
c36934a
guided tours implemented
dnenov Jan 19, 2024
42720d0
samples backend code
dnenov Jan 22, 2024
b9a0cf9
added ShowSampleFilesInFolder
dnenov Jan 23, 2024
0a33d79
local bundle files added to source for testing purposes
dnenov Jan 23, 2024
3fe0806
Merge remote-tracking branch 'upstream/master' into homepage-implemen…
dnenov Jan 24, 2024
89f9a46
Merge remote-tracking branch 'upstream/master' into homepage-implemen…
dnenov Jan 24, 2024
9aefed0
resolving build issues
dnenov Jan 24, 2024
b792e55
replaced .net6 complient API method
dnenov Jan 24, 2024
48bf145
Merge remote-tracking branch 'upstream/master' into homepage-implemen…
dnenov Jan 26, 2024
5ba8fb3
added guides description
dnenov Jan 29, 2024
b4e0dbf
send image author data test
dnenov Jan 30, 2024
7c679d3
set sidebar width relative to user
dnenov Jan 30, 2024
de84f1a
Merge remote-tracking branch 'upstream/master' into homepage-implemen…
dnenov Jan 30, 2024
65ad283
remove coupling to sidebar width, implemented Template API
dnenov Jan 30, 2024
3b65e9b
for review
dnenov Jan 30, 2024
23b8648
Merge remote-tracking branch 'upstream/master' into homepage-implemen…
dnenov Feb 5, 2024
ecf3020
tests added
dnenov Feb 7, 2024
e7d4a6d
Merge remote-tracking branch 'upstream/master' into homepage-implemen…
dnenov Feb 7, 2024
d152d57
Merge remote-tracking branch 'upstream/master' into homepage-implemen…
dnenov Feb 12, 2024
0518aef
remove old code
dnenov Feb 12, 2024
2927d6e
npm build implementation
dnenov Feb 19, 2024
42361fb
Merge remote-tracking branch 'upstream/master' into homepage-implemen…
dnenov Feb 19, 2024
c8b79f6
update dynamohome build
dnenov Feb 19, 2024
d1e3b7b
Merge remote-tracking branch 'upstream/master' into homepage-implemen…
dnenov Feb 26, 2024
98ee40b
comments
dnenov Feb 26, 2024
9c39751
tests for new helper methods
dnenov Feb 26, 2024
c8da6fa
checks for valid json dyn input
dnenov Feb 27, 2024
2dee99e
swap 1.0 for 1.x
dnenov Feb 27, 2024
9e2c5d7
update
QilongTang Feb 27, 2024
f768787
Update
QilongTang Feb 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 87 additions & 2 deletions src/DynamoCoreWpf/Controls/StartPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using Dynamo.Utilities;
using Dynamo.ViewModels;
using Dynamo.Wpf.Properties;
using Newtonsoft.Json;
using NotificationObject = Dynamo.Core.NotificationObject;

namespace Dynamo.UI.Controls
Expand Down Expand Up @@ -72,6 +73,10 @@ internal StartPageListItem(string caption, string iconPath)
public string Caption { get; private set; }
public string SubScript { get; set; }
public string ToolTip { get; set; }
public string DateModified { get; set; }
public string Description { get; internal set; }
public string Thumbnail { get; set; }
public string Author { get; internal set; }
public string ContextData { get; set; }
public Action ClickAction { get; set; }

Expand All @@ -86,6 +91,8 @@ public Visibility IconVisibility
get { return ((icon == null) ? Visibility.Collapsed : Visibility.Visible); }
}



#endregion

#region Private Class Helper Methods
Expand Down Expand Up @@ -367,29 +374,107 @@ private void RefreshFileList(ObservableCollection<StartPageListItem> files,
IEnumerable<string> filePaths)
QilongTang marked this conversation as resolved.
Show resolved Hide resolved
{
files.Clear();


Stopwatch stopwatch = new Stopwatch();

foreach (var filePath in filePaths.Where(x => x != null))
{
try
{
// Skip files which were moved or deleted (consistent with Revit behavior)
if (!System.IO.File.Exists(filePath)) continue;

var extension = Path.GetExtension(filePath).ToUpper();
// If not extension specified and code reach here, this means this is still a valid file
// only without file type. Otherwise, simply take extension substring skipping the 'dot'.
var subScript = extension.IndexOf(".") == 0 ? extension.Substring(1) : "";
var caption = Path.GetFileNameWithoutExtension(filePath);

// Measure the performance for this region
// deserializes the file only once
var jsonObject = DeserializeJsonFile(filePath);
dnenov marked this conversation as resolved.
Show resolved Hide resolved
var description = GetGraphDescription(jsonObject);
var thumbnail = GetGraphThumbnail(jsonObject);
var author = GetGraphAuthor(jsonObject);

var date = GetDateModified(filePath);

files.Add(new StartPageListItem(caption)
{
ContextData = filePath,
ToolTip = filePath,
SubScript = subScript,
ClickAction = StartPageListItem.Action.FilePath
});
Description = description,
Thumbnail = thumbnail,
Author = author,
DateModified = date,
ClickAction = StartPageListItem.Action.FilePath,

}); ;
}
catch (ArgumentException ex)
{
DynamoViewModel.Model.Logger.Log("File path is not valid: " + ex.StackTrace);
}
}

stopwatch.Stop(); // Stop the stopwatch

Debug.WriteLine($"Time taken to load {filePaths.Count()} files: {stopwatch.ElapsedMilliseconds} ms");
dnenov marked this conversation as resolved.
Show resolved Hide resolved
}

/// <summary>
/// Utility method to get the last time a file has been modified
/// </summary>
/// <param name="filePath"></param>
/// <returns></returns>
private string GetDateModified(string filePath)
{
FileInfo fileInfo = new FileInfo(filePath);

if (fileInfo.Exists)
{
DateTime lastModified = fileInfo.LastWriteTime;
return lastModified.ToString();
}
else
{
return string.Empty;
}
}

private Dictionary<string, object> DeserializeJsonFile(string filePath)
{
var jsonString = File.ReadAllText(filePath);
return JsonConvert.DeserializeObject<Dictionary<string, object>>(jsonString);
}

private const string BASE64PREFIX = "data:image/png;base64,";

private string GetGraphThumbnail(Dictionary<string, object> jsonObject)
{
jsonObject.TryGetValue("Thumbnail", out object thumbnail);

if (string.IsNullOrEmpty(thumbnail as string)) return string.Empty;

var base64 = String.Format("{0}{1}", BASE64PREFIX, thumbnail as string);

return base64;
}

private string GetGraphDescription(Dictionary<string, object> jsonObject)
{
jsonObject.TryGetValue("Description", out object description);

return description as string;
}

private string GetGraphAuthor(Dictionary<string, object> jsonObject)
{
jsonObject.TryGetValue("Author", out object author);

return author as string;
}

private void HandleRegularCommand(StartPageListItem item)
Expand Down
58 changes: 54 additions & 4 deletions src/DynamoCoreWpf/DynamoCoreWpf.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<UILib>true</UILib>
</PropertyGroup>
Expand Down Expand Up @@ -50,11 +50,46 @@

<!--Deletes the tgz file-->
<Delete Files="$(MSBuildProjectDirectory)\$(Last).tgz" />
</Target>

<ItemGroup>
</Target>


<Target Name="NpmRunBuildHomePage" BeforeTargets="BeforeBuild">
<!--This command updates the npm registry configuration if necessary-->
<Exec Command="$(PowerShellCommand) -ExecutionPolicy ByPass -Command $(SolutionDir)\setnpmreg.ps1" />
<!--Download the latest build of the Dynamo Home package-->
<Exec Command="npm pack @dynamods/dynamo-home@latest" />
</Target>

<Target Name="ExtractTGZFileDynamoHome" DependsOnTargets="NpmRunBuildHomePage" BeforeTargets="BeforeBuild">
<!--Locate the .tgz files for the Dynamo Home package-->
<ItemGroup>
<TGZFilesDynamoHome Include="./dynamods-dynamo-home-*.tgz" />
</ItemGroup>

<!--Reverse the order of the files to get the higher version-->
<ItemGroup>
<ReversedDynamoHome Include="@(TGZFilesDynamoHome-&gt;Reverse())" />
</ItemGroup>

<PropertyGroup>
<Last>%(TGZFilesDynamoHome.Filename)</Last>
</PropertyGroup>

<!--Create the folder for the Dynamo Home package-->
<MakeDir Directories="Packages/DynamoHome" />

<!--Extract the file to the specified directory-->
<Exec Command="tar -xzf $(MSBuildProjectDirectory)\$(Last).tgz --strip-components=1 --directory=Packages/DynamoHome"></Exec>

<!--Delete the tgz file-->
<Delete Files="$(MSBuildProjectDirectory)\$(Last).tgz" />
</Target>

<ItemGroup>
<None Remove="Packages\SplashScreen\build\index.bundle.js" />
<None Remove="Packages\SplashScreen\build\index.html" />
<None Remove="Packages\DynamoHome\build\index.bundle.js" />
<None Remove="Packages\DynamoHome\build\index.html" />
<None Remove="UI\Images\Canvas\canvas-button-geometry-scaling.png" />
<None Remove="UI\Images\checkmark_16px.png" />
<None Remove="UI\Images\close_16px.png" />
Expand Down Expand Up @@ -89,6 +124,8 @@
<EmbeddedResource Include="Packages\SplashScreen\build\index.bundle.js" />
<EmbeddedResource Include="Packages\SplashScreen\build\index.html" />
<EmbeddedResource Include="Views\SplashScreen\WebApp\splashScreenBackground.png" />
<EmbeddedResource Include="Packages\DynamoHome\build\index.bundle.js" />
<EmbeddedResource Include="Packages\DynamoHome\build\index.html" />
</ItemGroup>

<ItemGroup>
Expand Down Expand Up @@ -443,6 +480,7 @@
<Compile Include="Views\GuidedTour\SurveyPopupWindow.xaml.cs">
<DependentUpon>SurveyPopupWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Views\HomePage\HomePage.xaml.cs" />
<Compile Include="Views\Input\ParameterEditor.cs" />
<Compile Include="Views\PackageManager\Controls\CustomBrowserControl.xaml.cs" />
<Compile Include="Views\PackageManager\Controls\FilterTagControl.xaml.cs" />
Expand Down Expand Up @@ -499,6 +537,9 @@
<Compile Include="Views\SplashScreen\SplashScreen.xaml.cs">
<DependentUpon>SplashScreen.xaml</DependentUpon>
</Compile>
<Compile Include="Views\HomePage\HomePage.xaml.cs">
<DependentUpon>HomePage.xaml</DependentUpon>
</Compile>
<Compile Include="Views\Core\NodeView.xaml.cs">
<DependentUpon>NodeView.xaml</DependentUpon>
</Compile>
Expand Down Expand Up @@ -1550,6 +1591,12 @@
<SubType>Designer</SubType>
</Page>
</ItemGroup>
<ItemGroup>
<Page Include="Views\HomePage\HomePage.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\DynamoCore\DynamoCore.csproj">
<Project>{7858fa8c-475f-4b8e-b468-1f8200778cf8}</Project>
Expand Down Expand Up @@ -1762,6 +1809,9 @@
<Resource Include="UI\Images\not-authenticated.png" />
</ItemGroup>
<ItemGroup>
<None Update="Views\HomePage\HomePage.xaml">
<Generator>MSBuild:Compile</Generator>
</None>
<None Update="Views\PackageManager\Controls\CustomBrowserControl.xaml">
<Generator>MSBuild:Compile</Generator>
</None>
Expand Down
27 changes: 27 additions & 0 deletions src/DynamoCoreWpf/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions src/DynamoCoreWpf/Properties/Resources.en-US.resx
Original file line number Diff line number Diff line change
Expand Up @@ -2619,6 +2619,15 @@ Do you wish to uninstall {1}? Restart {2} to complete the uninstall and try down
<value>_User Interface Tour</value>
<comment>Get Started Dynamo Tour</comment>
</data>
<data name="GetStartedGuideDescription" xml:space="preserve">
<value>Start your visual programming journey with this short guide. Here you'll learn some basics about the Dynamo interface and features.</value>
</data>
<data name="OnboardingGuideDescription" xml:space="preserve">
<value>Learn about the basic building blocks of Dynamo. Get hands-on practice working with a graph.</value>
</data>
<data name="PackagesGuideDescription" xml:space="preserve">
<value>A package is a toolkit of utilities that let you do more with Dynamo, beyond its core functionality. This guide shows how to find, install, and use packages. It installs a sample Autodesk package for you to explore.</value>
</data>
<data name="InteractiveGuides" xml:space="preserve">
<value>_Interactive Guides</value>
<comment>Dynamo Guided Tours</comment>
Expand Down
9 changes: 9 additions & 0 deletions src/DynamoCoreWpf/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -2938,6 +2938,15 @@ Do you wish to uninstall {1}? Restart {2} to complete the uninstall and try down
<value>_Interactive Guides</value>
<comment>Dynamo Guided Tours</comment>
</data>
<data name="GetStartedGuideDescription" xml:space="preserve">
<value>Start your visual programming journey with this short guide. Here you'll learn some basics about the Dynamo interface and features.</value>
</data>
<data name="OnboardingGuideDescription" xml:space="preserve">
<value>Learn about the basic building blocks of Dynamo. Get hands-on practice working with a graph.</value>
</data>
<data name="PackagesGuideDescription" xml:space="preserve">
<value>A package is a toolkit of utilities that let you do more with Dynamo, beyond its core functionality. This guide shows how to find, install, and use packages. It installs a sample Autodesk package for you to explore.</value>
</data>
<data name="GetStartedGuideLibraryText" xml:space="preserve">
<value>The library contains all default functions #(nodes)=https://primer2.dynamobim.org/4_nodes_and_wires of Dynamo, as well as custom nodes you may have loaded. \n\nTo find a node, search the library or browse its categories.</value>
</data>
Expand Down
Loading
Loading