Skip to content

Commit

Permalink
fixed non-ascending default sort order
Browse files Browse the repository at this point in the history
  • Loading branch information
Henri Wahl committed Mar 13, 2014
1 parent e3cc77d commit 81c9829
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 11 deletions.
9 changes: 1 addition & 8 deletions Nagstamon/Nagstamon/GUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,14 +229,6 @@ def __init__(self, **kwds):
self.last_worst_status = "UP"

# defining sorting defaults in first render
HOST_COLUMN_ID = 0
SERVICE_COLUMN_ID = 1
STATUS_COLUMN_ID = 2
LAST_CHECK_COLUMN_ID = 3
DURATION_COLUMN_ID = 4
ATTEMPT_COLUMN_ID = 5
STATUS_INFO_COLUMN_ID = 6

self.COLUMNS_IDS_MAP = {"Host": 0,\
"Service": 1,\
"Status": 2,\
Expand All @@ -248,6 +240,7 @@ def __init__(self, **kwds):
# reverse mapping of column names and IDs for settings dialog
self.IDS_COLUMNS_MAP = dict((id, column) for column, id in self.COLUMNS_IDS_MAP.iteritems())

# use configured default sorting order
if str(self.conf.default_sort_order) == "Ascending":
self.startup_sort_order = gtk.SORT_ASCENDING
else:
Expand Down
2 changes: 1 addition & 1 deletion Nagstamon/Nagstamon/Objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def sort_function(cls, model, iter1, iter2, column):

class StatusColumn(CustomSortingColumn):
ATTR_NAME = 'status'
CHOICES = ['DOWN', 'UNREACHABLE', 'CRITICAL', 'UNKNOWN', 'WARNING']
CHOICES = ['WARNING', 'UNKNOWN', 'CRITICAL', 'UNREACHABLE', 'DOWN']


class HostColumn(Column):
Expand Down
1 change: 1 addition & 0 deletions Nagstamon/Nagstamon/Server/Icinga.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from Nagstamon.Server.Generic import GenericServer
import urllib
import sys
import copy
# this seems to be necessary for json to be packaged by pyinstaller
from encodings import hex_codec
import json
Expand Down
8 changes: 6 additions & 2 deletions Nagstamon/Nagstamon/Server/Multisite.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,17 @@ class LastCheckColumnMultisite(Column):
@classmethod
def sort_function(cls, model, iter1, iter2, column):
""" Overrides default sorting behaviour """

data1, data2 = [model.get_value(x, column) for x in (iter1, iter2)]

try:
first = Actions.MachineSortableDateMultisite(data1)
second = Actions.MachineSortableDateMultisite(data2)
except ValueError, err:
print err
return cmp(first, second)
return first - second
# other order than default function
return second - first


class DurationColumnMultisite(CustomSortingColumn):
Expand All @@ -79,7 +82,8 @@ def sort_function(cls, model, iter1, iter2, column):
except ValueError, err:
print err
return cmp(first, second)
return first - second
# other order than default function
return second - first


class MultisiteServer(GenericServer):
Expand Down

0 comments on commit 81c9829

Please sign in to comment.