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

Update WebService Datasource #129

Merged
merged 33 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
f851908
rdash unit tests for Rest DS
recca5p Dec 4, 2024
a8ad3a0
Merge branch 'main' into unit-test/rest
recca5p Dec 5, 2024
13c7b12
update UTs for webservice and items working with Rdashh file and RDas…
Dec 5, 2024
95bc453
update RestDataSourceItemFixture for assert the json
recca5p Dec 5, 2024
d0378f7
Merge branch 'unit-test/rest' of https://github.com/RevealBi/Reveal.S…
recca5p Dec 5, 2024
be195b7
Merge branch 'main' into unit-test/rest
recca5p Dec 6, 2024
e07a575
Merge branch 'main' into data-source/web-service
recca5p Dec 6, 2024
f8b81ab
add sandbox example fpr the webservice
recca5p Dec 6, 2024
587d8c0
imple WebServiceDataSourceItem
recca5p Dec 9, 2024
22d5bcc
fix create dashboard of WebServiceDataSourceDashboard
recca5p Dec 9, 2024
d6d4a58
fix the UTs
recca5p Dec 9, 2024
f4e8ca4
Merge branch 'unit-test/rest' of https://github.com/RevealBi/Reveal.S…
recca5p Dec 9, 2024
d2bc093
implement the WebServiceDataSourceItem
Dec 10, 2024
45268db
update UTs
Dec 10, 2024
f6e3032
ix the UTs
Dec 10, 2024
612b327
Merge branch 'main' into data-source/web-service
brianlagunas Dec 10, 2024
53fd444
Merge branch 'main' into unit-test/rest
brianlagunas Dec 10, 2024
61256a2
fix the UT name and create RestItem
recca5p Dec 11, 2024
ef4e538
fix UTs of RestDataSource
recca5p Dec 11, 2024
3d0bd80
fix UTs
recca5p Dec 11, 2024
f7f392e
fix the UTs
Dec 11, 2024
daa4530
add sandbox example for the csv and excel
Dec 11, 2024
fc99670
add UTs
Dec 11, 2024
2d469fa
refactor
Dec 11, 2024
0583d51
Merge branch 'main' into unit-test/rest
recca5p Dec 12, 2024
8203163
Merge branch 'main' into data-source/web-service
recca5p Dec 12, 2024
e9e3e3f
Merge branch 'data-source/web-service' of https://github.com/RevealBi…
Dec 12, 2024
6d476f4
Update UTs to test the return datasource too
recca5p Dec 12, 2024
1ab60de
Merge remote-tracking branch 'remotes/origin/main' into data-source/w…
recca5p Dec 12, 2024
a2d0209
Change uri to url
recca5p Dec 12, 2024
e3a2869
Merge remote-tracking branch 'remotes/origin/unit-test/rest' into dat…
Dec 12, 2024
0cc2a98
Update UTs
recca5p Dec 12, 2024
83a2c1e
Merge branch 'main' into data-source/web-service
brianlagunas Dec 12, 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
57 changes: 57 additions & 0 deletions e2e/Sandbox/DashboardCreators/WebServiceDataSourceDashboard.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
using Reveal.Sdk.Data.MySql;
using Reveal.Sdk.Data.Rest;
using Reveal.Sdk.Dom;
using Reveal.Sdk.Dom.Data;
using Reveal.Sdk.Dom.Filters;
using Reveal.Sdk.Dom.Visualizations;
using Sandbox.DashboardFactories;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Sandbox.DashboardCreators
{
public class WebServiceDataSourceDashboard : IDashboardCreator
{
public string Name => "Web Service Data Source";

public RdashDocument CreateDashboard()
{
var document = new RdashDocument()
{
Title = "Webservice DS",
Description = "Example for Webservice",
UseAutoLayout = false,
};

var dataSourceItems = new WebServiceDataSourceItem("DB Test", new DataSource { Title = "JSON DS", Subtitle = "JSON DS Subtitle" })
{
recca5p marked this conversation as resolved.
Show resolved Hide resolved
Id = "webServiceItemId",
Title = "Sales by Category",
Subtitle = "Excel2Json",
Fields = new List<IField>
{
new NumberField("CategoryID"),
new TextField("CategoryName"),
new TextField("ProductName"),
new NumberField("ProductSales"),
}
};

recca5p marked this conversation as resolved.
Show resolved Hide resolved
var dateFilter = new DashboardDateFilter("My Date Filter");
document.Filters.Add(dateFilter);

var countryFilter = new DashboardDataFilter("Country", dataSourceItems);
document.Filters.Add(countryFilter);

document.Visualizations.Add(
new ColumnChartVisualization("Test List", dataSourceItems)
.SetLabel("CategoryName")
.SetValue("ProductName")
);
return document;
}
}
}
4 changes: 3 additions & 1 deletion e2e/Sandbox/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
using Reveal.Sdk.Data.Rest;
using Reveal.Sdk.Data.Snowflake;
using Reveal.Sdk.Dom;
using Sandbox.DashboardCreators;
using Sandbox.DashboardFactories;
using Sandbox.RevealSDK;
using System;
Expand Down Expand Up @@ -51,6 +52,7 @@ public partial class MainWindow : Window
new RestDataSourceDashboard(),
new SalesDashboard(),
new SqlServerDataSourceDashboards(),
new WebServiceDataSourceDashboard()
};

public MainWindow()
Expand All @@ -60,7 +62,7 @@ public MainWindow()
RevealSdkSettings.DataSourceProvider = new Sandbox.RevealSDK.DataSourceProvider();
RevealSdkSettings.AuthenticationProvider = new AuthenticationProvider();
RevealSdkSettings.DataSources.RegisterMicrosoftSqlServer().RegisterMicrosoftAnalysisServices();

LoadDashboards();

_revealView.LinkedDashboardProvider = (string dashboardId, string linkTitle) =>
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
using Newtonsoft.Json.Linq;
using Reveal.Sdk.Dom.Core.Extensions;
using Reveal.Sdk.Dom.Data;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System;
using Xunit;
using Reveal.Sdk.Dom.Visualizations;
using Reveal.Sdk.Dom.Core.Serialization;

namespace Reveal.Sdk.Dom.Tests.Data.DataSourceItems
{
Expand All @@ -16,7 +23,6 @@ public void Constructor_SetsTitleAndDataSource_WhenConstructed()

// Assert
Assert.Equal(title, item.Title);
Assert.Equal(dataSource, item.DataSource);
}

[Theory]
Expand All @@ -34,5 +40,116 @@ public void Url_SetsAndGetsValue_WithDifferentInputs(string url)
Assert.Equal(url, item.Url);
Assert.Equal(url, item.Properties.GetValue<string>("Url"));
}

[Fact]
public void RDashDocument_HasCorrectDataSource_WhenLoadFromFile()
{
// Arrange
var filePath = Path.Combine(Environment.CurrentDirectory, "Dashboards", "TestWebResource.rdash");

// Act
var document = RdashDocument.Load(filePath);
var jsonDataSource = document.DataSources.FirstOrDefault();
var webServiceDataSource = document.DataSources.LastOrDefault();
var webServiceDataSourceItem = document.Visualizations.FirstOrDefault().DataDefinition.DataSourceItem;

// Assert
Assert.Equal(DataSourceProvider.JSON, jsonDataSource.Provider);
Assert.Equal(DataSourceProvider.WebService, webServiceDataSource.Provider);
Assert.NotNull(webServiceDataSource.Properties.GetValue<string>("Url"));
Assert.NotNull(webServiceDataSource.Properties.GetValue<string>("_rpUseAnonymousAuthentication"));
}

[Fact]
public void ToJsonString_CreatesFormattedJson_ForWebServiceDataSource()
{
// Arrange
var expectedJson = @"
{
""_type"": ""DataSourceItemType"",
""Id"": ""webServiceItemId"",
""Title"": ""Sales by Category"",
""Subtitle"": ""Excel2Json"",
""DataSourceId"": ""__JSON"",
""HasTabularData"": true,
""HasAsset"": false,
""Properties"": {},
""Parameters"": {
""config"": {
""iterationDepth"": 0,
""columnsConfig"": [
{
""key"": ""CategoryID"",
""type"": 1
},
{
""key"": ""CategoryName"",
""type"": 0
},
{
""key"": ""ProductName"",
""type"": 0
},
{
""key"": ""ProductSales"",
""type"": 1
}
]
}
},
""ResourceItem"": {
""_type"": ""DataSourceItemType"",
""Id"": ""webServiceItemId"",
""Title"": ""DB Test"",
""Subtitle"": ""Excel2Json"",
""DataSourceId"": ""webServiceId"",
""HasTabularData"": true,
""HasAsset"": false,
""Properties"": {},
""Parameters"": {}
}
}";

var dataSource = new WebServiceDataSource()
recca5p marked this conversation as resolved.
Show resolved Hide resolved
{
Id = "webServiceId",
Title = "Web Data Source",
Subtitle = "Web Data Source Subtitle",
Url = "https://excel2json.io/api/share/6e0f06b3-72d3-4fec-7984-08da43f56bb9",
UseAnonymousAuthentication = true,
};

var dataSourceItems = new WebServiceDataSourceItem("DB Test", dataSource)
{
Id = "webServiceItemId",
Title = "Sales by Category",
Subtitle = "Excel2Json",
Fields = new List<IField>
{
new NumberField("CategoryID"),
new TextField("CategoryName"),
new TextField("ProductName"),
new NumberField("ProductSales"),
}
};

var document = new RdashDocument("My Dashboard");
document.Visualizations.Add(
new ColumnChartVisualization("Test List", dataSourceItems)
.SetLabel("CategoryName")
.SetValue("ProductName")
);

var expectedJObject = JObject.Parse(expectedJson);

// Act
RdashSerializer.SerializeObject(document);
var json = document.ToJsonString();
var jObject = JObject.Parse(json);
var actualJObject = jObject["Widgets"].FirstOrDefault()["DataSpec"]["DataSourceItem"];
recca5p marked this conversation as resolved.
Show resolved Hide resolved

// Assert
Assert.Equal(expectedJObject, actualJObject);
}
}
}
Loading
Loading