1
0
Fork 0

show what deploys succeeded and correct some indentations

This commit is contained in:
Kevin Muller 2025-03-28 12:40:55 +01:00
parent 6866b7b2b3
commit 19c8e27cbd
3 changed files with 35 additions and 26 deletions

View file

@ -21,20 +21,7 @@
<span class="loader"></span>
</div>
<p id="deployment-result">
{% if deployment_status %}
<ul>
<li>
<input type="checkbox" id="peertube"> Peertube
</li>
<li>
<input type="checkbox" id="mastodon"> Mastodon
</li>
<li>
<input type="checkbox" id="pixelfed"> Pixelfed
</li>
</ul>
{% endif %}
</p>
<div id="deployment-result">
</div>
</form>
{% endblock %}

View file

@ -0,0 +1,13 @@
{% if deployment_status %}
<p>{{ deployment_status }}</p>
<ul>
{% for service, state in services.items %}
{% if state %}
<li>
&#x2713; {{ service }}
</li>
{% endif %}
{% endfor %}
</ul>
{% endif %}

View file

@ -8,12 +8,12 @@ from django.contrib.auth.mixins import LoginRequiredMixin
from django.contrib.auth.models import User
from django.views.generic import TemplateView, DetailView
from django.views.generic.edit import FormView
from django.http import HttpResponse
from django.shortcuts import render
from panel import models, settings
from panel import models
from panel.configuration import forms
class Index(TemplateView):
template_name = 'index.html'
@ -83,6 +83,7 @@ class ConfigurationForm(LoginRequiredMixin, FormView):
initial.update(self.convert_enums_to_names(config_dict))
return initial
class Save(ConfigurationForm):
def form_valid(self, form):
obj = self.get_object()
@ -91,6 +92,7 @@ class Save(ConfigurationForm):
return super().form_valid(form)
class DeploymentStatus(ConfigurationForm):
def form_valid(self, form):
obj = self.get_object()
@ -99,31 +101,38 @@ class DeploymentStatus(ConfigurationForm):
# Check for deploy button
if "deploy" in self.request.POST.keys():
deployment_result = self.deployment(obj)
deployment_result, deployment_params = self.deployment(obj)
if deployment_result.returncode == 0:
deployment_status = "Deployment Succeeded"
else:
deployment_status = "Deployment Failed"
return HttpResponse(deployment_status)
return render(self.request, "partials/deployment_result.html", {
"deployment_status": deployment_status,
"services": {
"peertube": deployment_params['peertube']['enable'],
"pixelfed": deployment_params['pixelfed']['enable'],
"mastodon": deployment_params['mastodon']['enable']
}
})
def deployment(self, obj):
submission = obj.parsed_value.model_dump_json()
# FIXME: let the user specify these from the form (#190)
dummy_user = {
"initialUser": {
"displayName": "Testy McTestface",
"username": "test",
"password": "testtest",
"email": "test@test.com",
"displayName": "Testy McTestface",
"username": "test",
"password": "testtest",
"email": "test@test.com",
},
}
# serialize back and forth now we still need to manually inject the dummy user
deployment = json.dumps(dummy_user | json.loads(submission))
deployment_params = json.dumps(dummy_user | json.loads(submission))
env = {
"PATH": settings.bin_path,
# pass in form info to our deployment
"DEPLOYMENT": deployment,
"DEPLOYMENT": deployment_params,
}
cmd = [
"nix",
@ -141,4 +150,4 @@ class DeploymentStatus(ConfigurationForm):
env=env,
)
print(deployment_result.returncode)
return deployment_result
return deployment_result, json.loads(deployment_params)