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 all 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
78 changes: 75 additions & 3 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 Down Expand Up @@ -371,27 +376,94 @@ private void RefreshFileList(ObservableCollection<StartPageListItem> files,
{
try
{
// Skip files which were moved or deleted (consistent with Revit behavior)
if (!DynamoUtilities.PathHelper.IsValidPath(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 subScript = extension.StartsWith(".") ? extension.Substring(1) : "";
var caption = Path.GetFileNameWithoutExtension(filePath);

// deserializes the file only once
var jsonObject = DeserializeJsonFile(filePath);
dnenov marked this conversation as resolved.
Show resolved Hide resolved
var description = jsonObject != null ? GetGraphDescription(jsonObject) : string.Empty;
var thumbnail = jsonObject != null ? GetGraphThumbnail(jsonObject) : string.Empty;
var author = jsonObject != null ? GetGraphAuthor(jsonObject) : Resources.DynamoXmlFileFormat;

var date = DynamoUtilities.PathHelper.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);
}
catch (Exception ex)
{
DynamoViewModel.Model.Logger.Log("Error loading the file: " + ex.StackTrace);
}
}
}

private Dictionary<string, object> DeserializeJsonFile(string filePath)
{
if (DynamoUtilities.PathHelper.isValidJson(filePath, out string jsonString, out Exception ex))
{
return JsonConvert.DeserializeObject<Dictionary<string, object>>(jsonString);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use DynamoUtilities.PathHelper.isValidJson(filePath, out fileContents, out ex)

}
else
{
if(ex is JsonReaderException)
{
DynamoViewModel.Model.Logger.Log("File is not a valid json format.");
}
else
{
DynamoViewModel.Model.Logger.Log("File is not valid: " + ex.StackTrace);
}
return null;
}
}

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)
{
var dvm = this.DynamoViewModel;
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 @@ -90,6 +125,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 @@ -447,6 +484,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 @@ -503,6 +541,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 @@ -1558,6 +1599,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 @@ -1770,6 +1817,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
36 changes: 36 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.

12 changes: 12 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 Expand Up @@ -3922,4 +3931,7 @@ In certain complex graphs or host program scenarios, Automatic mode may cause in
<value>Enable Paneling nodes</value>
<comment>Preferences | Features | Experimental | Enable Paneling nodes</comment>
</data>
<data name="DynamoXmlFileFormat" xml:space="preserve">
<value>Dynamo 1.x file format</value>
</data>
</root>
12 changes: 12 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 Expand Up @@ -3909,4 +3918,7 @@ In certain complex graphs or host program scenarios, Automatic mode may cause in
<value>Enable Paneling nodes</value>
<comment>Preferences | Features | Experimental | Enable Paneling nodes</comment>
</data>
<data name="DynamoXmlFileFormat" xml:space="preserve">
<value>Dynamo 1.x file format</value>
</data>
</root>
5 changes: 3 additions & 2 deletions src/DynamoCoreWpf/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
abstract Dynamo.PackageManager.UI.PackageItemViewModel.Items.get -> System.Collections.ObjectModel.ObservableCollection<Dynamo.PackageManager.UI.PackageItemViewModel>
abstract Dynamo.PackageManager.UI.PackageItemViewModel.Items.get -> System.Collections.ObjectModel.ObservableCollection<Dynamo.PackageManager.UI.PackageItemViewModel>
abstract Dynamo.PackageManager.UI.PackageItemViewModel.Items.set -> void
abstract Dynamo.Wpf.Extensions.ViewExtensionBase.Dispose() -> void
abstract Dynamo.Wpf.Extensions.ViewExtensionBase.Name.get -> string
Expand Down Expand Up @@ -197,6 +197,7 @@ Dynamo.Controls.DynamoView.ExtensionsCollapsed.get -> bool
Dynamo.Controls.DynamoView.InitializeComponent() -> void
Dynamo.Controls.DynamoView.LibraryCollapsed.get -> bool
Dynamo.Controls.DynamoView.PlacePopup(System.Windows.Size popupSize, System.Windows.Size targetSize, System.Windows.Point offset) -> System.Windows.Controls.Primitives.CustomPopupPlacement[]
Dynamo.Controls.DynamoView.IsNewAppHomeEnabled.get -> bool
Dynamo.Controls.ElementGroupToColorConverter
Dynamo.Controls.ElementGroupToColorConverter.Convert(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture) -> object
Dynamo.Controls.ElementGroupToColorConverter.ConvertBack(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture) -> object
Expand Down Expand Up @@ -5594,4 +5595,4 @@ virtual Dynamo.Wpf.ViewModels.Watch3D.DefaultWatch3DViewModel.UpdateHelpers() ->
virtual Dynamo.Wpf.ViewModels.Watch3D.DefaultWatch3DViewModel.ZoomToFit(object parameter) -> void
virtual Dynamo.Wpf.ViewModels.Watch3D.HelixWatch3DViewModel.OnWatchExecution() -> void
virtual Dynamo.Wpf.ViewModels.Watch3D.HelixWatch3DViewModel.UpdateUpstream() -> void
virtual UI.Prompts.PortPropertiesEditPrompt.OnPropertyChanged(System.ComponentModel.PropertyChangedEventArgs e) -> void
virtual UI.Prompts.PortPropertiesEditPrompt.OnPropertyChanged(System.ComponentModel.PropertyChangedEventArgs e) -> void
Loading
Loading