Skip to content

Commit

Permalink
Merge branch 'statisticssweden:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
runejo authored Sep 5, 2023
2 parents 6d26530 + 0be5e02 commit f259487
Show file tree
Hide file tree
Showing 20 changed files with 534 additions and 246 deletions.
17 changes: 11 additions & 6 deletions PCAxis.Web.Controls/CommandBar/CommandBarCodebehind.vb
Original file line number Diff line number Diff line change
Expand Up @@ -616,12 +616,17 @@ Namespace CommandBar
''' <param name="pluginId">Id of the plugin to remove</param>
''' <remarks></remarks>
Private Sub HidePluginDropDown(ByVal dropdown As DropDownList, ByVal pluginId As String)
For Each li As ListItem In dropdown.Items
If li.Value.Equals(pluginId) Then
dropdown.Items.Remove(li)
Exit Sub
End If
Next
If dropdown Is Nothing Then
Return
Else
For Each li As ListItem In dropdown.Items
If li.Value.Equals(pluginId) Then
dropdown.Items.Remove(li)
Exit Sub
End If

Next
End If
End Sub

''' <summary>
Expand Down
18 changes: 18 additions & 0 deletions PCAxis.Web.Controls/Query/TableQuery.ascx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,24 @@
</div>
</div>
</asp:Panel>
<asp:Panel ID="pnlQueryInformationV2" CssClass="tablequery_informationpanel" runat="server">
<asp:Label ID="lblV2text" runat="server" Text="" CssClass="tablequery_V2caption">Api-V2:</asp:Label>
<asp:Label ID="lblInformationTextV2" runat="server" Text="" CssClass="tablequery_informationtext"></asp:Label>
<asp:Label ID="lblUrlV2" runat="server" Text="" AssociatedControlID="txtUrl" CssClass="tablequery_urlcaption"></asp:Label>
<asp:TextBox ID="txtUrlV2" runat="server" ReadOnly="true" CssClass="tablequery_url"></asp:TextBox>
<asp:Button ID="btnCopyUrlV2" text="<%$ PxString: CtrlTableQueryCopy %>" runat="server" ClientIDMode="static" CssClass="pxweb-btn pxweb-buttons" OnClientClick="CopyQuery();return false" CausesValidation="false"></asp:Button>
</asp:Panel>
</div>
</div>
</asp:panel>
<script type="text/javascript">
function CopyQuery() {
var copyText = document.getElementById('<%=txtUrlV2.ClientID %>')
copyText.focus();
copyText.select(); // for mark as copied
// Copy the text inside the text field
navigator.clipboard.writeText("<%=txtUrlV2.Text%>");
return false;
}
</script>
24 changes: 23 additions & 1 deletion PCAxis.Web.Controls/Query/TableQuery.vb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Partial Public Class TableQuery
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
<PropertyPersistState(Core.Enums.PersistStateType.PerControlAndPage)> _
<PropertyPersistState(Core.Enums.PersistStateType.PerControlAndPage)>
Public Property URLRoot() As String
Get
Return _urlRoot
Expand All @@ -33,6 +33,28 @@ Partial Public Class TableQuery
End Set
End Property

Private _urlRootV2 As String
<PropertyPersistState(Core.Enums.PersistStateType.PerControlAndPage)>
Public Property URLRootV2() As String
Get
Return _urlRootV2
End Get
Set(ByVal value As String)
_urlRootV2 = value
End Set
End Property

Private _enableApiV2QueryLink As Boolean
<PropertyPersistState(Core.Enums.PersistStateType.PerControlAndPage)>
Public Property EnableApiV2QueryLink() As Boolean
Get
Return _enableApiV2QueryLink
End Get
Set(ByVal value As Boolean)
_enableApiV2QueryLink = value
End Set
End Property

Private _showRoutePrefix As Boolean = True
''' <summary>
''' If the route prefix should be displayed in the API url
Expand Down
84 changes: 84 additions & 0 deletions PCAxis.Web.Controls/Query/TableQueryCodebehind.vb
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,30 @@ Public Class TableQueryCodebehind

#Region "fields"
Protected pnlQueryInformation As Panel
Protected pnlQueryInformationV2 As Panel
Protected lblInformationText As Label
Protected lblInformationTextV2 As Label
Protected lblUrl As Label
Protected lblUrlV2 As Label
Protected txtUrl As TextBox
Protected txtUrlV2 As TextBox
Protected lblQuery As Label
Protected txtQuery As TextBox
Protected lnkMoreInfo As HyperLink
Protected WithEvents btnSaveQuery As Button
Protected lblTableQueryInformation As Label
Protected btnCopyUrlV2 As Button
#End Region

#Region "Localized strings"
Private Const LOC_TABLEQUERY_SHOW_INFORMATION As String = "CtrlTableQueryShowInformation"
Private Const LOC_TABLEQUERY_INFORMATION_TEXT As String = "CtrlTableQueryInformationText"
Private Const LOC_TABLEQUERY_V2_INFORMATION_TEXT As String = "CtrlTableQueryV2InformationText"
Private Const LOC_TABLEQUERY_URL_CAPTION As String = "CtrlTableQueryUrlCaption"
Private Const LOC_TABLEQUERY_QUERY_CAPTION As String = "CtrlTableQueryQueryCaption"
Private Const LOC_TABLEQUERY_MORE_INFORMATION As String = "CtrlTableQueryMoreInformation"
Private Const LOC_TABLEQUERY_SAVE_QUERY As String = "CtrlTableQuerySaveQuery"
Private Const LOC_TABLEQUERY_COPY As String = "CtrlTableQueryCopy"
#End Region

#Region "Events"
Expand All @@ -47,10 +54,12 @@ Public Class TableQueryCodebehind
If VerifyDatabase() Then
Me.Visible = True
ShowApiURL()
ShowApiV2URL()
ShowApiQuery()
ShowMoreInfoLink()
Localize()
btnSaveQuery.Visible = Marker.ShowSaveApiQueryButton
pnlQueryInformationV2.Visible = Marker.EnableApiV2QueryLink
Else
Me.Visible = False
End If
Expand All @@ -61,6 +70,7 @@ Public Class TableQueryCodebehind
If Me.Visible Then
Localize()
ShowApiURL()
ShowApiV2URL()
End If
End Sub

Expand Down Expand Up @@ -144,12 +154,15 @@ Public Class TableQueryCodebehind
''' <remarks></remarks>
Private Sub Localize()
lblInformationText.Text = GetLocalizedString(LOC_TABLEQUERY_INFORMATION_TEXT)
lblInformationTextV2.Text = GetLocalizedString(LOC_TABLEQUERY_V2_INFORMATION_TEXT)
lblUrl.Text = GetLocalizedString(LOC_TABLEQUERY_URL_CAPTION)
lblUrlV2.Text = GetLocalizedString(LOC_TABLEQUERY_URL_CAPTION)
lblQuery.Text = GetLocalizedString(LOC_TABLEQUERY_QUERY_CAPTION)

lnkMoreInfo.Text = String.Format("<span class=link-text>{0}</span>", Server.HtmlEncode(GetLocalizedString(LOC_TABLEQUERY_MORE_INFORMATION)))
btnSaveQuery.Text = GetLocalizedString(LOC_TABLEQUERY_SAVE_QUERY)
lblTableQueryInformation.Text = GetLocalizedString(LOC_TABLEQUERY_SHOW_INFORMATION)
btnCopyUrlV2.Text = GetLocalizedString(LOC_TABLEQUERY_COPY)
End Sub

''' <summary>
Expand Down Expand Up @@ -234,6 +247,77 @@ Public Class TableQueryCodebehind
txtUrl.Text = sb.ToString()
End Sub

''' <summary>
''' Show the API-V2 URL
''' </summary>
''' <remarks></remarks>
Private Sub ShowApiV2URL()
Dim sb As New System.Text.StringBuilder()
Dim route As String
If Not Marker.URLRootV2 Is Nothing Then
route = Marker.URLRootV2.Replace("\", "/")
sb.Append(route)
If Not route.EndsWith("/") Then
sb.Append("/")
End If
End If

sb.Append("tables/")

Dim builder As IPXModelBuilder = PaxiomManager.PaxiomModelBuilder()
Dim model As PXModel = PaxiomManager.PaxiomModel
Dim tableId As String = model.Meta.TableID

'If PX file the Matrix should be used as tabled identifier
If Marker.DatabaseType = PCAxis.Web.Core.Enums.DatabaseType.PX Then
tableId = model.Meta.Matrix
End If

sb.Append(tableId)

sb.Append("/data")

Dim lang As String = LocalizationManager.CurrentCulture.Name
lang = Util.GetLanguageForNet3_5(lang)
sb.Append("?lang=")
sb.Append(lang)


For Each var In model.Meta.Variables
Dim values As String = GetValuesString(var.Values)
'If var.CurrentValueSet IsNot Nothing Then
' sb.Append(String.Format("&codelist[{0}]={1}", var.Code, var.CurrentValueSet.ID))
'End If
'If var.CurrentGrouping IsNot Nothing Then
' sb.Append(String.Format("&outputValues[{0}]={1}", var.Code, "aggregated"))
'End If
sb.Append(String.Format("&valueCodes[{0}]={1}", var.Code, values))
Next

For Each var In PaxiomManager.QueryModel.Query
Dim filter As String = var.Selection.Filter
Dim prefix As String = filter.Split(":"c).First()
Dim suffix As String = filter.Split(":"c).Last()
If prefix.Equals("vs") Or prefix.Equals("agg") Then
sb.Append(String.Format("&codelist[{0}]={1}_{2}", var.Code, prefix, suffix))
End If
If prefix.Equals("agg") Then
sb.Append(String.Format("&outputValues[{0}]={1}", var.Code, "aggregated"))
End If
Next

txtUrlV2.Text = sb.ToString()
End Sub
Private Function GetValuesString(var As Values) As String
Dim valuesSB As New System.Text.StringBuilder()
For Each val As Value In var
valuesSB.Append(val.Code)
valuesSB.Append(",")
Next
valuesSB.Remove(valuesSB.Length - 1, 1)
Return valuesSB.ToString()
End Function

Private Function GetAppPath() As String
Dim appPath As String = String.Empty
Dim context As System.Web.HttpContext = System.Web.HttpContext.Current
Expand Down
18 changes: 18 additions & 0 deletions PXWeb/Admin/Features-Api-General.aspx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,24 @@
ErrorMessage="*" ValidateEmptyText="False" CssClass="setting-field-validator" ></asp:CustomValidator>
</div>

<div class="setting-field">
<asp:Label ID="lblEnableApiV2QueryLink" runat="server" Text="<%$ PxString: PxWebAdminFeaturesApiGeneralEnableApiV2QueryLink %>"></asp:Label>
<asp:DropDownList ID="cboEnableApiV2QueryLink" runat="server">
<asp:ListItem Value="True" Text="<%$ PxString: PxWebAdminYes %>"></asp:ListItem>
<asp:ListItem Value="False" Text="<%$ PxString: PxWebAdminNo %>"></asp:ListItem>
</asp:DropDownList>
&nbsp;<asp:ImageButton ID="imgEnableApiV2QueryLink" runat="server" onclick="EnableApiV2QueryLinkInfo" Height="15px" Width="15px" ImageUrl="<%$ PxImage: questionmark.gif %>" />
</div>

<div class="setting-field">
<asp:Label ID="lblUrlRootV2" runat="server" Text="<%$ PxString: PxWebAdminFeaturesApiGeneralUrlRootV2 %>"></asp:Label>
<asp:TextBox ID="txtUrlRootV2" runat="server"></asp:TextBox>
<asp:ImageButton ID="imgUrlRootV2" runat="server" onclick="UrlRootInfoV2" Height="15px" Width="15px" ImageUrl="<%$ PxImage: questionmark.gif %>" />
<asp:CustomValidator ID="validatorUrlRootV2" runat="server"
ControlToValidate="txtUrlRootV2" OnServerValidate="ValidateUrlRoot"
ErrorMessage="*" ValidateEmptyText="False" CssClass="setting-field-validator" ></asp:CustomValidator>
</div>

<div class="setting-field">
<asp:Label ID="lblMaxValuesReturned" runat="server" Text="<%$ PxString: PxWebAdminFeaturesApiGeneralMaxValuesReturned %>"></asp:Label>
<asp:TextBox ID="txtMaxValuesReturned" runat="server" CssClass="smallinput" MaxLength="10" Width="50px"></asp:TextBox>
Expand Down
12 changes: 12 additions & 0 deletions PXWeb/Admin/Features-Api-General.aspx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,15 @@ private void ReadSettings()
txtFetchCellLimit.Text = PXWeb.Settings.Current.Features.Api.FetchCellLimit.ToString();
cboEnableCORS.SelectedValue = PXWeb.Settings.Current.Features.Api.EnableCORS.ToString();
cboEnableCache.SelectedValue = PXWeb.Settings.Current.Features.Api.EnableCache.ToString();
cboEnableApiV2QueryLink.SelectedValue = PXWeb.Settings.Current.Features.Api.EnableApiV2QueryLink.ToString();
//txtClearCache.Text = PXWeb.Settings.Current.Features.Api.ClearCache;
cboShowQueryInformation.SelectedValue = PXWeb.Settings.Current.Features.Api.ShowQueryInformation.ToString();
cboDefaultExampleResponseFormat.SelectedValue = PXWeb.Settings.Current.Features.Api.DefaultExampleResponseFormat;
cboShowSaveApiQueryButton.SelectedValue = PXWeb.Settings.Current.Features.Api.ShowSaveApiQueryButton.ToString();
txtSaveApiQueryText.Text = PXWeb.Settings.Current.Features.Api.SaveApiQueryText.ToString();
ShowHideTextboxForQueryPrefix();
txtUrlRoot.Text = PXWeb.Settings.Current.Features.Api.UrlRoot;
txtUrlRootV2.Text = PXWeb.Settings.Current.Features.Api.UrlRootV2;
}

/// <summary>
Expand Down Expand Up @@ -224,6 +226,8 @@ protected void MasterSave_Click(Object sender, System.EventArgs e)
api.SaveApiQueryText = txtSaveApiQueryText.Text;

api.UrlRoot = txtUrlRoot.Text;
api.UrlRootV2 = txtUrlRootV2.Text;
api.EnableApiV2QueryLink = bool.Parse(cboEnableApiV2QueryLink.SelectedValue);

PXWeb.Settings.Save();

Expand Down Expand Up @@ -483,6 +487,14 @@ protected void UrlRootInfo(object sender, ImageClickEventArgs e)
Master.ShowInfoDialog("PxWebAdminFeaturesApiGeneralUrlRoot", "PxWebAdminFeaturesApiGeneralUrlRootInfo");
}

protected void UrlRootInfoV2(object sender, ImageClickEventArgs e)
{
Master.ShowInfoDialog("PxWebAdminFeaturesApiGeneralUrlRootV2", "PxWebAdminFeaturesApiGeneralUrlRootInfoV2");
}
protected void EnableApiV2QueryLinkInfo(object sender, ImageClickEventArgs e)
{
Master.ShowInfoDialog("PxWebAdminFeaturesApiGeneralEnableApiV2QueryLink", "PxWebAdminFeaturesApiGeneralEnableApiV2QueryLinkInfo");
}
protected void ShowSaveApiQueryButtonInfo(object sender, ImageClickEventArgs e)
{
Master.ShowInfoDialog("PxWebAdminFeaturesApiGeneralShowSaveApiQueryButton", "PxWebAdminFeaturesApiGeneralShowSaveApiQueryButtonInfo");
Expand Down
Loading

0 comments on commit f259487

Please sign in to comment.