diff --git a/.github/workflow/ci.yml b/.github/workflow/ci.yml new file mode 100644 index 0000000..22cdd62 --- /dev/null +++ b/.github/workflow/ci.yml @@ -0,0 +1,117 @@ +name: Continuous Integration + +on: + push: + pull_request: + branches: [main] + types: ['closed'] + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + prettier: + name: 💅 - Prettier + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + ref: ${{ github.head_ref }} + + - name: Prettify code + uses: creyD/prettier_action@v4.3 + with: + prettier_options: --write src/**/*.{js,ts,json,css,scss,html} + same_commit: true + + lint: + needs: [prettier] + name: 🚧 - Linter + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 19 + + - name: Install & Lint + uses: actions/cache@v3 + with: + path: ~/.npm + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} + restore-keys: ${{ runner.os }}-node- + + - run: npm ci + - run: npm run lint + + release: + if: ${{ github.event.pull_request.merged }} + needs: [prettier, lint] + name: 🏷️ - Release + permissions: + contents: write + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Use Node.js 16.x + uses: actions/setup-node@v2 + with: + node-version: '16' + + - name: Install dependencies + run: npm ci + + - name: Build + run: npm run build + + - name: Semantic Release + run: npx semantic-release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + + package: + if: ${{ github.event.pull_request.merged }} + needs: [prettier, lint, release] + name: 📦 - Package + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Log in to the Container registry + uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Build and push Docker image + uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + + deploy: + if: ${{ github.event.pull_request.merged }} + needs: [prettier, lint, release, package] + name: 🚀 - Deploy + runs-on: ubuntu-latest diff --git a/package.json b/package.json index c5325df..51575f7 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,8 @@ "author": "Christoph Merck", "type": "module", "scripts": { - "start": "webpack-dev-server --config webpack.development.cjs --client-logging error", + "start": "webpack-dev-server --host 0.0.0.0 --config webpack.development.cjs --client-logging error", + "start:ssl": "webpack-dev-server --host 0.0.0.0 --https --watch --config webpack.development.cjs --client-logging error", "build": "webpack --config webpack.production.cjs" }, "devDependencies": { @@ -20,6 +21,7 @@ "html-webpack-plugin": "5.5.0", "mini-css-extract-plugin": "2.7.5", "prettier": "2.8.7", + "resolve-url-loader": "^5.0.0", "sass": "^1.61.0", "sass-loader": "13.2.2", "ts-loader": "9.4.2", diff --git a/src/assets/icons/camera.svg b/src/assets/icons/camera.svg new file mode 100644 index 0000000..0fedd20 --- /dev/null +++ b/src/assets/icons/camera.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/assets/icons/close.svg b/src/assets/icons/close.svg new file mode 100644 index 0000000..0de3701 --- /dev/null +++ b/src/assets/icons/close.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/assets/icons/done.svg b/src/assets/icons/done.svg new file mode 100644 index 0000000..7971c5e --- /dev/null +++ b/src/assets/icons/done.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/assets/icons/help.svg b/src/assets/icons/help.svg new file mode 100644 index 0000000..aa8cd2c --- /dev/null +++ b/src/assets/icons/help.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/assets/icons/hero_image.svg b/src/assets/icons/hero_image.svg new file mode 100644 index 0000000..1e550fb --- /dev/null +++ b/src/assets/icons/hero_image.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/assets/icons/logout.svg b/src/assets/icons/logout.svg index 9674863..33ec88f 100644 --- a/src/assets/icons/logout.svg +++ b/src/assets/icons/logout.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/assets/icons/microphone-off.svg b/src/assets/icons/microphone-off.svg new file mode 100644 index 0000000..b4ee0e3 --- /dev/null +++ b/src/assets/icons/microphone-off.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/assets/icons/microphone.svg b/src/assets/icons/microphone.svg new file mode 100644 index 0000000..6cb7376 --- /dev/null +++ b/src/assets/icons/microphone.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/assets/icons/more.svg b/src/assets/icons/more.svg new file mode 100644 index 0000000..05fd314 --- /dev/null +++ b/src/assets/icons/more.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/assets/icons/password_hide.svg b/src/assets/icons/password_hide.svg index 90e9406..f05a60f 100644 --- a/src/assets/icons/password_hide.svg +++ b/src/assets/icons/password_hide.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/assets/icons/password_show.svg b/src/assets/icons/password_show.svg index 659d390..2a65f54 100644 --- a/src/assets/icons/password_show.svg +++ b/src/assets/icons/password_show.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/assets/icons/safari-pinned-tab.svg b/src/assets/icons/safari-pinned-tab.svg deleted file mode 100644 index a2aa125..0000000 --- a/src/assets/icons/safari-pinned-tab.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/assets/icons/search.svg b/src/assets/icons/search.svg new file mode 100644 index 0000000..30a06a1 --- /dev/null +++ b/src/assets/icons/search.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/assets/icons/send.svg b/src/assets/icons/send.svg new file mode 100644 index 0000000..c176c2b --- /dev/null +++ b/src/assets/icons/send.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/assets/icons/settings.svg b/src/assets/icons/settings.svg new file mode 100644 index 0000000..3116fd4 --- /dev/null +++ b/src/assets/icons/settings.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/assets/icons/upload.svg b/src/assets/icons/upload.svg new file mode 100644 index 0000000..5a6ee86 --- /dev/null +++ b/src/assets/icons/upload.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/assets/icons/wallpaper.svg b/src/assets/icons/wallpaper.svg new file mode 100644 index 0000000..30f8887 --- /dev/null +++ b/src/assets/icons/wallpaper.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/assets/images/apple-touch-icon.png b/src/assets/images/apple-touch-icon.png deleted file mode 100644 index f423d06..0000000 Binary files a/src/assets/images/apple-touch-icon.png and /dev/null differ diff --git a/src/assets/images/favicon-16x16.png b/src/assets/images/favicon-16x16.png deleted file mode 100644 index dd25c44..0000000 Binary files a/src/assets/images/favicon-16x16.png and /dev/null differ diff --git a/src/assets/images/favicon-32x32.png b/src/assets/images/favicon-32x32.png deleted file mode 100644 index f870dfc..0000000 Binary files a/src/assets/images/favicon-32x32.png and /dev/null differ diff --git a/src/assets/images/screenshots/dark.png b/src/assets/images/screenshots/dark.png new file mode 100644 index 0000000..b83532e Binary files /dev/null and b/src/assets/images/screenshots/dark.png differ diff --git a/src/assets/images/screenshots/light.png b/src/assets/images/screenshots/light.png new file mode 100644 index 0000000..e7562e4 Binary files /dev/null and b/src/assets/images/screenshots/light.png differ diff --git a/src/assets/images/screenshots/setting.png b/src/assets/images/screenshots/setting.png new file mode 100644 index 0000000..d91e3d2 Binary files /dev/null and b/src/assets/images/screenshots/setting.png differ diff --git a/src/assets/images/screenshots/signin.png b/src/assets/images/screenshots/signin.png new file mode 100644 index 0000000..722a388 Binary files /dev/null and b/src/assets/images/screenshots/signin.png differ diff --git a/src/components/message.html b/src/components/message.html index 90a3e9d..c2a71de 100644 --- a/src/components/message.html +++ b/src/components/message.html @@ -1,7 +1,12 @@ -
-
-

-

+
+
+
+
+
+ +
+ + +
-

diff --git a/src/components/messageDivider.html b/src/components/messageDivider.html new file mode 100644 index 0000000..103a9c3 --- /dev/null +++ b/src/components/messageDivider.html @@ -0,0 +1 @@ +
diff --git a/src/index.html b/src/index.html index 8e00ab1..cdb55fd 100644 --- a/src/index.html +++ b/src/index.html @@ -1,43 +1,23 @@ - - - - + + - + - - - - - - + - + + PWA Chat - + diff --git a/src/main.ts b/src/main.ts index 81148bf..728094c 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,24 +1,52 @@ -import './sass/main.sass'; -import { App } from './ts/app'; +import { Http } from './ts/_service/http/http'; +import { Auth } from './ts/auth/auth'; +import { Logger } from './ts/logger'; +import { LoginPage } from './ts/pages/login.page'; +import { Router } from './ts/router/router'; -interface SyncManager { - getTags(): Promise; - register(tag: string): Promise; -} +import './sass/main.sass'; +import { IndexedDBManager } from './ts/_service/idb/idb'; +import { ChatPage } from './ts/pages/chat.page'; declare global { - interface ServiceWorkerRegistration { - readonly sync: SyncManager; + interface Window { + webkitSpeechRecognition: any; } } -if (navigator.serviceWorker) { - navigator.serviceWorker.register('./sw.js').then(async () => { - console.log( - '%c[ServiceWorker] Registered', - 'background: #F7C8E0; color: #000' - ); - }); +window.addEventListener('load', () => { + if ('serviceWorker' in navigator) { + navigator.serviceWorker + .register('/sw.js') + .then(() => { + console.log('[ServiceWorker] registered'); + }) + .catch(err => { + console.log('[ServiceWorker] registration failed'); + console.log(err); + }); + } +}); +class PwaChat { + constructor() { + Logger.getInstance().enableLogging(); + IndexedDBManager.getInstance(); + Auth.getInstance(); + Router.getInstance(); + LoginPage.getInstance(); + ChatPage.getInstance(); + Http.getInstance(); + + this.init(); + } + + private init() { + Router.getInstance().init(); + } } -const _app = new App(); +IndexedDBManager.getInstance() + .init() + .then(() => { + new PwaChat(); + }); diff --git a/src/manifest.json b/src/manifest.json new file mode 100644 index 0000000..e8f78b3 --- /dev/null +++ b/src/manifest.json @@ -0,0 +1,44 @@ +{ + "short_name": "PWA-Chat", + "name": "PWA-Chat", + "description": "PWA-Chat is a simple chat application built with PWA technology to give the look and feel of a native application.", + "icons": [ + { + "src": "assets/images/android-chrome-192x192.png", + "sizes": "192x192", + "type": "image/png" + }, + { + "src": "assets/images/android-chrome-512x512.png", + "sizes": "512x512", + "type": "image/png" + } + ], + "start_url": "/", + "display": "standalone", + "theme_color": "#2e2e2e", + "background_color": "#ffffff", + "orientation": "portrait", + "screenshots": [ + { + "src": "assets/images/screenshots/signin.png", + "type": "image/png", + "sizes": "462x945" + }, + { + "src": "assets/images/screenshots/light.png", + "type": "image/png", + "sizes": "462x945" + }, + { + "src": "assets/images/screenshots/dark.png", + "type": "image/png", + "sizes": "462x945" + }, + { + "src": "assets/images/screenshots/setting.png", + "type": "image/png", + "sizes": "462x945" + } + ] +} diff --git a/src/manifest.webmanifest b/src/manifest.webmanifest deleted file mode 100644 index a447ad7..0000000 --- a/src/manifest.webmanifest +++ /dev/null @@ -1,22 +0,0 @@ -{ - "short_name": "PWA Chat", - "name": "PWA Chat", - "icons": [ - { - "src": "assets/images/android-chrome-192x192.png", - "sizes": "192x192", - "type": "image/png" - }, - { - "src": "assets/images/android-chrome-512x512.png", - "sizes": "512x512", - "type": "image/png" - } - ], - "start_url": "/", - "id": "/", - "background_color": "#F7F7F7", - "display": "standalone", - "theme_color": "#8b9e70", - "description": "A PWA Chat Application to chat with people at HS-Esslingen." -} diff --git a/src/pages/404.html b/src/pages/404.html index 6cd22b0..5257d22 100644 --- a/src/pages/404.html +++ b/src/pages/404.html @@ -1 +1,10 @@ -

404

+
+

Hello world

+

404

+
+ diff --git a/src/pages/chat.html b/src/pages/chat.html index e690303..7e66fbf 100644 --- a/src/pages/chat.html +++ b/src/pages/chat.html @@ -1,53 +1,158 @@ -
-
- - - -
-

Chat

- -
-
-

Theme

-
- - -
-
-
-

Font Size

-
- -
-
-
-
-

Deregister

-
-
-
-
-
-
-
- - -
+
+
+
+

Chatroom

+ + +
+
+
+
+
+
+
+
+
+

Settings

+
+
+
+
+
Font Size
+

Set the Font Size to your Preference

+
+
+ + + +
+
+
+
+
Theme
+

Toggle between Light and Dark Mode

+
+
+ +
+
+
+
+
Highlight Color
+

Pick an Highlight Color

+
+
+ + +
+
+
+
+
Wallpaper
+

Change the wallpaper of the chat

+ Reset +
+
+
+
+
+
+
+
+
+
+
+
+ + +
+
+
+
+
+
Delete Account
+

Delete your account

+
+
+ +
+
+
+
+
+
+
+

Help

+
+
+
+
+
+

Log out

+
+
+
+
+
+
+
+
+
+ preview Current Image +
+
+
+
+
+
+
+ +
+
+
+
+ +
+
+ +
+
+ +
+ +
+
+
+ +
+
+ +
+
diff --git a/src/pages/login.html b/src/pages/login.html index 929e276..6f4253b 100644 --- a/src/pages/login.html +++ b/src/pages/login.html @@ -1,50 +1,157 @@ -
-
-

Sign in

+