Skip to content

Commit

Permalink
Merge branch 'wh1te909:develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
subzdev authored Jan 10, 2022
2 parents 5a541b0 + a2fac5d commit 9ed8c5d
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.11 on 2022-01-09 21:27

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('autotasks', '0027_auto_20220107_0643'),
]

operations = [
migrations.AlterField(
model_name='automatedtask',
name='actions',
field=models.JSONField(default=list),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.10 on 2022-01-10 01:48

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('autotasks', '0028_alter_automatedtask_actions'),
]

operations = [
migrations.AlterField(
model_name='automatedtask',
name='task_type',
field=models.CharField(choices=[('daily', 'Daily'), ('weekly', 'Weekly'), ('monthly', 'Monthly'), ('monthlydow', 'Monthly Day of Week'), ('checkfailure', 'On Check Failure'), ('manual', 'Manual'), ('runonce', 'Run Once'), ('scheduled', 'Scheduled')], default='manual', max_length=100),
),
]
1 change: 1 addition & 0 deletions api/tacticalrmm/autotasks/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
("checkfailure", "On Check Failure"),
("manual", "Manual"),
("runonce", "Run Once"),
("scheduled", "Scheduled"), # deprecated
]

SYNC_STATUS_CHOICES = [
Expand Down
16 changes: 15 additions & 1 deletion api/tacticalrmm/core/management/commands/post_update_tasks.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import base64
from django.core.management.base import BaseCommand
import datetime as dt

from logs.models import PendingAction
from scripts.models import Script
Expand Down Expand Up @@ -35,8 +36,18 @@ def handle(self, *args, **kwargs):
# script.hash_script_body() # also saves script
script.save(update_fields=["script_body"])

# convert autotask actions to the new format
# convert autotask to the new format
for task in AutomatedTask.objects.all():
edited = False

# convert scheduled task_type
if task.task_type == "scheduled":
task.task_type = "daily"
task.run_time_date = dt.datetime.strptime(task.run_time_minute, "%H:%M")
task.daily_interval = 1
edited = True

# convert actions
if not task.actions:
task.actions = [
{
Expand All @@ -47,4 +58,7 @@ def handle(self, *args, **kwargs):
"name": task.script.name,
}
]
edited = True

if edited:
task.save()
6 changes: 3 additions & 3 deletions docker/containers/tactical-nats/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ config_watcher="$(cat << EOF
while true; do
sleep ${NATS_CONFIG_CHECK_INTERVAL};
if [[ ! -z \${NATS_CHECK} ]]; then
NATS_RELOAD=\$(date -r '/opt/tactical/api/nats-rmm.conf')
NATS_RELOAD=\$(date -r '${NATS_CONFIG}')
if [[ \$NATS_RELOAD == \$NATS_CHECK ]]; then
:
else
nats-server --signal reload;
NATS_CHECK=\$(date -r '/opt/tactical/api/nats-rmm.conf');
NATS_CHECK=\$(date -r '${NATS_CONFIG}');
fi
else NATS_CHECK=\$(date -r '/opt/tactical/api/nats-rmm.conf');
else NATS_CHECK=\$(date -r '${NATS_CONFIG}');
fi
done
Expand Down
19 changes: 13 additions & 6 deletions web/src/components/tasks/AutomatedTaskForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,16 @@
/>
</q-card-section>
<q-card-section>
<q-checkbox dense label="Collector Task" v-model="collector" class="q-pb-sm" />
<q-checkbox
dense
label="Collector Task"
v-model="collector"
class="q-pb-sm"
@update:model-value="
state.custom_field = null;
state.collector_all_output = false;
"
/>
<tactical-dropdown
v-if="collector"
:rules="[val => !!val || '*Required']"
Expand Down Expand Up @@ -567,7 +576,7 @@
/>
<q-btn
v-else
label="Add Task"
:label="task ? 'Edit Task' : 'Add Task'"
color="primary"
@click="validateStep($refs.taskDetailForm, $refs.stepper)"
:loading="loading"
Expand Down Expand Up @@ -875,10 +884,8 @@ export default {
}
);
watch(collector, (newValue, oldValue) => {
task.value.custom_field = null;
task.value.collector_all_ouput = false;
});
// check the collector box when editing task and custom field is set
if (props.task && props.task.custom_field) collector.value = true;
// stepper logic
const step = ref(1);
Expand Down

0 comments on commit 9ed8c5d

Please sign in to comment.