feat: dump
This commit is contained in:
parent
d68b103f36
commit
29202fd43b
12 changed files with 122 additions and 229 deletions
45
README.md
45
README.md
|
@ -1,38 +1,19 @@
|
||||||
# create-svelte
|
1. Please clone and build
|
||||||
|
https://git.batsense.net/realaravinth/forgejo-notifications-core in the
|
||||||
Everything you need to build a Svelte project, powered by [`create-svelte`](https://github.com/sveltejs/kit/tree/master/packages/create-svelte).
|
parent directory and install it on this project.
|
||||||
|
2. Please deploy a local instance of https://github.com/Bassetts/warp-cors with:
|
||||||
## Creating a project
|
|
||||||
|
|
||||||
If you're seeing this, you've probably already done this step. Congrats!
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# create a new project in the current directory
|
docker run -dp 3030:3030 bassetts/warp-cors
|
||||||
npm create svelte@latest
|
|
||||||
|
|
||||||
# create a new project in my-app
|
|
||||||
npm create svelte@latest my-app
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Developing
|
The URL is hardcoded, so it won't work if warp-cors isn't running on
|
||||||
|
`localhost:3030`
|
||||||
|
|
||||||
Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:
|
3. I Haven't figured out how to build and deploy this project. I'm not
|
||||||
|
even sure if it is possible (I'm new to svelte). But I know the
|
||||||
|
development server works ;) :
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm run dev
|
pnpm run dev
|
||||||
|
````
|
||||||
# or start the server and open the app in a new browser tab
|
|
||||||
npm run dev -- --open
|
|
||||||
```
|
|
||||||
|
|
||||||
## Building
|
|
||||||
|
|
||||||
To create a production version of your app:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
npm run build
|
|
||||||
```
|
|
||||||
|
|
||||||
You can preview the production build with `npm run preview`.
|
|
||||||
|
|
||||||
> To deploy your app, you may need to install an [adapter](https://kit.svelte.dev/docs/adapters) for your target environment.
|
|
||||||
|
|
|
@ -1120,7 +1120,7 @@ packages:
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
file:../forgejo-notifications-core/forgejo-notifications-core-0.1.0-alpha-1.tgz:
|
file:../forgejo-notifications-core/forgejo-notifications-core-0.1.0-alpha-1.tgz:
|
||||||
resolution: {integrity: sha512-Xz61PNEyFfQw+StI78kqMEp0QnI4TDU69JK3V1Ty1w5FWpF9Nv+3s6vZbXdv9GfEk630VTY3ELedbVB+nu9FBA==, tarball: file:../forgejo-notifications-core/forgejo-notifications-core-0.1.0-alpha-1.tgz}
|
resolution: {integrity: sha512-zXpAZjwjN1kPW/JBpziAG/YNvoXfco0ocWYHPut3NCsFUMqaWs0PfQ+vPRo8IaCeVP+sBgB6xTvMasclXmkP9g==, tarball: file:../forgejo-notifications-core/forgejo-notifications-core-0.1.0-alpha-1.tgz}
|
||||||
name: forgejo-notifications-core
|
name: forgejo-notifications-core
|
||||||
version: 0.1.0-alpha-1
|
version: 0.1.0-alpha-1
|
||||||
dev: false
|
dev: false
|
||||||
|
|
|
@ -15,12 +15,11 @@
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<main>
|
<main>
|
||||||
<Search />
|
|
||||||
|
|
||||||
{#if user_value}
|
{#if user_value}
|
||||||
|
<Search />
|
||||||
<p>Hello {user_value.username}</p>
|
<p>Hello {user_value.username}</p>
|
||||||
{/if}
|
|
||||||
|
|
||||||
<Login />
|
|
||||||
<Notifications />
|
<Notifications />
|
||||||
|
{:else}
|
||||||
|
<Login />
|
||||||
|
{/if}
|
||||||
</main>
|
</main>
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
<span>
|
<span>
|
||||||
{#if assignments > 0}
|
{#if assignments > 0}
|
||||||
{#if user_val}
|
{#if user_val}
|
||||||
<IssueAttr count={user.avatar_url} img={mentions_icon} />
|
<IssueAttr count={assignments} img={user.avatar_url} />
|
||||||
{/if}
|
{/if}
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,11 @@
|
||||||
user_val = value;
|
user_val = value;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let api_val;
|
||||||
|
api.subscribe((value) => {
|
||||||
|
api_val = value;
|
||||||
|
});
|
||||||
|
|
||||||
let notification_val;
|
let notification_val;
|
||||||
notification.subscribe((value) => {
|
notification.subscribe((value) => {
|
||||||
notification_val = value;
|
notification_val = value;
|
||||||
|
@ -125,23 +130,7 @@
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const login = async (e) => {
|
const isIssueAssigned = (i) => {
|
||||||
e.preventDefault();
|
|
||||||
let api_val = new Forgejo(instanceUrl);
|
|
||||||
await api_val.setTokenAuth(accessToken);
|
|
||||||
let tmpUser = await api_val.getUser();
|
|
||||||
let local_notifications = await api_val.getNotifications();
|
|
||||||
local_notifications.forEach(async (n) => {
|
|
||||||
if (n.subject.type == "Issue") {
|
|
||||||
let splits = n.subject.html_url.split("/");
|
|
||||||
let owner = splits[3];
|
|
||||||
let repo = splits[4];
|
|
||||||
let id = splits[6];
|
|
||||||
let i = await api_val.getIssue(owner, repo, id);
|
|
||||||
i = await api_val.getCommentsForIssue(i);
|
|
||||||
|
|
||||||
indexNotification(n, i);
|
|
||||||
|
|
||||||
let local_assigned = false;
|
let local_assigned = false;
|
||||||
if (i.assignee) {
|
if (i.assignee) {
|
||||||
if (i.assignee.username == user_val.username) {
|
if (i.assignee.username == user_val.username) {
|
||||||
|
@ -155,20 +144,44 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const hydrate = async () => {
|
||||||
|
let local_notifications = await api_val.getNotifications();
|
||||||
|
local_notifications.forEach(async (n) => {
|
||||||
|
if (n.subject.type == "Issue") {
|
||||||
|
let splits = n.subject.html_url.split("/");
|
||||||
|
let owner = splits[3];
|
||||||
|
let repo = splits[4];
|
||||||
|
let id = splits[6];
|
||||||
|
let i = await api_val.getIssue(owner, repo, id);
|
||||||
|
i = await api_val.getCommentsForIssue(i);
|
||||||
|
|
||||||
|
indexNotification(n, i);
|
||||||
|
|
||||||
n.subject["local_issue"] = i;
|
n.subject["local_issue"] = i;
|
||||||
|
n.subject["local_assigned"] = isIssueAssigned(i);
|
||||||
n.subject["local_mention"] = await api_val.findMentionsInIssue(i);
|
n.subject["local_mention"] = await api_val.findMentionsInIssue(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
organisations.update(() => updateOrg(n, organisations_val));
|
organisations.update(() => updateOrg(n, organisations_val));
|
||||||
});
|
});
|
||||||
|
|
||||||
user.update(() => tmpUser);
|
|
||||||
api.update(() => api_val);
|
|
||||||
|
|
||||||
notification.update(() => {
|
notification.update(() => {
|
||||||
return local_notifications;
|
return local_notifications;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const login = async (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
api_val = new Forgejo(instanceUrl);
|
||||||
|
api_val.setCors();
|
||||||
|
await api_val.setTokenAuth(accessToken);
|
||||||
|
user_val = await api_val.getUser();
|
||||||
|
user.update(() => user_val);
|
||||||
|
api.update(() => api_val);
|
||||||
|
await hydrate();
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<form on:submit|preventDefault={login}>
|
<form on:submit|preventDefault={login}>
|
||||||
|
|
|
@ -1,42 +0,0 @@
|
||||||
<script>
|
|
||||||
import { organisations, user } from "./store.js";
|
|
||||||
import IssueAttrGrp from "./IssueAttrGrp.svelte";
|
|
||||||
|
|
||||||
let organisations_val = [];
|
|
||||||
organisations.subscribe((value) => {
|
|
||||||
organisations_val = value;
|
|
||||||
});
|
|
||||||
|
|
||||||
let user_val = [];
|
|
||||||
user.subscribe((value) => {
|
|
||||||
user_val = value;
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<section>
|
|
||||||
<h2>Repositories</h2>
|
|
||||||
<ol>
|
|
||||||
{#each organisations_val as org}
|
|
||||||
<h3>
|
|
||||||
{org.name}
|
|
||||||
<IssueAttrGrp
|
|
||||||
mentions={org.mentions}
|
|
||||||
assignments={org.assignments}
|
|
||||||
issues={org.issues}
|
|
||||||
/>
|
|
||||||
</h3>
|
|
||||||
<ol>
|
|
||||||
{#each org.repo as repo}
|
|
||||||
<li>
|
|
||||||
{repo.name}
|
|
||||||
<IssueAttrGrp
|
|
||||||
mentions={repo.mentions}
|
|
||||||
assignments={repo.assignments}
|
|
||||||
issues={repo.issues}
|
|
||||||
/>
|
|
||||||
</li>
|
|
||||||
{/each}
|
|
||||||
</ol>
|
|
||||||
{/each}
|
|
||||||
</ol>
|
|
||||||
</section>
|
|
|
@ -8,6 +8,9 @@
|
||||||
notification.subscribe((value) => {
|
notification.subscribe((value) => {
|
||||||
notification_val = value;
|
notification_val = value;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let mentions_icon = "/at-sign.svg";
|
||||||
|
let issues_icon = "/bell.svg";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<section>
|
<section>
|
||||||
|
@ -34,8 +37,14 @@
|
||||||
{/if}
|
{/if}
|
||||||
{/if}
|
{/if}
|
||||||
{n.subject.title}
|
{n.subject.title}
|
||||||
|
{#if n.subject.html_url.local_assignments}
|
||||||
|
{#if user_val}
|
||||||
|
<IssueAttr count="1" img={user.avatar_url} />
|
||||||
|
{/if}
|
||||||
|
{/if}
|
||||||
|
|
||||||
{#if n.subject.html_url.local_mention}
|
{#if n.subject.html_url.local_mention}
|
||||||
<img src="/at-sign.svg" />
|
<IssueAttr count="1" img={mentions_icon} />
|
||||||
{/if}
|
{/if}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
@ -13,12 +13,16 @@
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<section>
|
<aside>
|
||||||
<h2>Repositories</h2>
|
<h2>Repositories</h2>
|
||||||
<ol>
|
<ol>
|
||||||
{#each organisations_val as org}
|
{#each organisations_val as org}
|
||||||
<h3>
|
<h3>
|
||||||
|
{#if org.name == user_val.username}
|
||||||
|
Personal
|
||||||
|
{:else}
|
||||||
{org.name}
|
{org.name}
|
||||||
|
{/if}
|
||||||
<IssueAttrGrp
|
<IssueAttrGrp
|
||||||
mentions={org.mentions}
|
mentions={org.mentions}
|
||||||
assignments={org.assignments}
|
assignments={org.assignments}
|
||||||
|
@ -39,4 +43,4 @@
|
||||||
</ol>
|
</ol>
|
||||||
{/each}
|
{/each}
|
||||||
</ol>
|
</ol>
|
||||||
</section>
|
</aside>
|
||||||
|
|
|
@ -13,17 +13,11 @@
|
||||||
const findDocuments = () => {
|
const findDocuments = () => {
|
||||||
let trimmed = search.trim();
|
let trimmed = search.trim();
|
||||||
results = index_val.search(trimmed);
|
results = index_val.search(trimmed);
|
||||||
if (results.length > 0) {
|
|
||||||
enableClearResults = true;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let enableClearResults = false;
|
|
||||||
|
|
||||||
const clearResults = () => {
|
const clearResults = () => {
|
||||||
$: results = [];
|
$: results = [];
|
||||||
console.log("cleared");
|
console.log("cleared");
|
||||||
enableClearResults = false;
|
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -35,11 +29,13 @@
|
||||||
on:keydown={findDocuments}
|
on:keydown={findDocuments}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{#if enableClearResults}
|
{#if results.length > 0}
|
||||||
<button on:click={clearResults}>Clear</button>
|
<button on:click={clearResults}>Clear</button>
|
||||||
{/if}
|
{/if}
|
||||||
<ol>
|
<ol>
|
||||||
|
{#if results.length > 0}
|
||||||
<h2>Search Results</h2>
|
<h2>Search Results</h2>
|
||||||
|
{/if}
|
||||||
{#each results as r}
|
{#each results as r}
|
||||||
<a href={r.id}>
|
<a href={r.id}>
|
||||||
<li>
|
<li>
|
||||||
|
|
|
@ -1,26 +0,0 @@
|
||||||
<script>
|
|
||||||
import Forgejo from "../../../forgejo-notifications-core/dist/web.js";
|
|
||||||
|
|
||||||
import Login from "./Login.svelte";
|
|
||||||
import Notifications from "./Notifications.svelte";
|
|
||||||
import Search from "./Search.svelte";
|
|
||||||
|
|
||||||
import { user } from "./store.js";
|
|
||||||
|
|
||||||
let user_value;
|
|
||||||
|
|
||||||
user.subscribe((value) => {
|
|
||||||
user_value = value;
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<main>
|
|
||||||
<Search />
|
|
||||||
|
|
||||||
{#if user_value}
|
|
||||||
<p>Hello {user_value.username}</p>
|
|
||||||
{/if}
|
|
||||||
|
|
||||||
<Login />
|
|
||||||
<Notifications />
|
|
||||||
</main>
|
|
|
@ -1,8 +0,0 @@
|
||||||
<script>
|
|
||||||
export let count = 0;
|
|
||||||
export let img;
|
|
||||||
</script>
|
|
||||||
|
|
||||||
{#if count > 0 && img}
|
|
||||||
<img src={img} /> {count}
|
|
||||||
{/if}
|
|
|
@ -1,33 +0,0 @@
|
||||||
<script>
|
|
||||||
import { user } from "./store.js";
|
|
||||||
|
|
||||||
import IssueAttr from "./IssueAttr.svelte";
|
|
||||||
|
|
||||||
let user_val = [];
|
|
||||||
user.subscribe((value) => {
|
|
||||||
user_val = value;
|
|
||||||
});
|
|
||||||
|
|
||||||
export let mentions = 0;
|
|
||||||
export let assignments = 0;
|
|
||||||
export let issues = 0;
|
|
||||||
|
|
||||||
let mentions_icon = "/at-sign.svg";
|
|
||||||
let issues_icon = "/bell.svg";
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<span>
|
|
||||||
{#if assignments > 0}
|
|
||||||
{#if user_val}
|
|
||||||
<IssueAttr count={user.avatar_url} img={mentions_icon} />
|
|
||||||
{/if}
|
|
||||||
{/if}
|
|
||||||
|
|
||||||
{#if mentions > 0}
|
|
||||||
<IssueAttr count={mentions} img={mentions_icon} />
|
|
||||||
{/if}
|
|
||||||
|
|
||||||
{#if issues > 0}
|
|
||||||
<IssueAttr count={issues} img={issues_icon} />
|
|
||||||
{/if}
|
|
||||||
</span>
|
|
Loading…
Reference in a new issue