This commit is contained in:
wh1te909
2020-09-11 02:38:16 +00:00
parent 0af30aa92a
commit 62da21609b
83 changed files with 769 additions and 379 deletions

View File

@@ -119,6 +119,8 @@ class Migration(migrations.Migration):
"verbose_name_plural": "users",
"abstract": False,
},
managers=[("objects", django.contrib.auth.models.UserManager()),],
managers=[
("objects", django.contrib.auth.models.UserManager()),
],
),
]

View File

@@ -6,13 +6,15 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('accounts', '0001_initial'),
("accounts", "0001_initial"),
]
operations = [
migrations.AlterField(
model_name='user',
name='first_name',
field=models.CharField(blank=True, max_length=150, verbose_name='first name'),
model_name="user",
name="first_name",
field=models.CharField(
blank=True, max_length=150, verbose_name="first name"
),
),
]

View File

@@ -9,7 +9,6 @@ from .models import User
class UserSerializer(ModelSerializer):
class Meta:
model = User
fields = (
@@ -22,6 +21,7 @@ class UserSerializer(ModelSerializer):
"last_login",
)
class TOTPSetupSerializer(ModelSerializer):
qr_url = SerializerMethodField()
@@ -35,4 +35,6 @@ class TOTPSetupSerializer(ModelSerializer):
)
def get_qr_url(self, obj):
return pyotp.totp.TOTP(obj.totp_key).provisioning_uri(obj.username, issuer_name="Tactical RMM")
return pyotp.totp.TOTP(obj.totp_key).provisioning_uri(
obj.username, issuer_name="Tactical RMM"
)

View File

@@ -148,4 +148,3 @@ class TOTPSetup(APIView):
return Response(TOTPSetupSerializer(user).data)
return Response("TOTP token already set")

View File

@@ -10,7 +10,10 @@ class Migration(migrations.Migration):
]
operations = [
migrations.RemoveField(model_name="agent", name="checks_last_generated",),
migrations.RemoveField(
model_name="agent",
name="checks_last_generated",
),
migrations.AddField(
model_name="agent",
name="policies_pending",

View File

@@ -10,6 +10,12 @@ class Migration(migrations.Migration):
]
operations = [
migrations.RemoveField(model_name="agent", name="uninstall_inprogress",),
migrations.RemoveField(model_name="agent", name="uninstall_pending",),
migrations.RemoveField(
model_name="agent",
name="uninstall_inprogress",
),
migrations.RemoveField(
model_name="agent",
name="uninstall_pending",
),
]

View File

@@ -10,5 +10,8 @@ class Migration(migrations.Migration):
]
operations = [
migrations.RemoveField(model_name="agent", name="policies_pending",),
migrations.RemoveField(
model_name="agent",
name="policies_pending",
),
]

View File

@@ -11,6 +11,8 @@ class Migration(migrations.Migration):
operations = [
migrations.RenameField(
model_name="agent", old_name="is_updating", new_name="update_pending",
model_name="agent",
old_name="is_updating",
new_name="update_pending",
),
]

View File

@@ -6,13 +6,13 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('agents', '0008_auto_20200702_2221'),
("agents", "0008_auto_20200702_2221"),
]
operations = [
migrations.AddField(
model_name='agent',
name='salt_id',
model_name="agent",
name="salt_id",
field=models.CharField(blank=True, max_length=255, null=True),
),
]

View File

@@ -6,18 +6,18 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('agents', '0009_agent_salt_id'),
("agents", "0009_agent_salt_id"),
]
operations = [
migrations.AddField(
model_name='agent',
name='salt_update_pending',
model_name="agent",
name="salt_update_pending",
field=models.BooleanField(default=False),
),
migrations.AddField(
model_name='agent',
name='salt_ver',
field=models.CharField(default='1.0.3', max_length=255),
model_name="agent",
name="salt_ver",
field=models.CharField(default="1.0.3", max_length=255),
),
]

View File

@@ -7,18 +7,44 @@ import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('agents', '0010_auto_20200809_0133'),
("agents", "0010_auto_20200809_0133"),
]
operations = [
migrations.CreateModel(
name='RecoveryAction',
name="RecoveryAction",
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('mode', models.CharField(choices=[('salt', 'Salt'), ('mesh', 'Mesh'), ('command', 'Command')], default='mesh', max_length=50)),
('command', models.TextField(blank=True, null=True)),
('last_run', models.DateTimeField(blank=True, null=True)),
('agent', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='recoveryactions', to='agents.Agent')),
(
"id",
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
(
"mode",
models.CharField(
choices=[
("salt", "Salt"),
("mesh", "Mesh"),
("command", "Command"),
],
default="mesh",
max_length=50,
),
),
("command", models.TextField(blank=True, null=True)),
("last_run", models.DateTimeField(blank=True, null=True)),
(
"agent",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="recoveryactions",
to="agents.Agent",
),
),
],
),
]

View File

@@ -6,23 +6,23 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('agents', '0011_recoveryaction'),
("agents", "0011_recoveryaction"),
]
operations = [
migrations.AlterField(
model_name='agent',
name='disks',
model_name="agent",
name="disks",
field=models.JSONField(null=True),
),
migrations.AlterField(
model_name='agent',
name='services',
model_name="agent",
name="services",
field=models.JSONField(null=True),
),
migrations.AlterField(
model_name='agent',
name='wmi_detail',
model_name="agent",
name="wmi_detail",
field=models.JSONField(null=True),
),
]

View File

@@ -6,13 +6,13 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('agents', '0012_auto_20200810_0544'),
("agents", "0012_auto_20200810_0544"),
]
operations = [
migrations.AddField(
model_name='agent',
name='patches_last_installed',
model_name="agent",
name="patches_last_installed",
field=models.DateTimeField(blank=True, null=True),
),
]

View File

@@ -6,12 +6,12 @@ from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('agents', '0013_agent_patches_last_installed'),
("agents", "0013_agent_patches_last_installed"),
]
operations = [
migrations.RemoveField(
model_name='agent',
name='managed_by_wsus',
model_name="agent",
name="managed_by_wsus",
),
]

View File

@@ -272,7 +272,8 @@ class Agent(models.Model):
# if patch policy still doesn't exist check default policy
elif (
core_settings.server_policy and core_settings.server_policy.winupdatepolicy
core_settings.server_policy
and core_settings.server_policy.winupdatepolicy
):
patch_policy = core_settings.server_policy.winupdatepolicy.get()
@@ -293,7 +294,8 @@ class Agent(models.Model):
# if patch policy still doesn't exist check default policy
elif (
core_settings.workstation_policy and core_settings.workstation_policy.winupdatepolicy
core_settings.workstation_policy
and core_settings.workstation_policy.winupdatepolicy
):
patch_policy = core_settings.workstation_policy.winupdatepolicy.get()
@@ -598,12 +600,15 @@ class Agent(models.Model):
enable_or_disable_win_task,
delete_win_task_schedule,
)
task_id = action.details.task_id
if action.details.action == "taskcreate":
create_win_task_schedule.delay(task_id, pending_action=action.id)
elif action.details.action == "tasktoggle":
enable_or_disable_win_task.delay(task_id, action.details.value, pending_action=action.id)
enable_or_disable_win_task.delay(
task_id, action.details.value, pending_action=action.id
)
elif action.details.action == "taskdelete":
delete_win_task_schedule.delay(task_id, pending_action=action.id)

View File

@@ -64,6 +64,7 @@ class AgentTableSerializer(serializers.ModelSerializer):
"logged_in_username",
]
class AgentEditSerializer(serializers.ModelSerializer):
winupdatepolicy = WinUpdatePolicySerializer(many=True, read_only=True)
all_timezones = serializers.SerializerMethodField()
@@ -90,6 +91,7 @@ class AgentEditSerializer(serializers.ModelSerializer):
"winupdatepolicy",
]
class WinAgentSerializer(serializers.ModelSerializer):
# for the windows agent
patches_pending = serializers.ReadOnlyField(source="has_patches_pending")

View File

@@ -28,7 +28,12 @@ from accounts.models import User
from core.models import CoreSettings
from scripts.models import Script
from .serializers import AgentSerializer, AgentHostnameSerializer, AgentTableSerializer, AgentEditSerializer
from .serializers import (
AgentSerializer,
AgentHostnameSerializer,
AgentTableSerializer,
AgentEditSerializer,
)
from winupdate.serializers import WinUpdatePolicySerializer
from .tasks import uninstall_agent_task, send_agent_update_task
@@ -181,7 +186,9 @@ def kill_proc(request, pk, pid):
def get_event_log(request, pk, logtype, days):
agent = get_object_or_404(Agent, pk=pk)
r = agent.salt_api_cmd(
timeout=30, func="win_agent.get_eventlog", arg=[logtype, int(days)],
timeout=30,
func="win_agent.get_eventlog",
arg=[logtype, int(days)],
)
if r == "timeout" or r == "error":
@@ -198,7 +205,10 @@ def power_action(request):
if action == "rebootnow":
logger.info(f"{agent.hostname} was scheduled for immediate reboot")
r = agent.salt_api_cmd(
timeout=30, func="system.reboot", arg=3, kwargs={"in_seconds": True},
timeout=30,
func="system.reboot",
arg=3,
kwargs={"in_seconds": True},
)
if r == "timeout" or r == "error" or (isinstance(r, bool) and not r):
return notify_error("Unable to contact the agent")
@@ -240,11 +250,13 @@ def list_agents_no_detail(request):
agents = Agent.objects.all()
return Response(AgentHostnameSerializer(agents, many=True).data)
@api_view()
def agent_edit_details(request, pk):
agent = get_object_or_404(Agent, pk=pk)
return Response(AgentEditSerializer(agent).data)
@api_view()
def by_client(request, client):
agents = Agent.objects.filter(client=client)
@@ -529,4 +541,3 @@ def run_script(request):
return Response(f"{script.name} will now be run on {agent.hostname}")
else:
return notify_error("Something went wrong")

View File

@@ -2,4 +2,4 @@ from django.apps import AppConfig
class AlertsConfig(AppConfig):
name = 'alerts'
name = "alerts"

View File

@@ -9,20 +9,37 @@ class Migration(migrations.Migration):
initial = True
dependencies = [
('agents', '0012_auto_20200810_0544'),
("agents", "0012_auto_20200810_0544"),
]
operations = [
migrations.CreateModel(
name='Alert',
name="Alert",
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('subject', models.TextField(blank=True, null=True)),
('message', models.TextField(blank=True, null=True)),
('alert_time', models.DateTimeField(blank=True, null=True)),
('snooze_until', models.DateTimeField(blank=True, null=True)),
('resolved', models.BooleanField(default=False)),
('agent', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='agent', to='agents.agent')),
(
"id",
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("subject", models.TextField(blank=True, null=True)),
("message", models.TextField(blank=True, null=True)),
("alert_time", models.DateTimeField(blank=True, null=True)),
("snooze_until", models.DateTimeField(blank=True, null=True)),
("resolved", models.BooleanField(default=False)),
(
"agent",
models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.CASCADE,
related_name="agent",
to="agents.agent",
),
),
],
),
]

View File

@@ -6,17 +6,25 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('alerts', '0001_initial'),
("alerts", "0001_initial"),
]
operations = [
migrations.RemoveField(
model_name='alert',
name='subject',
model_name="alert",
name="subject",
),
migrations.AddField(
model_name='alert',
name='severity',
field=models.CharField(choices=[('info', 'Informational'), ('warning', 'Warning'), ('error', 'Error')], default='info', max_length=100),
model_name="alert",
name="severity",
field=models.CharField(
choices=[
("info", "Informational"),
("warning", "Warning"),
("error", "Error"),
],
default="info",
max_length=100,
),
),
]

View File

@@ -7,6 +7,7 @@ SEVERITY_CHOICES = [
("error", "Error"),
]
class Alert(models.Model):
agent = models.ForeignKey(
"agents.Agent",

View File

@@ -9,6 +9,7 @@ from .models import Alert
from .serializers import AlertSerializer
class GetAddAlerts(APIView):
def get(self, request):
alerts = Alert.objects.all()

View File

@@ -10,8 +10,20 @@ class Migration(migrations.Migration):
]
operations = [
migrations.RemoveField(model_name="policy", name="agents",),
migrations.RemoveField(model_name="policy", name="clients",),
migrations.RemoveField(model_name="policy", name="sites",),
migrations.RemoveField(model_name="policyexclusions", name="clients",),
migrations.RemoveField(
model_name="policy",
name="agents",
),
migrations.RemoveField(
model_name="policy",
name="clients",
),
migrations.RemoveField(
model_name="policy",
name="sites",
),
migrations.RemoveField(
model_name="policyexclusions",
name="clients",
),
]

View File

@@ -18,7 +18,6 @@ class Policy(models.Model):
def is_default_workstation_policy(self):
return self.default_workstation_policy.exists()
def __str__(self):
return self.name

View File

@@ -20,7 +20,9 @@ def generate_agent_checks_from_policies_task(
clear=clear, parent_checks=parent_checks
)
if create_tasks:
agent.generate_tasks_from_policies(clear=clear,)
agent.generate_tasks_from_policies(
clear=clear,
)
else:
policy = Policy.objects.get(pk=policypk)
for agent in policy.related_agents():
@@ -28,7 +30,9 @@ def generate_agent_checks_from_policies_task(
clear=clear, parent_checks=parent_checks
)
if create_tasks:
agent.generate_tasks_from_policies(clear=clear,)
agent.generate_tasks_from_policies(
clear=clear,
)
@app.task
@@ -42,6 +46,7 @@ def generate_agent_checks_by_location_task(
if create_tasks:
agent.generate_tasks_from_policies(clear=clear)
@app.task
def generate_all_agent_checks_task(mon_type, clear=False, create_tasks=False):
for agent in Agent.objects.filter(monitoring_type=mon_type):
@@ -50,6 +55,7 @@ def generate_all_agent_checks_task(mon_type, clear=False, create_tasks=False):
if create_tasks:
agent.generate_tasks_from_policies(clear=clear)
@app.task
def delete_policy_check_task(checkpk):

View File

@@ -178,7 +178,9 @@ class TestPolicyViews(BaseTestCase):
@patch("agents.models.Agent.generate_checks_from_policies")
@patch("automation.tasks.generate_agent_checks_by_location_task.delay")
def test_update_policy_add(
self, mock_checks_location_task, mock_checks_task,
self,
mock_checks_location_task,
mock_checks_task,
):
url = f"/automation/related/"
@@ -473,7 +475,9 @@ class TestPolicyTasks(BaseTestCase):
)
policy = Policy.objects.create(
name="Policy Relate Tests", desc="my awesome policy", active=True,
name="Policy Relate Tests",
desc="my awesome policy",
active=True,
)
# Add Client to Policy

View File

@@ -426,6 +426,7 @@ class GetRelated(APIView):
content = {"error": "Data was submitted incorrectly"}
return Response(content, status=status.HTTP_400_BAD_REQUEST)
class UpdatePatchPolicy(APIView):
# create new patch policy
@@ -443,7 +444,9 @@ class UpdatePatchPolicy(APIView):
def put(self, request, patchpolicy):
policy = get_object_or_404(WinUpdatePolicy, pk=patchpolicy)
serializer = WinUpdatePolicySerializer(instance=policy, data=request.data, partial=True)
serializer = WinUpdatePolicySerializer(
instance=policy, data=request.data, partial=True
)
serializer.is_valid(raise_exception=True)
serializer.save()
@@ -453,7 +456,9 @@ class UpdatePatchPolicy(APIView):
agents = None
if "client" in request.data and "site" in request.data:
agents = Agent.objects.filter(client=request.data["client"], site=request.data["site"])
agents = Agent.objects.filter(
client=request.data["client"], site=request.data["site"]
)
elif "client" in request.data:
agents = Agent.objects.filter(client=request.data["client"])
else:
@@ -473,7 +478,6 @@ class UpdatePatchPolicy(APIView):
return Response("ok")
# delete patch policy
def delete(self, request, patchpolicy):
get_object_or_404(WinUpdatePolicy, pk=patchpolicy).delete()

View File

@@ -7,13 +7,19 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('autotasks', '0002_auto_20200701_1615'),
("autotasks", "0002_auto_20200701_1615"),
]
operations = [
migrations.AddField(
model_name='automatedtask',
name='script_args',
field=django.contrib.postgres.fields.ArrayField(base_field=models.CharField(blank=True, max_length=255, null=True), blank=True, default=list, null=True, size=None),
model_name="automatedtask",
name="script_args",
field=django.contrib.postgres.fields.ArrayField(
base_field=models.CharField(blank=True, max_length=255, null=True),
blank=True,
default=list,
null=True,
size=None,
),
),
]

View File

@@ -6,13 +6,21 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('autotasks', '0003_automatedtask_script_args'),
("autotasks", "0003_automatedtask_script_args"),
]
operations = [
migrations.AddField(
model_name='automatedtask',
name='sync_status',
field=models.CharField(choices=[('synced', 'Synced With Agent'), ('notsynced', 'Waiting On Agent Checkin'), ('pendingdeletion', 'Pending Deletion on Agent')], default='notsynced', max_length=100),
model_name="automatedtask",
name="sync_status",
field=models.CharField(
choices=[
("synced", "Synced With Agent"),
("notsynced", "Waiting On Agent Checkin"),
("pendingdeletion", "Pending Deletion on Agent"),
],
default="notsynced",
max_length=100,
),
),
]

View File

@@ -6,13 +6,21 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('autotasks', '0004_automatedtask_sync_status'),
("autotasks", "0004_automatedtask_sync_status"),
]
operations = [
migrations.AlterField(
model_name='automatedtask',
name='sync_status',
field=models.CharField(choices=[('synced', 'Synced With Agent'), ('notsynced', 'Waiting On Agent Checkin'), ('pendingdeletion', 'Pending Deletion on Agent')], default='synced', max_length=100),
model_name="automatedtask",
name="sync_status",
field=models.CharField(
choices=[
("synced", "Synced With Agent"),
("notsynced", "Waiting On Agent Checkin"),
("pendingdeletion", "Pending Deletion on Agent"),
],
default="synced",
max_length=100,
),
),
]

View File

@@ -88,7 +88,9 @@ class AutomatedTask(models.Model):
execution_time = models.CharField(max_length=100, default="0.0000")
last_run = models.DateTimeField(null=True, blank=True)
enabled = models.BooleanField(default=True)
sync_status = models.CharField(max_length=100, choices=SYNC_STATUS_CHOICES, default="synced")
sync_status = models.CharField(
max_length=100, choices=SYNC_STATUS_CHOICES, default="synced"
)
def __str__(self):
return self.name

View File

@@ -63,7 +63,11 @@ def create_win_task_schedule(pk, pending_action=False):
if r == "timeout" or r == "error" or (isinstance(r, bool) and not r):
# don't create pending action if this task was initiated by a pending action
if not pending_action:
PendingAction(agent = task.agent, action_type="taskaction", details={"action": "createtask", "task_id": task.id}).save()
PendingAction(
agent=task.agent,
action_type="taskaction",
details={"action": "createtask", "task_id": task.id},
).save()
task.sync_status = "notsynced"
task.save(update_fields=["sync_status"])
@@ -78,7 +82,6 @@ def create_win_task_schedule(pk, pending_action=False):
pendingaction.status = "completed"
pendingaction.save(update_fields=["status"])
task.sync_status = "synced"
task.save(update_fields=["sync_status"])
@@ -92,13 +95,23 @@ def enable_or_disable_win_task(pk, action, pending_action=False):
task = AutomatedTask.objects.get(pk=pk)
r = task.agent.salt_api_cmd(
timeout=20, func="task.edit_task", arg=[f"name={task.win_task_name}", f"enabled={action}"]
timeout=20,
func="task.edit_task",
arg=[f"name={task.win_task_name}", f"enabled={action}"],
)
if r == "timeout" or r == "error" or (isinstance(r, bool) and not r):
# don't create pending action if this task was initiated by a pending action
if not pending_action:
PendingAction(agent = task.agent, action_type="taskaction", details={"action": "tasktoggle", "value":task.enabled, "task_id": task.id}).save()
PendingAction(
agent=task.agent,
action_type="taskaction",
details={
"action": "tasktoggle",
"value": task.enabled,
"task_id": task.id,
},
).save()
task.sync_status = "notsynced"
task.save(update_fields=["sync_status"])
@@ -124,13 +137,19 @@ def delete_win_task_schedule(pk, pending_action=False):
task = AutomatedTask.objects.get(pk=pk)
r = task.agent.salt_api_cmd(
timeout=20, func="task.delete_task", arg=[f"name={task.win_task_name}"],
timeout=20,
func="task.delete_task",
arg=[f"name={task.win_task_name}"],
)
if r == "timeout" or r == "error" or (isinstance(r, bool) and not r):
# don't create pending action if this task was initiated by a pending action
if not pending_action:
PendingAction(agent = task.agent, action_type="taskaction", details={"action": "taskdelete", "task_id": task.id}).save()
PendingAction(
agent=task.agent,
action_type="taskaction",
details={"action": "taskdelete", "task_id": task.id},
).save()
task.sync_status = "pendingdeletion"
task.save(update_fields=["sync_status"])

View File

@@ -6,18 +6,18 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('checks', '0004_check_parent_check'),
("checks", "0004_check_parent_check"),
]
operations = [
migrations.AlterField(
model_name='check',
name='extra_details',
model_name="check",
name="extra_details",
field=models.JSONField(blank=True, null=True),
),
migrations.AlterField(
model_name='check',
name='outage_history',
model_name="check",
name="outage_history",
field=models.JSONField(blank=True, null=True),
),
]

View File

@@ -6,13 +6,13 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('checks', '0005_auto_20200810_0544'),
("checks", "0005_auto_20200810_0544"),
]
operations = [
migrations.AddField(
model_name='check',
name='event_id_is_wildcard',
model_name="check",
name="event_id_is_wildcard",
field=models.BooleanField(default=False),
),
]

View File

@@ -7,13 +7,19 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('checks', '0006_check_event_id_is_wildcard'),
("checks", "0006_check_event_id_is_wildcard"),
]
operations = [
migrations.AddField(
model_name='check',
name='script_args',
field=django.contrib.postgres.fields.ArrayField(base_field=models.CharField(blank=True, max_length=255, null=True), blank=True, default=list, null=True, size=None),
model_name="check",
name="script_args",
field=django.contrib.postgres.fields.ArrayField(
base_field=models.CharField(blank=True, max_length=255, null=True),
blank=True,
default=list,
null=True,
size=None,
),
),
]

View File

@@ -112,4 +112,3 @@ class TestCheckViews(BaseTestCase):
self.assertEqual(resp.status_code, 200)
self.check_not_authenticated("patch", url_a)

View File

@@ -7,37 +7,61 @@ import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('automation', '0004_auto_20200617_0332'),
('clients', '0003_auto_20200609_1607'),
("automation", "0004_auto_20200617_0332"),
("clients", "0003_auto_20200609_1607"),
]
operations = [
migrations.RemoveField(
model_name='client',
name='policy',
model_name="client",
name="policy",
),
migrations.RemoveField(
model_name='site',
name='policy',
model_name="site",
name="policy",
),
migrations.AddField(
model_name='client',
name='server_policy',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='server_clients', to='automation.policy'),
model_name="client",
name="server_policy",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="server_clients",
to="automation.policy",
),
),
migrations.AddField(
model_name='client',
name='workstation_policy',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='workstation_clients', to='automation.policy'),
model_name="client",
name="workstation_policy",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="workstation_clients",
to="automation.policy",
),
),
migrations.AddField(
model_name='site',
name='server_policy',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='server_sites', to='automation.policy'),
model_name="site",
name="server_policy",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="server_sites",
to="automation.policy",
),
),
migrations.AddField(
model_name='site',
name='workstation_policy',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='workstation_sites', to='automation.policy'),
model_name="site",
name="workstation_policy",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="workstation_sites",
to="automation.policy",
),
),
]

View File

@@ -105,4 +105,3 @@ class Command(BaseCommand):
# load community scripts into the db
Script.load_community_scripts()

View File

@@ -10,7 +10,10 @@ class Migration(migrations.Migration):
]
operations = [
migrations.RemoveField(model_name="coresettings", name="smtp_use_tls",),
migrations.RemoveField(
model_name="coresettings",
name="smtp_use_tls",
),
migrations.AddField(
model_name="coresettings",
name="smtp_from_email",

View File

@@ -6,13 +6,15 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('core', '0005_auto_20200712_0454'),
("core", "0005_auto_20200712_0454"),
]
operations = [
migrations.AlterField(
model_name='coresettings',
name='smtp_host_user',
field=models.CharField(blank=True, default='admin@example.com', max_length=255, null=True),
model_name="coresettings",
name="smtp_host_user",
field=models.CharField(
blank=True, default="admin@example.com", max_length=255, null=True
),
),
]

View File

@@ -6,13 +6,13 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('core', '0006_auto_20200812_0223'),
("core", "0006_auto_20200812_0223"),
]
operations = [
migrations.AddField(
model_name='coresettings',
name='smtp_requires_auth',
model_name="coresettings",
name="smtp_requires_auth",
field=models.BooleanField(default=True),
),
]

View File

@@ -7,19 +7,31 @@ import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('automation', '0004_auto_20200617_0332'),
('core', '0007_coresettings_smtp_requires_auth'),
("automation", "0004_auto_20200617_0332"),
("core", "0007_coresettings_smtp_requires_auth"),
]
operations = [
migrations.AddField(
model_name='coresettings',
name='server_policy',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='default_server_policy', to='automation.policy'),
model_name="coresettings",
name="server_policy",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="default_server_policy",
to="automation.policy",
),
),
migrations.AddField(
model_name='coresettings',
name='workstation_policy',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='default_workstation_policy', to='automation.policy'),
model_name="coresettings",
name="workstation_policy",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="default_workstation_policy",
to="automation.policy",
),
),
]

View File

@@ -17,7 +17,10 @@ TZ_CHOICES = [(_, _) for _ in pytz.all_timezones]
class CoreSettings(models.Model):
email_alert_recipients = ArrayField(
models.EmailField(null=True, blank=True), null=True, blank=True, default=list,
models.EmailField(null=True, blank=True),
null=True,
blank=True,
default=list,
)
smtp_from_email = models.CharField(
max_length=255, null=True, blank=True, default="from@example.com"

View File

@@ -46,10 +46,14 @@ def edit_settings(request):
# check if default policies changed
if settings.server_policy != new_settings.server_policy:
generate_all_agent_checks_task.delay(mon_type="server", clear=True, create_tasks=True)
generate_all_agent_checks_task.delay(
mon_type="server", clear=True, create_tasks=True
)
if settings.workstation_policy != new_settings.workstation_policy:
generate_all_agent_checks_task.delay(mon_type="workstation", clear=True, create_tasks=True)
generate_all_agent_checks_task.delay(
mon_type="workstation", clear=True, create_tasks=True
)
return Response("ok")

View File

@@ -1,2 +1 @@
default_app_config = "logs.apps.LogsConfig"

View File

@@ -6,13 +6,13 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('logs', '0001_initial'),
("logs", "0001_initial"),
]
operations = [
migrations.AlterField(
model_name='pendingaction',
name='details',
model_name="pendingaction",
name="details",
field=models.JSONField(blank=True, null=True),
),
]

View File

@@ -6,13 +6,21 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('logs', '0002_auto_20200810_0544'),
("logs", "0002_auto_20200810_0544"),
]
operations = [
migrations.AlterField(
model_name='pendingaction',
name='action_type',
field=models.CharField(blank=True, choices=[('schedreboot', 'Scheduled Reboot'), ('taskaction', 'Scheduled Task Action')], max_length=255, null=True),
model_name="pendingaction",
name="action_type",
field=models.CharField(
blank=True,
choices=[
("schedreboot", "Scheduled Reboot"),
("taskaction", "Scheduled Task Action"),
],
max_length=255,
null=True,
),
),
]

View File

@@ -25,14 +25,18 @@ STATUS_CHOICES = [
class PendingAction(models.Model):
agent = models.ForeignKey(
Agent, related_name="pendingactions", on_delete=models.CASCADE,
Agent,
related_name="pendingactions",
on_delete=models.CASCADE,
)
entry_time = models.DateTimeField(auto_now_add=True)
action_type = models.CharField(
max_length=255, choices=ACTION_TYPE_CHOICES, null=True, blank=True
)
status = models.CharField(
max_length=255, choices=STATUS_CHOICES, default="pending",
max_length=255,
choices=STATUS_CHOICES,
default="pending",
)
celery_id = models.CharField(null=True, blank=True, max_length=255)
details = models.JSONField(null=True, blank=True)
@@ -58,4 +62,3 @@ class PendingAction(models.Model):
return "Device pending task creation"
elif self.details.action == "tasktoggle":
return f"Device pending task {self.details.value}"

View File

@@ -6,13 +6,17 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('scripts', '0001_initial'),
("scripts", "0001_initial"),
]
operations = [
migrations.AddField(
model_name='script',
name='script_type',
field=models.CharField(choices=[('userdefined', 'User Defined'), ('builtin', 'Built In')], default='userdefined', max_length=100),
model_name="script",
name="script_type",
field=models.CharField(
choices=[("userdefined", "User Defined"), ("builtin", "Built In")],
default="userdefined",
max_length=100,
),
),
]

View File

@@ -56,7 +56,9 @@ def service_action(request):
service_action = data["sv_action"]
agent = get_object_or_404(Agent, pk=pk)
r = agent.salt_api_cmd(
timeout=45, func=f"service.{service_action}", arg=service_name,
timeout=45,
func=f"service.{service_action}",
arg=service_name,
)
if r == "timeout":
@@ -97,7 +99,10 @@ def edit_service(request):
kwargs = {"start_type": edit_action}
r = agent.salt_api_cmd(
timeout=20, func="service.modify", arg=service_name, kwargs=kwargs,
timeout=20,
func="service.modify",
arg=service_name,
kwargs=kwargs,
)
if r == "timeout":

View File

@@ -6,18 +6,18 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('software', '0001_initial'),
("software", "0001_initial"),
]
operations = [
migrations.AlterField(
model_name='chocosoftware',
name='chocos',
model_name="chocosoftware",
name="chocos",
field=models.JSONField(),
),
migrations.AlterField(
model_name='installedsoftware',
name='software',
model_name="installedsoftware",
name="software",
field=models.JSONField(),
),
]

View File

@@ -113,7 +113,9 @@ def install_program(pk, name, version):
agent = Agent.objects.get(pk=pk)
r = agent.salt_api_cmd(
timeout=900, func="chocolatey.install", arg=[name, f"version={version}"],
timeout=900,
func="chocolatey.install",
arg=[name, f"version={version}"],
)
if r == "timeout" or r == "error":

View File

@@ -38,7 +38,9 @@ class BaseTestCase(TestCase):
Site.objects.create(client=facebook, site="NY Office")
self.policy = Policy.objects.create(
name="testpolicy", desc="my awesome policy", active=True,
name="testpolicy",
desc="my awesome policy",
active=True,
)
self.policy.server_clients.add(google)
self.policy.workstation_clients.add(facebook)

View File

@@ -6,13 +6,21 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('winupdate', '0001_initial'),
("winupdate", "0001_initial"),
]
operations = [
migrations.AlterField(
model_name='winupdatepolicy',
name='reboot_after_install',
field=models.CharField(choices=[('never', 'Never'), ('required', 'When Required'), ('always', 'Always')], default='never', max_length=50),
model_name="winupdatepolicy",
name="reboot_after_install",
field=models.CharField(
choices=[
("never", "Never"),
("required", "When Required"),
("always", "Always"),
],
default="never",
max_length=50,
),
),
]

View File

@@ -7,20 +7,32 @@ import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('automation', '0004_auto_20200617_0332'),
('agents', '0012_auto_20200810_0544'),
('winupdate', '0002_auto_20200715_0445'),
("automation", "0004_auto_20200617_0332"),
("agents", "0012_auto_20200810_0544"),
("winupdate", "0002_auto_20200715_0445"),
]
operations = [
migrations.AddField(
model_name='winupdatepolicy',
name='policy',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='winupdatepolicy', to='automation.policy'),
model_name="winupdatepolicy",
name="policy",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.CASCADE,
related_name="winupdatepolicy",
to="automation.policy",
),
),
migrations.AlterField(
model_name='winupdatepolicy',
name='agent',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='winupdatepolicy', to='agents.agent'),
model_name="winupdatepolicy",
name="agent",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.CASCADE,
related_name="winupdatepolicy",
to="agents.agent",
),
),
]

View File

@@ -6,33 +6,78 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('winupdate', '0003_auto_20200828_0134'),
("winupdate", "0003_auto_20200828_0134"),
]
operations = [
migrations.AlterField(
model_name='winupdatepolicy',
name='critical',
field=models.CharField(choices=[('manual', 'Manual'), ('approve', 'Approve'), ('ignore', 'Ignore'), ('inherit', 'Inherit')], default='manual', max_length=100),
model_name="winupdatepolicy",
name="critical",
field=models.CharField(
choices=[
("manual", "Manual"),
("approve", "Approve"),
("ignore", "Ignore"),
("inherit", "Inherit"),
],
default="manual",
max_length=100,
),
),
migrations.AlterField(
model_name='winupdatepolicy',
name='important',
field=models.CharField(choices=[('manual', 'Manual'), ('approve', 'Approve'), ('ignore', 'Ignore'), ('inherit', 'Inherit')], default='manual', max_length=100),
model_name="winupdatepolicy",
name="important",
field=models.CharField(
choices=[
("manual", "Manual"),
("approve", "Approve"),
("ignore", "Ignore"),
("inherit", "Inherit"),
],
default="manual",
max_length=100,
),
),
migrations.AlterField(
model_name='winupdatepolicy',
name='low',
field=models.CharField(choices=[('manual', 'Manual'), ('approve', 'Approve'), ('ignore', 'Ignore'), ('inherit', 'Inherit')], default='manual', max_length=100),
model_name="winupdatepolicy",
name="low",
field=models.CharField(
choices=[
("manual", "Manual"),
("approve", "Approve"),
("ignore", "Ignore"),
("inherit", "Inherit"),
],
default="manual",
max_length=100,
),
),
migrations.AlterField(
model_name='winupdatepolicy',
name='moderate',
field=models.CharField(choices=[('manual', 'Manual'), ('approve', 'Approve'), ('ignore', 'Ignore'), ('inherit', 'Inherit')], default='manual', max_length=100),
model_name="winupdatepolicy",
name="moderate",
field=models.CharField(
choices=[
("manual", "Manual"),
("approve", "Approve"),
("ignore", "Ignore"),
("inherit", "Inherit"),
],
default="manual",
max_length=100,
),
),
migrations.AlterField(
model_name='winupdatepolicy',
name='other',
field=models.CharField(choices=[('manual', 'Manual'), ('approve', 'Approve'), ('ignore', 'Ignore'), ('inherit', 'Inherit')], default='manual', max_length=100),
model_name="winupdatepolicy",
name="other",
field=models.CharField(
choices=[
("manual", "Manual"),
("approve", "Approve"),
("ignore", "Ignore"),
("inherit", "Inherit"),
],
default="manual",
max_length=100,
),
),
]

View File

@@ -6,33 +6,78 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('winupdate', '0004_auto_20200904_0103'),
("winupdate", "0004_auto_20200904_0103"),
]
operations = [
migrations.AlterField(
model_name='winupdatepolicy',
name='critical',
field=models.CharField(choices=[('manual', 'Manual'), ('approve', 'Approve'), ('ignore', 'Ignore'), ('inherit', 'Inherit')], default='inherit', max_length=100),
model_name="winupdatepolicy",
name="critical",
field=models.CharField(
choices=[
("manual", "Manual"),
("approve", "Approve"),
("ignore", "Ignore"),
("inherit", "Inherit"),
],
default="inherit",
max_length=100,
),
),
migrations.AlterField(
model_name='winupdatepolicy',
name='important',
field=models.CharField(choices=[('manual', 'Manual'), ('approve', 'Approve'), ('ignore', 'Ignore'), ('inherit', 'Inherit')], default='inherit', max_length=100),
model_name="winupdatepolicy",
name="important",
field=models.CharField(
choices=[
("manual", "Manual"),
("approve", "Approve"),
("ignore", "Ignore"),
("inherit", "Inherit"),
],
default="inherit",
max_length=100,
),
),
migrations.AlterField(
model_name='winupdatepolicy',
name='low',
field=models.CharField(choices=[('manual', 'Manual'), ('approve', 'Approve'), ('ignore', 'Ignore'), ('inherit', 'Inherit')], default='inherit', max_length=100),
model_name="winupdatepolicy",
name="low",
field=models.CharField(
choices=[
("manual", "Manual"),
("approve", "Approve"),
("ignore", "Ignore"),
("inherit", "Inherit"),
],
default="inherit",
max_length=100,
),
),
migrations.AlterField(
model_name='winupdatepolicy',
name='moderate',
field=models.CharField(choices=[('manual', 'Manual'), ('approve', 'Approve'), ('ignore', 'Ignore'), ('inherit', 'Inherit')], default='inherit', max_length=100),
model_name="winupdatepolicy",
name="moderate",
field=models.CharField(
choices=[
("manual", "Manual"),
("approve", "Approve"),
("ignore", "Ignore"),
("inherit", "Inherit"),
],
default="inherit",
max_length=100,
),
),
migrations.AlterField(
model_name='winupdatepolicy',
name='other',
field=models.CharField(choices=[('manual', 'Manual'), ('approve', 'Approve'), ('ignore', 'Ignore'), ('inherit', 'Inherit')], default='inherit', max_length=100),
model_name="winupdatepolicy",
name="other",
field=models.CharField(
choices=[
("manual", "Manual"),
("approve", "Approve"),
("ignore", "Ignore"),
("inherit", "Inherit"),
],
default="inherit",
max_length=100,
),
),
]

View File

@@ -6,23 +6,40 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('winupdate', '0005_auto_20200905_2114'),
("winupdate", "0005_auto_20200905_2114"),
]
operations = [
migrations.AddField(
model_name='winupdatepolicy',
name='reprocess_failed_inherit',
model_name="winupdatepolicy",
name="reprocess_failed_inherit",
field=models.BooleanField(default=True),
),
migrations.AddField(
model_name='winupdatepolicy',
name='run_time_frequency',
field=models.CharField(choices=[('daily', 'Daily/Weekly'), ('monthly', 'Monthly'), ('inherit', 'Inherit')], default='inherit', max_length=100),
model_name="winupdatepolicy",
name="run_time_frequency",
field=models.CharField(
choices=[
("daily", "Daily/Weekly"),
("monthly", "Monthly"),
("inherit", "Inherit"),
],
default="inherit",
max_length=100,
),
),
migrations.AlterField(
model_name='winupdatepolicy',
name='reboot_after_install',
field=models.CharField(choices=[('never', 'Never'), ('required', 'When Required'), ('always', 'Always'), ('inherit', 'Inherit')], default='inherit', max_length=50),
model_name="winupdatepolicy",
name="reboot_after_install",
field=models.CharField(
choices=[
("never", "Never"),
("required", "When Required"),
("always", "Always"),
("inherit", "Inherit"),
],
default="inherit",
max_length=50,
),
),
]

View File

@@ -6,13 +6,48 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('winupdate', '0006_auto_20200910_1909'),
("winupdate", "0006_auto_20200910_1909"),
]
operations = [
migrations.AddField(
model_name='winupdatepolicy',
name='run_time_day',
field=models.IntegerField(choices=[(0, '1'), (1, '1'), (2, '1'), (3, '1'), (4, '1'), (5, '1'), (6, '1'), (7, '1'), (8, '1'), (9, '1'), (10, '1'), (11, '1'), (12, '1'), (13, '1'), (14, '1'), (15, '1'), (16, '1'), (17, '1'), (18, '1'), (19, '1'), (20, '1'), (21, '1'), (22, '1'), (23, '1'), (24, '1'), (25, '1'), (26, '1'), (27, '1'), (28, '1'), (29, '1'), (30, '1')], default=1),
model_name="winupdatepolicy",
name="run_time_day",
field=models.IntegerField(
choices=[
(0, "1"),
(1, "1"),
(2, "1"),
(3, "1"),
(4, "1"),
(5, "1"),
(6, "1"),
(7, "1"),
(8, "1"),
(9, "1"),
(10, "1"),
(11, "1"),
(12, "1"),
(13, "1"),
(14, "1"),
(15, "1"),
(16, "1"),
(17, "1"),
(18, "1"),
(19, "1"),
(20, "1"),
(21, "1"),
(22, "1"),
(23, "1"),
(24, "1"),
(25, "1"),
(26, "1"),
(27, "1"),
(28, "1"),
(29, "1"),
(30, "1"),
],
default=1,
),
),
]

View File

@@ -95,7 +95,9 @@ class WinUpdatePolicy(models.Model):
run_time_hour = models.IntegerField(choices=RUN_TIME_HOUR_CHOICES, default=3)
run_time_frequency = models.CharField(max_length=100, choices=SCHEDULE_FREQUENCY_CHOICES, default="inherit")
run_time_frequency = models.CharField(
max_length=100, choices=SCHEDULE_FREQUENCY_CHOICES, default="inherit"
)
# 0 to 6 = Monday to Sunday
run_time_days = ArrayField(

View File

@@ -64,10 +64,9 @@ def check_agent_update_schedule_task():
last_installed = agent.patches_last_installed.astimezone(timezone)
# check if patches were already run for this cycle and exit if so
if (
last_installed
and last_installed.strftime("%d/%m/%Y") == agent_localtime_now.strftime("%d/%m/%Y")
):
if last_installed and last_installed.strftime(
"%d/%m/%Y"
) == agent_localtime_now.strftime("%d/%m/%Y"):
return
# check if schedule is set to daily/weekly

View File

@@ -8,7 +8,11 @@
<q-item-section>
<q-item-label overline>{{ alert.client }} - {{ alert.site }} - {{ alert.hostname }}</q-item-label>
<q-item-label>
<q-icon size="xs" :class="`text-${alertColor(alert.severity)}`" :name="alert.severity"></q-icon>
<q-icon
size="xs"
:class="`text-${alertColor(alert.severity)}`"
:name="alert.severity"
></q-icon>
{{ alert.message }}
</q-item-label>
</q-item-section>
@@ -17,14 +21,10 @@
<q-item-label caption>{{ alertTime(alert.alert_time) }}</q-item-label>
<q-item-label>
<q-icon name="snooze" size="xs">
<q-tooltip>
Snooze the alert for 24 hours
</q-tooltip>
<q-tooltip>Snooze the alert for 24 hours</q-tooltip>
</q-icon>
<q-icon name="alarm_off" size="xs">
<q-tooltip>
Dismiss alert
</q-tooltip>
<q-tooltip>Dismiss alert</q-tooltip>
</q-icon>
</q-item-label>
</q-item-section>
@@ -46,7 +46,7 @@
<script>
import { mapGetters } from "vuex";
import mixins from "@/mixins/mixins"
import mixins from "@/mixins/mixins";
import AlertsOverview from "@/components/modals/alerts/AlertsOverview";
export default {
@@ -60,10 +60,8 @@ export default {
},
methods: {
getAlerts() {
this.$store
.dispatch("alerts/getAlerts")
.catch(error => {
console.error(error)
this.$store.dispatch("alerts/getAlerts").catch(error => {
console.error(error);
});
},
alertColor(type) {
@@ -80,16 +78,16 @@ export default {
} else {
return this.alerts.length;
}
}
},
},
computed: {
...mapGetters({
newAlerts: "alerts/getNewAlerts",
alerts: "alerts/getAlerts"
})
alerts: "alerts/getAlerts",
}),
},
mounted() {
this.getAlerts()
}
this.getAlerts();
},
};
</script>

View File

@@ -81,7 +81,7 @@ export default {
components: { WmiDetail },
data() {
return {
tab: "os"
tab: "os",
};
},
computed: {
@@ -124,8 +124,8 @@ export default {
},
network_adapter() {
return this.assets.network_adapter;
}
}
},
},
};
</script>

View File

@@ -71,7 +71,7 @@ export default {
pagination: {
rowsPerPage: 99999,
sortBy: "cpu_percent",
descending: true
descending: true,
},
columns: [
{
@@ -79,44 +79,44 @@ export default {
label: "Name",
field: "name",
align: "left",
sortable: true
sortable: true,
},
{
name: "cpu_percent",
label: "CPU",
field: "cpu_percent",
align: "left",
sortable: true
sortable: true,
},
{
name: "memory_percent",
label: "Memory",
field: "memory_percent",
align: "left",
sortable: true
sortable: true,
},
{
name: "username",
label: "User",
field: "username",
align: "left",
sortable: true
sortable: true,
},
{
name: "pid",
label: "PID",
field: "pid",
align: "left",
sortable: true
sortable: true,
},
{
name: "status",
label: "Status",
field: "status",
align: "left",
sortable: true
}
]
sortable: true,
},
],
};
},
methods: {
@@ -170,7 +170,7 @@ export default {
convert(percent) {
const mb = this.mem * 1024;
return Math.ceil((percent * mb) / 100).toLocaleString();
}
},
},
beforeDestroy() {
clearInterval(this.polling);
@@ -184,6 +184,6 @@ export default {
},
mounted() {
this.refreshProcs();
}
},
};
</script>

View File

@@ -57,13 +57,13 @@ export default {
AutomatedTasksTab,
WindowsUpdates,
SoftwareTab,
AssetsTab
AssetsTab,
},
data() {
return {
subtab: "summary"
subtab: "summary",
};
}
},
};
</script>

View File

@@ -100,7 +100,7 @@ export default {
methods: {
awaitingSync(total, passing, failing) {
return total !== 0 && passing === 0 && failing === 0 ? true : false;
}
},
},
computed: {
summary() {
@@ -117,8 +117,8 @@ export default {
ret.push(v);
}
return ret;
}
}
},
},
};
</script>

View File

@@ -79,11 +79,11 @@ export default {
};
this.$axios
.post("/agents/recover/", data)
.then((r) => {
.then(r => {
this.$emit("close");
this.notifySuccess(r.data, 5000);
})
.catch((e) => {
.catch(e => {
this.notifyError(e.response.data, 5000);
});
},

View File

@@ -43,7 +43,7 @@ export default {
mixins: [mixins],
data() {
return {
datetime: null
datetime: null,
};
},
methods: {
@@ -72,15 +72,15 @@ export default {
style: "width: 40vw",
message: `A reboot has been scheduled for <strong>${data.time}</strong> on ${data.agent}.
<br />It can be cancelled from the Pending Actions menu until the scheduled time.`,
html: true
html: true,
});
}
},
},
computed: {
...mapGetters(["selectedAgentPk"])
...mapGetters(["selectedAgentPk"]),
},
created() {
this.getCurrentDate();
}
},
};
</script>

View File

@@ -59,7 +59,7 @@ export default {
name: "SendCommand",
mixins: [mixins],
props: {
pk: Number
pk: Number,
},
data() {
return {
@@ -67,7 +67,7 @@ export default {
shell: "cmd",
cmd: null,
timeout: 30,
ret: null
ret: null,
};
},
computed: {
@@ -76,7 +76,7 @@ export default {
},
width() {
return this.ret === null ? "40vw" : "70vw";
}
},
},
methods: {
send() {
@@ -86,7 +86,7 @@ export default {
pk: this.pk,
cmd: this.cmd,
shell: this.shell,
timeout: this.timeout
timeout: this.timeout,
};
this.$axios
.post("/agents/sendrawcmd/", data)
@@ -98,7 +98,7 @@ export default {
this.loading = false;
this.notifyError(e.response.data);
});
}
}
},
},
};
</script>

View File

@@ -18,9 +18,7 @@
<q-icon name="search" />
</template>
<template v-slot:hint>
Type in client, site, or agent name
</template>
<template v-slot:hint>Type in client, site, or agent name</template>
</q-input>
</div>
@@ -46,14 +44,10 @@
<q-item-label caption>{{ alertTime(alert.alert_time) }}</q-item-label>
<q-item-label>
<q-icon name="snooze" size="sm">
<q-tooltip>
Snooze the alert for 24 hours
</q-tooltip>
<q-tooltip>Snooze the alert for 24 hours</q-tooltip>
</q-icon>
<q-icon name="alarm_off" size="sm">
<q-tooltip>
Dismiss alert
</q-tooltip>
<q-tooltip>Dismiss alert</q-tooltip>
</q-icon>
</q-item-label>
</q-item-section>
@@ -72,7 +66,7 @@ export default {
data() {
return {
search: "",
includeDismissed: false
includeDismissed: false,
};
},
methods: {
@@ -103,11 +97,11 @@ export default {
},
computed: {
...mapGetters({
alerts: "alerts/getAlerts"
})
alerts: "alerts/getAlerts",
}),
},
mounted() {
this.getAlerts()
}
this.getAlerts();
},
};
</script>

View File

@@ -33,19 +33,19 @@ export default {
pagination: {
rowsPerPage: 0,
sortBy: "time",
descending: true
descending: true,
},
columns: [
{ name: "eventType", label: "Type", field: "eventType", align: "left", sortable: true },
{ name: "source", label: "Source", field: "source", align: "left", sortable: true },
{ name: "eventID", label: "Event ID", field: "eventID", align: "left", sortable: true },
{ name: "time", label: "Time", field: "time", align: "left", sortable: true },
{ name: "message", label: "Message", field: "message", align: "left", sortable: true }
]
{ name: "message", label: "Message", field: "message", align: "left", sortable: true },
],
};
},
beforeDestroy() {
this.$emit("close");
}
},
};
</script>

View File

@@ -39,6 +39,6 @@ export default {
props: ["scriptInfo"],
beforeDestroy() {
this.$emit("close");
}
},
};
</script>

View File

@@ -46,8 +46,8 @@ export default {
return {
client: {
client: null,
site: null
}
site: null,
},
};
},
methods: {
@@ -67,7 +67,7 @@ export default {
this.notifyError(e.response.data.non_field_errors);
}
});
}
}
},
},
};
</script>

View File

@@ -37,7 +37,7 @@ export default {
mixins: [mixins],
data() {
return {
meshagent: null
meshagent: null,
};
},
methods: {
@@ -56,7 +56,7 @@ export default {
this.$q.loading.hide();
this.notifyError("Unable to upload");
});
}
}
},
},
};
</script>

View File

@@ -82,6 +82,7 @@ export default {
this.$emit("close");
})
.catch(e => {
this.$q.loading.hide();
this.$q.notify(notifyErrorConfig("There was an error reseting policies"));
});
},

View File

@@ -95,7 +95,7 @@ export default {
pagination: {
rowsPerPage: 0,
sortBy: "due",
descending: true
descending: true,
},
all_columns: [
{ name: "id", field: "id" },
@@ -105,7 +105,7 @@ export default {
{ name: "desc", label: "Description", align: "left", sortable: true },
{ name: "agent", label: "Agent", align: "left", sortable: true },
{ name: "client", label: "Client", align: "left", sortable: true },
{ name: "site", label: "Site", align: "left", sortable: true }
{ name: "site", label: "Site", align: "left", sortable: true },
],
all_visibleColumns: ["type", "due", "desc", "agent", "client", "site"],
agent_columns: [
@@ -113,9 +113,9 @@ export default {
{ name: "status", field: "status" },
{ name: "type", label: "Type", align: "left", sortable: true },
{ name: "due", label: "Due", field: "due", align: "left", sortable: true },
{ name: "desc", label: "Description", align: "left", sortable: true }
{ name: "desc", label: "Description", align: "left", sortable: true },
],
agent_visibleColumns: ["type", "due", "desc"]
agent_visibleColumns: ["type", "due", "desc"],
};
},
methods: {
@@ -128,7 +128,7 @@ export default {
.dialog({
title: "Delete this pending action?",
cancel: true,
ok: { label: "Delete", color: "negative" }
ok: { label: "Delete", color: "negative" },
})
.onOk(() => {
this.$q.loading.show();
@@ -164,7 +164,7 @@ export default {
} else if (status === "completed") {
return "action-completed";
}
}
},
},
computed: {
...mapGetters({
@@ -172,7 +172,7 @@ export default {
togglePendingActions: "logs/togglePendingActions",
actions: "logs/allPendingActions",
agentpk: "logs/actionsAgentPk",
actionsLoading: "logs/pendingActionsLoading"
actionsLoading: "logs/pendingActionsLoading",
}),
filter() {
return this.showCompleted ? this.actions : this.actions.filter(k => k.status === "pending");
@@ -188,7 +188,7 @@ export default {
},
completedCount() {
return this.actions.filter(k => k.status === "completed").length;
}
}
},
},
};
</script>

View File

@@ -62,7 +62,7 @@ export default {
pagination: {
rowsPerPage: 0,
sortBy: "name",
descending: false
descending: false,
},
columns: [
{ name: "install", align: "left", label: "Install", sortable: false },
@@ -71,16 +71,16 @@ export default {
align: "left",
label: "Name",
field: "name",
sortable: true
sortable: true,
},
{
name: "version",
align: "left",
label: "Version",
field: "version",
sortable: false
}
]
sortable: false,
},
],
};
},
methods: {
@@ -100,7 +100,7 @@ export default {
message: `Install ${name} on ${this.agentHostname}?`,
persistent: true,
ok: { label: "Install" },
cancel: { color: "negative" }
cancel: { color: "negative" },
})
.onOk(() => {
axios
@@ -113,13 +113,13 @@ export default {
this.notifyError("Something went wrong");
});
});
}
},
},
computed: {
...mapGetters(["agentHostname"])
...mapGetters(["agentHostname"]),
},
created() {
this.getChocos();
}
},
};
</script>

View File

@@ -10,6 +10,6 @@
<script>
export default {
name: "NotFound"
name: "NotFound",
};
</script>

View File

@@ -60,14 +60,14 @@ export default {
components: {
Services,
EventLog,
ProcessManager
ProcessManager,
},
data() {
return {
terminal: "",
file: "",
tab: "terminal",
title: ""
title: "",
};
},
methods: {
@@ -77,20 +77,20 @@ export default {
this.file = r.data.file;
this.title = `${r.data.hostname} | Remote Background`;
});
}
},
},
meta() {
return {
title: this.title
title: this.title,
};
},
computed: {
pk() {
return this.$route.params.pk;
}
},
},
created() {
this.genURLS();
}
},
};
</script>

View File

@@ -10,6 +10,6 @@ export default {
name: "SessionExpired",
created() {
this.$store.dispatch("destroyToken");
}
},
};
</script>

View File

@@ -8,8 +8,10 @@
<div class="text-h6">Setup 2-Factor</div>
</q-card-section>
<q-card-section>
<p> Scan the QR Code with your authenticator app and then click
Finish to be redirected back to the signin page.</p>
<p>
Scan the QR Code with your authenticator app and then click
Finish to be redirected back to the signin page.
</p>
<qrcode-vue :value="qr_url" size="200" level="H" />
</q-card-section>
<q-card-section>
@@ -27,7 +29,7 @@
</template>
<script>
import QrcodeVue from 'qrcode.vue';
import QrcodeVue from "qrcode.vue";
export default {
name: "TOTPSetup",
@@ -35,7 +37,7 @@ export default {
data() {
return {
totp_key: "",
qr_url: ""
qr_url: "",
};
},
methods: {
@@ -43,7 +45,7 @@ export default {
this.$q.loading = true;
const data = {
username: this.$route.params.username
username: this.$route.params.username,
};
this.$store
@@ -61,16 +63,15 @@ export default {
.catch(e => {
this.$q.loading = false;
console.log(e.response);
});
},
finish() {
this.$router.push({ name: "Login" });
}
},
},
created() {
this.$q.dark.set(false);
this.getQRCodeData();
}
},
};
</script>

View File

@@ -15,17 +15,17 @@ export default {
name: "TakeControl",
data() {
return {
control: ""
control: "",
};
},
methods: {
genURL() {
const pk = this.$route.params.pk;
axios.get(`/agents/${pk}/meshcentral/`).then(r => (this.control = r.data.control));
}
},
},
created() {
this.genURL();
}
},
};
</script>