mirror of
https://github.com/donaldzou/WGDashboard.git
synced 2025-07-15 17:46:59 +00:00
Refactor some code
This commit is contained in:
parent
cc3773817b
commit
edbb5cef92
@ -19,6 +19,7 @@ from modules.Email import EmailSender
|
|||||||
from modules.Log import Log
|
from modules.Log import Log
|
||||||
from modules.DashboardLogger import DashboardLogger
|
from modules.DashboardLogger import DashboardLogger
|
||||||
from modules.PeerJobLogger import PeerJobLogger
|
from modules.PeerJobLogger import PeerJobLogger
|
||||||
|
from modules.PeerJob import PeerJob
|
||||||
|
|
||||||
DASHBOARD_VERSION = 'v4.2.0'
|
DASHBOARD_VERSION = 'v4.2.0'
|
||||||
|
|
||||||
@ -55,43 +56,12 @@ def ResponseObject(status=True, message=None, data=None) -> Flask.response_class
|
|||||||
response.content_type = "application/json"
|
response.content_type = "application/json"
|
||||||
return response
|
return response
|
||||||
|
|
||||||
"""
|
|
||||||
Peer Job
|
|
||||||
"""
|
|
||||||
class PeerJob:
|
|
||||||
def __init__(self, JobID: str, Configuration: str, Peer: str,
|
|
||||||
Field: str, Operator: str, Value: str, CreationDate: datetime, ExpireDate: datetime, Action: str):
|
|
||||||
self.Action = Action
|
|
||||||
self.ExpireDate = ExpireDate
|
|
||||||
self.CreationDate = CreationDate
|
|
||||||
self.Value = Value
|
|
||||||
self.Operator = Operator
|
|
||||||
self.Field = Field
|
|
||||||
self.Configuration = Configuration
|
|
||||||
self.Peer = Peer
|
|
||||||
self.JobID = JobID
|
|
||||||
|
|
||||||
def toJson(self):
|
|
||||||
return {
|
|
||||||
"JobID": self.JobID,
|
|
||||||
"Configuration": self.Configuration,
|
|
||||||
"Peer": self.Peer,
|
|
||||||
"Field": self.Field,
|
|
||||||
"Operator": self.Operator,
|
|
||||||
"Value": self.Value,
|
|
||||||
"CreationDate": self.CreationDate,
|
|
||||||
"ExpireDate": self.ExpireDate,
|
|
||||||
"Action": self.Action
|
|
||||||
}
|
|
||||||
|
|
||||||
def __dict__(self):
|
|
||||||
return self.toJson()
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Peer Jobs
|
Peer Jobs
|
||||||
"""
|
"""
|
||||||
class PeerJobs:
|
class PeerJobs:
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.Jobs: list[PeerJob] = []
|
self.Jobs: list[PeerJob] = []
|
||||||
self.jobdb = sqlite3.connect(os.path.join(CONFIGURATION_PATH, 'db', 'wgdashboard_job.db'),
|
self.jobdb = sqlite3.connect(os.path.join(CONFIGURATION_PATH, 'db', 'wgdashboard_job.db'),
|
||||||
|
32
src/modules/PeerJob.py
Normal file
32
src/modules/PeerJob.py
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
"""
|
||||||
|
Peer Job
|
||||||
|
"""
|
||||||
|
from datetime import datetime
|
||||||
|
class PeerJob:
|
||||||
|
def __init__(self, JobID: str, Configuration: str, Peer: str,
|
||||||
|
Field: str, Operator: str, Value: str, CreationDate: datetime, ExpireDate: datetime, Action: str):
|
||||||
|
self.Action = Action
|
||||||
|
self.ExpireDate = ExpireDate
|
||||||
|
self.CreationDate = CreationDate
|
||||||
|
self.Value = Value
|
||||||
|
self.Operator = Operator
|
||||||
|
self.Field = Field
|
||||||
|
self.Configuration = Configuration
|
||||||
|
self.Peer = Peer
|
||||||
|
self.JobID = JobID
|
||||||
|
|
||||||
|
def toJson(self):
|
||||||
|
return {
|
||||||
|
"JobID": self.JobID,
|
||||||
|
"Configuration": self.Configuration,
|
||||||
|
"Peer": self.Peer,
|
||||||
|
"Field": self.Field,
|
||||||
|
"Operator": self.Operator,
|
||||||
|
"Value": self.Value,
|
||||||
|
"CreationDate": self.CreationDate,
|
||||||
|
"ExpireDate": self.ExpireDate,
|
||||||
|
"Action": self.Action
|
||||||
|
}
|
||||||
|
|
||||||
|
def __dict__(self):
|
||||||
|
return self.toJson()
|
Loading…
x
Reference in New Issue
Block a user