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 Jul 5, 2023
2 parents 02f68cb + ec1efd9 commit 6d26530
Show file tree
Hide file tree
Showing 16 changed files with 431 additions and 169 deletions.
2 changes: 2 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
=== Release of PxWeb 2023 v1 ===
- Dcat file uses the organizations.json file to map between organization names and existing organization uris
- Dcat admin tool and api-endpoint is now updated to allow for catalog titles and descriptions in multiple languages
- Dcat admin tool settings are now saved separately for each database, in the corresponding database.config file
- Dcat admin tool now uses the BackgroundWorker to run tasks as background processes
- Upgraded versions of nuget-packages
Expand Down
29 changes: 16 additions & 13 deletions PXWeb/Admin/Settings-General-Language.aspx.designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 34 additions & 12 deletions PXWeb/Admin/Tools-XMLGenerator.aspx
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,6 @@
<asp:TextBox ID="textBoxSelectBaseURI" runat="server"></asp:TextBox>
<asp:ImageButton ID="imgSelectBaseURI" runat="server" onclick="imgSelectBaseURI_Click" Height="15px" Width="15px" ImageUrl="<%$ PxImage: questionmark.gif %>"/>
</div>
<div class="setting-field">
<asp:Label ID="lblSelectCatalogTitle" runat="server" Text="<%$ PxString: PxWebAdminToolsXMLGeneratorSelectCatalogTitle %>">"></asp:Label>
<asp:TextBox ID="textBoxSelectCatalogTitle" runat="server"></asp:TextBox>
<asp:ImageButton ID="imgSelectCatalogTitle" runat="server" onclick="imgSelectCatalogTitle_Click" Height="15px" Width="15px" ImageUrl="<%$ PxImage: questionmark.gif %>"/>
</div>
<div class="setting-field">
<asp:Label ID="lblSelectCatalogDesc" runat="server" Text="<%$ PxString: PxWebAdminToolsXMLGeneratorSelectCatalogDesc %>">"></asp:Label>
<asp:TextBox ID="textBoxSelectCatalogDesc" runat="server"></asp:TextBox>
<asp:ImageButton ID="imgSelectCatalogDesc" runat="server" onclick="imgSelectCatalogDesc_Click" Height="15px" Width="15px" ImageUrl="<%$ PxImage: questionmark.gif %>"/>
</div>
<div class="setting-field">
<asp:Label ID="lblSelectLicense" runat="server" Text="<%$ PxString: PxWebAdminToolsXMLGeneratorSelectLicense %>">"></asp:Label>
<asp:TextBox ID="textBoxSelectLicense" runat="server"></asp:TextBox>
Expand All @@ -50,14 +40,46 @@
<asp:TextBox ID="textBoxSelectPublisher" runat="server"></asp:TextBox>
<asp:ImageButton ID="imgSelectPublisher" runat="server" onclick="imgSelectPublisher_Click" Height="15px" Width="15px" ImageUrl="<%$ PxImage: questionmark.gif %>"/>
</div>
<div class="setting-field">

<div class="setting-field">
<asp:Repeater ID="dcatLanguageSpecificSettings" runat="server">
<ItemTemplate>
<div class="dcatLanguageSpecific">
<asp:HiddenField ID="hidSetting" runat="server" value='<%# Bind("Id") %>' />
<asp:Label ID="lblSiteLanguages" runat="server" Text="<%$ PxString: PxWebAdminSettingsLanguageSiteLanguages %>"></asp:Label>
<asp:Label ID="lblLanguage" runat="server" CssClass="dcatTextLanguage" Text=<%# Eval("Name") %>></asp:Label>
</div>
<div class="dcatCatalogTitle">
<asp:Label ID="lblSelectCatalogTitle" runat="server" Text="<%$ PxString: PxWebAdminToolsXMLGeneratorSelectCatalogTitle %>"></asp:Label>
<asp:TextBox ID="textBoxSelectCatalogTitle" CssClass="dcatCatalogTitleTextbox" runat="server" Text=<%# Eval("Title") %>></asp:TextBox>
<asp:ImageButton ID="imgSelectCatalogTitle" runat="server" onclick="imgSelectCatalogTitle_Click" Height="15px" Width="15px" ImageUrl="<%$ PxImage: questionmark.gif %>"/>
</div>
<div class="dcatCatalogDesc">
<asp:Label ID="lblSelectCatalogDesc" runat="server" Text="<%$ PxString: PxWebAdminToolsXMLGeneratorSelectCatalogDesc %>"></asp:Label>
<asp:TextBox ID="textBoxSelectCatalogDescription" CssClass="dcatCatalogDescTextbox" runat="server" Text=<%# Eval("Description") %>></asp:TextBox>
<asp:ImageButton ID="imgSelectCatalogDesc" runat="server" onclick="imgSelectCatalogDesc_Click" Height="15px" Width="15px" ImageUrl="<%$ PxImage: questionmark.gif %>"/>
</div>
</ItemTemplate>
<%-- <AlternatingItemTemplate>
<p class="evenRow">
<asp:HiddenField ID="hidSetting" runat="server" value='<%# Bind("Id") %>' />
<asp:Label id="lblLanguage" runat="server" Text=<%# Eval("Name") %>></asp:Label>
<asp:TextBox id="textBoxSelectCatalogTitle" runat="server" Text=<%# Eval("Title") %>></asp:TextBox>
<asp:TextBox id="textBoxSelectCatalogDescription" runat="server" Text=<%# Eval("Description") %>></asp:TextBox>
</p>
</AlternatingItemTemplate>--%>
</asp:Repeater>

</div>

<div class="setting-field">
<asp:Label ID="lblStatus" runat="server" Text="<%$ PxString: PxWebAdminToolsXMLGeneratorStatus %>">"></asp:Label>
<asp:Label ID="lblStatusValue" runat="server" Text="NotCreated"></asp:Label>
<asp:ImageButton ID="imgStatus" runat="server" onclick="imgStatus_Click" Height="15px" Width="15px" ImageUrl="<%$ PxImage: questionmark.gif %>"/>
</div>

<div class="setting-field">
<asp:Button ID="btnGenerateXML" onclick="btnGenerateXML_Click" runat="server" Text="<%$ PxString: PxWebAdminGenerateButton %>" />
<asp:Button ID="btnGenerateXML" CssClass="dcatGenerateBtn" OnClick="btnGenerateXML_Click" runat="server" Text="<%$ PxString: PxWebAdminGenerateButton %>" />
</div>


Expand Down
74 changes: 69 additions & 5 deletions PXWeb/Admin/Tools-XMLGenerator.aspx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
using System.Globalization;
using System.Collections.Generic;
using System.IO;
using Px.Rdf;
using Px.Dcat;

namespace PXWeb.Admin
{
Expand Down Expand Up @@ -45,6 +45,7 @@ protected void fillCNMMDatabases(DropDownList ddl)
ddl.Items.Add(new ListItem(db.Id, db.Id));
}
}

protected void cboSelectDbType_SelectedIndexChanged(object sender, EventArgs e)
{
if (cboSelectDbType.SelectedItem.Value == "PX") fillPxDatabases(cboSelectDb);
Expand Down Expand Up @@ -130,8 +131,8 @@ private void ReadSettings(string database)
textBoxSelectApiURL.Text = dcatSettings.BaseApiUrl;
textBoxSelectLandingPageURL.Text = dcatSettings.LandingPageUrl;
textBoxSelectPublisher.Text = dcatSettings.Publisher;
textBoxSelectCatalogTitle.Text = dcatSettings.CatalogTitle;
textBoxSelectCatalogDesc.Text = dcatSettings.CatalogDescription;
// textBoxSelectCatalogTitle.Text = dcatSettings.CatalogTitle;
// textBoxSelectCatalogDesc.Text = dcatSettings.CatalogDescription;
textBoxSelectLicense.Text = dcatSettings.License;
updateStatusLabel(dcatSettings);

Expand All @@ -142,8 +143,48 @@ private void ReadSettings(string database)
{
btnGenerateXML.Enabled = true;
}

var settingsLookup = new Dictionary<string, IDcatLanguageSpecificSettings>();
IEnumerable<IDcatLanguageSpecificSettings> languageSpecificSettings = dcatSettings.LanguageSpecificSettings;
if (languageSpecificSettings != null) {
foreach (IDcatLanguageSpecificSettings l in dcatSettings.LanguageSpecificSettings)
{
settingsLookup.Add(l.Language, l);
}
}

var langSettings = new List<object>();
foreach (ILanguageSettings l in Settings.Current.General.Language.SiteLanguages) {
string id = l.Name;
IDcatLanguageSpecificSettings settings;
string title;
string desc;
if (settingsLookup.TryGetValue(id, out settings))
{
title = settings.CatalogTitle;
desc = settings.CatalogDescription;
}
else
{
title = "Catalog title";
desc = "Catalog desc";
}
langSettings.Add(
new
{
Id = id,
Name = new CultureInfo(id).EnglishName,
Title = title,
Description = desc,
}
);
}

dcatLanguageSpecificSettings.DataSource = langSettings;
dcatLanguageSpecificSettings.DataBind();
}


private void updateStatusLabel(DcatSettings dcatSettings)
{
lblStatusValue.Text = dcatSettings.FileStatus.ToString();
Expand All @@ -162,15 +203,38 @@ private void saveCurrentSettings()
dcats.BaseApiUrl = textBoxSelectApiURL.Text;
dcats.LandingPageUrl = textBoxSelectLandingPageURL.Text;
dcats.Publisher = textBoxSelectPublisher.Text;
dcats.CatalogTitle = textBoxSelectCatalogTitle.Text;
dcats.CatalogDescription = textBoxSelectCatalogDesc.Text;
// dcats.CatalogTitle = textBoxSelectCatalogTitle.Text;
// dcats.CatalogDescription = textBoxSelectCatalogDesc.Text;
dcats.License = textBoxSelectLicense.Text;
dcats.Database = cboSelectDb.Text;
dcats.DatabaseType = cboSelectDbType.Text;

var languageSpecificSettingsList = new List<IDcatLanguageSpecificSettings>();

foreach (RepeaterItem itm in dcatLanguageSpecificSettings.Items)
{
IDcatLanguageSpecificSettings langSpecificSettings = GetLangSpecificSettings(itm);
languageSpecificSettingsList.Add(langSpecificSettings);
}
dcats.LanguageSpecificSettings = languageSpecificSettingsList;

db.Save();
}

private IDcatLanguageSpecificSettings GetLangSpecificSettings(RepeaterItem itm)
{
var hf = (HiddenField)itm.FindControl("hidSetting");
string lang = hf.Value;

var titleTextBox = (TextBox)itm.FindControl("textBoxSelectCatalogTitle");
string title = titleTextBox.Text;

var descTextBox = (TextBox)itm.FindControl("textBoxSelectCatalogDescription");
var desc = descTextBox.Text;

return new DcatLanguageSpecificSettings(lang, title, desc);
}

protected void MasterSave_Click(object sender, EventArgs e) {
saveCurrentSettings();
}
Expand Down
63 changes: 9 additions & 54 deletions PXWeb/Admin/Tools-XMLGenerator.aspx.designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 6d26530

Please sign in to comment.