Skip to content

Commit

Permalink
Fix various defect to be able to edit and package "web services "
Browse files Browse the repository at this point in the history
  • Loading branch information
vletroye committed Nov 7, 2022
1 parent fcaf7c3 commit 1da1dd1
Show file tree
Hide file tree
Showing 6 changed files with 312 additions and 155 deletions.
25 changes: 17 additions & 8 deletions Mods/Forms/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,8 @@ private void SaveResourceConfig(string path)
if (addKey)
info.Add("support_conf_folder", "yes");
}

ResetEditScriptMenuIcons();
}

private void LoadPrivilegeConfig(string path)
Expand Down Expand Up @@ -4465,7 +4467,7 @@ private void menuDelete_Click(object sender, EventArgs e)
private DialogResult CloseCurrentPackage(bool trySavingPendingChange = true, bool forceSavingPendingChange = false)
{
warnings.Clear();
pictureBoxWarning.Visible=false;
pictureBoxWarning.Visible = false;

DialogResult closed = DialogResult.No;
if (info != null && Directory.Exists(CurrentPackageFolder)) try
Expand Down Expand Up @@ -4763,6 +4765,7 @@ private bool TransformIntoSingleApp()
}
else if (list.items.Count > 1)
{
MessageBoxEx.Show(this, string.Format("You cannot tansform this package into a single app as it has already {0} items.", list.items.Count), "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
succeed = false;
}
}
Expand Down Expand Up @@ -5161,6 +5164,9 @@ private void textBoxFirmware_Validating(object sender, CancelEventArgs e)
{
e.Cancel = true;
textBox.Text = info["os_min_ver"];
}
else
{
isDSM7x = false;
}
}
Expand All @@ -5170,6 +5176,9 @@ private void textBoxFirmware_Validating(object sender, CancelEventArgs e)
{
e.Cancel = true;
textBox.Text = info["os_min_ver"];
}
else
{
isDSM7x = true;
}
}
Expand Down Expand Up @@ -5613,7 +5622,7 @@ private void syslogConfigToolStripMenuItem_Click(object sender, EventArgs e)

if (!Helper.CheckDSMVersionMin(info, 6, 0, 7145))
{
MessageBoxEx.Show(this, "Port-Config worker is only supported by firmware >= 6.0-7145", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
MessageBoxEx.Show(this, "Syslog config worker is only supported by firmware >= 6.0-7145", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
}
else
{
Expand All @@ -5627,7 +5636,7 @@ private void pHPINIToolStripMenuItem_Click(object sender, EventArgs e)

if (!Helper.CheckDSMVersionMin(info, 4, 2, 3160))
{
MessageBoxEx.Show(this, "Port-Config worker is only supported by firmware >= 4.2-3160", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
MessageBoxEx.Show(this, "Php INI worker is only supported by firmware >= 4.2-3160", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
}
else
{
Expand All @@ -5641,7 +5650,7 @@ private void mariaDBToolStripMenuItem_Click(object sender, EventArgs e)

if (!Helper.CheckDSMVersionMin(info, 5, 5, 0062))
{
MessageBoxEx.Show(this, "Port-Config worker is only supported by firmware >= 5.5.47-0062", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
MessageBoxEx.Show(this, "Maria DB worker is only supported by firmware >= 5.5.47-0062", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
}
else
{
Expand All @@ -5655,7 +5664,7 @@ private void indexDBToolStripMenuItem_Click(object sender, EventArgs e)

if (!Helper.CheckDSMVersionMin(info, 6, 0, 5924))
{
MessageBoxEx.Show(this, "Port-Config worker is only supported by firmware >= 6.0-5924", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
MessageBoxEx.Show(this, "index DB worker is only supported by firmware >= 6.0-5924", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
}
else
{
Expand All @@ -5669,7 +5678,7 @@ private void dataShareToolStripMenuItem_Click(object sender, EventArgs e)

if (!Helper.CheckDSMVersionMin(info, 6, 0, 5941))
{
MessageBoxEx.Show(this, "Port-Config worker is only supported by firmware >= 6.0-5941", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
MessageBoxEx.Show(this, "Data Share worker is only supported by firmware >= 6.0-5941", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
}
else
{
Expand All @@ -5683,7 +5692,7 @@ private void apacheToolStripMenuItem_Click(object sender, EventArgs e)

if (!Helper.CheckDSMVersionMin(info, 4, 2, 3160))
{
MessageBoxEx.Show(this, "Port-Config worker is only supported by firmware >= 4.2-3160", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
MessageBoxEx.Show(this, "Apache worker is only supported by firmware >= 4.2-3160", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
}
else
{
Expand All @@ -5697,7 +5706,7 @@ private void linkerToolStripMenuItem_Click(object sender, EventArgs e)

if (!Helper.CheckDSMVersionMin(info, 6, 0, 5941))
{
MessageBoxEx.Show(this, "Port-Config worker is only supported by firmware >= 6.0-5941", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
MessageBoxEx.Show(this, "Linker worker is only supported by firmware >= 6.0-5941", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
}
else
{
Expand Down
21 changes: 12 additions & 9 deletions Mods/Helpers/JSonResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,25 @@ public class Service
{
public string service { get; set; }
public string display_name { get; set; }
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Include)]
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Include)]
public bool support_alias { get; set; }
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Include)]
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Include)]
public bool support_server { get; set; }
public string type { get; set; }
public string root { get; set; }
[DefaultValue("")]
public string index { get; set; }
[DefaultValue(null)]
public string[] index { get; set; }
[DefaultValue("")]
public string icon { get; set; }
public int backend { get; set; }
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Include)]
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Include)]
public bool intercept_errors { get; set; }
public Php php { get; set; }
[DefaultValue(0)]
public int connect_timeout { get; set; }
[DefaultValue(0)]
public int read_timeout { get; set; }
[DefaultValue(0)]
public int send_timeout { get; set; }
}

Expand Down Expand Up @@ -80,10 +83,10 @@ public class Portal
public string alias { get; set; }
[DefaultValue("")]
public string app { get; set; }
[DefaultValue("")]
public string http_port { get; set; }
[DefaultValue("")]
public string https_port { get; set; }
[DefaultValue(null)]
public int[] http_port { get; set; }
[DefaultValue(null)]
public int[] https_port { get; set; }
[DefaultValue("")]
public string host { get; set; }
}
Expand Down
25 changes: 25 additions & 0 deletions Mods/Workers/Worker_Privilege.Designer.cs

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

21 changes: 20 additions & 1 deletion Mods/Workers/Worker_Privilege.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ namespace BeatificaBytes.Synology.Mods
// "defaults":{
// "run-as": "<run-as>"
// },
// "username": "<username>",
// "username": "<username>",?
// "groupname": "<groupname>",
// "join-groupname": "<existing groupname>", => use "join-groupname" if it already exist as mentionned (but not explained) in this PDF: https://global.download.synology.com/download/Document/Software/DeveloperGuide/Os/DSM/All/enu/DSM_Developer_Guide_7_enu.pdf
// "ctrl-script":[{
// "action": "<action>",
// "run-as": "<run-as>"
Expand Down Expand Up @@ -95,6 +96,9 @@ private void DisplayPrivilege()
var groupname = privilege.SelectToken("groupname");
if (groupname != null) textBoxGroupname.Text = groupname.ToString();

var joingroupname = privilege.SelectToken("join-groupname");
if (joingroupname != null) textBoxJoinGroupname.Text = joingroupname.ToString();

var ctrlScript = privilege.SelectToken("ctrl-script");
if (ctrlScript != null)
foreach (var ctrl in ctrlScript)
Expand Down Expand Up @@ -130,10 +134,12 @@ private void buttonOk_Click(object sender, EventArgs e)
var defaults = JObject.Parse(string.Format("{{\"run-as\": \"{0}\"}}", comboBoxRunAs.SelectedItem));
var username = textBoxUsername.Text;
var groupname = textBoxGroupname.Text;
var joingroupname = textBoxJoinGroupname.Text;
var package = info["package"];

if (string.IsNullOrEmpty(username) || username == package) username = null;
if (string.IsNullOrEmpty(groupname) || groupname == package) groupname = null;
if (string.IsNullOrEmpty(joingroupname) || joingroupname == package) joingroupname = null;

//Update the Resource file
privilege["defaults"] = defaults;
Expand All @@ -147,6 +153,10 @@ private void buttonOk_Click(object sender, EventArgs e)
if (groupname != null)
privilege["groupname"] = groupname;

if (privilege.SelectToken("join-groupname") != null) ((JObject)privilege).Remove("join-groupname");
if (joingroupname != null)
privilege["join-groupname"] = joingroupname;

if (privilege.SelectToken("ctrl-script") != null) ((JObject)privilege).Remove("ctrl-script");
var ctrlScript = new List<string>();
foreach (ListViewItem item in listViewCtrlScript.Items)
Expand Down Expand Up @@ -697,5 +707,14 @@ private void SafeClose()
this.FormClosing -= new System.Windows.Forms.FormClosingEventHandler(this.Worker_Privilege_FormClosing);
Close();
}

private void textBoxGroupname_Validating(object sender, CancelEventArgs e)
{
if (textBoxGroupname.Text == "http" || textBoxGroupname.Text == "service")
{
textBoxJoinGroupname.Text = textBoxGroupname.Text;
textBoxGroupname.Text = "";
}
}
}
}
Loading

0 comments on commit 1da1dd1

Please sign in to comment.