Skip to content

Commit

Permalink
fix: state render,Layout removed admin
Browse files Browse the repository at this point in the history
  • Loading branch information
mattLLVW committed Dec 10, 2019
1 parent a8ddbf5 commit 497be6b
Show file tree
Hide file tree
Showing 18 changed files with 49 additions and 30 deletions.
2 changes: 1 addition & 1 deletion api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def success_bool(self):
if "return" in ret:
# It shouldn't happened unless you have a custom module
# so let's assume we can trust retcode
if isinstance(ret["return"], str):
if isinstance(ret["return"], str) or isinstance(ret["return"], bool):
return True if "retcode" in ret and ret["retcode"] == 0 else False
if "success" in ret["return"]:
return ret["return"]["success"]
Expand Down
1 change: 1 addition & 0 deletions api/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def graph_data(period=7, **kwargs):
Retrieve graph data, count nb of jobs per days.
:param period: nb of days
:return: (days, count): list of days, nb of jobs.
# FIXME: use retcode instead of success
"""
period_frame = timezone.now().date() - timedelta(days=period)

Expand Down
20 changes: 17 additions & 3 deletions api/views/alcali.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,22 +446,36 @@ def run(request):
html = conv.convert(formatted, ensure_trailing_newline=True)
return HttpResponse(html)

cli_ret = request.POST.get("cli")
conv = Ansi2HTMLConverter(inline=False, scheme="xterm")
ret = run_raw(parsed_command)
formatted = "\n"
if (

# Error.
if isinstance(ret, str):
item_ret = nested_output.output(ret)
formatted += item_ret + "\n\n"
# runner or wheel client.
elif isinstance(ret, list):
for item in ret:
item_ret = nested_output.output(item)
formatted += item_ret + "\n\n"
# Highstate.
elif (
parsed_command[0]["fun"] in ["state.apply", "state.highstate"]
and parsed_command[0]["client"] != "local_async"
):
for state, out in ret.items():
minion_ret = highstate_output.output({state: out})
formatted += minion_ret + "\n\n"
# Everything else.
else:
for state, out in ret.items():
minion_ret = nested_output.output({state: out})
formatted += minion_ret + "\n\n"
if request.POST.get("cli"):

if cli_ret:
return JsonResponse({"results": formatted})
conv = Ansi2HTMLConverter(inline=False, scheme="xterm")
html = conv.convert(formatted, ensure_trailing_newline=True)
return HttpResponse(html)

Expand Down
5 changes: 2 additions & 3 deletions config/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path, include
from django.urls import include
from django.conf.urls import url

urlpatterns = [url(r"^", include("api.urls")), path("admin/", admin.site.urls)]
urlpatterns = [url(r"^", include("api.urls"))]
2 changes: 1 addition & 1 deletion dist/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!DOCTYPE html><html lang=en><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1"><link rel=icon href=/favicon.ico><title>ALCALI</title><link rel=stylesheet href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900"><link rel=stylesheet href=https://cdn.jsdelivr.net/npm/@mdi/font@latest/css/materialdesignicons.min.css><link href="https://fonts.googleapis.com/css?family=Material+Icons" rel=stylesheet><link href=/static/css/app.7dd676e0.css rel=preload as=style><link href=/static/css/chunk-vendors.47ff193e.css rel=preload as=style><link href=/static/js/app.6bf41df6.js rel=preload as=script><link href=/static/js/chunk-vendors.439a09fa.js rel=preload as=script><link href=/static/css/chunk-vendors.47ff193e.css rel=stylesheet><link href=/static/css/app.7dd676e0.css rel=stylesheet></head><body><noscript><strong>We're sorry but my-app doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id=app></div><script src=/static/js/chunk-vendors.439a09fa.js></script><script src=/static/js/app.6bf41df6.js></script></body></html>
<!DOCTYPE html><html lang=en><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1"><link rel=icon href=/favicon.ico><title>ALCALI</title><link rel=stylesheet href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900"><link rel=stylesheet href=https://cdn.jsdelivr.net/npm/@mdi/font@latest/css/materialdesignicons.min.css><link href="https://fonts.googleapis.com/css?family=Material+Icons" rel=stylesheet><link href=/static/css/app.7dd676e0.css rel=preload as=style><link href=/static/css/chunk-vendors.79d99540.css rel=preload as=style><link href=/static/js/app.2911b6e4.js rel=preload as=script><link href=/static/js/chunk-vendors.ff4d722f.js rel=preload as=script><link href=/static/css/chunk-vendors.79d99540.css rel=stylesheet><link href=/static/css/app.7dd676e0.css rel=stylesheet></head><body><noscript><strong>We're sorry but my-app doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id=app></div><script src=/static/js/chunk-vendors.ff4d722f.js></script><script src=/static/js/app.2911b6e4.js></script></body></html>
1 change: 0 additions & 1 deletion dist/static/css/chunk-vendors.47ff193e.css

This file was deleted.

1 change: 1 addition & 0 deletions dist/static/css/chunk-vendors.79d99540.css

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions dist/static/js/app.2911b6e4.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/static/js/app.2911b6e4.js.map

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions dist/static/js/app.6bf41df6.js

This file was deleted.

1 change: 0 additions & 1 deletion dist/static/js/app.6bf41df6.js.map

This file was deleted.

1 change: 0 additions & 1 deletion dist/static/js/chunk-vendors.439a09fa.js.map

This file was deleted.

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/static/js/chunk-vendors.ff4d722f.js.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"vue": "^2.6.10",
"vue-codemirror": "^4.0.6",
"vue-router": "^3.1.3",
"vuetify": "^2.1.6",
"vuetify": "^2.1.7",
"vuetify-toast-snackbar": "^0.5.0",
"vuex": "^3.0.1",
"xterm": "^4.2.0",
Expand Down
11 changes: 10 additions & 1 deletion src/components/EventsTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
</template>
<template v-slot:expanded-item="{ headers,item }">
<td :colspan="headers.length">
<pre>{{JSON.stringify(JSON.parse(item.data), null, 2)}}</pre>
<pre>{{JSON.stringify(safeParse(item.data), null, 2)}}</pre>
</td>
</template>
</v-data-table>
Expand Down Expand Up @@ -77,6 +77,15 @@
this.loading = false
})
},
safeParse(json) {
let parsed
try {
parsed = JSON.parse(json)
} catch (e) {
return {}
}
return parsed
}
},
}
</script>
Expand Down
8 changes: 2 additions & 6 deletions src/components/core/Layout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
</v-list-item>
</v-list>
<v-divider></v-divider>
<v-list dense v-for="route in routes" :key="route.name">
<v-list-item :to="`${route.path}`">
<v-list dense>
<v-list-item v-for="route in routes" :key="route.name" :to="`${route.path}`">
<v-list-item-action v-if="mini">
<v-tooltip right>
<template v-slot:activator="{ on }">
Expand Down Expand Up @@ -181,13 +181,9 @@
</v-menu>
</v-app-bar>
<v-content>
<v-container>
<v-fade-transition mode="out-in">

<router-view></router-view>

</v-fade-transition>
</v-container>
</v-content>
</v-app>
</template>
Expand Down

0 comments on commit 497be6b

Please sign in to comment.