Permalink
Browse files

more changes

  • Loading branch information...
1 parent e8e30a3 commit 6158e6615e51dd7f841ec47619ec2bcaf460772a @lformella committed Nov 24, 2012
View
@@ -73,9 +73,9 @@ protected object ObjectLock
readonly List<AObject> _children;
- protected List<AObject> All
+ protected AObject[] All
{
- get { return _children.ToList(); }
+ get { return _children.ToArray(); }
}
#endregion
View
@@ -66,23 +66,43 @@ public Int64 Size
[JsonProperty]
public Int64 CurrentSize
{
- get { return (from part in Parts select part.CurrentSize).Sum(); }
+ get
+ {
+ try
+ {
+ return (from part in Parts select part.CurrentSize).Sum();
+ }
+ catch
+ {
+ return 0;
+ }
+ }
}
[JsonProperty]
public Int64 TimeMissing
{
- get { return (from part in Parts select part.TimeMissing).Max(); }
+ get
+ {
+ try
+ {
+ return (from part in Parts select part.TimeMissing).Max();
+ }
+ catch
+ {
+ return 0;
+ }
+ }
}
#endregion
#region CHILDREN
[JsonProperty]
- public List<FilePart> Parts
+ public IEnumerable<FilePart> Parts
{
- get { return All.Cast<FilePart>().ToList(); }
+ get { return All.Cast<FilePart>(); }
}
public bool Add(FilePart aPart)
View
@@ -130,7 +130,11 @@ public Int64 MissingSize
[MySql]
public Int64 TimeMissing
{
- get { return (_speed > 0 ? (MissingSize / Speed) : 0); }
+ get
+ {
+ Int64 time = (_speed > 0 ? (MissingSize / Speed) : 0);
+ return time;
+ }
}
Int64 _speed;
View
@@ -49,9 +49,9 @@ protected void FireAdded(Snapshot aSnapshot)
readonly List<Snapshot> _all;
- public List<Snapshot> All
+ public IEnumerable<Snapshot> All
{
- get { return _all.ToList(); }
+ get { return _all.ToArray(); }
}
public void Add(Snapshot aSnapshot)
@@ -0,0 +1,44 @@
+//
+// ExternalSearch.cs
+//
+// Author:
+// Lars Formella <ich@larsformella.de>
+//
+// Copyright (c) 2012 Lars Formella
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+
+using Newtonsoft.Json;
+
+using System;
+
+using XG.Core;
+
+namespace XG.Server.Plugin.General.Webserver.Object
+{
+ [JsonObject(MemberSerialization.OptIn)]
+ public class ExternalSearch : Packet
+ {
+ [JsonProperty]
+ public string BotName { get; set; }
+
+ [JsonProperty]
+ public Int64 BotSpeed { get; set; }
+
+ [JsonProperty]
+ public string IrcLink { get; set; }
+ }
+}
@@ -1,5 +1,5 @@
//
-// Object.cs
+// Flot.cs
//
// Author:
// Lars Formella <ich@larsformella.de>
@@ -25,10 +25,10 @@
using System;
-namespace XG.Server.Plugin.General.Webserver.Flot
+namespace XG.Server.Plugin.General.Webserver.Object
{
[JsonObject(MemberSerialization.OptIn)]
- public class Object
+ public class Flot
{
[JsonProperty(PropertyName = "label")]
public string Label { get; set; }
@@ -214,8 +214,8 @@
<div id="tabs_2" style="padding: 0px;">
- <table width="100%" id="searches_xg_bitpir_at"></table>
- <div id="searches_pager_xg_bitpir_at"></div>
+ <table width="100%" id="packets_external"></table>
+ <div id="packets_external_pager"></div>
</div>
@@ -36,21 +36,22 @@ Enum.Request =
DeactivateObject: 6,
Search: 7,
+ SearchExternal: 8,
- Servers: 8,
- ChannelsFromServer: 9,
- PacketsFromBot: 10,
- Files: 11,
+ Servers: 9,
+ ChannelsFromServer: 10,
+ PacketsFromBot: 11,
+ Files: 12,
- AddSearch: 12,
- RemoveSearch: 13,
- Searches: 14,
+ AddSearch: 13,
+ RemoveSearch: 14,
+ Searches: 15,
- Statistics: 15,
- Snapshots: 16,
- ParseXdccLink: 17,
+ Statistics: 16,
+ Snapshots: 17,
+ ParseXdccLink: 18,
- CloseServer: 18
+ CloseServer: 19
};
Enum.Response =
@@ -63,17 +64,18 @@ Enum.Response =
SearchPacket: 11,
SearchBot: 12,
+ SearchExternal: 13,
- Servers: 13,
- ChannelsFromServer: 14,
- PacketsFromBot: 15,
+ Servers: 14,
+ ChannelsFromServer: 15,
+ PacketsFromBot: 16,
- Files: 16,
- Searches: 17,
+ Files: 17,
+ Searches: 18,
- Snapshots: 18,
+ Snapshots: 19,
- Statistics: 19
+ Statistics: 20
}
Enum.TangoColor =
@@ -107,19 +107,5 @@ var XGHelper = Class.create(
}
return moment.humanizeDuration(time, "seconds");
- },
-
- /**
- * @param {int} timestamp
- * @return {String}
- */
- timeStampToHuman: function (timestamp)
- {
- if (timestamp <= 0)
- {
- return "";
- }
-
- return this.cookie.getCookie("human_dates", "0") == "1" ? moment.unix(timestamp).fromNow() : moment.unix(timestamp).format("L LT");
}
});
@@ -590,18 +590,7 @@ var XGBase = Class.create(
{
var search = self.websocket.getRowData("search_table", guid);
- switch(self.activeTab)
- {
- case 0:
- self.websocket.sendGuid(Enum.Request.Search, search.Guid);
- break;
- case 1:
- var gridElement = $("#searches_xg_bitpir_at");
- gridElement.clearGridData();
- gridElement.setGridParam({url: "http://xg.bitpir.at/index.php?show=search&action=json&do=search_packets&searchString=" + search.Name, page: 1});
- gridElement.trigger("reloadGrid");
- break;
- }
+ self.websocket.sendGuid(self.activeTab == 0 ? Enum.Request.Search : Enum.Request.SearchExternal, search.Guid);
},
ExpandColumn : 'Name',
viewrecords: true,
@@ -622,12 +611,12 @@ var XGBase = Class.create(
/* SEARCH GRID */
/**************************************************************************************************************/
- $("#searches_xg_bitpir_at").jqGrid(
+ $("#packets_external").jqGrid(
{
url: "",
- datatype:'jsonp',
+ datatype:'local',
cmTemplate:{fixed:true},
- colNames: ['', '', _('Id'), _('Name'), _('Last Mentioned'), _('Size'), _('Bot'), _('Speed'), ''],
+ colNames: ['', '', _('Id'), _('Name'), _('Last Mentioned'), _('Size'), _('Bot'), _('Speed')],
colModel: [
{
name: 'Object',
@@ -639,12 +628,12 @@ var XGBase = Class.create(
hidden: true
},
{
- name: 'Connected',
- index: 'Connected',
+ name: 'Icon',
+ index: 'Icon',
formatter: function (cell, grid, obj)
{
obj = JSON.parse(obj.Object);
- return self.formatter.formatPacketIcon(obj, "XG.downloadLink(\"" + obj.rowId + "\");", true);
+ return self.formatter.formatPacketIcon(obj, "XG.downloadLink(\"" + obj.Guid + "\");", true);
},
width: 24,
sortable: false
@@ -657,6 +646,10 @@ var XGBase = Class.create(
obj = JSON.parse(obj.Object);
return self.formatter.formatPacketId(obj);
},
+ sorttype: function (c, o)
+ {
+ return o.Id;
+ },
width: 38,
align: "right"
},
@@ -676,7 +669,11 @@ var XGBase = Class.create(
formatter: function (cell, grid, obj)
{
obj = JSON.parse(obj.Object);
- return self.helper.timeStampToHuman(obj.LastMentioned);
+ return self.helper.date2Human(obj.LastMentioned);
+ },
+ sorttype: function (c, o)
+ {
+ return moment(o.LastMentioned).valueOf();
},
width: 140,
align: "right"
@@ -689,6 +686,10 @@ var XGBase = Class.create(
obj = JSON.parse(obj.Object);
return self.helper.size2Human(obj.Size);
},
+ sorttype: function (c, o)
+ {
+ return o.Size;
+ },
width: 60,
align: "right"
},
@@ -710,26 +711,20 @@ var XGBase = Class.create(
obj = JSON.parse(obj.Object);
return self.helper.speed2Human(obj.BotSpeed);
},
- width: 80,
- align: "right"
- },
- {
- name: 'IrcLink',
- index: 'IrcLink',
- formatter: function (cell, grid, obj)
+ sorttype: function (c, o)
{
- obj = JSON.parse(obj.Object);
- return obj.IrcLink;
+ return o.BotSpeed;
},
- hidden: true
+ width: 80,
+ align: "right"
}
],
onSortCol: function(index, iCol, sortorder)
{
- self.cookie.setCookie('searches_xg_bitpir_at.sort.index', index);
- self.cookie.setCookie('searches_xg_bitpir_at.sort.sortorder', sortorder);
+ self.cookie.setCookie('packets_external.sort.index', index);
+ self.cookie.setCookie('packets_external.sort.sortorder', sortorder);
},
- pager:$('#searches_pager_xg_bitpir_at'),
+ pager:$('#packets_external_pager'),
pgbuttons: false,
pginput: false,
ExpandColumn: 'Name',
@@ -738,8 +733,8 @@ var XGBase = Class.create(
scrollrows: true,
hidegrid: false,
rowNum: 999999999,
- sortname: self.cookie.getCookie('searches_xg_bitpir_at.sort.index', 'Id'),
- sortorder: self.cookie.getCookie('searches_xg_bitpir_at.sort.sortorder', 'asc'),
+ sortname: self.cookie.getCookie('packets_external.sort.index', 'Id'),
+ sortorder: self.cookie.getCookie('packets_external.sort.sortorder', 'asc'),
caption: _("Search via xg.bitpir.at")
});
@@ -1034,7 +1029,7 @@ var XGBase = Class.create(
$("#" + guid).effect("transfer", { to: $("#00000000-0000-0000-0000-000000000004") }, 500);
- var data = self.websocket.getRowData("searches_xg_bitpir_at", guid);
+ var data = self.websocket.getRowData("packets_external", guid);
self.websocket.sendName(Enum.Request.ParseXdccLink, data.IrcLink);
}
});
@@ -94,11 +94,11 @@ var XGResize = Class.create(
{
subSize += 1;
}
- $("#searches_xg_bitpir_at, #files_table")
+ $("#packets_external, #files_table")
.setGridWidth(objectLayout.width() - 1)
.setGridHeight(objectLayout.height() - subSize);
- $($("#searches_xg_bitpir_at .jqgfirstrow td")[3]).width("");
- $("#searches_xg_bitpir_at_Name").width("");
+ $($("#packets_external .jqgfirstrow td")[3]).width("");
+ $("#packets_external_Name").width("");
$($("#files_table .jqgfirstrow td")[2]).width("");
$("#files_table_Name").width("");
Oops, something went wrong.

0 comments on commit 6158e66

Please sign in to comment.