[chronojump] Compujump dialog_person_popup shows "other stations with pending tasks"
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Compujump dialog_person_popup shows "other stations with pending tasks"
- Date: Sun, 9 Jul 2017 18:30:17 +0000 (UTC)
commit d28522b2ae8f3f57d57de08357b77ec2bcf3c9af
Author: Xavier de Blas <xaviblas gmail com>
Date: Sun Jul 9 20:24:31 2017 +0200
Compujump dialog_person_popup shows "other stations with pending tasks"
glade/dialog_person_popup.glade | 91 +++++++++++++++++++++++++++----------
src/gui/dialogPersonPopup.cs | 32 +++++++++++--
src/gui/networks.cs | 11 +++--
src/json.cs | 93 +++++++++++++++++++++++++++++++++++++++
4 files changed, 193 insertions(+), 34 deletions(-)
---
diff --git a/glade/dialog_person_popup.glade b/glade/dialog_person_popup.glade
index 5133e0c..0062201 100644
--- a/glade/dialog_person_popup.glade
+++ b/glade/dialog_person_popup.glade
@@ -49,6 +49,17 @@
<property name="can_focus">False</property>
<property name="spacing">20</property>
<child>
+ <widget class="GtkLabel" id="label_rfid">
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">label</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
<widget class="GtkHBox" id="hbox3">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -197,17 +208,6 @@
<property name="position">0</property>
</packing>
</child>
- <child>
- <widget class="GtkLabel" id="label_rfid">
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">label</property>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
</widget>
<packing>
<property name="expand">True</property>
@@ -230,12 +230,11 @@
</packing>
</child>
<child>
- <widget class="GtkFrame" id="frame_tasks_parametrized">
+ <widget class="GtkNotebook" id="notebook">
<property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label_xalign">0</property>
- <property name="label_yalign">0.69999998807907104</property>
- <property name="shadow_type">out</property>
+ <property name="can_focus">True</property>
+ <property name="tab_hborder">10</property>
+ <property name="tab_vborder">8</property>
<child>
<widget class="GtkAlignment" id="alignment2">
<property name="visible">True</property>
@@ -258,8 +257,8 @@
</child>
</widget>
<packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
@@ -268,27 +267,69 @@
</widget>
</child>
<child>
- <widget class="GtkLabel" id="label23">
+ <widget class="GtkLabel" id="label3">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="label">Tasques</property>
- <property name="use_markup">True</property>
+ <property name="label" translatable="yes">Tasks at this station</property>
</widget>
<packing>
- <property name="type">label_item</property>
+ <property name="tab_fill">False</property>
+ <property name="type">tab</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkAlignment" id="alignment1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="top_padding">10</property>
+ <property name="bottom_padding">10</property>
+ <property name="left_padding">10</property>
+ <property name="right_padding">10</property>
+ <child>
+ <widget class="GtkVBox" id="vbox5">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <widget class="GtkLabel" id="label_other_stations">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </widget>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label4">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Other stations with assigned tasks</property>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ <property name="tab_fill">False</property>
+ <property name="type">tab</property>
</packing>
</child>
</widget>
<packing>
- <property name="expand">False</property>
+ <property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</widget>
<packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
diff --git a/src/gui/dialogPersonPopup.cs b/src/gui/dialogPersonPopup.cs
index 72a1127..0d4f922 100644
--- a/src/gui/dialogPersonPopup.cs
+++ b/src/gui/dialogPersonPopup.cs
@@ -33,7 +33,7 @@ public class DialogPersonPopup
[Widget] Gtk.Image image_person_logout;
[Widget] Gtk.Image image_close;
[Widget] Gtk.Label label_rfid;
- [Widget] Gtk.Frame frame_tasks_parametrized;
+ [Widget] Gtk.Notebook notebook;
[Widget] Gtk.VBox vbox_tasks_parametrized;
private List<Task> list_tasks_fixed; //This list has "R,L" separated
@@ -41,13 +41,14 @@ public class DialogPersonPopup
private List<Gtk.Button> list_buttons_done;
private List<int> list_buttons_done_id; //this has right id to mark task (also R,L) done
private List<Gtk.HBox> list_hboxs_row; //to unsensitive when done!
+ [Widget] Gtk.Label label_other_stations;
private Task taskActive;
public Button Fake_button_start_task;
public Button Fake_button_person_logout;
public bool Visible;
- public DialogPersonPopup (int personID, string name, string rfid, List<Task> tasks)
+ public DialogPersonPopup (int personID, string name, string rfid, List<Task> tasks,
List<StationCount> stationsCount)
{
Glade.XML gladeXML;
gladeXML = Glade.XML.FromAssembly (Util.GetGladePath() + "dialog_person_popup.glade",
"dialog_person_popup", null);
@@ -58,6 +59,7 @@ public class DialogPersonPopup
Visible = true;
+ //1) Show top of the window widgets
label_name.Text = "<b>" + name + "</b>";
label_name.UseMarkup = true;
label_rfid.Text = rfid;
@@ -84,6 +86,8 @@ public class DialogPersonPopup
}
}
+
+ //2) Show tasks stuff
list_tasks_fixed = new List<Task>();
list_hboxs_row = new List<Gtk.HBox>();
list_buttons_start = new List<Gtk.Button>();
@@ -138,10 +142,28 @@ public class DialogPersonPopup
vbox_tasks_parametrized.PackStart(hboxRow, false, false, 0);
}
- if(task_parametrized_exist)
- vbox_tasks_parametrized.ShowAll();
+ if(! task_parametrized_exist)
+ {
+ Gtk.Label label = new Gtk.Label("There are no pending tasks on this station.");
+ vbox_tasks_parametrized.PackStart(label, false, false, 0);
+ }
+
+ vbox_tasks_parametrized.ShowAll();
+
+ //3) Show other stations tasks
+ string sep = "";
+ string stationsString = "";
+ foreach(StationCount sc in stationsCount)
+ {
+ stationsString += sep + sc.ToString();
+ sep = ", ";
+ }
+
+ if(stationsString == "")
+ label_other_stations.Text = "There are no tasks at other stations";
else
- frame_tasks_parametrized.Visible = false;
+ //label_other_stations.Text = "There are task at this stations:" + "\n\n" +
stationsString;
+ label_other_stations.Text = stationsString;
}
private Gtk.HBox createHBoxStartAndLabel(Task t, Pixbuf pixbuf)
diff --git a/src/gui/networks.cs b/src/gui/networks.cs
index 8c72fde..15c19d7 100644
--- a/src/gui/networks.cs
+++ b/src/gui/networks.cs
@@ -612,11 +612,14 @@ public partial class ChronoJumpWindow
}
}
- //3) show dialog
- showDialogPersonPopup(tasks);
+ //3) get other stationsCount
+ List<StationCount> stationsCount =
json.GetOtherStationsWithPendingTasks(currentPerson.UniqueID, configChronojump.CompujumpStationID);
+
+ //4) show dialog
+ showDialogPersonPopup(tasks, stationsCount);
}
- private void showDialogPersonPopup(List<Task> tasks)
+ private void showDialogPersonPopup(List<Task> tasks, List<StationCount> stationsCount)
{
if(dialogPersonPopup != null)
dialogPersonPopup.DestroyDialog();
@@ -625,7 +628,7 @@ public partial class ChronoJumpWindow
dialogMessageNotAtServer.on_close_button_clicked(new object(), new EventArgs());
dialogPersonPopup = new DialogPersonPopup(
- currentPerson.UniqueID, currentPerson.Name, capturedRFID, tasks);
+ currentPerson.UniqueID, currentPerson.Name, capturedRFID, tasks,
stationsCount);
dialogPersonPopup.Fake_button_start_task.Clicked -= new EventHandler(compujumpTaskStart);
dialogPersonPopup.Fake_button_start_task.Clicked += new EventHandler(compujumpTaskStart);
diff --git a/src/json.cs b/src/json.cs
index f6f898c..0ba2fdc 100644
--- a/src/json.cs
+++ b/src/json.cs
@@ -544,6 +544,78 @@ public class Json
return true;
}
+ //get pending tasks on other stations
+ public List<StationCount> GetOtherStationsWithPendingTasks(int personID, int stationID)
+ {
+ // Create a request using a URL that can receive a post.
+ WebRequest request = WebRequest.Create (serverUrl + "/getOtherStationsWithPendingTasks");
+
+ // Set the Method property of the request to POST.
+ request.Method = "POST";
+
+ // Set the ContentType property of the WebRequest.
+ request.ContentType = "application/json; Charset=UTF-8"; //but this is not enough, see this
line:
+
+ // Creates the json object
+ JsonObject json = new JsonObject();
+ json.Add("personId", personID.ToString());
+ json.Add("stationId", stationID.ToString());
+
+ // Converts it to a String
+ String js = json.ToString();
+
+ // Writes the json object into the request dataStream
+ Stream dataStream;
+ try {
+ dataStream = request.GetRequestStream ();
+ } catch {
+ this.ResultMessage =
+ string.Format(Catalog.GetString("You are not connected to the Internet\nor
{0} server is down."),
+ serverUrl);
+ return new List<StationCount>();
+ }
+
+ dataStream.Write (Encoding.UTF8.GetBytes(js), 0, js.Length);
+ dataStream.Close ();
+
+ HttpWebResponse response;
+ try {
+ response = (HttpWebResponse) request.GetResponse();
+ } catch {
+ this.ResultMessage =
+ string.Format(Catalog.GetString("You are not connected to the Internet\nor
{0} server is down."),
+ serverUrl);
+ return new List<StationCount>();
+ }
+
+ string responseFromServer;
+ using (var sr = new StreamReader(response.GetResponseStream()))
+ {
+ responseFromServer = sr.ReadToEnd();
+ }
+
+ LogB.Information("GetOtherStationsWithPendingTasks: " + responseFromServer);
+
+ if(responseFromServer == "" || responseFromServer == "[]")
+ {
+ LogB.Information(" Empty ");
+ return new List<StationCount>();
+ }
+
+ //return taskDeserializeFromServer (responseFromServer);
+ List<StationCount> stations = new List<StationCount>();
+ JsonValue jsonStations = JsonValue.Parse (responseFromServer);
+
+ foreach (JsonValue jsonStation in jsonStations)
+ {
+ string stationName = jsonStation ["stationName"];
+ int tasksCount = jsonStation ["tasksCount"];
+ stations.Add(new StationCount(stationName, tasksCount));
+ }
+ return stations;
+ }
+
+
public EncoderExercise GetEncoderExercise(int exerciseId)
{
EncoderExercise ex = new EncoderExercise();
@@ -974,3 +1046,24 @@ public class Task
return ExerciseName + ": " + str;
}
}
+
+public class StationCount
+{
+ private string stationName;
+ private int tasksCount;
+
+ public StationCount()
+ {
+ }
+
+ public StationCount(string name, int count)
+ {
+ stationName = name;
+ tasksCount = count;
+ }
+
+ public override string ToString()
+ {
+ return stationName + " (" + tasksCount.ToString() + ")";
+ }
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]