endpoints "credentials" (routers.admin)
This commit is contained in:
parent
2d0209ae61
commit
bd7bc38954
3 changed files with 127 additions and 12 deletions
|
@ -149,3 +149,26 @@ async def put_doors(
|
|||
key=lambda door: door.day,
|
||||
)
|
||||
await cal_cfg.change(cfg)
|
||||
|
||||
|
||||
@router.get("/dav_credentials")
|
||||
async def get_dav_credentials(
|
||||
_: None = Depends(require_admin),
|
||||
) -> tuple[str, str]:
|
||||
"""
|
||||
Zugangsdaten für WebDAV
|
||||
"""
|
||||
|
||||
return SETTINGS.webdav.username, SETTINGS.webdav.password
|
||||
|
||||
|
||||
@router.get("/ui_credentials")
|
||||
async def get_ui_credentials(
|
||||
_: None = Depends(require_admin),
|
||||
cfg: Config = Depends(get_config),
|
||||
) -> tuple[str, str]:
|
||||
"""
|
||||
Zugangsdaten für Admin-UI
|
||||
"""
|
||||
|
||||
return cfg.admin.name, cfg.admin.password
|
||||
|
|
|
@ -90,12 +90,14 @@
|
|||
<dd>{{ config_model.webdav.url }}</dd>
|
||||
|
||||
<dt>Zugangsdaten</dt>
|
||||
<!-- TODO -->
|
||||
<dd>
|
||||
<span>***</span>
|
||||
<button class="tag button icon is-primary ml-2">
|
||||
<font-awesome-icon icon="fa-solid fa-eye" />
|
||||
</button>
|
||||
<dd class="is-family-monospace">
|
||||
<BulmaSecret @load="load_dav_credentials">
|
||||
<span class="tag is-danger">user</span>
|
||||
{{ dav_credentials.username }}
|
||||
<br />
|
||||
<span class="tag is-danger">pass</span>
|
||||
{{ dav_credentials.password }}
|
||||
</BulmaSecret>
|
||||
</dd>
|
||||
|
||||
<dt>Cache-Dauer</dt>
|
||||
|
@ -105,12 +107,14 @@
|
|||
<dd>{{ config_model.webdav.config_file }}</dd>
|
||||
|
||||
<dt>UI-Admin</dt>
|
||||
<!-- TODO -->
|
||||
<dd>
|
||||
<span>***</span>
|
||||
<button class="tag button icon is-primary ml-2">
|
||||
<font-awesome-icon icon="fa-solid fa-eye" />
|
||||
</button>
|
||||
<dd class="is-family-monospace">
|
||||
<BulmaSecret @load="load_ui_credentials">
|
||||
<span class="tag is-danger">user</span>
|
||||
{{ ui_credentials.username }}
|
||||
<br />
|
||||
<span class="tag is-danger">pass</span>
|
||||
{{ ui_credentials.password }}
|
||||
</BulmaSecret>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
@ -125,10 +129,17 @@ import { ConfigModel, DayStrModel, DoorsSaved } from "@/lib/api";
|
|||
import { Options, Vue } from "vue-class-component";
|
||||
|
||||
import BulmaDrawer from "./bulma/Drawer.vue";
|
||||
import BulmaSecret from "./bulma/Secret.vue";
|
||||
|
||||
interface Credentials {
|
||||
username: string;
|
||||
password: string;
|
||||
}
|
||||
|
||||
@Options({
|
||||
components: {
|
||||
BulmaDrawer,
|
||||
BulmaSecret,
|
||||
},
|
||||
})
|
||||
export default class extends Vue {
|
||||
|
@ -159,6 +170,8 @@ export default class extends Vue {
|
|||
};
|
||||
public day_parts: DayStrModel[] = [];
|
||||
public num_user_doors = 0;
|
||||
public dav_credentials: Credentials = { username: "", password: "" };
|
||||
public ui_credentials: Credentials = { username: "", password: "" };
|
||||
|
||||
public on_open(): void {
|
||||
this.is_loaded = false;
|
||||
|
@ -177,6 +190,30 @@ export default class extends Vue {
|
|||
})
|
||||
.catch(console.log);
|
||||
}
|
||||
|
||||
public load_dav_credentials(): void {
|
||||
this.$advent22
|
||||
.api_get<string[]>("admin/dav_credentials")
|
||||
.then(([username, password]) => {
|
||||
this.dav_credentials = {
|
||||
username: username,
|
||||
password: password,
|
||||
};
|
||||
})
|
||||
.catch(console.log);
|
||||
}
|
||||
|
||||
public load_ui_credentials(): void {
|
||||
this.$advent22
|
||||
.api_get<string[]>("admin/ui_credentials")
|
||||
.then(([username, password]) => {
|
||||
this.ui_credentials = {
|
||||
username: username,
|
||||
password: password,
|
||||
};
|
||||
})
|
||||
.catch(console.log);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
55
ui/src/components/bulma/Secret.vue
Normal file
55
ui/src/components/bulma/Secret.vue
Normal file
|
@ -0,0 +1,55 @@
|
|||
<template>
|
||||
<slot v-if="show" name="default" />
|
||||
<span v-else>***</span>
|
||||
<button :class="`tag button icon is-${button_class} ml-2`" @click="on_click">
|
||||
<font-awesome-icon :icon="`fa-solid fa-${button_icon}`" />
|
||||
</button>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { Options, Vue } from "vue-class-component";
|
||||
|
||||
enum ClickState {
|
||||
Green = 0,
|
||||
Yellow = 1,
|
||||
Red = 2,
|
||||
}
|
||||
|
||||
@Options({
|
||||
emits: ["load"],
|
||||
})
|
||||
export default class extends Vue {
|
||||
public click_state = ClickState.Green;
|
||||
|
||||
public on_click(): void {
|
||||
this.click_state = (this.click_state + 1) % 3;
|
||||
|
||||
if (this.click_state === ClickState.Red) {
|
||||
this.$emit("load");
|
||||
}
|
||||
}
|
||||
|
||||
public get show(): boolean {
|
||||
return this.click_state === ClickState.Red;
|
||||
}
|
||||
|
||||
public get button_class(): string {
|
||||
switch (this.click_state) {
|
||||
case ClickState.Red:
|
||||
return "danger";
|
||||
case ClickState.Yellow:
|
||||
return "warning";
|
||||
default:
|
||||
return "primary";
|
||||
}
|
||||
}
|
||||
|
||||
public get button_icon(): string {
|
||||
if (this.click_state === ClickState.Red) {
|
||||
return "eye-slash";
|
||||
} else {
|
||||
return "eye";
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
Loading…
Reference in a new issue