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

Renaming of GingerAnalytics to GingerOps #3914

Merged
merged 14 commits into from
Sep 23, 2024
1 change: 1 addition & 0 deletions Ginger/Ginger/Environments/AppDataBasesPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ private void SetDBListView()
DatabaseListView.SetDefaultListDataTemplate(dbListViewHelper);
DatabaseListView.ListSelectionMode = SelectionMode.Extended;


DatabaseListView.List.MouseDoubleClick += DBListView_MouseDoubleClick;
DatabaseListView.List.SetValue(ScrollViewer.CanContentScrollProperty, true);
DatabaseListView.DataSourceList = AppOwner.Dbs;
Expand Down
2 changes: 1 addition & 1 deletion Ginger/Ginger/Environments/ApplicationPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

<StackPanel Grid.Row="0">
<Label Style="{StaticResource @InputFieldLabelStyle}" Content="Name:"/>
<TextBox x:Name="ApplicationNameTextBox" Style="{StaticResource @TextBoxStyle}" FontSize="14" FontWeight="Bold"></TextBox>
<TextBox x:Name="ApplicationNameTextBox" IsEnabled="True" Style="{StaticResource @TextBoxStyle}" FontSize="14" FontWeight="Bold"></TextBox>

<Label Style="{StaticResource @InputFieldLabelStyle}" Content="Description:" Margin="0,5,0,0"/>
<TextBox x:Name="DescriptionTextBox" Style="{StaticResource @TextBoxStyle}" FontSize="14" FontWeight="Bold" ></TextBox>
Expand Down
8 changes: 8 additions & 0 deletions Ginger/Ginger/Environments/ApplicationPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,17 @@ public ApplicationPage(EnvApplication app, Context context)
mEnvApplication = app;
mContext = context;
CurrentItemToSave = mContext.Environment;


GingerCore.GeneralLib.BindingHandler.ObjFieldBinding(ApplicationNameTextBox, TextBox.TextProperty, app, nameof(EnvApplication.Name));
GingerCore.GeneralLib.BindingHandler.ObjFieldBinding(DescriptionTextBox, TextBox.TextProperty, app, nameof(EnvApplication.Description));

if (mContext.Environment.GOpsFlag)
{
ApplicationNameTextBox.IsEnabled = false;
DescriptionTextBox.IsEnabled = false;
}

UpdateParametersTabHeader();
CollectionChangedEventManager.AddHandler(source: app.Variables, handler: GeneralParams_CollectionChanged);
UpdateDBsTabHeader();
Expand Down
10 changes: 5 additions & 5 deletions Ginger/Ginger/Environments/AppsListPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@
<StackPanel>
<DockPanel>
<Label Style="{StaticResource $LabelStyle}" Content="Release:"/>
<ComboBox x:Name="xReleaseCombobox" IsEnabled="True" Style="{StaticResource $FlatEditInputComboBoxStyle}" MinWidth="300px" HorizontalAlignment="Left"></ComboBox>
<usercontrols2:ImageMakerControl x:Name="xProcessingImage" ImageType="Processing" Margin="640,0,0,0" HorizontalAlignment="Left" Height="30" Width="20" Visibility="Hidden"></usercontrols2:ImageMakerControl>
<Button x:Name="xGASyncBtn" IsEnabled="True" Style="{StaticResource $InputButtonStyle}" Visibility="Collapsed" Margin="0,0,10,0" HorizontalAlignment="Right" Click="xGASyncBtn_Click" FontWeight="Bold" Content="Sync with Ginger Analytics"/>
<ComboBox x:Name="xReleaseCombobox" IsEnabled="True" Style="{StaticResource $FlatEditInputComboBoxStyle}" Margin="0,0,0,20" MinWidth="300px" HorizontalAlignment="Left"></ComboBox>
<usercontrols2:ImageMakerControl x:Name="xProcessingImage" ImageType="Processing" Margin="630,-30,0,0" HorizontalAlignment="Left" Height="30" Width="20" Visibility="Hidden"></usercontrols2:ImageMakerControl>
<usercontrols2:ucButton x:Name="xGASyncBtn" IsEnabled="True" Width="200" Margin="0,-30,0,0" DockPanel.Dock="Top" HorizontalAlignment="Right" Visibility="Collapsed" ButtonType="RoundTextAndImageButton" ButtonText="Sync with GingerOps" ButtonImageType="Retry" ButtonFontImageSize="12" ButtonImageWidth="12" ButtonImageHeight="12" Click="xGASyncBtn_Click" ButtonStyle="{StaticResource $RoundTextAndImageButtonStyle}" ToolTip="Sync with GingerOps"/>
</DockPanel>

<CheckBox x:Name="xPublishcheckbox" Content="Publish" ToolTip="Publish to third party applications" DockPanel.Dock="Top" HorizontalAlignment="Left" Margin="0,5,0,0" Style="{StaticResource $CeckBoxStyle}"/>
<CheckBox x:Name="xPublishcheckbox" IsEnabled="True" Content="Publish" ToolTip="Publish to third party applications" DockPanel.Dock="Top" HorizontalAlignment="Left" Margin="0,-5,0,0" Style="{StaticResource $CeckBoxStyle}"/>
</StackPanel>

</StackPanel>

<Ginger:ucGrid x:Name="grdApps" Title="Environment Applications" Grid.Row="1" ShowEdit="Collapsed" ShowRefresh="Collapsed"/>
<Ginger:ucGrid x:Name="grdApps" IsEnabled="True" Title="Environment Applications" Grid.Row="1" ShowEdit="Collapsed" ShowRefresh="Collapsed"/>
</Grid>
</UserControlsLib:GingerUIPage>
87 changes: 52 additions & 35 deletions Ginger/Ginger/Environments/AppsListPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ limitations under the License.
using Amdocs.Ginger.Common;
using Amdocs.Ginger.CoreNET.Run.SolutionCategory;
using Amdocs.Ginger.Repository;
using Ginger.Environments.GingerAnalyticsEnvWizardLib;
using Ginger.Environments.GingerOpsEnvWizardLib;
using Ginger.ExternalConfigurations;
using Ginger.SolutionWindows.TreeViewItems.EnvironmentsTreeItems;
using Ginger.UserControls;
Expand All @@ -29,16 +29,13 @@ limitations under the License.
using GingerCore.GeneralLib;
using GingerCore.Variables;
using GingerCoreNET.SolutionRepositoryLib.RepositoryObjectsLib.PlatformsLib;
using GingerTest.WizardLib;
using Microsoft.Graph;
using Microsoft.Identity.Client.Kerberos;
using Microsoft.VisualStudio.Services.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using static Ginger.Environments.GingerAnalyticsEnvWizardLib.GingerAnalyticsAPIResponseInfo;
using static Ginger.Environments.GingerOpsEnvWizardLib.GingerOpsAPIResponseInfo;

namespace Ginger.Environments
{
Expand All @@ -48,8 +45,8 @@ namespace Ginger.Environments
public partial class AppsListPage : GingerUIPage
{
public ProjEnvironment AppEnvironment { get; set; }
public AddGingerAnalyticsEnvPage AddGingerAnalyticsEnvPage;
public GingerAnalyticsAPI GingerAnalyticsAPI;
public AddGingerOpsEnvPage AddGingerOpsEnvPage;
public GingerOpsAPI GingerOpsAPI;
public AppsListPage(ProjEnvironment env)
{
InitializeComponent();
Expand All @@ -60,16 +57,19 @@ public AppsListPage(ProjEnvironment env)
SetGridView();
SetGridData();

if (AppEnvironment.GAFlag)
if (AppEnvironment.GOpsFlag)
{
xPublishcheckbox.IsEnabled = false;
EnvNameTextBox.IsEnabled = false;
xGASyncBtn.Visibility = Visibility.Visible;
}
else
{
EnvNameTextBox.IsEnabled = true;
xPublishcheckbox.IsEnabled = true;
xGASyncBtn.Visibility = Visibility.Collapsed;
InitReleaseComboBox();
grdApps.AddToolbarTool("@Share_16x16.png", "Add Selected Applications to All Environments", new RoutedEventHandler(AddAppsToOtherEnvironments));
}

BindingHandler.ObjFieldBinding(EnvNameTextBox, TextBox.TextProperty, env, ProjEnvironment.Fields.Name);
Expand All @@ -79,7 +79,6 @@ public AppsListPage(ProjEnvironment env)


grdApps.btnAdd.AddHandler(Button.ClickEvent, new RoutedEventHandler(AddApp));
grdApps.AddToolbarTool("@Share_16x16.png", "Add Selected Applications to All Environments", new RoutedEventHandler(AddAppsToOtherEnvironments));

TagsViewer.Init(AppEnvironment.Tags);
}
Expand Down Expand Up @@ -136,6 +135,18 @@ private void SetGridData()
{
AppEnvironment.Applications.ForEach((app) => app.SetDataFromAppPlatform(WorkSpace.Instance.Solution.ApplicationPlatforms));
grdApps.DataSourceList = AppEnvironment.Applications;

if (AppEnvironment.GOpsFlag)
{
grdApps.DisableGridColoumns();
grdApps.btnDelete.IsEnabled = false;
grdApps.btnAdd.IsEnabled = false;
grdApps.btnCut.IsEnabled = false;
grdApps.btnUndo.IsEnabled = false;
grdApps.btnClearAll.IsEnabled = false;
grdApps.btnDuplicate.Visibility = Visibility.Collapsed;
grdApps.btnCopy.IsEnabled = false;
}
}

private void AddAppsToOtherEnvironments(object sender, RoutedEventArgs e)
Expand Down Expand Up @@ -186,16 +197,16 @@ private async void xGASyncBtn_Click(object sender, RoutedEventArgs e)
{
xGASyncBtn.IsEnabled = false;
ShowLoader();
AddGingerAnalyticsEnvPage = new();
GingerAnalyticsAPI = new();
AddGingerAnalyticsEnvPage.environmentListGA = await GingerAnalyticsAPI.FetchApplicationDataFromGA(AppEnvironment.GingerAnalyticsEnvId.ToString(), AddGingerAnalyticsEnvPage.environmentListGA);
AddGingerOpsEnvPage = new();
GingerOpsAPI = new();
AddGingerOpsEnvPage.environmentListGOps = await GingerOpsAPI.FetchApplicationDataFromGOps(AppEnvironment.GingerOpsEnvId.ToString(), AddGingerOpsEnvPage.environmentListGOps);

foreach (var appEnv in AddGingerAnalyticsEnvPage.environmentListGA)
foreach (var appEnv in AddGingerOpsEnvPage.environmentListGOps)
{
var appListEnv = appEnv.Value.GingerAnalyticsApplications;
var appListEnv = appEnv.Value.GingerOpsApplications;
foreach (var item in appListEnv)
{
var existingApp = AppEnvironment.Applications.FirstOrDefault(k => k.GingerAnalyticsAppId == item.Id);
var existingApp = AppEnvironment.Applications.FirstOrDefault(k => k.GingerOpsAppId == item.Id);
if (existingApp != null)
{
UpdateExistingApplication(existingApp, item);
Expand All @@ -206,10 +217,12 @@ private async void xGASyncBtn_Click(object sender, RoutedEventArgs e)
}
}
}
Reporter.ToUser(eUserMsgKey.GingerOpsSyncSuccess);
}
catch (Exception ex)
{
Reporter.ToLog(eLogLevel.ERROR, "Failed to Sync with Ginger Analytics", ex);
Reporter.ToLog(eLogLevel.ERROR, "Failed to Sync with GingerOps", ex);
AmanPrasad43 marked this conversation as resolved.
Show resolved Hide resolved
Reporter.ToUser(eUserMsgKey.GingerOpsSyncFailed, ex.Message);
}
finally
{
Expand All @@ -218,26 +231,26 @@ private async void xGASyncBtn_Click(object sender, RoutedEventArgs e)
}
}

private void UpdateExistingApplication(EnvApplication existingApp, GingerAnalyticsApplication item)
private void UpdateExistingApplication(EnvApplication existingApp, GingerOpsApplication item)
{
bool parametersChanged = false;

// Check if the name, platform, or URL has changed
if (!existingApp.Name.Equals(item.Name) ||
existingApp.Platform != MapToPlatformType(item.GAApplicationParameters.FirstOrDefault(k => k.Name == "Application Type")?.Value) ||
!existingApp.Url.Equals(item.GAApplicationParameters.FirstOrDefault(k => k.Name == "Application URL")?.Value))
existingApp.Platform != MapToPlatformType(item.GOpsApplicationParameters.FirstOrDefault(k => k.Name == "Application Type")?.Value) ||
!existingApp.Url.Equals(item.GOpsApplicationParameters.FirstOrDefault(k => k.Name == "Application URL")?.Value))
{
existingApp.Name = item.Name;
existingApp.Platform = MapToPlatformType(item.GAApplicationParameters.FirstOrDefault(k => k.Name == "Application Type")?.Value);
existingApp.Url = item.GAApplicationParameters.FirstOrDefault(k => k.Name == "Application URL")?.Value;
existingApp.Platform = MapToPlatformType(item.GOpsApplicationParameters.FirstOrDefault(k => k.Name == "Application Type")?.Value);
existingApp.Url = item.GOpsApplicationParameters.FirstOrDefault(k => k.Name == "Application URL")?.Value;
parametersChanged = true;
}

// Create a hash set of existing parameters in GeneralParams
var existingParamNames = new HashSet<string>(existingApp.Variables.Select(v => v.Name));

// Check if any other parameters have changed or new parameters added
foreach (var param in item.GAApplicationParameters)
foreach (var param in item.GOpsApplicationParameters)
{
if (param.Name != "Application Type" && param.Name != "Application URL")
{
Expand All @@ -253,7 +266,7 @@ private void UpdateExistingApplication(EnvApplication existingApp, GingerAnalyti
if (parametersChanged)
{
existingApp.Variables.ClearAll();
foreach (var param in item.GAApplicationParameters)
foreach (var param in item.GOpsApplicationParameters)
{
if (param.Name != "Application Type" && param.Name != "Application URL")
{
Expand All @@ -265,17 +278,17 @@ private void UpdateExistingApplication(EnvApplication existingApp, GingerAnalyti
UpdateApplicationPlatform(existingApp, item);
}

private void AddNewApplication(GingerAnalyticsApplication item)
private void AddNewApplication(GingerOpsApplication item)
{
if (!string.IsNullOrEmpty(item.Name) && !string.IsNullOrEmpty(item.Id))
{
var platformType = MapToPlatformType(item.GAApplicationParameters.FirstOrDefault(k => k.Name == "Application Type")?.Value);
var appUrl = item.GAApplicationParameters.FirstOrDefault(k => k.Name == "Application URL")?.Value;
var platformType = MapToPlatformType(item.GOpsApplicationParameters.FirstOrDefault(k => k.Name == "Application Type")?.Value);
var appUrl = item.GOpsApplicationParameters.FirstOrDefault(k => k.Name == "Application URL")?.Value;

EnvApplication newEnvApp = new() { Name = item.Name, Platform = platformType, GingerAnalyticsAppId = item.Id, Active = true, Url = appUrl, GingerAnalyticsStatus=item.Status };
EnvApplication newEnvApp = new() { Name = item.Name, Platform = platformType, GingerOpsAppId = item.Id, Active = true, Url = appUrl, GOpsFlag = true };

// Add all other parameters to GeneralParams
foreach (var param in item.GAApplicationParameters)
foreach (var param in item.GOpsApplicationParameters)
{
if (param.Name != "Application Type" && param.Name != "Application URL")
{
Expand All @@ -289,31 +302,35 @@ private void AddNewApplication(GingerAnalyticsApplication item)
}
}

private void UpdateApplicationPlatform(EnvApplication app, GingerAnalyticsApplication item)
private void UpdateApplicationPlatform(EnvApplication app, GingerOpsApplication item)
{
var existingPlatform = WorkSpace.Instance.Solution.ApplicationPlatforms.FirstOrDefault(k => k.GingerAnalyticsAppId == item.Id);
var existingPlatform = WorkSpace.Instance.Solution.ApplicationPlatforms.FirstOrDefault(k => k.GingerOpsAppId == item.Id);
if (existingPlatform == null)
{
AddApplicationPlatform(app, item);
}
else
{
existingPlatform.AppName = WorkSpace.Instance.Solution.ApplicationPlatforms.FirstOrDefault(k => k.AppName == item.Name && k.GingerAnalyticsAppId != item.Id) == null
? item.Name : item.Name + "_GingerAnalytics";
existingPlatform.AppName = WorkSpace.Instance.Solution.ApplicationPlatforms.FirstOrDefault(k => k.AppName == item.Name && k.GingerOpsAppId != item.Id) == null
? item.Name : item.Name + "_GingerOps";
existingPlatform.Platform = app.Platform;

app.Name = existingPlatform.AppName;
}
}

private void AddApplicationPlatform(EnvApplication app, GingerAnalyticsApplication item)
private void AddApplicationPlatform(EnvApplication app, GingerOpsApplication item)
{
var selectedApp = new ApplicationPlatform
{
AppName = WorkSpace.Instance.Solution.ApplicationPlatforms.FirstOrDefault(k => k.AppName == item.Name) != null
? item.Name + "_GingerAnalytics" : item.Name,
? item.Name + "_GingerOps" : item.Name,
Platform = app.Platform,
GingerAnalyticsAppId = item.Id
GingerOpsAppId = item.Id,
GOpsFlag = true
};

app.Name = selectedApp.AppName;
WorkSpace.Instance.Solution.ApplicationPlatforms.Add(selectedApp);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<Page x:Class="Ginger.Environments.GingerAnalyticsEnvWizardLib.AddGingerAnalyticsEnvPage"
<Page x:Class="Ginger.Environments.GingerOpsEnvWizardLib.AddGingerOpsEnvPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Ginger.Environments.GingerAnalyticsEnvWizardLib"
xmlns:local="clr-namespace:Ginger.Environments.GingerOpsEnvWizardLib"
xmlns:usercontrols2="clr-namespace:Amdocs.Ginger.UserControls"
xmlns:UserControlsLib="clr-namespace:Ginger.UserControlsLib"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"
Title="AddGingerAnalyticsEnvPage">
Title="AddGingerOpsEnvPage">

<Grid Margin="10">
<Grid.RowDefinitions>
Expand All @@ -24,17 +24,17 @@

<!-- Project Label and ComboBox -->
<Label x:Name="xProject" Grid.Column="0" Grid.Row="0" Content="Project :" Margin="0,10,0,0" Style="{StaticResource $LabelStyle}"/>
<ComboBox x:Name="xProjectComboBox" Grid.Column="1" Margin="0,0,0,0" Style="{StaticResource $FlatInputComboBoxStyle}" HorizontalAlignment="Left" SelectionChanged="xProjectComboBox_SelectionChanged" ToolTip="Select Ginger Analytics Project" Width="180"/>
<ComboBox x:Name="xProjectComboBox" Grid.Column="1" Margin="0,0,0,0" Style="{StaticResource $FlatInputComboBoxStyle}" HorizontalAlignment="Left" SelectionChanged="xProjectComboBox_SelectionChanged" ToolTip="Select GingerOps Project" Width="250"/>


<!-- Architecture Label and ComboBox -->
<Label x:Name="xArchitecture" Grid.Row="1" Grid.Column="0" Content="Architecture :" Margin="0,10,0,0" Style="{StaticResource $LabelStyle}"/>
<ComboBox x:Name="xArchitectureComboBox" Grid.Row="1" Grid.Column="1" Margin="0,0,0,0" Style="{StaticResource $FlatInputComboBoxStyle}" HorizontalAlignment="Left" SelectionChanged="xArchitectureComboBox_SelectionChanged" ToolTip="Select Ginger Analytics Architecture" Width="180"/>
<ComboBox x:Name="xArchitectureComboBox" Grid.Row="1" Grid.Column="1" Margin="0,0,0,0" Style="{StaticResource $FlatInputComboBoxStyle}" HorizontalAlignment="Left" SelectionChanged="xArchitectureComboBox_SelectionChanged" ToolTip="Select GingerOps Architecture" Width="250"/>


<!-- Environment Label and ComboBox -->
<Label x:Name="xEnvironment" Grid.Row="2" Grid.Column="0" Content="Environment :" Margin="0,10,0,0" Style="{StaticResource $LabelStyle}"/>
<UserControlsLib:MultiSelectComboBox x:Name="xEnvironmentComboBox" Grid.Row="2" Grid.Column="1" Margin="0,0,0,0" HorizontalAlignment="Left" ToolTip="Select Ginger Analytics Environment" Width="180"/>
<UserControlsLib:MultiSelectComboBox x:Name="xEnvironmentComboBox" Grid.Row="2" Grid.Column="1" Margin="1,0,0,0" HorizontalAlignment="Left" ToolTip="Select GingerOps Environment" Width="250"/>

</Grid>
</Page>
Loading
Loading