|
1 | 1 | <script lang="ts"> |
2 | | - import api from '$endpoints'; |
3 | | - import Background from '$components/Background.svelte'; |
4 | | - import Navbar from '$components/navbar'; |
5 | | - import Paper from '$components/Paper.svelte'; |
6 | | - import consts from '$lib/consts'; |
7 | | -
|
8 | | - export let data: import('./$types').PageData; |
9 | | -
|
10 | | - // Git setup |
11 | | - let gitUrl = ''; |
12 | | -
|
13 | | - async function submitSwitchToGit() { |
14 | | - await api().admin.git.init(gitUrl); |
15 | | - } |
16 | | -
|
17 | | - // Git controls |
18 | | - let commitMessage = ''; |
19 | | -
|
20 | | - async function gitCommit() { |
21 | | - await api().admin.git.commit(commitMessage); |
22 | | - } |
| 2 | + import Background from "$components/Background.svelte"; |
| 3 | + import Navbar from "$components/navbar"; |
| 4 | + import Paper from "$components/Paper.svelte"; |
| 5 | + import consts from "$lib/consts"; |
| 6 | + import GitSettings from "./GitSettings.svelte"; |
| 7 | + import ChangePassword from "./ChangePassword.svelte"; |
| 8 | + import ReloadData from "./ReloadData.svelte"; |
| 9 | + import LogOutAll from "./LogOutAll.svelte"; |
| 10 | +
|
| 11 | + export let data: import("./$types").PageData; |
23 | 12 | </script> |
24 | 13 |
|
25 | 14 | <svelte:head> |
26 | 15 | <title>Admin - {data.globals.config.siteName}</title> |
27 | | - <meta name="generator" content="{consts.APP_NAME}"> |
28 | | - <meta name="theme-color" content="{data.globals.config.color}"> |
| 16 | + <meta name="generator" content={consts.APP_NAME} /> |
| 17 | + <meta name="theme-color" content={data.globals.config.color} /> |
29 | 18 | <!-- Prevent web crawlers from indexing the admin page --> |
30 | | - <meta name="robots" content="noindex"> |
| 19 | + <meta name="robots" content="noindex" /> |
31 | 20 | </svelte:head> |
32 | 21 |
|
33 | 22 | <Navbar |
34 | | - path={[{ txt: 'Admin', url: 'admin' }]} |
| 23 | + path={[{ txt: "Admin", url: "admin" }]} |
35 | 24 | config={data.globals.config} |
36 | 25 | loggedIn={true} |
37 | 26 | /> |
|
42 | 31 | <div id="paper-container"> |
43 | 32 | <Paper> |
44 | 33 | <div id="contents"> |
45 | | - <div> |
46 | | - {#if data.repo} |
47 | | - <h2>Git status</h2> |
48 | | - <p>Current branch: {data.repo.branch}</p> |
49 | | - <p>Current commit: {data.repo.commit}</p> |
50 | | - <p> |
51 | | - {#if data.repo.behind} |
52 | | - {data.repo.behind} commits behind. |
53 | | - {/if} |
54 | | - {#if data.repo.ahead} |
55 | | - {data.repo.ahead} commits ahead. |
56 | | - {/if} |
57 | | - </p> |
58 | | - |
59 | | - <!-- Push/pull --> |
60 | | - {#if data.repo.behind} |
61 | | - <button on:click={() => api().admin.git.push()}>Push</button> |
62 | | - {:else if data.repo.ahead} |
63 | | - <button on:click={() => api().admin.git.pull()}>Pull</button> |
64 | | - {/if} |
65 | | - |
66 | | - <!-- Commit --> |
67 | | - {#if !data.repo.clean} |
68 | | - |
69 | | - <h3>Changes</h3> |
70 | | - |
71 | | - <ul> |
72 | | - {#each data.repo.changes as change} |
73 | | - {#if change.from} |
74 | | - <li>Rename {change.from} to ({change.path})</li> |
75 | | - {:else if change.index === '?'} |
76 | | - <li>Create {change.path}</li> |
77 | | - {:else if change.index === 'D'} |
78 | | - <li>Delete {change.path}</li> |
79 | | - {:else} |
80 | | - <li>Update {change.path}</li> |
81 | | - {/if} |
82 | | - {/each} |
83 | | - </ul> |
84 | | - |
85 | | - <form on:submit|preventDefault={gitCommit}> |
86 | | - <input required type="text" name="commit-message" id="commit-message" placeholder="Commit message" bind:value={commitMessage}> |
87 | | - <input type="submit" value="Commit changes"> |
88 | | - </form> |
89 | | - {/if} |
90 | | - |
91 | | - {:else} |
92 | | - <h2>Git is currently not in use</h2> |
93 | | - |
94 | | - You can use a Git repository to back up your portfolio data. Enter the |
95 | | - clone URL for an empty Git repository and it will be set up for you. |
96 | | - |
97 | | - <form on:submit|preventDefault={submitSwitchToGit}> |
98 | | - <input required type="text" name="git-url" id="git-url" placeholder="git@github.com:MaddyGuthridge/Minifolio.git" bind:value={gitUrl}> |
99 | | - <input type="submit" value="Switch to a Git repository"> |
100 | | - </form> |
101 | | - {/if} |
102 | | - </div> |
103 | | - <div> |
104 | | - <h2>Reload data from disk</h2> |
105 | | - If you have edited your data manually, you can use this button to |
106 | | - refresh it. |
107 | | - <button on:click={() => api().admin.data.refresh()}>Refresh data</button> |
108 | | - </div> |
| 34 | + <GitSettings {data} /> |
| 35 | + <ChangePassword username={"admin"} /> |
| 36 | + <LogOutAll /> |
| 37 | + <ReloadData /> |
109 | 38 | </div> |
110 | 39 | </Paper> |
111 | 40 | </div> |
|
0 commit comments