diff --git a/manifest.json b/manifest.json index 138c8ab..1659982 100644 --- a/manifest.json +++ b/manifest.json @@ -1,5 +1,5 @@ { - "description": "Adds a toolbar extension from whence you can create permanent or temporari aliasses", + "description": "Adds a toolbar extension from whence you can create permanent or temporari aliases", "manifest_version": 3, "name": "Moossages", "version": "0.1", diff --git a/package-lock.json b/package-lock.json index 42d831f..9ac3c2d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,6 +8,8 @@ "name": "popup", "version": "0.0.0", "dependencies": { + "@heroicons/vue": "^2.2.0", + "ky": "^1.8.0", "vue": "^3.5.13", "vue-router": "^4.5.0" }, @@ -918,6 +920,15 @@ "node": ">=18" } }, + "node_modules/@heroicons/vue": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@heroicons/vue/-/vue-2.2.0.tgz", + "integrity": "sha512-G3dbSxoeEKqbi/DFalhRxJU4mTXJn7GwZ7ae8NuEQzd1bqdd0jAbdaBZlHPcvPD2xI1iGzNVB4k20Un2AguYPw==", + "license": "MIT", + "peerDependencies": { + "vue": ">= 3" + } + }, "node_modules/@jridgewell/gen-mapping": { "version": "0.3.8", "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.8.tgz", @@ -2517,6 +2528,18 @@ "dev": true, "license": "MIT" }, + "node_modules/ky": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/ky/-/ky-1.8.0.tgz", + "integrity": "sha512-DoKGmG27nT8t/1F9gV8vNzggJ3mLAyD49J8tTMWHeZvS8qLc7GlyTieicYtFzvDznMe/q2u38peOjkWc5/pjvw==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sindresorhus/ky?sponsor=1" + } + }, "node_modules/lru-cache": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", diff --git a/package.json b/package.json index 7757b8b..cf78d98 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,8 @@ "type-check": "vue-tsc --build" }, "dependencies": { + "@heroicons/vue": "^2.2.0", + "ky": "^1.8.0", "vue": "^3.5.13", "vue-router": "^4.5.0" }, @@ -24,7 +26,6 @@ "typescript": "~5.8.0", "vite": "^6.2.4", "vite-plugin-static-copy": "^2.3.0", - "vite-plugin-vue-devtools": "^7.7.2", "vue-tsc": "^2.2.8" } } diff --git a/src/components/AliasList.vue b/src/components/AliasList.vue index 5c19e21..c0c382b 100644 --- a/src/components/AliasList.vue +++ b/src/components/AliasList.vue @@ -1,19 +1,31 @@ - + + - + diff --git a/src/components/AliasListItem.vue b/src/components/AliasListItem.vue index 3d58a8c..85072f3 100644 --- a/src/components/AliasListItem.vue +++ b/src/components/AliasListItem.vue @@ -1,13 +1,62 @@ - {{ props.alias }} + + + {{ props.alias.address }} + + {{ props.alias.goto }} + + + + {{ getValidity }} + + + - + diff --git a/src/components/HeaderBar.vue b/src/components/HeaderBar.vue new file mode 100644 index 0000000..85a22bc --- /dev/null +++ b/src/components/HeaderBar.vue @@ -0,0 +1,20 @@ + + + Aliases + + + + + + + diff --git a/src/components/SpinnerComponent.vue b/src/components/SpinnerComponent.vue new file mode 100644 index 0000000..0add444 --- /dev/null +++ b/src/components/SpinnerComponent.vue @@ -0,0 +1,28 @@ + + + + + + + diff --git a/src/css/main.css b/src/css/main.css new file mode 100644 index 0000000..8dfc8b7 --- /dev/null +++ b/src/css/main.css @@ -0,0 +1,6 @@ +.icon { + width: 2em; + height: 2em; + cursor: pointer; +} + diff --git a/src/lib/mailcow.ts b/src/lib/mailcow.ts index 64d5899..fdb3fff 100644 --- a/src/lib/mailcow.ts +++ b/src/lib/mailcow.ts @@ -1,3 +1,24 @@ -class Mailcow { - apiUrl: string = "kaas"; +import type { Aliases } from "@/types/alias"; +import ky from "ky"; + +export const getAliases = async (): Promise => { + let aliases: Aliases = []; + let domainAliases = await ky("http://mail.example.com/api/v1/get/alias/all", { + headers: { + "X-Api-Key": "06144A-E4FD48-6E8373-7FF408-DE84A7" + } + }).json(); + if (domainAliases instanceof Array) { + aliases = aliases.concat(domainAliases); + } + + let temporaryAliases = await ky("http://mail.example.com/api/v1/get/time_limited_aliases/kaas@example.com", { + headers: { + "X-Api-Key": "06144A-E4FD48-6E8373-7FF408-DE84A7" + } + }).json(); + if (temporaryAliases instanceof Array) { + aliases = aliases.concat(temporaryAliases); + } + return aliases; } diff --git a/src/main.ts b/src/main.ts index 757c57c..cbe9cf7 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,3 +1,4 @@ +import './css/main.css' import { createApp } from 'vue' import App from './App.vue' import router from './router.ts' diff --git a/src/types/alias.ts b/src/types/alias.ts index b392c2e..ec7d93e 100644 --- a/src/types/alias.ts +++ b/src/types/alias.ts @@ -1,24 +1,17 @@ -// export default class Alias { -// address: string; -// expiration: Date; -// description: string; -// -// constructor(address: string, expiration: Date, description: string) { -// this.address = address; -// this.expiration = expiration; -// this.description = description; -// } -// } -// +export type Aliases = Alias[] -export default class Alias { - address: string; - expiration: Date; - description: string; - - constructor(address: string, expiration: Date, description: string) { - this.address = address; - this.expiration = expiration; - this.description = description; - } -}; +export interface Alias { + active: string + address: string + created: string + domain: string + goto: string + id: number + in_primary_domain: string + is_catch_all: number + modified?: any + private_comment?: any + public_comment?: any + // Only if its a temporary alias + validity?: number +} diff --git a/src/views/HomeView.vue b/src/views/HomeView.vue index dc06866..6468987 100644 --- a/src/views/HomeView.vue +++ b/src/views/HomeView.vue @@ -1,8 +1,10 @@ + diff --git a/vite.config.ts b/vite.config.ts index 058a5cf..9483969 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -2,13 +2,11 @@ import { fileURLToPath, URL } from 'node:url' import { defineConfig } from 'vite' import vue from '@vitejs/plugin-vue' -import vueDevTools from 'vite-plugin-vue-devtools' import { viteStaticCopy } from 'vite-plugin-static-copy' export default defineConfig({ plugins: [ vue(), - vueDevTools(), viteStaticCopy({ targets: [ {