-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added system apps from examples folder
- Loading branch information
Showing
20 changed files
with
19,730 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.DS_Store | ||
.sw* | ||
.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
{{ block "clace_body" . }} | ||
{{ block "du_table_block" . }} | ||
<div id="du_table"> | ||
<h3> | ||
Disk usage for | ||
{{ .Data.Current }} | ||
<img | ||
id="spinner" | ||
alt="Loading..." | ||
class="htmx-indicator" | ||
src="{{ static "images/spinner.svg" }}" /> | ||
</h3> | ||
<div><em>{{ .Data.Error }}</em></div> | ||
|
||
<table> | ||
<thead> | ||
<th>Name</th> | ||
<th></th> | ||
<th>Size (MB)</th> | ||
</thead> | ||
{{ range .Data.Dirs }} | ||
<tr> | ||
{{ $dirUrl := printf "%s?dir=%s" $.AppPath .Dir }} | ||
<td> | ||
<a | ||
href="{{ $dirUrl }}" | ||
hx-target="#du_table" | ||
hx-push-url="true" | ||
hx-get="{{ $dirUrl }}" | ||
hx-indicator="#spinner" | ||
>{{ .Dir }}</a | ||
> | ||
</td> | ||
<td> | ||
<progress max="{{- $.Data.MaxSize -}}" value="{{- .Size -}}"> | ||
{{ .Size }} | ||
</progress> | ||
</td> | ||
<td>{{ .Size }}</td> | ||
</tr> | ||
{{ end }} | ||
|
||
</table> | ||
|
||
<h3> | ||
{{ if ne .Data.Current "/" }} | ||
{{ $parentUrl := printf "%s?dir=%s/.." $.AppPath .Data.Current }} | ||
Parent Directory : | ||
<a | ||
href="{{ $parentUrl }}" | ||
hx-target="#du_table" | ||
hx-push-url="true" | ||
hx-get="{{ $parentUrl }}" | ||
hx-indicator="#spinner" | ||
>{{ .Data.Current }}/..</a | ||
> | ||
{{ end }} | ||
</h3> | ||
</div> | ||
{{ end }} | ||
{{ end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
load("exec.in", "exec") | ||
|
||
|
||
def handler(req): | ||
dir = req.Query.get("dir") | ||
current = dir[0] if dir and dir[0] else "." | ||
|
||
# Run readlink -f to get the absolute path for the current directory | ||
ret = exec.run("readlink", ["-f", current], process_partial=True) | ||
if not ret: | ||
print("Failed to run readlink stderr " + ret.error) | ||
return {"Current": current, | ||
"Error": "readlink -f {current} failed with {error}".format(current=current, error=ret.error)} | ||
current = ret.value[0].strip() | ||
|
||
args = ["-m", "-d", "1"] | ||
args.append(current) | ||
|
||
# run the du command, allow for partial results to handle permission errors on some dirs | ||
ret = exec.run("du", args, process_partial=True) | ||
if not ret: | ||
print("Failed to run du " + ret.error) | ||
return {"Current": current, | ||
"Error": "du -h {current} failed with {error}".format(current=current, error=ret.error)} | ||
|
||
# Parse the results | ||
dirs = [] | ||
for line in ret.value: | ||
cols = line.split("\t", 1) | ||
dirs.append({"Size": int(cols[0]), "Dir": cols[1]}) | ||
|
||
# Descending sort on size, limit to 20 dirs | ||
dirs = sorted(dirs, key=lambda d: d["Size"], reverse=True)[:20] | ||
if len(dirs) > 1 and dirs[1]["Dir"] == current: | ||
# swap current dir to the top (if not already), useful when a child is at same usage level as current | ||
dirs[0], dirs[1] = dirs[1], dirs[0] | ||
|
||
return {"Current": current, "Dirs": dirs, "Error": "", "MaxSize": dirs[0]["Size"] if dirs else 0} | ||
|
||
|
||
app = ace.app("Disk Usage", | ||
pages=[ace.page("/", partial="du_table_block")], | ||
permissions=[ | ||
ace.permission("exec.in", "run", ["du"], type="READ"), | ||
ace.permission("exec.in", "run", ["readlink"], type="READ") | ||
], | ||
style=ace.style("https://unpkg.com/[email protected]/mvp.css"), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{{ block "clace_gen_import" . }} | ||
<!-- Include the generated style file if present --> | ||
{{ if fileNonEmpty "gen/css/style.css" }} | ||
<link rel="stylesheet" href="{{ static "gen/css/style.css" }}" /> | ||
{{ end }} | ||
|
||
|
||
<!-- Include the custom style file if present --> | ||
{{ if fileNonEmpty "css/style.css" }} | ||
<link rel="stylesheet" href="{{ static "css/style.css" }}" /> | ||
{{ end }} | ||
|
||
{{ if fileNonEmpty "gen/lib/htmx.min.js" }} | ||
<script src="{{ static "gen/lib/htmx.min.js" }}"></script> | ||
{{ end }} | ||
{{ if or .IsDev .PushEvents }} | ||
{{ if fileNonEmpty "gen/lib/sse.js" }} | ||
<script src="{{ static "gen/lib/sse.js" }}"></script> | ||
{{ end }} | ||
{{ end }} | ||
|
||
{{ if .IsDev }} | ||
<div | ||
id="cl_reload_listener" | ||
hx-ext="sse" | ||
sse-connect="{{ .AppPath }}/_clace_app/sse" | ||
sse-swap="clace_reload" | ||
hx-trigger="sse:clace_reload"></div> | ||
<script> | ||
document | ||
.getElementById("cl_reload_listener") | ||
.addEventListener("sse:clace_reload", function (event) { | ||
location.reload(); | ||
}); | ||
</script> | ||
{{ end }} | ||
{{ end -}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"routing": { | ||
"template_locations": [ | ||
"*.go.html" | ||
], | ||
"push_events": false | ||
}, | ||
"htmx": { | ||
"version": "1.9.2" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<title>{{ .AppName }}</title> | ||
{{ template "clace_gen_import" . }} | ||
</head> | ||
|
||
<body> | ||
<h1>Clace: {{ .AppName }}</h1> | ||
|
||
{{ template "clace_body" . }} | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.htmx-indicator { | ||
opacity: 0; | ||
transition: opacity 200ms ease-in; | ||
} |
Oops, something went wrong.