-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0a78b79
commit 14f117d
Showing
14 changed files
with
254 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using Reveal.Sdk.Dom; | ||
using Reveal.Sdk.Dom.Data; | ||
using Reveal.Sdk.Dom.Visualizations; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Sandbox.Factories | ||
{ | ||
public class GoogleSheetDataSourceDashboards | ||
{ | ||
public static RdashDocument CreateDashboard() | ||
{ | ||
var googleSheetDS = new GoogleSheetsDataSourceItem("Google Sheet Data Source", "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms") | ||
{ | ||
Title = "Google Sheet Data Source", | ||
Subtitle = "Google Sheet Data Source Subtitle", | ||
Sheet = "Class Data", | ||
Fields = new List<IField> | ||
{ | ||
new TextField("Student Name"), | ||
new TextField("Gender"), | ||
new TextField("Class Level"), | ||
new TextField("Home State"), | ||
new TextField("Major"), | ||
new TextField("Extracurricular Activity") | ||
} | ||
}; | ||
|
||
var document = new RdashDocument("My Dashboard"); | ||
|
||
document.Visualizations.Add(new GridVisualization("Class List", googleSheetDS).SetColumns("Student Name", "Gender", "Major", "Extracurricular Activity")); | ||
|
||
return document; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,45 @@ | ||
using Reveal.Sdk.Data; | ||
using Reveal.Sdk.Data.Google.Drive; | ||
using Reveal.Sdk.Data.Microsoft.AnalysisServices; | ||
using Reveal.Sdk.Data.Microsoft.SqlServer; | ||
using System; | ||
using System.Threading.Tasks; | ||
using Google.Apis.Auth.OAuth2; | ||
using System.IO; | ||
|
||
namespace Sandbox.RevealSDK | ||
{ | ||
internal class AuthenticationProvider : IRVAuthenticationProvider | ||
{ | ||
public Task<IRVDataSourceCredential> ResolveCredentialsAsync(RVDashboardDataSource dataSource) | ||
public async Task<IRVDataSourceCredential> ResolveCredentialsAsync(RVDashboardDataSource dataSource) | ||
{ | ||
IRVDataSourceCredential userCredential = null; | ||
string _token = string.Empty; | ||
if (dataSource is RVSqlServerDataSource) | ||
{ | ||
userCredential = new RVUsernamePasswordDataSourceCredential(); | ||
} | ||
else if (dataSource is RVNativeAnalysisServicesDataSource) | ||
{ | ||
userCredential = new RVUsernamePasswordDataSourceCredential("username", "password", "domain"); | ||
} else if (dataSource is RVGoogleDriveDataSource) | ||
{ | ||
if (string.IsNullOrEmpty(_token)) | ||
_token = await CreateJwtToken(); | ||
|
||
userCredential = new RVBearerTokenDataSourceCredential(_token, null); | ||
} | ||
return Task.FromResult(userCredential); | ||
return userCredential; | ||
} | ||
|
||
async Task<string> CreateJwtToken() | ||
{ | ||
var pathToJsonFile = Path.Combine(Environment.CurrentDirectory, "Data/GoogleServiceAccountAuth.json"); | ||
var credentials = GoogleCredential.FromFile(pathToJsonFile).CreateScoped("https://www.googleapis.com/auth/drive", | ||
"https://www.googleapis.com/auth/userinfo.email", | ||
"https://www.googleapis.com/auth/userinfo.profile"); | ||
var token = await credentials.UnderlyingCredential.GetAccessTokenForRequestAsync().ConfigureAwait(false); | ||
return token; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.