forked from Fediversity/Fediversity
remove the sepparate thread for deploying and finish load indicator
This commit is contained in:
parent
ad00dcbc0f
commit
4d950e2b38
3 changed files with 42 additions and 47 deletions
panel/src/panel
|
@ -12,10 +12,7 @@ body
|
|||
border-radius: 50%
|
||||
box-sizing: border-box
|
||||
animation: rotation 1s linear infinite
|
||||
display: none
|
||||
|
||||
.loading
|
||||
display inline-block
|
||||
display: inline-block
|
||||
|
||||
@keyframes rotation
|
||||
0% { transform: rotate(0deg) }
|
||||
|
@ -32,4 +29,7 @@ body
|
|||
display: none
|
||||
|
||||
.htmx-request .htmx-indicator
|
||||
display: inline-block
|
||||
display: inline
|
||||
|
||||
.htmx-request.htmx-indicator
|
||||
display: inline
|
||||
|
|
|
@ -10,17 +10,14 @@
|
|||
hx-indicator="#spinner-container"
|
||||
hx-vals='{"deploy": ""}'
|
||||
hx-swap="none"
|
||||
.loading .loader
|
||||
hx-on:click="document.getElementById('spinner').classList.add('loading')"
|
||||
>
|
||||
Deploy
|
||||
<span class="htmx-indicator loader"></span>
|
||||
</button>
|
||||
|
||||
<button class="button" type="submit" name="save">Save</button>
|
||||
|
||||
<div id="spinner-container">
|
||||
<span id="spinner" class="loader"></span>
|
||||
<div id="spinner-container" class="htmx-indicator">
|
||||
<span class="loader"></span>
|
||||
</div>
|
||||
</form>
|
||||
{% endblock %}
|
||||
|
|
|
@ -50,42 +50,6 @@ class ConfigurationForm(LoginRequiredMixin, FormView):
|
|||
|
||||
return obj
|
||||
|
||||
def run_deployment(self, obj):
|
||||
print("DEPLOYING:")
|
||||
print(os.getenv("REPO_DIR"))
|
||||
print(os.getenv("NIX_DIR"))
|
||||
submission = obj.parsed_value.model_dump_json()
|
||||
deployment = json.dumps(json.loads(submission) | {
|
||||
"initialUser": {
|
||||
"displayName": "Testy McTestface",
|
||||
"username": "test",
|
||||
"password": "testtest",
|
||||
"email": "test@test.com",
|
||||
},
|
||||
})
|
||||
env = {
|
||||
"DEPLOYMENT": deployment,
|
||||
"PATH": f"{os.getenv("NIX_DIR")}/bin/",
|
||||
}
|
||||
print(f"env: {env}")
|
||||
print(f"Path: {os.getcwd()}/..")
|
||||
cmd = [
|
||||
"nix",
|
||||
"develop",
|
||||
"--extra-experimental-features",
|
||||
"configurable-impure-env",
|
||||
"--command",
|
||||
"nixops4",
|
||||
"--show-trace",
|
||||
"--verbose",
|
||||
"apply",
|
||||
"test",
|
||||
]
|
||||
print('start deployment')
|
||||
sleep(20)
|
||||
print('done with deployment')
|
||||
#subprocess.run(cmd, cwd=os.getenv("REPO_DIR") or f"{os.getcwd()}/..", env=env)
|
||||
|
||||
# TODO(@fricklerhandwerk):
|
||||
# this should probably live somewhere else
|
||||
def convert_enums_to_names(self, data_dict):
|
||||
|
@ -136,6 +100,40 @@ class ConfigurationForm(LoginRequiredMixin, FormView):
|
|||
print('-------------debug-------------')
|
||||
|
||||
if "deploy" in self.request.POST.keys():
|
||||
threading.Thread(target=self.run_deployment, args=(obj,)).start()
|
||||
#threading.Thread(target=self.run_deployment, args=(obj,)).start()
|
||||
print("DEPLOYING:")
|
||||
print(os.getenv("REPO_DIR"))
|
||||
print(os.getenv("NIX_DIR"))
|
||||
submission = obj.parsed_value.model_dump_json()
|
||||
deployment = json.dumps(json.loads(submission) | {
|
||||
"initialUser": {
|
||||
"displayName": "Testy McTestface",
|
||||
"username": "test",
|
||||
"password": "testtest",
|
||||
"email": "test@test.com",
|
||||
},
|
||||
})
|
||||
env = {
|
||||
"DEPLOYMENT": deployment,
|
||||
"PATH": f"{os.getenv("NIX_DIR")}/bin/",
|
||||
}
|
||||
print(f"env: {env}")
|
||||
print(f"Path: {os.getcwd()}/..")
|
||||
cmd = [
|
||||
"nix",
|
||||
"develop",
|
||||
"--extra-experimental-features",
|
||||
"configurable-impure-env",
|
||||
"--command",
|
||||
"nixops4",
|
||||
"--show-trace",
|
||||
"--verbose",
|
||||
"apply",
|
||||
"test",
|
||||
]
|
||||
print('start deployment')
|
||||
sleep(10)
|
||||
print('done with deployment')
|
||||
#subprocess.run(cmd, cwd=os.getenv("REPO_DIR") or f"{os.getcwd()}/..", env=env)
|
||||
|
||||
return super().form_valid(form)
|
||||
|
|
Loading…
Add table
Reference in a new issue