Compare commits
32 Commits
v1.33.1_52
...
v1.34.0_53
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
948ff5530c | ||
|
|
2ff1a81f19 | ||
|
|
d90527a095 | ||
|
|
f0874ff3fd | ||
|
|
c8538cc62f | ||
|
|
bbe820d797 | ||
|
|
b5751a3fa8 | ||
|
|
02bc84062e | ||
|
|
dd8a4c0c56 | ||
|
|
4274fceafe | ||
|
|
da06440fdc | ||
|
|
c1c1d7fabb | ||
|
|
8b39a1da00 | ||
|
|
86e50f97ba | ||
|
|
0d7ccc2b26 | ||
|
|
5aa06ed3be | ||
|
|
d696ce4e41 | ||
|
|
2782dae518 | ||
|
|
0f9c2f0a38 | ||
|
|
296a5e786e | ||
|
|
db0a55cd65 | ||
|
|
32e79ce7b3 | ||
|
|
a898610f13 | ||
|
|
dc7df5bcfa | ||
|
|
dcefd53bfe | ||
|
|
cfa04fadd1 | ||
|
|
4a6c337960 | ||
|
|
3cf85bb837 | ||
|
|
dc2c92e721 | ||
|
|
b7f1a1ad4b | ||
|
|
1967c1e237 | ||
|
|
6e638cd673 |
297
README.md
@@ -1,36 +1,47 @@
|
||||
<h1 align="center"> Immich </h1>
|
||||
<p align="center"> <b>High performance self-hosted photo and video backup solution.</b> </p>
|
||||
<p align="center">
|
||||
<img src="design/feature-panel.png" title="Immich Logo">
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<p align="center">
|
||||
<br/>
|
||||
<a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/license-MIT-green.svg?color=3F51B5&style=for-the-badge&label=License&logoColor=000000&labelColor=ececec" alt="License: MIT"></a>
|
||||
<a href="https://github.com/alextran1502/immich"><img src="https://img.shields.io/github/stars/alextran1502/immich.svg?style=for-the-badge&logo=github&color=3F51B5&label=Stars&logoColor=000000&labelColor=ececec" alt="Star on Github"></a>
|
||||
<a href="https://immichci.little-home.net/viewType.html?buildTypeId=Immich_BuildAndroidAndGetArtifact&guest=1">
|
||||
<img src="https://img.shields.io/teamcity/http/immichci.little-home.net/s/Immich_BuildAndroidAndGetArtifact.svg?style=for-the-badge&label=Android&logo=teamcity&logoColor=000000&labelColor=ececec" alt="Android Build"/>
|
||||
</a>
|
||||
<a href="https://immichci.little-home.net/viewType.html?buildTypeId=Immich_BuildAndPublishIOSToTestFlight&guest=1">
|
||||
<img src="https://img.shields.io/teamcity/http/immichci.little-home.net/s/Immich_BuildAndPublishIOSToTestFlight.svg?style=for-the-badge&label=iOS&logo=teamcity&logoColor=000000&labelColor=ececec" alt="iOS Build"/>
|
||||
</a>
|
||||
<a href="https://actions-badge.atrox.dev/alextran1502/immich/goto?ref=main">
|
||||
<img alt="Build Status" src="https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Falextran1502%2Fimmich%2Fbadge%3Fref%3Dmain&style=for-the-badge&label=Github Action&logo=github&labelColor=ececec&logoColor=000000" />
|
||||
</a>
|
||||
<a href="https://discord.gg/D8JsnBEuKb">
|
||||
<img src="https://img.shields.io/discord/979116623879368755.svg?label=Immich%20Discord&logo=Discord&style=for-the-badge&logoColor=000000&labelColor=ececec" atl="Immich Discord"/>
|
||||
<img src="https://img.shields.io/discord/979116623879368755.svg?label=Discord&logo=Discord&style=for-the-badge&logoColor=000000&labelColor=ececec" atl="Discord"/>
|
||||
</a>
|
||||
<br/>
|
||||
<br/>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<img src="design/immich-logo.svg" width="150" title="Login With Custom URL">
|
||||
</p>
|
||||
<h3 align="center">Immich - High performance self-hosted photo and video backup solution</h3>
|
||||
<br/>
|
||||
<a href="https://immich.app">
|
||||
<img src="design/immich-screenshots.png" title="Main Screenshot">
|
||||
</a>
|
||||
<br/>
|
||||
|
||||
## Disclaimer
|
||||
|
||||
- ⚠️ The project is under **very active** development.
|
||||
- ⚠️ Expect bugs and breaking changes.
|
||||
- ⚠️ **Do not use as a single source to store of your photos and videos!**
|
||||
|
||||
## Content
|
||||
|
||||
- [Official Documentation](https://immich.app/docs/overview/introduction)
|
||||
- [Demo](#demo)
|
||||
- [Features](#features)
|
||||
- [Introduction](https://immich.app/docs/overview/introduction)
|
||||
- [Installation](https://immich.app/docs/installation/requirements)
|
||||
- [Contribution Guidelines](https://immich.app/docs/contribution-guidelines)
|
||||
- [Support The Project](#support-the-project)
|
||||
- [Known Issues](#known-issues)
|
||||
|
||||
## Demo
|
||||
|
||||
You can access the web demo at https://demo.immich.app
|
||||
|
||||
For the mobile app, you can use https://demo.immich.app/api for the `Server Endpoint URL`
|
||||
For the mobile app, you can use `https://demo.immich.app/api` for the `Server Endpoint URL`
|
||||
|
||||
|
||||
```
|
||||
```bash title="Demo Credential"
|
||||
The credential
|
||||
email: demo@immich.app
|
||||
password: demo
|
||||
@@ -40,236 +51,52 @@ password: demo
|
||||
Spec: Free-tier Oracle VM - Amsterdam - 2.4Ghz quad-core ARM64 CPU, 24GB RAM
|
||||
```
|
||||
|
||||
## Content
|
||||
- [Features](#features)
|
||||
- [Screenshots](#screenshots)
|
||||
- [Installation](#installation)
|
||||
- [Update](#update)
|
||||
- [Mobile App](#mobile-app)
|
||||
- [App Beta Invitation links](#App-Beta-release-channel)
|
||||
- [Development](#development)
|
||||
- [Support](#support)
|
||||
- [Known Issues](#known-issues)
|
||||
# Features
|
||||
|
||||
# Features
|
||||
| Features | Mobile | Web |
|
||||
| ------------------------------------------- | ------- | --- |
|
||||
| Upload and view videos and photos | Yes | Yes |
|
||||
| Auto backup when the app is opened | Yes | N/A |
|
||||
| Selective album(s) for backup | Yes | N/A |
|
||||
| Download photos and videos to local device | Yes | Yes |
|
||||
| Multi-user support | Yes | Yes |
|
||||
| Album | Yes | Yes |
|
||||
| Shared Albums | Yes | Yes |
|
||||
| Quick navigation with draggable scrollbar | Yes | Yes |
|
||||
| Support RAW (HEIC, HEIF, DNG, Apple ProRaw) | Yes | Yes |
|
||||
| Metadata view (EXIF, map) | Yes | Yes |
|
||||
| Search by metadata, objects and image tags | Yes | No |
|
||||
| Administrative functions (user management) | N/A | Yes |
|
||||
| Background backup | Android | N/A |
|
||||
| Virtual scroll | N/A | Yes |
|
||||
|
||||
> ⚠️ WARNING: **NOT READY FOR PRODUCTION! DO NOT USE TO STORE YOUR ASSETS**. This project is under heavy development. There will be continuous functions, features and api changes.
|
||||
# Support the project
|
||||
|
||||
| Features | Mobile | Web |
|
||||
| - | - | - |
|
||||
| Upload and view videos and photos | Yes | Yes
|
||||
| Auto backup when the app is opened | Yes | N/A
|
||||
| Selective album(s) for backup | Yes | N/A
|
||||
| Download photos and videos to local device | Yes | Yes
|
||||
| Multi-user support | Yes | Yes
|
||||
| Album | Yes | Yes
|
||||
| Shared Albums | Yes | Yes
|
||||
| Quick navigation with draggable scrollbar | Yes | Yes
|
||||
| Support RAW (HEIC, HEIF, DNG, Apple ProRaw) | Yes | Yes
|
||||
| Metadata view (EXIF, map) | Yes | Yes
|
||||
| Search by metadata, objects and image tags | Yes | No
|
||||
| Administrative functions (user management) | N/A | Yes
|
||||
| Background backup | Android | N/A
|
||||
| Virtual scroll | N/A | Yes
|
||||
I've committed to this project, and I will not stop. I will keep updating the docs, adding new features, and fixing bugs. But I can't do it alone. So I need your help to give me additional motivation to keep going.
|
||||
|
||||
As our hosts in the [selfhosted.show - In the episode 'The-organization-must-not-be-name is a Hostile Actor'](https://selfhosted.show/79?t=1418) said, this is a massive undertaking of what the team and I are doing. And I would love to someday be able to do this full-time, and I am asking for your help to make that happen.
|
||||
|
||||
<br/>
|
||||
If you feel like this is the right cause and the app is something you are seeing yourself using for a long time, please consider supporting the project with the option below.
|
||||
|
||||
# Screenshots
|
||||
## Donation
|
||||
|
||||
### Mobile
|
||||
| | | | | |
|
||||
| - | - | - | - | - |
|
||||
| <img src="design/login-screen.png" width="150" title="Login With Custom URL"> <p align="center"> Login with custom URL </p> | <img src="design/backup-screen.png" width="150" title="Backup Setting Info"> <p align="center"> Backup Settings </p> | <img src="design/selective-backup-screen.png" width="150" title="Backup Setting Info"> <p align="center"> Backup selection </p> | <img src="design/home-screen.jpeg" width="150" title="Home Screen"> <p align="center"> Home Screen </p> | <img src="design/search-screen.jpeg" width="150" title="Curated Search Info"> <p align="center"> Curated search </p> |
|
||||
| <img src="design/shared-albums.png" width="150" title="Shared Albums"> <p align="center"> Shared albums </p> | <img src="design/nsc6.png" width="150" title="EXIF Info"> <p align="center"> EXIF info </p> | <img src="https://media.giphy.com/media/y8ZeaAigGmNvlSoKhU/giphy.gif" width="150" title="Loading ~4000 images/videos"> <p align="center"> Loading ~4000 images/videos </p> |
|
||||
|
||||
### Web
|
||||
| Home Dashboard | Image view |
|
||||
| - | - |
|
||||
|<img src="design/web-home.jpeg" width="100%" title="Home Dashboard"> | <img src="design/web-detail.jpeg" width="100%" title="Detail">|
|
||||
|
||||
|
||||
<br/>
|
||||
|
||||
# Project Details
|
||||
## 💾 System Requirements
|
||||
|
||||
- **OS**: Preferred unix-based operating system (Ubuntu, Debian, MacOS...etc).
|
||||
|
||||
- **RAM**: At least 2GB, preferred 4GB.
|
||||
|
||||
- **Core**: At least 2 cores, preferred 4 cores.
|
||||
|
||||
## 🔩 Technology Stack
|
||||
|
||||
There are several services that compose Immich:
|
||||
|
||||
1. **NestJs** - Backend of the application
|
||||
2. **SvelteKit** - Web frontend of the application
|
||||
3. **PostgreSQL** - Main database of the application
|
||||
4. **Redis** - For sharing websocket instance between docker instances and background tasks message queue.
|
||||
5. **Nginx** - Load balancing and optimized file uploading.
|
||||
6. **TensorFlow** - Object Detection (COCO SSD) and Image Classification (ImageNet).
|
||||
|
||||
|
||||
<br/>
|
||||
|
||||
# Installation
|
||||
|
||||
NOTE: When using a reverse proxy in front of Immich (such as NGINX), the reverse proxy might require extra configuration to allow large files to be uploaded (such as `client_max_body_size` in the case of NGINX).
|
||||
## Testing one-step installation (not recommended for production)
|
||||
|
||||
> ⚠️ *This installation method is for evaluating Immich before further customization to meet the users' needs.*
|
||||
|
||||
*Applicable operating systems: Ubuntu, Debian, MacOS*
|
||||
|
||||
- In the shell, from the directory of your choice, run the following command:
|
||||
|
||||
```bash
|
||||
curl -o- https://raw.githubusercontent.com/immich-app/immich/main/install.sh | bash
|
||||
```
|
||||
|
||||
This script will download the `docker-compose.yml` file and the `.env` file, then populate the necessary information, and finally run the `docker-compose up` or `docker compose up` (based on your docker's version) command.
|
||||
|
||||
The web application will be available at `http://<machine-ip-address>:2283`, and the server URL for the mobile app will be `http://<machine-ip-address>:2283/api`.
|
||||
|
||||
The directory which is used to store the backup file is `./immich-app/immich-data`.
|
||||
|
||||
|
||||
<br/>
|
||||
|
||||
## Custom installation (Recommended)
|
||||
|
||||
### Step 1 - Download necessary files
|
||||
|
||||
- Create a directory called `immich-app` and cd into it.
|
||||
|
||||
- Get `docker-compose.yml`
|
||||
|
||||
```bash
|
||||
wget https://raw.githubusercontent.com/immich-app/immich/main/docker/docker-compose.yml
|
||||
```
|
||||
|
||||
- Get `.env`
|
||||
|
||||
```bash
|
||||
wget -O .env https://raw.githubusercontent.com/immich-app/immich/main/docker/.env.example
|
||||
```
|
||||
|
||||
### Step 2 - Populate .env file with custom information
|
||||
|
||||
<a href="https://github.com/immich-app/immich/blob/main/docker/.env.example" target="_blank"><b>See the example <code>.env</code> file</b></a>
|
||||
|
||||
* Populate custom database information if necessary.
|
||||
* Populate `UPLOAD_LOCATION` as prefered location for storing backup assets.
|
||||
* Populate a secret value for `JWT_SECRET`, you can use this command: `openssl rand -base64 128`
|
||||
|
||||
### Step 3 - Start the containers
|
||||
|
||||
- Run `docker-compose up` or `docker compose up` (based on your docker's version)
|
||||
|
||||
### Step 4 - Register admin user
|
||||
|
||||
- Navigate to the web at `http://<machine-ip-address>:2283` and follow the prompts to register admin user.
|
||||
<p align="center">
|
||||
<img src="design/admin-registration-form.png" width="300" title="Admin Registration">
|
||||
</p>
|
||||
|
||||
- You can add and manage users from the administration page.
|
||||
<p align="center">
|
||||
<img src="design/admin-interface.png" width="500" title="Admin User Management">
|
||||
</p>
|
||||
|
||||
### Step 5 - Access the mobile app
|
||||
|
||||
- Login the mobile app with the server endpoint URL at `http://<machine-ip-address>:2283/api`
|
||||
<p align="center">
|
||||
<img src="design/login-screen.jpeg" width="250" title="Example login screen">
|
||||
</p>
|
||||
|
||||
<br/>
|
||||
|
||||
## Update
|
||||
|
||||
If you have installed, you can update the application by navigate to the directory that contains the `docker-compose.yml` file and run the following command:
|
||||
|
||||
```bash
|
||||
docker-compose pull && docker-compose up -d
|
||||
```
|
||||
# Unraid Installation
|
||||
|
||||
Please follow this [article](https://mfaz.dev/posts/immich-unraid/) for a tutorial on how to install Immich on Unraid
|
||||
|
||||
|
||||
# Mobile app
|
||||
|
||||
| F-Droid | Google Play | iOS |
|
||||
| - | - | - |
|
||||
| <a href="https://f-droid.org/packages/app.alextran.immich"><img src="https://fdroid.gitlab.io/artwork/badge/get-it-on.png" alt="Get it on F-Droid" height="80"></a> | <p align="left"> <a href="https://play.google.com/store/apps/details?id=app.alextran.immich"><img src="design/google-play-qr-code.png" width="200" title="Google Play Store"></a> <p/> | <p align="left"> <a href="https://apps.apple.com/us/app/immich/id1613945652"><img src="design/ios-qr-code.png" width="200" title="Apple App Store"></a> <p/> |
|
||||
|
||||
> *The Play/App Store version might be lagging behind the latest release due to their review process.*
|
||||
|
||||
# App Beta release channel
|
||||
|
||||
You can opt-in to join app beta release channel by following the links below:
|
||||
* Android: Invitation link from [web](https://play.google.com/store/apps/details?id=app.alextran.immich) or from [mobile](https://play.google.com/store/apps/details?id=app.alextran.immich)
|
||||
* iOS: [TestFlight invitation link](https://testflight.apple.com/join/1vYsAa8P)
|
||||
<br/>
|
||||
|
||||
# Development
|
||||
|
||||
The development environment can be started from the root of the project after populating the `.env` file with the command:
|
||||
|
||||
```bash
|
||||
make dev # required Makefile installed on the system.
|
||||
```
|
||||
|
||||
All servers and web container are hot reload for quick feedback loop.
|
||||
|
||||
## Note for developers
|
||||
### 1 - OpenAPI
|
||||
OpenAPI is used to generate the client (Typescript, Dart) SDK. `openapi-generator-cli` can be installed [here](https://openapi-generator.tech/docs/installation/). When you add a new or modify an existing endpoint, you must run the generate command below to update the client SDK.
|
||||
|
||||
```bash
|
||||
npm run api:generate # Run from server directory
|
||||
```
|
||||
You can find the generated client SDK in the [`web/src/api`](web/src/api) for Typescript SDK and [`mobile/openapi`](mobile/openapi) for Dart SDK.
|
||||
|
||||
|
||||
<br/>
|
||||
|
||||
# Support
|
||||
|
||||
If you like the app, find it helpful, and want to support me to offset the cost of publishing to AppStores, you can sponsor the project with [**one time**](https://github.com/sponsors/alextran1502?frequency=one-time&sponsor=alextran1502) or monthly donation from [**Github Sponsor**](https://github.com/sponsors/alextran1502).
|
||||
|
||||
You can also donate using crypto currency with the following addresses:
|
||||
|
||||
<p align="" style="display: flex; place-items: center; gap: 15px" title="Bitcoin(BTC)"><img src="design/bitcoin.png" width="25" title="Bitcoin"> <b>Bitcoin</b>: <code>1FvEp6P6NM8EZEkpGUFAN2LqJ1gxusNxZX</code></p>
|
||||
|
||||
<p align="" style="display: flex; place-items: center; gap: 15px" title="Cardano(ADA)"> <img src="design/cardano.png" width="30" title="Cardano"> <b>Cardano</b>: <code>addr1qyy567vqhqrr3p7vpszr5p264gw89sqcwts2z8wqy4yek87cdmy79zazyjp7tmwhkluhk3krvslkzfvg0h43tytp3f5q49nycc</code> </p>
|
||||
|
||||
|
||||
This is also a meaningful way to give me motivation and encouragement to continue working on the app.
|
||||
|
||||
Cheers! 🎉
|
||||
|
||||
|
||||
<br/>
|
||||
- [Monthly donation](https://github.com/sponsors/alextran1502) via GitHub Sponsors
|
||||
- [One-time donation](https://github.com/sponsors/alextran1502?frequency=one-time&sponsor=alextran1502) via Github Sponsors
|
||||
|
||||
# Known Issues
|
||||
|
||||
## TensorFlow Build Issue
|
||||
|
||||
*This is a known issue for incorrect Proxmox setup*
|
||||
_This is a known issue for incorrect Proxmox setup_
|
||||
|
||||
TensorFlow doesn't run with older CPU architecture, it requires a CPU with AVX and AVX2 instruction set. If you encounter the error `illegal instruction core dump` when running the docker-compose command above, check for your CPU flags with the command and make sure you see `AVX` and `AVX2`:
|
||||
|
||||
|
||||
```bash
|
||||
more /proc/cpuinfo | grep flags
|
||||
```
|
||||
|
||||
```
|
||||
|
||||
If you are running virtualization in Proxmox, the VM doesn't have the flag enabled.
|
||||
|
||||
|
||||
You need to change the CPU type from `kvm64` to `host` under VMs hardware tab.
|
||||
|
||||
|
||||
`Hardware > Processors > Edit > Advanced > Type (dropdown menu) > host`
|
||||
|
||||
BIN
design/immich-screenshots.png
Normal file
|
After Width: | Height: | Size: 1.7 MiB |
@@ -1,5 +1,5 @@
|
||||
---
|
||||
sidebar_position: 4
|
||||
sidebar_position: 6
|
||||
---
|
||||
|
||||
# FAQ
|
||||
82
docs/docs/contribution-guidelines.md
Normal file
@@ -0,0 +1,82 @@
|
||||
---
|
||||
sidebar_position: 5
|
||||
---
|
||||
|
||||
# Contribution guidelines
|
||||
|
||||
## Environment setup
|
||||
|
||||
### Server and web app
|
||||
|
||||
This environment includes the following services:
|
||||
|
||||
- Core server - `/server/apps/immich`
|
||||
- Machine learning - `/machine-learning`
|
||||
- Microservices - `/server/apps/microservicess`
|
||||
- Web app - `/web`
|
||||
- Redis
|
||||
- PostgreSQL development database with exposed port `5432` so you can use any database client to acess it
|
||||
- NGINX Proxy - `nginx/nginx.conf`
|
||||
|
||||
All the services are packaged to run as with single Docker Compose command.
|
||||
|
||||
After cloning the project, from the root directory run
|
||||
|
||||
```bash title="Start development server"
|
||||
make dev # required Makefile installed on the system.
|
||||
```
|
||||
|
||||
All the services will be started with hot-reloading enabled for a quick feedback loop.
|
||||
|
||||
### Mobile app
|
||||
|
||||
The mobile app `(/mobile)` will required Flutter toolchain to be installed on your system.
|
||||
|
||||
Please refer to the [Flutter's official documentation](https://flutter.dev/docs/get-started/install) for more information on setting up the toolchain on your machine.
|
||||
|
||||
## IDE setup
|
||||
|
||||
### Lint / format extensions
|
||||
|
||||
Setting these in the IDE give a better developer experience, auto-formatting code on save, and providing instant feedback on lint issues.
|
||||
|
||||
### VSCode
|
||||
|
||||
Install `Flutter`, `Prettier`, `ESLint` and `Svelte` extensions.
|
||||
|
||||
in User `settings.json` (`cmd + shift + p` and search for `Open User Settings JSON`) add the following:
|
||||
|
||||
```json title="settings.json"
|
||||
{
|
||||
"editor.formatOnSave": true,
|
||||
"[javascript][typescript][css]": {
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
||||
"editor.tabSize": 2,
|
||||
"editor.formatOnSave": true
|
||||
},
|
||||
"[svelte]": {
|
||||
"editor.defaultFormatter": "svelte.svelte-vscode",
|
||||
"editor.tabSize": 2
|
||||
},
|
||||
"svelte.enable-ts-plugin": true,
|
||||
"eslint.validate": ["javascript", "svelte"],
|
||||
"[dart]": {
|
||||
"editor.formatOnSave": true,
|
||||
"editor.selectionHighlight": false,
|
||||
"editor.suggest.snippetsPreventQuickSuggestions": false,
|
||||
"editor.suggestSelection": "first",
|
||||
"editor.tabCompletion": "onlySnippets",
|
||||
"editor.wordBasedSuggestions": false,
|
||||
"editor.defaultFormatter": "Dart-Code.dart-code"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## OpenAPI generator
|
||||
|
||||
OpenAPI is used to generate the client (Typescript, Dart) SDK. `openapi-generator-cli` can be installed [here](https://openapi-generator.tech/docs/installation/). When you add a new or modify an existing endpoint, you must run the command below to update the client SDK.
|
||||
|
||||
```bash
|
||||
npm run api:generate # Run from the `server` directory
|
||||
```
|
||||
You can find the generated client SDK in the `web/src/api` for Typescript SDK and `mobile/openapi` for Dart SDK.
|
||||
BIN
docs/docs/installation/img/dot-env.png
Normal file
|
After Width: | Height: | Size: 211 KiB |
BIN
docs/docs/installation/img/env-1.png
Normal file
|
After Width: | Height: | Size: 33 KiB |
BIN
docs/docs/installation/img/env-2.png
Normal file
|
After Width: | Height: | Size: 202 KiB |
@@ -0,0 +1,29 @@
|
||||
---
|
||||
sidebar_position: 2
|
||||
---
|
||||
|
||||
# One-step installation
|
||||
|
||||
:::caution
|
||||
This method is for evaluation purposes only. It is not recommended for production use. For production usage, please refer to the recommended installation method [here](/docs/installation/recommended-installation).
|
||||
:::
|
||||
|
||||
In the shell, from a directory of your choice, run the following command:
|
||||
|
||||
```bash
|
||||
curl -o- https://raw.githubusercontent.com/immich-app/immich/main/install.sh | bash
|
||||
```
|
||||
|
||||
The script will perform the following actions:
|
||||
|
||||
1. Download [docker-compose.yml](https://github.com/immich-app/immich/blob/main/docker/docker-compose.yml), and the [.env](https://github.com/immich-app/immich/blob/main/docker/.env.example) file from the main branch of the [repository](https://github.com/immich-app/immich).
|
||||
2. Populate the `.env` file with necessary information based on the current directory path.
|
||||
3. Start the containers.
|
||||
|
||||
The web application will be available at `http://<machine-ip-address>:2283`, and the server URL for the mobile app will be `http://<machine-ip-address>:2283/api`
|
||||
|
||||
The directory which is used to store the backup file is `./immich-app/immich-data` relative to the current directory.
|
||||
|
||||
:::tip
|
||||
For more information on how to use the application, please refer to the [Post Installation](/docs/usage/post-installation) guide.
|
||||
:::
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
---
|
||||
sidebar_position: 4
|
||||
---
|
||||
|
||||
# Portainer
|
||||
|
||||
Install Immich using Portainer's Stack feature.
|
||||
|
||||
1. Go to "**Stacks**" in the left sidebar.
|
||||
2. Click on "**Add stack**".
|
||||
3. Give the stack a name (i.e. Immich), and select "**Web Editor**" as the build method.
|
||||
4. Copy the content of the `docker-compose.yml` file from the [GitHub repository](https://raw.githubusercontent.com/immich-app/immich/main/docker/docker-compose.yml)
|
||||
5. Replace `.env` with `stack.env` for all containers that need to use environment variables in the web editor.
|
||||
|
||||
<img
|
||||
src={require('./img/dot-env.png').default}
|
||||
width="50%"
|
||||
style={{border: '1px solid #ddd'}}
|
||||
alt="Dot Env Example"
|
||||
/>
|
||||
|
||||
8. Click on "**Advanced Mode**" in the **Environment Variables** section.
|
||||
|
||||
<img
|
||||
src={require('./img/env-1.png').default}
|
||||
width="50%"
|
||||
style={{border: '1px solid #ddd'}}
|
||||
alt="Dot Env Example"
|
||||
/>
|
||||
|
||||
9. Copy the content of the `.env.example` file from the [GitHub repository](https://raw.githubusercontent.com/immich-app/immich/main/docker/.env.example) and paste to the editor.
|
||||
10. Switch back to "**Simple Mode**".
|
||||
|
||||
<img
|
||||
src={require('./img/env-2.png').default}
|
||||
width="50%"
|
||||
style={{border: '1px solid #ddd'}}
|
||||
alt="Dot Env Example"
|
||||
/>
|
||||
|
||||
* Populate custom database information if necessary.
|
||||
* Populate `UPLOAD_LOCATION` as prefered location for storing backup assets.
|
||||
* Populate a secret value for `JWT_SECRET`, you can use the command below to generate a secured key
|
||||
|
||||
```bash title="Generate secure JWT_SECRET key"
|
||||
openssl rand -base64 128
|
||||
```
|
||||
|
||||
11. Click on "**Deploy the stack**".
|
||||
|
||||
|
||||
:::tip
|
||||
For more information on how to use the application, please refer to the [Post Installation](/docs/usage/post-installation) guide.
|
||||
:::
|
||||
|
||||
120
docs/docs/installation/recommended-installation.md
Normal file
@@ -0,0 +1,120 @@
|
||||
---
|
||||
sidebar_position: 3
|
||||
---
|
||||
|
||||
|
||||
# Recommended installation
|
||||
|
||||
This is the recommended installation method for production use.
|
||||
|
||||
### Step 1 - Download the required files
|
||||
|
||||
From a directory of your choice (e.g. `./immich-app`) run the following commands
|
||||
|
||||
```bash title="Get docker-compose.yml file"
|
||||
wget https://raw.githubusercontent.com/immich-app/immich/main/docker/docker-compose.yml
|
||||
```
|
||||
|
||||
```bash title="Get .env file"
|
||||
wget -O .env https://raw.githubusercontent.com/immich-app/immich/main/docker/.env.example
|
||||
```
|
||||
|
||||
### Step 2 - Populate the .env file with custom values
|
||||
|
||||
<details>
|
||||
|
||||
<summary>Example <code>.env</code> content</summary>
|
||||
|
||||
```bash
|
||||
###################################################################################
|
||||
# Database
|
||||
###################################################################################
|
||||
|
||||
DB_HOSTNAME=immich_postgres
|
||||
DB_USERNAME=postgres
|
||||
DB_PASSWORD=postgres
|
||||
DB_DATABASE_NAME=immich
|
||||
|
||||
# Optional Database settings:
|
||||
# DB_PORT=5432
|
||||
|
||||
###################################################################################
|
||||
# Redis
|
||||
###################################################################################
|
||||
|
||||
REDIS_HOSTNAME=immich_redis
|
||||
|
||||
# Optional Redis settings:
|
||||
# REDIS_PORT=6379
|
||||
# REDIS_DBINDEX=0
|
||||
# REDIS_PASSWORD=
|
||||
# REDIS_SOCKET=
|
||||
|
||||
###################################################################################
|
||||
# Upload File Config
|
||||
###################################################################################
|
||||
|
||||
UPLOAD_LOCATION=absolute_location_on_your_machine_where_you_want_to_store_the_backup
|
||||
|
||||
###################################################################################
|
||||
# Log message level - [simple|verbose]
|
||||
###################################################################################
|
||||
|
||||
LOG_LEVEL=simple
|
||||
|
||||
###################################################################################
|
||||
# JWT SECRET
|
||||
###################################################################################
|
||||
|
||||
# This JWT_SECRET is used to sign the authentication keys for user login
|
||||
# You should set it to a long randomly generated value
|
||||
# You can use this command to generate one: openssl rand -base64 128
|
||||
JWT_SECRET=kWPdavjCECB0yoXgUHA/vpwpIKdCi/4ODVLIOe9WIi6AQlFfjWEuIVhWT3DtJE+T
|
||||
CTckJnpwGgSK5AoqD+A8DZKsHCRdfVnlQIVqqmyR8isZTcxL5DWYQUSDRzyOO5OA
|
||||
ZRUTE63FxiYhrRoe/y1yr5mV1osGy6mm6NZW8T2Tjwc=
|
||||
|
||||
###################################################################################
|
||||
# Reverse Geocoding
|
||||
####################################################################################
|
||||
|
||||
# DISABLE_REVERSE_GEOCODING=false
|
||||
|
||||
# Reverse geocoding is done locally which has a small impact on memory usage
|
||||
# This memory usage can be altered by changing the REVERSE_GEOCODING_PRECISION variable
|
||||
# This ranges from 0-3 with 3 being the most precise
|
||||
# 3 - Cities > 500 population: ~200MB RAM
|
||||
# 2 - Cities > 1000 population: ~150MB RAM
|
||||
# 1 - Cities > 5000 population: ~80MB RAM
|
||||
# 0 - Cities > 15000 population: ~40MB RAM
|
||||
|
||||
# REVERSE_GEOCODING_PRECISION=3
|
||||
|
||||
####################################################################################
|
||||
# WEB - Optional
|
||||
####################################################################################
|
||||
|
||||
# Custom message on the login page, should be written in HTML form.
|
||||
# For example PUBLIC_LOGIN_PAGE_MESSAGE="This is a demo instance of Immich.<br><br>Email: <i>demo@demo.de</i><br>Password: <i>demo</i>"
|
||||
|
||||
PUBLIC_LOGIN_PAGE_MESSAGE="My Family Photos and Videos Backup Server"
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
* Populate custom database information if necessary.
|
||||
* Populate `UPLOAD_LOCATION` as prefered location for storing backup assets.
|
||||
* Populate a secret value for `JWT_SECRET`, you can use the command below to generate a secure key
|
||||
|
||||
```bash title="Command to generate secure JWT_SECRET key"
|
||||
openssl rand -base64 128
|
||||
```
|
||||
|
||||
### Step 3 - Start the containers
|
||||
|
||||
```bash title="Start the containers using docker compose command"
|
||||
docker-compose up -d # or `docker compose up -d` based on your docker-compose version
|
||||
```
|
||||
|
||||
:::tip
|
||||
For more information on how to use the application, please refer to the [Post Installation](/docs/usage/post-installation) guide.
|
||||
:::
|
||||
@@ -0,0 +1,31 @@
|
||||
---
|
||||
sidebar_position: 1
|
||||
---
|
||||
|
||||
|
||||
# Requirements
|
||||
Hardware and software requirements for Immich
|
||||
|
||||
## Software
|
||||
|
||||
- [Docker](https://docs.docker.com/get-docker/)
|
||||
- [Docker Compose](https://docs.docker.com/compose/install/)
|
||||
|
||||
:::info Podman
|
||||
You can also use Podman to run the application. However, additional configurations might be required on your end.
|
||||
:::
|
||||
|
||||
## Hardware
|
||||
|
||||
- **OS**: Preferred unix-based operating system (Ubuntu, Debian, MacOS...etc). Windows works too, with [Docker Desktop on Windows](https://docs.docker.com/desktop/install/windows-install/)
|
||||
- **Ram**: At least 2GB, preferred 4GB.
|
||||
- **Core**: At least 2 cores, preferred 4 cores.
|
||||
|
||||
## Installation methods
|
||||
|
||||
There are a couple installation methods that you can use to install the application. You can choose the one that suits you the best.
|
||||
|
||||
1. [One-step installation (Evaluation only)](/docs/installation/one-step-installation)
|
||||
2. **[Docker Compose with manual configuration (Recommended)](/docs/installation/recommended-installation)**
|
||||
3. [Portainer](/docs/installation/portainer-installation)
|
||||
4. [Unraid (Community contribution)](/docs/installation/unraid-installation)
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
---
|
||||
sidebar_position: 5
|
||||
---
|
||||
|
||||
# Unraid
|
||||
|
||||
Install Immich on Unraid.
|
||||
|
||||
:::info Community contribution
|
||||
Please follow this community contributed [article](https://mfaz.dev/posts/immich-unraid/) to install Immich on Unraid.
|
||||
:::
|
||||
|
||||
:::tip
|
||||
For more information on how to use the application, please refer to the [Post Installation](/docs/usage/post-installation) guide.
|
||||
:::
|
||||
@@ -1,5 +1,12 @@
|
||||
---
|
||||
sidebar_position: 5
|
||||
sidebar_position: 4
|
||||
---
|
||||
|
||||
# Mobile App Beta Program
|
||||
|
||||
# Mobile app Beta program
|
||||
|
||||
Join the beta release channel to test the latest update of the app
|
||||
|
||||
You can opt-in to join app beta release channel by following the links below:
|
||||
* Android: Invitation link from [web](https://play.google.com/store/apps/details?id=app.alextran.immich) or from [mobile](https://play.google.com/store/apps/details?id=app.alextran.immich)
|
||||
* iOS: [TestFlight invitation link](https://testflight.apple.com/join/1vYsAa8P)
|
||||
BIN
docs/docs/overview/img/alex-picture.jpeg
Normal file
|
After Width: | Height: | Size: 20 KiB |
BIN
docs/docs/overview/img/app-architecture.png
Normal file
|
After Width: | Height: | Size: 691 KiB |
BIN
docs/docs/overview/img/appicon.png
Normal file
|
After Width: | Height: | Size: 115 KiB |
BIN
docs/docs/overview/img/feature-panel.png
Normal file
|
After Width: | Height: | Size: 48 KiB |
@@ -1,7 +0,0 @@
|
||||
---
|
||||
sidebar_position: 1
|
||||
---
|
||||
|
||||
# Introduction
|
||||
|
||||
This is the first
|
||||
25
docs/docs/overview/introduction.mdx
Normal file
@@ -0,0 +1,25 @@
|
||||
---
|
||||
sidebar_position: 1
|
||||
---
|
||||
|
||||
# Introduction
|
||||
|
||||
Hello, I am glad you are here.
|
||||
|
||||
<p style={{textAlign: 'center'}}>
|
||||
|
||||

|
||||
|
||||
</p>
|
||||
|
||||
My name is Alex. I am an Electrical Engineer by schooling, then turned into a Software Engineer by trade and the pure love of problem solving.
|
||||
|
||||
We were lying in bed with our newborn, and my wife said, "We are starting to accumulate a lot of photos and videos of our baby, and I don't want to pay for **_App-Which-Must-Not-Be-Named_** anymore. You always want to build something for me, so why don't you build me an app which can do that?"
|
||||
|
||||
That was how the idea started to grow in my head. After that, I began to find existing solutions in the self-hosting space with similar backup functionality and the performance level of the **_App-Which-Must-Not-Be-Named_**. I found that the current solutions mainly focus on the gallery-type application. However, I want a simple-to-use backup tool with a native mobile app that can view photos and videos efficiently. So I set sail on this journey as a hungry engineer on the hunt.
|
||||
|
||||
Another motivation that pushed me to deliver my execution of the **_App-Which-Must-Not-Be-Named_** alternative or replacement is for contributing back to the open source community that I have greatly benefited from over the years.
|
||||
|
||||
I'm proud to share this creation with you, which values privacy, memories, and the joy of looking back at those moments in an easy-to-use and friendly interface.
|
||||
|
||||
If you like the application or it helps you in some way, please consider [supporting](./support-the-project.md) to the project. It will help me to continue to develop and maintain the application.
|
||||
@@ -2,4 +2,16 @@
|
||||
sidebar_position: 2
|
||||
---
|
||||
|
||||
# Logo meaning
|
||||
# Logo meaning
|
||||
|
||||
Why the colorful flower, you ask?
|
||||
|
||||
I really like the Japanese culture, especially the books, history, and food. The current logo is a spin-off of [the Oda clan's symbol](https://en.wikipedia.org/wiki/Oda_clan).
|
||||
|
||||

|
||||
|
||||
One of my favorite books is [Taikō](https://www.goodreads.com/book/show/336228.Taiko), it is the story about a prominent figure in the history of Japan, [Toyotomy Hideyoshi](https://www.britannica.com/biography/Toyotomi-Hideyoshi). He came from nothing, and through his resilience and wonderful mind, he has become one of the most powerful rulers in Japan's history. I enjoy his personality and the way he moved through life.
|
||||
|
||||
The color is an adaptation of **_App-Which-Must-Not-Be-Named_**'s color scheme, with an extra color (pink) to complete the flower's fifth petal. The petal layers are the same color scheme as the main layer rotating back and forth to "bring the flower to life."
|
||||
|
||||

|
||||
|
||||
@@ -2,4 +2,19 @@
|
||||
sidebar_position: 3
|
||||
---
|
||||
|
||||
# Support the project
|
||||
# Support the project
|
||||
|
||||
I've committed to this project, and I will not stop. I will keep updating the docs, adding new features, and fixing bugs. But I can't do it alone, so I need your help to give me additional motivation to keep going.
|
||||
|
||||
As our hosts in the [selfhosted.show - In the episode 'The-organization-must-not-be-name is a Hostile Actor'](https://selfhosted.show/79?t=1418) said, this is a massive undertaking; what the team and I are doing. I would love to someday be able to do this full-time, and I am asking for your help to make that happen.
|
||||
|
||||
If you feel like this is the right cause and the app is something you see yourself using for a long time, please consider supporting the project with the options below.
|
||||
|
||||
## Donation
|
||||
|
||||
* Monthly donation via [GitHub Sponsors](https://github.com/sponsors/alextran1502)
|
||||
* One-time donation via [Github Sponsors](https://github.com/sponsors/alextran1502?frequency=one-time&sponsor=alextran1502)
|
||||
|
||||
## Contribution
|
||||
|
||||
If you are a programmer/developer and the app's [technology stack](./technology-stack.md) is something you are familiar with, please consider contributing to the project. The team and I are always looking for new contributors. You can refer to the [contribution guildelines](/docs/contribution-guidelines) to start leaving your mark on the project.
|
||||
|
||||
@@ -2,4 +2,22 @@
|
||||
sidebar_position: 4
|
||||
---
|
||||
|
||||
# Technology stack
|
||||
# Technology stack
|
||||
|
||||
The app is built with the following technologies
|
||||
|
||||
## Frontend
|
||||
* [Flutter](https://flutter.dev/) for the mobile app
|
||||
* [Riverpod](https://riverpod.dev/) as state management.
|
||||
* [SvelteKit](https://kit.svelte.dev/) for the Web.
|
||||
|
||||
## Backend
|
||||
* [Nest.js](https://nestjs.com/) for the server.
|
||||
* [TypeORM](https://typeorm.io/) for database management.
|
||||
* [PostgreSQL](https://www.postgresql.org/) for the database.
|
||||
* [Redis](https://redis.io/) for communication between the core server and the microservices.
|
||||
* [NGINX](https://www.nginx.com/) for internal communication between containers and load balancing when scaling.
|
||||
|
||||
## High level architecture
|
||||
|
||||

|
||||
@@ -1,8 +0,0 @@
|
||||
{
|
||||
"label": "Tutorial - Basics",
|
||||
"position": 6,
|
||||
"link": {
|
||||
"type": "generated-index",
|
||||
"description": "5 minutes to learn the most important Docusaurus concepts."
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
---
|
||||
sidebar_position: 6
|
||||
---
|
||||
|
||||
# Congratulations!
|
||||
|
||||
You have just learned the **basics of Docusaurus** and made some changes to the **initial template**.
|
||||
|
||||
Docusaurus has **much more to offer**!
|
||||
|
||||
Have **5 more minutes**? Take a look at **[versioning](../tutorial-extras/manage-docs-versions.md)** and **[i18n](../tutorial-extras/translate-your-site.md)**.
|
||||
|
||||
Anything **unclear** or **buggy** in this tutorial? [Please report it!](https://github.com/facebook/docusaurus/discussions/4610)
|
||||
|
||||
## What's next?
|
||||
|
||||
- Read the [official documentation](https://docusaurus.io/)
|
||||
- Modify your site configuration with [`docusaurus.config.js`](https://docusaurus.io/docs/api/docusaurus-config)
|
||||
- Add navbar and footer items with [`themeConfig`](https://docusaurus.io/docs/api/themes/configuration)
|
||||
- Add a custom [Design and Layout](https://docusaurus.io/docs/styling-layout)
|
||||
- Add a [search bar](https://docusaurus.io/docs/search)
|
||||
- Find inspirations in the [Docusaurus showcase](https://docusaurus.io/showcase)
|
||||
- Get involved in the [Docusaurus Community](https://docusaurus.io/community/support)
|
||||
@@ -1,34 +0,0 @@
|
||||
---
|
||||
sidebar_position: 3
|
||||
---
|
||||
|
||||
# Create a Blog Post
|
||||
|
||||
Docusaurus creates a **page for each blog post**, but also a **blog index page**, a **tag system**, an **RSS** feed...
|
||||
|
||||
## Create your first Post
|
||||
|
||||
Create a file at `blog/2021-02-28-greetings.md`:
|
||||
|
||||
```md title="blog/2021-02-28-greetings.md"
|
||||
---
|
||||
slug: greetings
|
||||
title: Greetings!
|
||||
authors:
|
||||
- name: Joel Marcey
|
||||
title: Co-creator of Docusaurus 1
|
||||
url: https://github.com/JoelMarcey
|
||||
image_url: https://github.com/JoelMarcey.png
|
||||
- name: Sébastien Lorber
|
||||
title: Docusaurus maintainer
|
||||
url: https://sebastienlorber.com
|
||||
image_url: https://github.com/slorber.png
|
||||
tags: [greetings]
|
||||
---
|
||||
|
||||
Congratulations, you have made your first post!
|
||||
|
||||
Feel free to play around and edit this post as much you like.
|
||||
```
|
||||
|
||||
A new blog post is now available at [http://localhost:3000/blog/greetings](http://localhost:3000/blog/greetings).
|
||||
@@ -1,57 +0,0 @@
|
||||
---
|
||||
sidebar_position: 2
|
||||
---
|
||||
|
||||
# Create a Document
|
||||
|
||||
Documents are **groups of pages** connected through:
|
||||
|
||||
- a **sidebar**
|
||||
- **previous/next navigation**
|
||||
- **versioning**
|
||||
|
||||
## Create your first Doc
|
||||
|
||||
Create a Markdown file at `docs/hello.md`:
|
||||
|
||||
```md title="docs/hello.md"
|
||||
# Hello
|
||||
|
||||
This is my **first Docusaurus document**!
|
||||
```
|
||||
|
||||
A new document is now available at [http://localhost:3000/docs/hello](http://localhost:3000/docs/hello).
|
||||
|
||||
## Configure the Sidebar
|
||||
|
||||
Docusaurus automatically **creates a sidebar** from the `docs` folder.
|
||||
|
||||
Add metadata to customize the sidebar label and position:
|
||||
|
||||
```md title="docs/hello.md" {1-4}
|
||||
---
|
||||
sidebar_label: 'Hi!'
|
||||
sidebar_position: 3
|
||||
---
|
||||
|
||||
# Hello
|
||||
|
||||
This is my **first Docusaurus document**!
|
||||
```
|
||||
|
||||
It is also possible to create your sidebar explicitly in `sidebars.js`:
|
||||
|
||||
```js title="sidebars.js"
|
||||
module.exports = {
|
||||
tutorialSidebar: [
|
||||
'intro',
|
||||
// highlight-next-line
|
||||
'hello',
|
||||
{
|
||||
type: 'category',
|
||||
label: 'Tutorial',
|
||||
items: ['tutorial-basics/create-a-document'],
|
||||
},
|
||||
],
|
||||
};
|
||||
```
|
||||
@@ -1,43 +0,0 @@
|
||||
---
|
||||
sidebar_position: 1
|
||||
---
|
||||
|
||||
# Create a Page
|
||||
|
||||
Add **Markdown or React** files to `src/pages` to create a **standalone page**:
|
||||
|
||||
- `src/pages/index.js` → `localhost:3000/`
|
||||
- `src/pages/foo.md` → `localhost:3000/foo`
|
||||
- `src/pages/foo/bar.js` → `localhost:3000/foo/bar`
|
||||
|
||||
## Create your first React Page
|
||||
|
||||
Create a file at `src/pages/my-react-page.js`:
|
||||
|
||||
```jsx title="src/pages/my-react-page.js"
|
||||
import React from 'react';
|
||||
import Layout from '@theme/Layout';
|
||||
|
||||
export default function MyReactPage() {
|
||||
return (
|
||||
<Layout>
|
||||
<h1>My React page</h1>
|
||||
<p>This is a React page</p>
|
||||
</Layout>
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
A new page is now available at [http://localhost:3000/my-react-page](http://localhost:3000/my-react-page).
|
||||
|
||||
## Create your first Markdown Page
|
||||
|
||||
Create a file at `src/pages/my-markdown-page.md`:
|
||||
|
||||
```mdx title="src/pages/my-markdown-page.md"
|
||||
# My Markdown page
|
||||
|
||||
This is a Markdown page
|
||||
```
|
||||
|
||||
A new page is now available at [http://localhost:3000/my-markdown-page](http://localhost:3000/my-markdown-page).
|
||||
@@ -1,31 +0,0 @@
|
||||
---
|
||||
sidebar_position: 5
|
||||
---
|
||||
|
||||
# Deploy your site
|
||||
|
||||
Docusaurus is a **static-site-generator** (also called **[Jamstack](https://jamstack.org/)**).
|
||||
|
||||
It builds your site as simple **static HTML, JavaScript and CSS files**.
|
||||
|
||||
## Build your site
|
||||
|
||||
Build your site **for production**:
|
||||
|
||||
```bash
|
||||
npm run build
|
||||
```
|
||||
|
||||
The static files are generated in the `build` folder.
|
||||
|
||||
## Deploy your site
|
||||
|
||||
Test your production build locally:
|
||||
|
||||
```bash
|
||||
npm run serve
|
||||
```
|
||||
|
||||
The `build` folder is now served at [http://localhost:3000/](http://localhost:3000/).
|
||||
|
||||
You can now deploy the `build` folder **almost anywhere** easily, **for free** or very small cost (read the **[Deployment Guide](https://docusaurus.io/docs/deployment)**).
|
||||
@@ -1,146 +0,0 @@
|
||||
---
|
||||
sidebar_position: 4
|
||||
---
|
||||
|
||||
# Markdown Features
|
||||
|
||||
Docusaurus supports **[Markdown](https://daringfireball.net/projects/markdown/syntax)** and a few **additional features**.
|
||||
|
||||
## Front Matter
|
||||
|
||||
Markdown documents have metadata at the top called [Front Matter](https://jekyllrb.com/docs/front-matter/):
|
||||
|
||||
```text title="my-doc.md"
|
||||
// highlight-start
|
||||
---
|
||||
id: my-doc-id
|
||||
title: My document title
|
||||
description: My document description
|
||||
slug: /my-custom-url
|
||||
---
|
||||
// highlight-end
|
||||
|
||||
## Markdown heading
|
||||
|
||||
Markdown text with [links](./hello.md)
|
||||
```
|
||||
|
||||
## Links
|
||||
|
||||
Regular Markdown links are supported, using url paths or relative file paths.
|
||||
|
||||
```md
|
||||
Let's see how to [Create a page](/create-a-page).
|
||||
```
|
||||
|
||||
```md
|
||||
Let's see how to [Create a page](./create-a-page.md).
|
||||
```
|
||||
|
||||
**Result:** Let's see how to [Create a page](./create-a-page.md).
|
||||
|
||||
## Images
|
||||
|
||||
Regular Markdown images are supported.
|
||||
|
||||
You can use absolute paths to reference images in the static directory (`static/img/docusaurus.png`):
|
||||
|
||||
```md
|
||||

|
||||
```
|
||||
|
||||

|
||||
|
||||
You can reference images relative to the current file as well, as shown in [the extra guides](../tutorial-extras/manage-docs-versions.md).
|
||||
|
||||
## Code Blocks
|
||||
|
||||
Markdown code blocks are supported with Syntax highlighting.
|
||||
|
||||
```jsx title="src/components/HelloDocusaurus.js"
|
||||
function HelloDocusaurus() {
|
||||
return (
|
||||
<h1>Hello, Docusaurus!</h1>
|
||||
)
|
||||
}
|
||||
```
|
||||
|
||||
```jsx title="src/components/HelloDocusaurus.js"
|
||||
function HelloDocusaurus() {
|
||||
return <h1>Hello, Docusaurus!</h1>;
|
||||
}
|
||||
```
|
||||
|
||||
## Admonitions
|
||||
|
||||
Docusaurus has a special syntax to create admonitions and callouts:
|
||||
|
||||
:::tip My tip
|
||||
|
||||
Use this awesome feature option
|
||||
|
||||
:::
|
||||
|
||||
:::danger Take care
|
||||
|
||||
This action is dangerous
|
||||
|
||||
:::
|
||||
|
||||
:::tip My tip
|
||||
|
||||
Use this awesome feature option
|
||||
|
||||
:::
|
||||
|
||||
:::danger Take care
|
||||
|
||||
This action is dangerous
|
||||
|
||||
:::
|
||||
|
||||
## MDX and React Components
|
||||
|
||||
[MDX](https://mdxjs.com/) can make your documentation more **interactive** and allows using any **React components inside Markdown**:
|
||||
|
||||
```jsx
|
||||
export const Highlight = ({children, color}) => (
|
||||
<span
|
||||
style={{
|
||||
backgroundColor: color,
|
||||
borderRadius: '20px',
|
||||
color: '#fff',
|
||||
padding: '10px',
|
||||
cursor: 'pointer',
|
||||
}}
|
||||
onClick={() => {
|
||||
alert(`You clicked the color ${color} with label ${children}`)
|
||||
}}>
|
||||
{children}
|
||||
</span>
|
||||
);
|
||||
|
||||
This is <Highlight color="#25c2a0">Docusaurus green</Highlight> !
|
||||
|
||||
This is <Highlight color="#1877F2">Facebook blue</Highlight> !
|
||||
```
|
||||
|
||||
export const Highlight = ({children, color}) => (
|
||||
<span
|
||||
style={{
|
||||
backgroundColor: color,
|
||||
borderRadius: '20px',
|
||||
color: '#fff',
|
||||
padding: '10px',
|
||||
cursor: 'pointer',
|
||||
}}
|
||||
onClick={() => {
|
||||
alert(`You clicked the color ${color} with label ${children}`);
|
||||
}}>
|
||||
{children}
|
||||
</span>
|
||||
);
|
||||
|
||||
This is <Highlight color="#25c2a0">Docusaurus green</Highlight> !
|
||||
|
||||
This is <Highlight color="#1877F2">Facebook blue</Highlight> !
|
||||
@@ -1,7 +0,0 @@
|
||||
{
|
||||
"label": "Tutorial - Extras",
|
||||
"position": 6,
|
||||
"link": {
|
||||
"type": "generated-index"
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 25 KiB |
|
Before Width: | Height: | Size: 27 KiB |
@@ -1,55 +0,0 @@
|
||||
---
|
||||
sidebar_position: 1
|
||||
---
|
||||
|
||||
# Manage Docs Versions
|
||||
|
||||
Docusaurus can manage multiple versions of your docs.
|
||||
|
||||
## Create a docs version
|
||||
|
||||
Release a version 1.0 of your project:
|
||||
|
||||
```bash
|
||||
npm run docusaurus docs:version 1.0
|
||||
```
|
||||
|
||||
The `docs` folder is copied into `versioned_docs/version-1.0` and `versions.json` is created.
|
||||
|
||||
Your docs now have 2 versions:
|
||||
|
||||
- `1.0` at `http://localhost:3000/docs/` for the version 1.0 docs
|
||||
- `current` at `http://localhost:3000/docs/next/` for the **upcoming, unreleased docs**
|
||||
|
||||
## Add a Version Dropdown
|
||||
|
||||
To navigate seamlessly across versions, add a version dropdown.
|
||||
|
||||
Modify the `docusaurus.config.js` file:
|
||||
|
||||
```js title="docusaurus.config.js"
|
||||
module.exports = {
|
||||
themeConfig: {
|
||||
navbar: {
|
||||
items: [
|
||||
// highlight-start
|
||||
{
|
||||
type: 'docsVersionDropdown',
|
||||
},
|
||||
// highlight-end
|
||||
],
|
||||
},
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
The docs version dropdown appears in your navbar:
|
||||
|
||||

|
||||
|
||||
## Update an existing version
|
||||
|
||||
It is possible to edit versioned docs in their respective folder:
|
||||
|
||||
- `versioned_docs/version-1.0/hello.md` updates `http://localhost:3000/docs/hello`
|
||||
- `docs/hello.md` updates `http://localhost:3000/docs/next/hello`
|
||||
@@ -1,88 +0,0 @@
|
||||
---
|
||||
sidebar_position: 2
|
||||
---
|
||||
|
||||
# Translate your site
|
||||
|
||||
Let's translate `docs/intro.md` to French.
|
||||
|
||||
## Configure i18n
|
||||
|
||||
Modify `docusaurus.config.js` to add support for the `fr` locale:
|
||||
|
||||
```js title="docusaurus.config.js"
|
||||
module.exports = {
|
||||
i18n: {
|
||||
defaultLocale: 'en',
|
||||
locales: ['en', 'fr'],
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
## Translate a doc
|
||||
|
||||
Copy the `docs/intro.md` file to the `i18n/fr` folder:
|
||||
|
||||
```bash
|
||||
mkdir -p i18n/fr/docusaurus-plugin-content-docs/current/
|
||||
|
||||
cp docs/intro.md i18n/fr/docusaurus-plugin-content-docs/current/intro.md
|
||||
```
|
||||
|
||||
Translate `i18n/fr/docusaurus-plugin-content-docs/current/intro.md` in French.
|
||||
|
||||
## Start your localized site
|
||||
|
||||
Start your site on the French locale:
|
||||
|
||||
```bash
|
||||
npm run start -- --locale fr
|
||||
```
|
||||
|
||||
Your localized site is accessible at [http://localhost:3000/fr/](http://localhost:3000/fr/) and the `Getting Started` page is translated.
|
||||
|
||||
:::caution
|
||||
|
||||
In development, you can only use one locale at a same time.
|
||||
|
||||
:::
|
||||
|
||||
## Add a Locale Dropdown
|
||||
|
||||
To navigate seamlessly across languages, add a locale dropdown.
|
||||
|
||||
Modify the `docusaurus.config.js` file:
|
||||
|
||||
```js title="docusaurus.config.js"
|
||||
module.exports = {
|
||||
themeConfig: {
|
||||
navbar: {
|
||||
items: [
|
||||
// highlight-start
|
||||
{
|
||||
type: 'localeDropdown',
|
||||
},
|
||||
// highlight-end
|
||||
],
|
||||
},
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
The locale dropdown now appears in your navbar:
|
||||
|
||||

|
||||
|
||||
## Build your localized site
|
||||
|
||||
Build your site for a specific locale:
|
||||
|
||||
```bash
|
||||
npm run build -- --locale fr
|
||||
```
|
||||
|
||||
Or build your site to include all the locales at once:
|
||||
|
||||
```bash
|
||||
npm run build
|
||||
```
|
||||
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"label": "How to use the app",
|
||||
"label": "How to use the application",
|
||||
"position": 3,
|
||||
"link": {
|
||||
"type": "generated-index",
|
||||
"description": "5 minutes to learn the most important Docusaurus concepts."
|
||||
"description": "Quick start on how to use the app on mobile and the web"
|
||||
}
|
||||
}
|
||||
|
||||
35
docs/docs/usage/automatic-backup.md
Normal file
@@ -0,0 +1,35 @@
|
||||
---
|
||||
sidebar_position: 2
|
||||
---
|
||||
|
||||
|
||||
# Automatic Backup
|
||||
|
||||
A guide on how the foreground and background automatic backup works.
|
||||
|
||||
<img src={require('./img/background-foreground-backup.png').default} width="50%" title="Foreground&Background Backup" />
|
||||
|
||||
On iOS, there is only one option for automatic backup
|
||||
* [**Foreground backup**](#foreground-backup)
|
||||
|
||||
On Android, there are two options for automatic backup
|
||||
* [**Foreground backup**](#foreground-backup)
|
||||
* [**Background backup**](#background-backup)
|
||||
|
||||
## Foreground backup
|
||||
|
||||
If foreground backup is enabled: whenever the app is opened or resumed, it will check if any photos or videos in the selected album(s) have yet to be uploaded to the cloud (the remainder count). If there are any, they will be uploaded.
|
||||
|
||||
## Background backup
|
||||
|
||||
Background backup is only available on Android thanks to the contribution effort of [@zoodyy](https://github.com/zoodyy).
|
||||
|
||||
If background backup is enabled. The app will periodically check if there are any new photos or videos in the selected album(s) to be uploaded to the cloud. If there are, it will upload them to the cloud in the background.
|
||||
|
||||
A native Android notification shows up when the background upload is in progress. You can further customize the notification by going to the app's settings.
|
||||
|
||||
:::note
|
||||
* The app must be in the background for the backup worker to start running.
|
||||
* It is a well-known problem that some Android models are very strict with battery optimization settings, which can cause a problem with the background worker. Please visit [Don't kill my app](https://dontkillmyapp.com/) for a guide on disabling this setting on your phone.
|
||||
* If you reopen the app and the first page you see is the backup page, the counts will reflect the background uploaded result. You have to navigate out of the page and come back to see the updated counts.
|
||||
:::
|
||||
75
docs/docs/usage/bulk-upload.md
Normal file
@@ -0,0 +1,75 @@
|
||||
---
|
||||
sidebar_position: 3
|
||||
---
|
||||
|
||||
# Bulk Upload (Using the CLI)
|
||||
|
||||
You can use the CLI to upload an existing gallery to the Immich server
|
||||
|
||||
[Immich CLI Repository](https://github.com/immich-app/CLI)
|
||||
|
||||
|
||||
## Requirements
|
||||
* Node.js 16 or above
|
||||
* Npm
|
||||
|
||||
## Installation
|
||||
```bash
|
||||
npm i -g immich
|
||||
```
|
||||
|
||||
## Quick Start
|
||||
Specify user's credentials, Immich's server address and port, and the directory you would like to upload videos/photos from.
|
||||
|
||||
```bash
|
||||
immich upload --email testuser@email.com --password password --server http://192.168.1.216:2283/api -d your/target/directory
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Parameters
|
||||
|
||||
| Parameter | Description |
|
||||
| ---------------- | ------------------------------------------------------------------- |
|
||||
| --yes / -y | Assume yes on all interactive prompts |
|
||||
| --delete / -da | Delete local assets after upload |
|
||||
| --email / -e | User's email |
|
||||
| --password / -pw | User's password |
|
||||
| --server / -s | Immich's server address |
|
||||
| --directory / -d | Directory to upload from |
|
||||
| --threads / -t | Number of threads to use (Default 5) |
|
||||
| --album/ -al | Create albums for assets based on the parent folder or a given name |
|
||||
|
||||
### Run via Docker
|
||||
|
||||
Be aware that as this runs inside a container it mounts your current directory as a volume, and for the -d flag you need to use the path inside the container.
|
||||
|
||||
```bash
|
||||
docker run -it --rm -v $(pwd):/import ghcr.io/immich-app/immich-cli:latest upload --email testuser@email.com --password password --server http://192.168.1.216:2283/api -d /import
|
||||
```
|
||||
|
||||
Optionally, you can create an alias:
|
||||
|
||||
```bash
|
||||
alias immich="docker run -it --rm -v $(pwd):/import ghcr.io/immich-app/immich-cli:latest"
|
||||
immich upload --email testuser@email.com --password password --server http://192.168.1.216:2283/api -d /import
|
||||
```
|
||||
|
||||
### Run from source
|
||||
|
||||
```bash title="Clone Repository"
|
||||
git clone https://github.com/alextran1502/immich-cli
|
||||
```
|
||||
|
||||
|
||||
```bash title="Install dependencies"
|
||||
npm install
|
||||
```
|
||||
|
||||
```bash title="Build the project"
|
||||
npm run build
|
||||
```
|
||||
|
||||
```bash title="Run the command"
|
||||
node bin/index.js upload --email testuser@email.com --password password --server http://192.168.1.216:2283/api -d your/target/directory
|
||||
```
|
||||
BIN
docs/docs/usage/img/admin-registration-form.png
Normal file
|
After Width: | Height: | Size: 105 KiB |
BIN
docs/docs/usage/img/album-selection.png
Normal file
|
After Width: | Height: | Size: 160 KiB |
BIN
docs/docs/usage/img/background-foreground-backup.png
Normal file
|
After Width: | Height: | Size: 220 KiB |
BIN
docs/docs/usage/img/backup-header.png
Normal file
|
After Width: | Height: | Size: 35 KiB |
BIN
docs/docs/usage/img/create-new-user.png
Normal file
|
After Width: | Height: | Size: 48 KiB |
BIN
docs/docs/usage/img/sign-in-phone.jpeg
Normal file
|
After Width: | Height: | Size: 321 KiB |
57
docs/docs/usage/post-installation.md
Normal file
@@ -0,0 +1,57 @@
|
||||
---
|
||||
sidebar_position: 1
|
||||
---
|
||||
|
||||
# Post Installation
|
||||
|
||||
This page contains information about what to do after you have installed the application.
|
||||
|
||||
## Step 1 - Download the mobile app
|
||||
|
||||
The mobile app can be downloaded from
|
||||
|
||||
- [Google Play Store](https://play.google.com/store/apps/details?id=app.alextran.immich)
|
||||
- [Apple App Store](https://apps.apple.com/us/app/immich/id1613945652)
|
||||
- [F-Droid](https://f-droid.org/packages/app.alextran.immich)
|
||||
|
||||
## Step 2 - Register the admin user
|
||||
|
||||
The first user to register will be the admin user. The admin user will be able to add other users to the application.
|
||||
|
||||
To register for the admin user, access the web application at `http://<machine-ip-address>:2283` and click on the **Getting Started** button.
|
||||
|
||||
<img src={require('./img/admin-registration-form.png').default} width="500" title="Admin Registration" />
|
||||
|
||||
Follow the prompts to register as the admin user and log in to the application.
|
||||
|
||||
## Step 3 - Create a new user (optional)
|
||||
|
||||
If you have a family member who wants to use the application, you can create a new account. The default password is `password`, and the user can change their password after logging in to the application for the first time.
|
||||
|
||||
<img src={require('./img/create-new-user.png').default} title="Admin Registration" />
|
||||
|
||||
## Step 4 - Access the mobile app
|
||||
|
||||
Login to the mobile app with the server endpoint URL at `http://<machine-ip-address>:2283/api`
|
||||
|
||||
<img src={require('./img/sign-in-phone.jpeg').default} width="50%" title="Mobile App Sign In" />
|
||||
|
||||
## Step 5 - Back up your photos and videos
|
||||
|
||||
Navigate to the backup screen by clicking on the cloud icon in the top right corner of the screen.
|
||||
|
||||
<img src={require('./img/backup-header.png').default} width="50%" title="Backup button" />
|
||||
|
||||
You can select which album(s) you want to back up to the Immich server from the backup screen.
|
||||
|
||||
<img src={require('./img/album-selection.png').default} width="50%" title="Backup button" />
|
||||
|
||||
Scroll down to the bottom and press "**Start Backup**" to start the backup process.
|
||||
|
||||
You can also enable auto foreground or background backup (only on Android). For more information about the app mechanism, please visit the next pages.
|
||||
|
||||
|
||||
:::tip Application Mechanism
|
||||
#### [Foreground and background backup](/docs/usage/automatic-backup)
|
||||
#### [Bulk upload (using the CLI)](/docs/usage/bulk-upload)
|
||||
:::
|
||||
11
docs/docs/usage/update.md
Normal file
@@ -0,0 +1,11 @@
|
||||
---
|
||||
sidebar_position: 4
|
||||
---
|
||||
|
||||
# Update the application
|
||||
|
||||
If you are using Docker Compose, update the application use the following commands in the directory where the `docker-compose.yml` file is located:
|
||||
|
||||
```bash title="Update Immich"
|
||||
docker-compose pull && docker-compose up -d # Or `docker compose`
|
||||
```
|
||||
@@ -6,9 +6,9 @@ const darkCodeTheme = require("prism-react-renderer/themes/dracula");
|
||||
|
||||
/** @type {import('@docusaurus/types').Config} */
|
||||
const config = {
|
||||
title: "Immich Documentation",
|
||||
title: "Immich",
|
||||
tagline:
|
||||
"Self-hosted photo and video backup solution directly from your mobile phone",
|
||||
"High performance self-hosted photo and video backup solution directly from your mobile phone",
|
||||
url: "https://documentation.immich.app",
|
||||
baseUrl: "/",
|
||||
onBrokenLinks: "throw",
|
||||
@@ -34,19 +34,18 @@ const config = {
|
||||
/** @type {import('@docusaurus/preset-classic').Options} */
|
||||
({
|
||||
docs: {
|
||||
showLastUpdateAuthor: true,
|
||||
showLastUpdateTime: true,
|
||||
|
||||
sidebarPath: require.resolve("./sidebars.js"),
|
||||
// Please change this to your repo.
|
||||
// Remove this to remove the "edit this page" links.
|
||||
editUrl:
|
||||
"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/",
|
||||
},
|
||||
blog: {
|
||||
showReadingTime: true,
|
||||
// Please change this to your repo.
|
||||
// Remove this to remove the "edit this page" links.
|
||||
editUrl:
|
||||
"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/",
|
||||
editUrl: "https://github.com/immich-app/immich/tree/main/docs/",
|
||||
},
|
||||
// blog: {
|
||||
// showReadingTime: true,
|
||||
// editUrl: "https://github.com/immich-app/immich/tree/main/docs/",
|
||||
// },
|
||||
theme: {
|
||||
customCss: require.resolve("./src/css/custom.css"),
|
||||
},
|
||||
@@ -57,16 +56,23 @@ const config = {
|
||||
themeConfig:
|
||||
/** @type {import('@docusaurus/preset-classic').ThemeConfig} */
|
||||
({
|
||||
announcementBar: {
|
||||
id: "site_announcement_immich",
|
||||
content: `⚠️ The project is under <strong>very active</strong> development. Expect bugs and changes. Do not use as a <strong>single source</strong> to store of your photos and videos!`,
|
||||
backgroundColor: "#593f00",
|
||||
textColor: "#ffefc9",
|
||||
isCloseable: false,
|
||||
},
|
||||
docs: {
|
||||
sidebar: {
|
||||
autoCollapseCategories: false,
|
||||
},
|
||||
},
|
||||
navbar: {
|
||||
title: "Immich",
|
||||
logo: {
|
||||
alt: "Immich University Logo",
|
||||
src: "img/logo.png",
|
||||
src: "img/color-logo.png",
|
||||
srcDark: "img/logo.png",
|
||||
},
|
||||
items: [
|
||||
{
|
||||
@@ -74,7 +80,7 @@ const config = {
|
||||
position: "right",
|
||||
label: "Documentation",
|
||||
},
|
||||
{ to: "/blog", label: "Blog", position: "right" },
|
||||
// { to: "/blog", label: "Blog", position: "right" },
|
||||
{
|
||||
href: "https://github.com/immich-app/immich",
|
||||
label: "GitHub",
|
||||
@@ -83,7 +89,7 @@ const config = {
|
||||
],
|
||||
},
|
||||
footer: {
|
||||
style: "dark",
|
||||
style: "light",
|
||||
links: [
|
||||
{
|
||||
title: "Overview",
|
||||
@@ -121,7 +127,7 @@ const config = {
|
||||
],
|
||||
},
|
||||
],
|
||||
copyright: `Alex Tran - For my family`,
|
||||
copyright: `Immich is available as open source under the terms of the MIT License.`,
|
||||
},
|
||||
prism: {
|
||||
theme: lightCodeTheme,
|
||||
|
||||
35
docs/package-lock.json
generated
@@ -10356,31 +10356,20 @@
|
||||
}
|
||||
},
|
||||
"node_modules/serve-handler": {
|
||||
"version": "6.1.3",
|
||||
"resolved": "https://registry.npmjs.org/serve-handler/-/serve-handler-6.1.3.tgz",
|
||||
"integrity": "sha512-FosMqFBNrLyeiIDvP1zgO6YoTzFYHxLDEIavhlmQ+knB2Z7l1t+kGLHkZIDN7UVWqQAmKI3D20A6F6jo3nDd4w==",
|
||||
"version": "6.1.5",
|
||||
"resolved": "https://registry.npmjs.org/serve-handler/-/serve-handler-6.1.5.tgz",
|
||||
"integrity": "sha512-ijPFle6Hwe8zfmBxJdE+5fta53fdIY0lHISJvuikXB3VYFafRjMRpOffSPvCYsbKyBA7pvy9oYr/BT1O3EArlg==",
|
||||
"dependencies": {
|
||||
"bytes": "3.0.0",
|
||||
"content-disposition": "0.5.2",
|
||||
"fast-url-parser": "1.1.3",
|
||||
"mime-types": "2.1.18",
|
||||
"minimatch": "3.0.4",
|
||||
"minimatch": "3.1.2",
|
||||
"path-is-inside": "1.0.2",
|
||||
"path-to-regexp": "2.2.1",
|
||||
"range-parser": "1.2.0"
|
||||
}
|
||||
},
|
||||
"node_modules/serve-handler/node_modules/minimatch": {
|
||||
"version": "3.0.4",
|
||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
|
||||
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
|
||||
"dependencies": {
|
||||
"brace-expansion": "^1.1.7"
|
||||
},
|
||||
"engines": {
|
||||
"node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/serve-handler/node_modules/path-to-regexp": {
|
||||
"version": "2.2.1",
|
||||
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-2.2.1.tgz",
|
||||
@@ -19878,28 +19867,20 @@
|
||||
}
|
||||
},
|
||||
"serve-handler": {
|
||||
"version": "6.1.3",
|
||||
"resolved": "https://registry.npmjs.org/serve-handler/-/serve-handler-6.1.3.tgz",
|
||||
"integrity": "sha512-FosMqFBNrLyeiIDvP1zgO6YoTzFYHxLDEIavhlmQ+knB2Z7l1t+kGLHkZIDN7UVWqQAmKI3D20A6F6jo3nDd4w==",
|
||||
"version": "6.1.5",
|
||||
"resolved": "https://registry.npmjs.org/serve-handler/-/serve-handler-6.1.5.tgz",
|
||||
"integrity": "sha512-ijPFle6Hwe8zfmBxJdE+5fta53fdIY0lHISJvuikXB3VYFafRjMRpOffSPvCYsbKyBA7pvy9oYr/BT1O3EArlg==",
|
||||
"requires": {
|
||||
"bytes": "3.0.0",
|
||||
"content-disposition": "0.5.2",
|
||||
"fast-url-parser": "1.1.3",
|
||||
"mime-types": "2.1.18",
|
||||
"minimatch": "3.0.4",
|
||||
"minimatch": "3.1.2",
|
||||
"path-is-inside": "1.0.2",
|
||||
"path-to-regexp": "2.2.1",
|
||||
"range-parser": "1.2.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"minimatch": {
|
||||
"version": "3.0.4",
|
||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
|
||||
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
|
||||
"requires": {
|
||||
"brace-expansion": "^1.1.7"
|
||||
}
|
||||
},
|
||||
"path-to-regexp": {
|
||||
"version": "2.2.1",
|
||||
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-2.2.1.tgz",
|
||||
|
||||
@@ -4,10 +4,11 @@
|
||||
* work well for content-centric websites.
|
||||
*/
|
||||
|
||||
@import url("https://fonts.googleapis.com/css2?family=Work+Sans:ital,wght@0,400;0,500;0,600;0,700;1,400;1,500;1,600;1,700&display=swap");
|
||||
@import url("https://fonts.googleapis.com/css2?family=Overpass:ital,wght@0,300;0,400;0,500;0,600;0,700;1,300;1,400;1,500;1,600;1,700&display=swap");
|
||||
@import url("https://fonts.googleapis.com/css2?family=Snowburst+One&display=swap");
|
||||
|
||||
html {
|
||||
font-family: "Work Sans", sans-serif;
|
||||
font-family: "Overpass", sans-serif;
|
||||
}
|
||||
|
||||
/* You can override the default Infima variables here. */
|
||||
|
||||
@@ -5,10 +5,13 @@
|
||||
|
||||
.heroBanner {
|
||||
padding: 4rem 0;
|
||||
text-align: center;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
height: 40rem;
|
||||
text-align: center;
|
||||
background: #606c88;
|
||||
background: -webkit-linear-gradient(to top, #4e5362, #606c88);
|
||||
background: linear-gradient(to top, #4e5362, #606c88);
|
||||
color: whitesmoke;
|
||||
}
|
||||
|
||||
@media screen and (max-width: 996px) {
|
||||
@@ -22,3 +25,32 @@
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.buttonsRow {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-wrap: wrap;
|
||||
margin-bottom: 4rem;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.installButton {
|
||||
background-color: #adcbfa;
|
||||
color: #000000;
|
||||
border-radius: 50px;
|
||||
}
|
||||
|
||||
.installButton:hover {
|
||||
color: #000000;
|
||||
}
|
||||
|
||||
.introButton {
|
||||
background-color: #e6ebf5;
|
||||
color: #000000;
|
||||
border-radius: 50px;
|
||||
}
|
||||
|
||||
.introButton:hover {
|
||||
color: #000000;
|
||||
}
|
||||
|
||||
@@ -12,16 +12,37 @@ function HomepageHeader() {
|
||||
return (
|
||||
<header className={clsx("hero hero--primary", styles.heroBanner)}>
|
||||
<div className="container">
|
||||
<h1 className="hero__title">{siteConfig.title}</h1>
|
||||
<h1
|
||||
className="hero__title"
|
||||
style={{
|
||||
fontFamily: "Snowburst One",
|
||||
color: "#adcbfa",
|
||||
}}
|
||||
>
|
||||
IMMICH
|
||||
</h1>
|
||||
<p className="hero__subtitle">{siteConfig.tagline}</p>
|
||||
<div className={styles.buttons}>
|
||||
<Link
|
||||
className="button button--secondary button--lg"
|
||||
to="docs/installation/requirements"
|
||||
>
|
||||
Getting Started
|
||||
</Link>
|
||||
<div className={styles.buttonsRow}>
|
||||
<div className={styles.buttons}>
|
||||
<Link
|
||||
className={clsx("button button--lg", styles.introButton)}
|
||||
to="docs/overview/introduction"
|
||||
>
|
||||
Introduction
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
<div className={styles.buttons}>
|
||||
<Link
|
||||
className={clsx("button button--lg", styles.installButton)}
|
||||
to="docs/installation/requirements"
|
||||
>
|
||||
Installation
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<img src="/img/immich-screenshots.webp" alt="logo" />
|
||||
</div>
|
||||
</header>
|
||||
);
|
||||
@@ -31,13 +52,11 @@ export default function Home(): JSX.Element {
|
||||
const { siteConfig } = useDocusaurusContext();
|
||||
return (
|
||||
<Layout
|
||||
title={`${siteConfig.title}`}
|
||||
description="Description will go into a meta tag in <head />"
|
||||
title={`Home`}
|
||||
description="immich Self-hosted photo and video backup solution directly from your mobile phone "
|
||||
>
|
||||
<HomepageHeader />
|
||||
<main>
|
||||
<HomepageFeatures />
|
||||
</main>
|
||||
<main>{/* <HomepageFeatures /> */}</main>
|
||||
</Layout>
|
||||
);
|
||||
}
|
||||
|
||||
BIN
docs/static/img/color-logo.png
vendored
Normal file
|
After Width: | Height: | Size: 46 KiB |
BIN
docs/static/img/immich-screenshots.webp
vendored
Normal file
|
After Width: | Height: | Size: 162 KiB |
@@ -50,6 +50,7 @@ class BackupWorker(ctx: Context, params: WorkerParameters) : ListenableWorker(ct
|
||||
private var timeBackupStarted: Long = 0L
|
||||
private var notificationBuilder: NotificationCompat.Builder? = null
|
||||
private var notificationDetailBuilder: NotificationCompat.Builder? = null
|
||||
private var fgFuture: ListenableFuture<Void>? = null
|
||||
|
||||
override fun startWork(): ListenableFuture<ListenableWorker.Result> {
|
||||
|
||||
@@ -112,6 +113,7 @@ class BackupWorker(ctx: Context, params: WorkerParameters) : ListenableWorker(ct
|
||||
Handler(Looper.getMainLooper()).postAtFrontOfQueue {
|
||||
backgroundChannel.invokeMethod("systemStop", null)
|
||||
}
|
||||
waitOnSetForegroundAsync()
|
||||
// cannot await/get(block) on resolvableFuture as its already cancelled (would throw CancellationException)
|
||||
// instead, wait for 5 seconds until forcefully stopping backup work
|
||||
Handler(Looper.getMainLooper()).postDelayed({
|
||||
@@ -119,6 +121,17 @@ class BackupWorker(ctx: Context, params: WorkerParameters) : ListenableWorker(ct
|
||||
}, 5000)
|
||||
}
|
||||
|
||||
private fun waitOnSetForegroundAsync() {
|
||||
val fgFuture = this.fgFuture
|
||||
if (fgFuture != null && !fgFuture.isCancelled() && !fgFuture.isDone()) {
|
||||
try {
|
||||
fgFuture.get(500, TimeUnit.MILLISECONDS)
|
||||
}
|
||||
catch (e: Exception) {
|
||||
// ignored, there is nothing to be done
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun stopEngine(result: Result?) {
|
||||
if (result != null) {
|
||||
@@ -128,6 +141,7 @@ class BackupWorker(ctx: Context, params: WorkerParameters) : ListenableWorker(ct
|
||||
engine?.destroy()
|
||||
engine = null
|
||||
clearBackgroundNotification()
|
||||
waitOnSetForegroundAsync()
|
||||
}
|
||||
|
||||
override fun onMethodCall(call: MethodCall, r: MethodChannel.Result) {
|
||||
@@ -207,8 +221,8 @@ class BackupWorker(ctx: Context, params: WorkerParameters) : ListenableWorker(ct
|
||||
|
||||
private fun showInfo(notification: Notification, isDetail: Boolean = false) {
|
||||
val id = if(isDetail) NOTIFICATION_DETAIL_ID else NOTIFICATION_ID
|
||||
if (isIgnoringBatteryOptimizations) {
|
||||
setForegroundAsync(ForegroundInfo(id, notification))
|
||||
if (isIgnoringBatteryOptimizations && !isDetail) {
|
||||
fgFuture = setForegroundAsync(ForegroundInfo(id, notification))
|
||||
} else {
|
||||
notificationManager.notify(id, notification)
|
||||
}
|
||||
|
||||
@@ -35,8 +35,8 @@ platform :android do
|
||||
task: 'bundle',
|
||||
build_type: 'Release',
|
||||
properties: {
|
||||
"android.injected.version.code" => 52,
|
||||
"android.injected.version.name" => "1.33.0",
|
||||
"android.injected.version.code" => 53,
|
||||
"android.injected.version.name" => "1.34.0",
|
||||
}
|
||||
)
|
||||
upload_to_play_store(skip_upload_apk: true, skip_upload_images: true, skip_upload_screenshots: true, aab: '../build/app/outputs/bundle/release/app-release.aab')
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
* Reduce app startup time by loading Hive boxes in parallel
|
||||
* Throttle detail progress notifications & wait on foregroundInfo
|
||||
* Throttle all background backup progress notifications
|
||||
* Add selected assets to album
|
||||
* Enhanced vertical swiping motion in image viewer
|
||||
* Enhance the bottom app bar on the home page
|
||||
@@ -171,5 +171,11 @@
|
||||
"version_announcement_overlay_text_3": " and ensure your docker-compose and .env setup is up-to-date to prevent any misconfigurations, especially if you use WatchTower or any mechanism that handles updating your server application automatically.",
|
||||
"version_announcement_overlay_title": "New Server Version Available \uD83C\uDF89",
|
||||
"experimental_settings_title": "Experimental",
|
||||
"experimental_settings_subtitle": "Use at your own risk!"
|
||||
"experimental_settings_subtitle": "Use at your own risk!",
|
||||
"control_bottom_app_bar_add_to_album": "Add to album",
|
||||
"home_page_add_to_album_success": "Added {added} assets to album {album}.",
|
||||
"home_page_add_to_album_conflicts": "Added {added} assets to album {album}. {failed} assets are already in the album.",
|
||||
"control_bottom_app_bar_album_info": "{} items",
|
||||
"control_bottom_app_bar_album_info_shared": "{} items · Shared",
|
||||
"control_bottom_app_bar_create_new_album": "Create new album"
|
||||
}
|
||||
|
||||
@@ -360,7 +360,7 @@
|
||||
CODE_SIGN_ENTITLEMENTS = Runner/RunnerProfile.entitlements;
|
||||
CODE_SIGN_IDENTITY = "Apple Development";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 62;
|
||||
CURRENT_PROJECT_VERSION = 68;
|
||||
DEVELOPMENT_TEAM = 2F67MQ8R79;
|
||||
ENABLE_BITCODE = NO;
|
||||
INFOPLIST_FILE = Runner/Info.plist;
|
||||
@@ -495,7 +495,7 @@
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CODE_SIGN_IDENTITY = "Apple Development";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 62;
|
||||
CURRENT_PROJECT_VERSION = 68;
|
||||
DEVELOPMENT_TEAM = 2F67MQ8R79;
|
||||
ENABLE_BITCODE = NO;
|
||||
INFOPLIST_FILE = Runner/Info.plist;
|
||||
@@ -522,7 +522,7 @@
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CODE_SIGN_IDENTITY = "Apple Development";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 62;
|
||||
CURRENT_PROJECT_VERSION = 68;
|
||||
DEVELOPMENT_TEAM = 2F67MQ8R79;
|
||||
ENABLE_BITCODE = NO;
|
||||
INFOPLIST_FILE = Runner/Info.plist;
|
||||
|
||||
@@ -17,11 +17,11 @@
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.30.1</string>
|
||||
<string>1.34.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>62</string>
|
||||
<string>68</string>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
<true />
|
||||
<key>MGLMapboxMetricsEnabledSettingShownInApp</key>
|
||||
|
||||
@@ -19,7 +19,7 @@ platform :ios do
|
||||
desc "iOS Beta"
|
||||
lane :beta do
|
||||
increment_version_number(
|
||||
version_number: "1.33.0"
|
||||
version_number: "1.34.0"
|
||||
)
|
||||
increment_build_number(
|
||||
build_number: latest_testflight_build_number + 1,
|
||||
|
||||
@@ -5,32 +5,32 @@
|
||||
|
||||
|
||||
|
||||
<testcase classname="fastlane.lanes" name="0: default_platform" time="0.000209">
|
||||
<testcase classname="fastlane.lanes" name="0: default_platform" time="0.000304">
|
||||
|
||||
</testcase>
|
||||
|
||||
|
||||
<testcase classname="fastlane.lanes" name="1: increment_version_number" time="0.78333">
|
||||
<testcase classname="fastlane.lanes" name="1: increment_version_number" time="0.606546">
|
||||
|
||||
</testcase>
|
||||
|
||||
|
||||
<testcase classname="fastlane.lanes" name="2: latest_testflight_build_number" time="3.947588">
|
||||
<testcase classname="fastlane.lanes" name="2: latest_testflight_build_number" time="3.706234">
|
||||
|
||||
</testcase>
|
||||
|
||||
|
||||
<testcase classname="fastlane.lanes" name="3: increment_build_number" time="0.505399">
|
||||
<testcase classname="fastlane.lanes" name="3: increment_build_number" time="0.657686">
|
||||
|
||||
</testcase>
|
||||
|
||||
|
||||
<testcase classname="fastlane.lanes" name="4: build_app" time="80.954627">
|
||||
<testcase classname="fastlane.lanes" name="4: build_app" time="68.78265">
|
||||
|
||||
</testcase>
|
||||
|
||||
|
||||
<testcase classname="fastlane.lanes" name="5: upload_to_testflight" time="58.295965">
|
||||
<testcase classname="fastlane.lanes" name="5: upload_to_testflight" time="60.883182">
|
||||
|
||||
</testcase>
|
||||
|
||||
|
||||
@@ -28,17 +28,19 @@ import 'constants/hive_box.dart';
|
||||
|
||||
void main() async {
|
||||
await Hive.initFlutter();
|
||||
|
||||
Hive.registerAdapter(HiveSavedLoginInfoAdapter());
|
||||
Hive.registerAdapter(HiveBackupAlbumsAdapter());
|
||||
Hive.registerAdapter(HiveDuplicatedAssetsAdapter());
|
||||
|
||||
await Hive.openBox(userInfoBox);
|
||||
await Hive.openBox<HiveSavedLoginInfo>(hiveLoginInfoBox);
|
||||
await Hive.openBox<HiveBackupAlbums>(hiveBackupInfoBox);
|
||||
await Hive.openBox(hiveGithubReleaseInfoBox);
|
||||
await Hive.openBox(userSettingInfoBox);
|
||||
await Hive.openBox<HiveDuplicatedAssets>(duplicatedAssetsBox);
|
||||
await Future.wait([
|
||||
Hive.openBox(userInfoBox),
|
||||
Hive.openBox<HiveSavedLoginInfo>(hiveLoginInfoBox),
|
||||
Hive.openBox<HiveBackupAlbums>(hiveBackupInfoBox),
|
||||
Hive.openBox(hiveGithubReleaseInfoBox),
|
||||
Hive.openBox(userSettingInfoBox),
|
||||
Hive.openBox<HiveDuplicatedAssets>(duplicatedAssetsBox),
|
||||
EasyLocalization.ensureInitialized(),
|
||||
]);
|
||||
|
||||
SystemChrome.setSystemUIOverlayStyle(
|
||||
const SystemUiOverlayStyle(
|
||||
@@ -46,8 +48,6 @@ void main() async {
|
||||
),
|
||||
);
|
||||
|
||||
await EasyLocalization.ensureInitialized();
|
||||
|
||||
if (kReleaseMode && Platform.isAndroid) {
|
||||
try {
|
||||
await FlutterDisplayMode.setHighRefreshRate();
|
||||
|
||||
@@ -46,6 +46,31 @@ class AlbumService {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Creates names like Untitled, Untitled (1), Untitled (2), ...
|
||||
*/
|
||||
String _getNextAlbumName(List<AlbumResponseDto>? albums) {
|
||||
const baseName = "Untitled";
|
||||
|
||||
if (albums != null) {
|
||||
for (int round = 0; round < albums.length; round++) {
|
||||
final proposedName = "$baseName${round == 0 ? "" : " ($round)"}";
|
||||
|
||||
if (albums.where((a) => a.albumName == proposedName).isEmpty) {
|
||||
return proposedName;
|
||||
}
|
||||
}
|
||||
}
|
||||
return baseName;
|
||||
}
|
||||
|
||||
Future<AlbumResponseDto?> createAlbumWithGeneratedName(
|
||||
Set<AssetResponseDto> assets,
|
||||
) async {
|
||||
return createAlbum(
|
||||
_getNextAlbumName(await getAlbums(isShared: false)), assets, []);
|
||||
}
|
||||
|
||||
Future<AlbumResponseDto?> getAlbumDetail(String albumId) async {
|
||||
try {
|
||||
return await _apiService.albumApi.getAlbumInfo(albumId);
|
||||
@@ -55,7 +80,7 @@ class AlbumService {
|
||||
}
|
||||
}
|
||||
|
||||
Future<bool> addAdditionalAssetToAlbum(
|
||||
Future<AddAssetsResponseDto?> addAdditionalAssetToAlbum(
|
||||
Set<AssetResponseDto> assets,
|
||||
String albumId,
|
||||
) async {
|
||||
@@ -64,10 +89,10 @@ class AlbumService {
|
||||
albumId,
|
||||
AddAssetsDto(assetIds: assets.map((asset) => asset.id).toList()),
|
||||
);
|
||||
return result != null;
|
||||
return result;
|
||||
} catch (e) {
|
||||
debugPrint("Error addAdditionalAssetToAlbum ${e.toString()}");
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -53,13 +53,13 @@ class AlbumViewerPage extends HookConsumerWidget {
|
||||
if (returnPayload.selectedAdditionalAsset.isNotEmpty) {
|
||||
ImmichLoadingOverlayController.appLoader.show();
|
||||
|
||||
var isSuccess =
|
||||
var addAssetsResult =
|
||||
await ref.watch(albumServiceProvider).addAdditionalAssetToAlbum(
|
||||
returnPayload.selectedAdditionalAsset,
|
||||
albumId,
|
||||
);
|
||||
|
||||
if (isSuccess) {
|
||||
if (addAssetsResult != null && addAssetsResult.successfullyAdded > 0) {
|
||||
ref.refresh(sharedAlbumDetailProvider(albumId));
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@ class _RemotePhotoViewState extends State<RemotePhotoView> {
|
||||
_RemoteImageStatus _status = _RemoteImageStatus.empty;
|
||||
bool _zoomedIn = false;
|
||||
|
||||
static const int swipeThreshold = 100;
|
||||
late CachedNetworkImageProvider fullProvider;
|
||||
late CachedNetworkImageProvider previewProvider;
|
||||
late CachedNetworkImageProvider thumbnailProvider;
|
||||
@@ -20,34 +19,33 @@ class _RemotePhotoViewState extends State<RemotePhotoView> {
|
||||
|
||||
return IgnorePointer(
|
||||
ignoring: !allowMoving,
|
||||
child: PhotoView(
|
||||
imageProvider: _imageProvider,
|
||||
minScale: PhotoViewComputedScale.contained,
|
||||
enablePanAlways: true,
|
||||
scaleStateChangedCallback: _scaleStateChanged,
|
||||
onScaleEnd: _onScaleListener,
|
||||
child: Listener(
|
||||
onPointerMove: handleSwipUpDown,
|
||||
child: PhotoView(
|
||||
imageProvider: _imageProvider,
|
||||
minScale: PhotoViewComputedScale.contained,
|
||||
enablePanAlways: false,
|
||||
scaleStateChangedCallback: _scaleStateChanged,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _onScaleListener(
|
||||
BuildContext context,
|
||||
ScaleEndDetails details,
|
||||
PhotoViewControllerValue controllerValue,
|
||||
) {
|
||||
// Disable swipe events when zoomed in
|
||||
void handleSwipUpDown(PointerMoveEvent details) {
|
||||
int sensitivity = 10;
|
||||
|
||||
if (_zoomedIn) {
|
||||
return;
|
||||
}
|
||||
if (controllerValue.position.dy > swipeThreshold) {
|
||||
|
||||
if (details.delta.dy > sensitivity) {
|
||||
widget.onSwipeDown();
|
||||
} else if (controllerValue.position.dy < -swipeThreshold) {
|
||||
} else if (details.delta.dy < -sensitivity) {
|
||||
widget.onSwipeUp();
|
||||
}
|
||||
}
|
||||
|
||||
void _scaleStateChanged(PhotoViewScaleState state) {
|
||||
// _onScaleListener;
|
||||
_zoomedIn = state != PhotoViewScaleState.initial;
|
||||
if (_zoomedIn) {
|
||||
widget.isZoomedListener.value = true;
|
||||
|
||||
@@ -33,6 +33,7 @@ class BackgroundService {
|
||||
static const MethodChannel _backgroundChannel =
|
||||
MethodChannel('immich/backgroundChannel');
|
||||
static final NumberFormat numberFormat = NumberFormat("###0.##");
|
||||
static const notifyInterval = Duration(milliseconds: 400);
|
||||
bool _isBackgroundInitialized = false;
|
||||
CancellationToken? _cancellationToken;
|
||||
bool _canceledBySystem = false;
|
||||
@@ -43,8 +44,12 @@ class BackgroundService {
|
||||
bool _errorGracePeriodExceeded = true;
|
||||
int _uploadedAssetsCount = 0;
|
||||
int _assetsToUploadCount = 0;
|
||||
int _lastDetailProgressUpdate = 0;
|
||||
String _lastPrintedProgress = "";
|
||||
String _lastPrintedDetailContent = "";
|
||||
String? _lastPrintedDetailTitle;
|
||||
late final _Throttle _throttledNotifiy =
|
||||
_Throttle(_updateProgress, notifyInterval);
|
||||
late final _Throttle _throttledDetailNotify =
|
||||
_Throttle(_updateDetailProgress, notifyInterval);
|
||||
|
||||
bool get isBackgroundInitialized {
|
||||
return _isBackgroundInitialized;
|
||||
@@ -319,11 +324,14 @@ class BackgroundService {
|
||||
Hive.registerAdapter(HiveBackupAlbumsAdapter());
|
||||
Hive.registerAdapter(HiveDuplicatedAssetsAdapter());
|
||||
|
||||
await Hive.openBox(userInfoBox);
|
||||
await Hive.openBox<HiveSavedLoginInfo>(hiveLoginInfoBox);
|
||||
await Hive.openBox(userSettingInfoBox);
|
||||
await Hive.openBox(backgroundBackupInfoBox);
|
||||
await Hive.openBox<HiveDuplicatedAssets>(duplicatedAssetsBox);
|
||||
await Future.wait([
|
||||
Hive.openBox(userInfoBox),
|
||||
Hive.openBox<HiveSavedLoginInfo>(hiveLoginInfoBox),
|
||||
Hive.openBox(userSettingInfoBox),
|
||||
Hive.openBox(backgroundBackupInfoBox),
|
||||
Hive.openBox<HiveDuplicatedAssets>(duplicatedAssetsBox),
|
||||
Hive.openBox<HiveBackupAlbums>(hiveBackupInfoBox),
|
||||
]);
|
||||
|
||||
ApiService apiService = ApiService();
|
||||
apiService.setEndpoint(Hive.box(userInfoBox).get(serverEndpointKey));
|
||||
@@ -332,7 +340,7 @@ class BackgroundService {
|
||||
AppSettingsService settingsService = AppSettingsService();
|
||||
|
||||
final Box<HiveBackupAlbums> box =
|
||||
await Hive.openBox<HiveBackupAlbums>(hiveBackupInfoBox);
|
||||
Hive.box<HiveBackupAlbums>(hiveBackupInfoBox);
|
||||
final HiveBackupAlbums? backupAlbumInfo = box.get(backupInfoKey);
|
||||
if (backupAlbumInfo == null) {
|
||||
return true;
|
||||
@@ -434,34 +442,40 @@ class BackgroundService {
|
||||
}
|
||||
|
||||
void _onAssetUploaded(String deviceAssetId, String deviceId, bool isDup) {
|
||||
debugPrint("Uploaded $deviceAssetId from $deviceId");
|
||||
_uploadedAssetsCount++;
|
||||
_updateNotification(
|
||||
progress: _uploadedAssetsCount,
|
||||
max: _assetsToUploadCount,
|
||||
content: _formatAssetBackupProgress(),
|
||||
);
|
||||
_throttledNotifiy();
|
||||
}
|
||||
|
||||
void _onProgress(int sent, int total) {
|
||||
final int now = Timeline.now;
|
||||
// limit updates to 10 per second (or Android drops important notifications)
|
||||
if (now > _lastDetailProgressUpdate + 100000) {
|
||||
final String msg = _humanReadableBytesProgress(sent, total);
|
||||
// only update if message actually differs (to stop many useless notification updates on large assets or slow connections)
|
||||
if (msg != _lastPrintedProgress) {
|
||||
_lastDetailProgressUpdate = now;
|
||||
_lastPrintedProgress = msg;
|
||||
_updateNotification(
|
||||
progress: sent,
|
||||
max: total,
|
||||
isDetail: true,
|
||||
content: msg,
|
||||
);
|
||||
}
|
||||
_throttledDetailNotify(progress: sent, total: total);
|
||||
}
|
||||
|
||||
void _updateDetailProgress(String? title, int progress, int total) {
|
||||
final String msg =
|
||||
total > 0 ? _humanReadableBytesProgress(progress, total) : "";
|
||||
// only update if message actually differs (to stop many useless notification updates on large assets or slow connections)
|
||||
if (msg != _lastPrintedDetailContent || _lastPrintedDetailTitle != title) {
|
||||
_lastPrintedDetailContent = msg;
|
||||
_lastPrintedDetailTitle = title;
|
||||
_updateNotification(
|
||||
progress: total > 0 ? (progress * 1000) ~/ total : 0,
|
||||
max: 1000,
|
||||
isDetail: true,
|
||||
title: title,
|
||||
content: msg,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void _updateProgress(String? title, int progress, int total) {
|
||||
_updateNotification(
|
||||
progress: _uploadedAssetsCount,
|
||||
max: _assetsToUploadCount,
|
||||
title: title,
|
||||
content: _formatAssetBackupProgress(),
|
||||
);
|
||||
}
|
||||
|
||||
void _onBackupError(ErrorUploadAsset errorAssetInfo) {
|
||||
_showErrorNotification(
|
||||
title: "backup_background_service_upload_failure_notification"
|
||||
@@ -471,14 +485,11 @@ class BackgroundService {
|
||||
}
|
||||
|
||||
void _onSetCurrentBackupAsset(CurrentUploadAsset currentUploadAsset) {
|
||||
_updateNotification(
|
||||
title: "backup_background_service_current_upload_notification"
|
||||
.tr(args: [currentUploadAsset.fileName]),
|
||||
content: "",
|
||||
isDetail: true,
|
||||
progress: 0,
|
||||
max: 0,
|
||||
);
|
||||
_throttledDetailNotify.title =
|
||||
"backup_background_service_current_upload_notification"
|
||||
.tr(args: [currentUploadAsset.fileName]);
|
||||
_throttledDetailNotify.progress = 0;
|
||||
_throttledDetailNotify.total = 0;
|
||||
}
|
||||
|
||||
bool _isErrorGracePeriodExceeded(AppSettingsService appSettingsService) {
|
||||
@@ -529,6 +540,43 @@ class BackgroundService {
|
||||
}
|
||||
}
|
||||
|
||||
class _Throttle {
|
||||
_Throttle(this._fun, Duration interval) : _interval = interval.inMicroseconds;
|
||||
final void Function(String?, int, int) _fun;
|
||||
final int _interval;
|
||||
int _invokedAt = 0;
|
||||
Timer? _timer;
|
||||
|
||||
String? title;
|
||||
int progress = 0;
|
||||
int total = 0;
|
||||
|
||||
void call({
|
||||
final String? title,
|
||||
final int progress = 0,
|
||||
final int total = 0,
|
||||
}) {
|
||||
final time = Timeline.now;
|
||||
this.title = title ?? this.title;
|
||||
this.progress = progress;
|
||||
this.total = total;
|
||||
if (time > _invokedAt + _interval) {
|
||||
_timer?.cancel();
|
||||
_onTimeElapsed();
|
||||
} else {
|
||||
_timer ??= Timer(Duration(microseconds: _interval), _onTimeElapsed);
|
||||
}
|
||||
}
|
||||
|
||||
void _onTimeElapsed() {
|
||||
_invokedAt = Timeline.now;
|
||||
_fun(title, progress, total);
|
||||
_timer = null;
|
||||
// clear title to not send/overwrite it next time if unchanged
|
||||
title = null;
|
||||
}
|
||||
}
|
||||
|
||||
/// entry point called by Kotlin/Java code; needs to be a top-level function
|
||||
@pragma('vm:entry-point')
|
||||
void _nativeEntry() {
|
||||
|
||||
@@ -14,7 +14,7 @@ class DisableMultiSelectButton extends ConsumerWidget {
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(left: 16.0, top: 15),
|
||||
padding: const EdgeInsets.only(left: 16.0, top: 16.0),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 4.0),
|
||||
child: ElevatedButton.icon(
|
||||
|
||||
@@ -1,64 +1,220 @@
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:immich_mobile/constants/hive_box.dart';
|
||||
import 'package:immich_mobile/modules/home/ui/delete_diaglog.dart';
|
||||
import 'package:immich_mobile/utils/image_url_builder.dart';
|
||||
import 'package:openapi/api.dart';
|
||||
|
||||
class ControlBottomAppBar extends ConsumerWidget {
|
||||
final Function onShare;
|
||||
final Function onDelete;
|
||||
final Function(AlbumResponseDto album) onAddToAlbum;
|
||||
final void Function() onCreateNewAlbum;
|
||||
|
||||
const ControlBottomAppBar(
|
||||
{Key? key, required this.onShare, required this.onDelete})
|
||||
: super(key: key);
|
||||
final List<AlbumResponseDto> albums;
|
||||
|
||||
const ControlBottomAppBar({
|
||||
Key? key,
|
||||
required this.onShare,
|
||||
required this.onDelete,
|
||||
required this.albums,
|
||||
required this.onAddToAlbum,
|
||||
required this.onCreateNewAlbum,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
return Positioned(
|
||||
bottom: 0,
|
||||
left: 0,
|
||||
child: Container(
|
||||
width: MediaQuery.of(context).size.width,
|
||||
height: MediaQuery.of(context).size.height * 0.15,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: const BorderRadius.only(
|
||||
topLeft: Radius.circular(8),
|
||||
topRight: Radius.circular(8),
|
||||
Widget renderActionButtons() {
|
||||
return Row(
|
||||
children: [
|
||||
ControlBoxButton(
|
||||
iconData: Icons.ios_share_rounded,
|
||||
label: "control_bottom_app_bar_share".tr(),
|
||||
onPressed: () {
|
||||
onShare();
|
||||
},
|
||||
),
|
||||
color: Theme.of(context).scaffoldBackgroundColor.withOpacity(0.95),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 20),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
ControlBoxButton(
|
||||
iconData: Icons.delete_outline_rounded,
|
||||
label: "control_bottom_app_bar_delete".tr(),
|
||||
onPressed: () {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return DeleteDialog(
|
||||
onDelete: onDelete,
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget renderAlbums() {
|
||||
Widget renderAlbum(AlbumResponseDto album) {
|
||||
final box = Hive.box(userInfoBox);
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(left: 8.0),
|
||||
child: GestureDetector(
|
||||
onTap: () => onAddToAlbum(album),
|
||||
child: Container(
|
||||
width: 112,
|
||||
padding: const EdgeInsets.all(6),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
ControlBoxButton(
|
||||
iconData: Icons.delete_forever_rounded,
|
||||
label: "control_bottom_app_bar_delete".tr(),
|
||||
onPressed: () {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return DeleteDialog(
|
||||
onDelete: onDelete,
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
ClipRRect(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
child: CachedNetworkImage(
|
||||
width: 100,
|
||||
height: 100,
|
||||
fit: BoxFit.cover,
|
||||
imageUrl: getAlbumThumbnailUrl(
|
||||
album,
|
||||
type: ThumbnailFormat.JPEG,
|
||||
),
|
||||
httpHeaders: {
|
||||
"Authorization": "Bearer ${box.get(accessTokenKey)}"
|
||||
},
|
||||
cacheKey: "${album.albumThumbnailAssetId}",
|
||||
),
|
||||
),
|
||||
ControlBoxButton(
|
||||
iconData: Icons.share,
|
||||
label: "control_bottom_app_bar_share".tr(),
|
||||
onPressed: () {
|
||||
onShare();
|
||||
},
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 12),
|
||||
child: Text(
|
||||
album.albumName,
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 12.0,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return SizedBox(
|
||||
height: 200,
|
||||
child: ListView.builder(
|
||||
scrollDirection: Axis.horizontal,
|
||||
itemBuilder: (buildContext, i) => renderAlbum(albums[i]),
|
||||
itemCount: albums.length,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return DraggableScrollableSheet(
|
||||
initialChildSize: 0.30,
|
||||
minChildSize: 0.15,
|
||||
maxChildSize: 0.57,
|
||||
snap: true,
|
||||
builder: (
|
||||
BuildContext context,
|
||||
ScrollController scrollController,
|
||||
) {
|
||||
return SingleChildScrollView(
|
||||
controller: scrollController,
|
||||
child: Card(
|
||||
elevation: 12.0,
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.only(
|
||||
topLeft: Radius.circular(12),
|
||||
topRight: Radius.circular(12),
|
||||
),
|
||||
),
|
||||
margin: const EdgeInsets.all(0),
|
||||
child: Container(
|
||||
decoration: const BoxDecoration(
|
||||
borderRadius: BorderRadius.only(
|
||||
topLeft: Radius.circular(12),
|
||||
topRight: Radius.circular(12),
|
||||
),
|
||||
),
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
const SizedBox(height: 12),
|
||||
const CustomDraggingHandle(),
|
||||
const SizedBox(height: 12),
|
||||
renderActionButtons(),
|
||||
const Divider(
|
||||
indent: 16,
|
||||
endIndent: 16,
|
||||
thickness: 1,
|
||||
),
|
||||
AddToAlbumTitleRow(
|
||||
onCreateNewAlbum: () => onCreateNewAlbum(),
|
||||
),
|
||||
renderAlbums(),
|
||||
const SizedBox(height: 200),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class AddToAlbumTitleRow extends StatelessWidget {
|
||||
const AddToAlbumTitleRow({
|
||||
super.key,
|
||||
required this.onCreateNewAlbum,
|
||||
});
|
||||
|
||||
final VoidCallback onCreateNewAlbum;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
const Text(
|
||||
"control_bottom_app_bar_add_to_album",
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
).tr(),
|
||||
TextButton(
|
||||
onPressed: onCreateNewAlbum,
|
||||
child: Text(
|
||||
"control_bottom_app_bar_create_new_album",
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).primaryColor,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 14,
|
||||
),
|
||||
).tr(),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class CustomDraggingHandle extends StatelessWidget {
|
||||
const CustomDraggingHandle({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
height: 5,
|
||||
width: 30,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey[500],
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -78,19 +234,20 @@ class ControlBoxButton extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SizedBox(
|
||||
width: 60,
|
||||
return MaterialButton(
|
||||
padding: const EdgeInsets.all(10),
|
||||
shape: const CircleBorder(),
|
||||
onPressed: () => onPressed(),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
onPressed();
|
||||
},
|
||||
icon: Icon(iconData, size: 30),
|
||||
Icon(iconData, size: 24),
|
||||
const SizedBox(height: 6),
|
||||
Text(
|
||||
label,
|
||||
style: const TextStyle(fontSize: 12.0),
|
||||
),
|
||||
Text(label)
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
import 'package:auto_route/auto_route.dart';
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:immich_mobile/modules/album/providers/album.provider.dart';
|
||||
import 'package:immich_mobile/modules/album/services/album.service.dart';
|
||||
import 'package:immich_mobile/modules/home/providers/home_page_render_list_provider.dart';
|
||||
import 'package:immich_mobile/modules/home/providers/multiselect.provider.dart';
|
||||
import 'package:immich_mobile/modules/home/ui/asset_grid/immich_asset_grid.dart';
|
||||
@@ -9,10 +13,12 @@ import 'package:immich_mobile/modules/home/ui/immich_sliver_appbar.dart';
|
||||
import 'package:immich_mobile/modules/home/ui/profile_drawer/profile_drawer.dart';
|
||||
import 'package:immich_mobile/modules/settings/providers/app_settings.provider.dart';
|
||||
import 'package:immich_mobile/modules/settings/services/app_settings.service.dart';
|
||||
import 'package:immich_mobile/routing/router.dart';
|
||||
import 'package:immich_mobile/shared/providers/asset.provider.dart';
|
||||
import 'package:immich_mobile/shared/providers/server_info.provider.dart';
|
||||
import 'package:immich_mobile/shared/providers/websocket.provider.dart';
|
||||
import 'package:immich_mobile/shared/services/share.service.dart';
|
||||
import 'package:immich_mobile/shared/ui/immich_toast.dart';
|
||||
import 'package:openapi/api.dart';
|
||||
|
||||
class HomePage extends HookConsumerWidget {
|
||||
@@ -23,14 +29,26 @@ class HomePage extends HookConsumerWidget {
|
||||
final appSettingService = ref.watch(appSettingsServiceProvider);
|
||||
var renderList = ref.watch(renderListProvider);
|
||||
final multiselectEnabled = ref.watch(multiselectProvider.notifier);
|
||||
final selectionEnabledHook = useState(false);
|
||||
|
||||
final selection = useState(<AssetResponseDto>{});
|
||||
final albums = ref.watch(albumProvider);
|
||||
final albumService = ref.watch(albumServiceProvider);
|
||||
|
||||
useEffect(
|
||||
() {
|
||||
ref.read(websocketProvider.notifier).connect();
|
||||
ref.read(assetProvider.notifier).getAllAsset();
|
||||
ref.read(albumProvider.notifier).getAllAlbums();
|
||||
ref.watch(serverInfoProvider.notifier).getServerVersion();
|
||||
return null;
|
||||
|
||||
selectionEnabledHook.addListener(() {
|
||||
multiselectEnabled.state = selectionEnabledHook.value;
|
||||
});
|
||||
|
||||
return () {
|
||||
selectionEnabledHook.dispose();
|
||||
};
|
||||
},
|
||||
[],
|
||||
);
|
||||
@@ -44,41 +62,84 @@ class HomePage extends HookConsumerWidget {
|
||||
bool multiselect,
|
||||
Set<AssetResponseDto> selectedAssets,
|
||||
) {
|
||||
multiselectEnabled.state = multiselect;
|
||||
selectionEnabledHook.value = multiselect;
|
||||
selection.value = selectedAssets;
|
||||
}
|
||||
|
||||
void onShareAssets() {
|
||||
ref.watch(shareServiceProvider).shareAssets(selection.value.toList());
|
||||
multiselectEnabled.state = false;
|
||||
selectionEnabledHook.value = false;
|
||||
}
|
||||
|
||||
void onDelete() {
|
||||
ref.watch(assetProvider.notifier).deleteAssets(selection.value);
|
||||
multiselectEnabled.state = false;
|
||||
selectionEnabledHook.value = false;
|
||||
}
|
||||
|
||||
void onAddToAlbum(AlbumResponseDto album) async {
|
||||
final result = await albumService.addAdditionalAssetToAlbum(
|
||||
selection.value,
|
||||
album.id,
|
||||
);
|
||||
|
||||
if (result != null) {
|
||||
if (result.alreadyInAlbum.isNotEmpty) {
|
||||
ImmichToast.show(
|
||||
context: context,
|
||||
msg: "home_page_add_to_album_conflicts".tr(
|
||||
namedArgs: {
|
||||
"album": album.albumName,
|
||||
"added": result.successfullyAdded.toString(),
|
||||
"failed": result.alreadyInAlbum.length.toString()
|
||||
},
|
||||
),
|
||||
);
|
||||
} else {
|
||||
ImmichToast.show(
|
||||
context: context,
|
||||
msg: "home_page_add_to_album_success".tr(
|
||||
namedArgs: {
|
||||
"album": album.albumName,
|
||||
"added": result.successfullyAdded.toString(),
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
selectionEnabledHook.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
void onCreateNewAlbum() async {
|
||||
final result =
|
||||
await albumService.createAlbumWithGeneratedName(selection.value);
|
||||
|
||||
if (result != null) {
|
||||
ref.watch(albumProvider.notifier).getAllAlbums();
|
||||
selectionEnabledHook.value = false;
|
||||
|
||||
AutoRouter.of(context).push(AlbumViewerRoute(albumId: result.id));
|
||||
}
|
||||
}
|
||||
|
||||
return SafeArea(
|
||||
bottom: !multiselectEnabled.state,
|
||||
top: !multiselectEnabled.state,
|
||||
top: true,
|
||||
child: Stack(
|
||||
children: [
|
||||
CustomScrollView(
|
||||
slivers: [
|
||||
multiselectEnabled.state
|
||||
? const SliverToBoxAdapter(
|
||||
child: SizedBox(
|
||||
height: 70,
|
||||
child: null,
|
||||
),
|
||||
)
|
||||
: ImmichSliverAppBar(
|
||||
onPopBack: reloadAllAsset,
|
||||
),
|
||||
if (!multiselectEnabled.state)
|
||||
ImmichSliverAppBar(
|
||||
onPopBack: reloadAllAsset,
|
||||
),
|
||||
],
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 60.0, bottom: 0.0),
|
||||
padding: EdgeInsets.only(
|
||||
top: selectionEnabledHook.value ? 0 : 60,
|
||||
bottom: 0.0,
|
||||
),
|
||||
child: ImmichAssetGrid(
|
||||
renderList: renderList,
|
||||
assetsPerRow:
|
||||
@@ -86,15 +147,17 @@ class HomePage extends HookConsumerWidget {
|
||||
showStorageIndicator: appSettingService
|
||||
.getSetting(AppSettingsEnum.storageIndicator),
|
||||
listener: selectionListener,
|
||||
selectionActive: multiselectEnabled.state,
|
||||
selectionActive: selectionEnabledHook.value,
|
||||
),
|
||||
),
|
||||
if (multiselectEnabled.state) ...[
|
||||
if (selectionEnabledHook.value)
|
||||
ControlBottomAppBar(
|
||||
onShare: onShareAssets,
|
||||
onDelete: onDelete,
|
||||
onAddToAlbum: onAddToAlbum,
|
||||
albums: albums,
|
||||
onCreateNewAlbum: onCreateNewAlbum,
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
@@ -69,6 +69,7 @@ Class | Method | HTTP request | Description
|
||||
*AlbumApi* | [**addUsersToAlbum**](doc//AlbumApi.md#adduserstoalbum) | **PUT** /album/{albumId}/users |
|
||||
*AlbumApi* | [**createAlbum**](doc//AlbumApi.md#createalbum) | **POST** /album |
|
||||
*AlbumApi* | [**deleteAlbum**](doc//AlbumApi.md#deletealbum) | **DELETE** /album/{albumId} |
|
||||
*AlbumApi* | [**downloadArchive**](doc//AlbumApi.md#downloadarchive) | **GET** /album/{albumId}/download |
|
||||
*AlbumApi* | [**getAlbumCountByUserId**](doc//AlbumApi.md#getalbumcountbyuserid) | **GET** /album/count-by-user-id |
|
||||
*AlbumApi* | [**getAlbumInfo**](doc//AlbumApi.md#getalbuminfo) | **GET** /album/{albumId} |
|
||||
*AlbumApi* | [**getAllAlbums**](doc//AlbumApi.md#getallalbums) | **GET** /album |
|
||||
|
||||
@@ -13,6 +13,7 @@ Method | HTTP request | Description
|
||||
[**addUsersToAlbum**](AlbumApi.md#adduserstoalbum) | **PUT** /album/{albumId}/users |
|
||||
[**createAlbum**](AlbumApi.md#createalbum) | **POST** /album |
|
||||
[**deleteAlbum**](AlbumApi.md#deletealbum) | **DELETE** /album/{albumId} |
|
||||
[**downloadArchive**](AlbumApi.md#downloadarchive) | **GET** /album/{albumId}/download |
|
||||
[**getAlbumCountByUserId**](AlbumApi.md#getalbumcountbyuserid) | **GET** /album/count-by-user-id |
|
||||
[**getAlbumInfo**](AlbumApi.md#getalbuminfo) | **GET** /album/{albumId} |
|
||||
[**getAllAlbums**](AlbumApi.md#getallalbums) | **GET** /album |
|
||||
@@ -212,6 +213,53 @@ void (empty response body)
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
||||
# **downloadArchive**
|
||||
> Object downloadArchive(albumId)
|
||||
|
||||
|
||||
|
||||
### Example
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
// TODO Configure HTTP Bearer authorization: bearer
|
||||
// Case 1. Use String Token
|
||||
//defaultApiClient.getAuthentication<HttpBearerAuth>('bearer').setAccessToken('YOUR_ACCESS_TOKEN');
|
||||
// Case 2. Use Function which generate token.
|
||||
// String yourTokenGeneratorFunction() { ... }
|
||||
//defaultApiClient.getAuthentication<HttpBearerAuth>('bearer').setAccessToken(yourTokenGeneratorFunction);
|
||||
|
||||
final api_instance = AlbumApi();
|
||||
final albumId = albumId_example; // String |
|
||||
|
||||
try {
|
||||
final result = api_instance.downloadArchive(albumId);
|
||||
print(result);
|
||||
} catch (e) {
|
||||
print('Exception when calling AlbumApi->downloadArchive: $e\n');
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**albumId** | **String**| |
|
||||
|
||||
### Return type
|
||||
|
||||
[**Object**](Object.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
[bearer](../README.md#bearer)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/json
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
||||
# **getAlbumCountByUserId**
|
||||
> AlbumCountResponseDto getAlbumCountByUserId()
|
||||
|
||||
|
||||
@@ -207,6 +207,54 @@ class AlbumApi {
|
||||
}
|
||||
}
|
||||
|
||||
/// Performs an HTTP 'GET /album/{albumId}/download' operation and returns the [Response].
|
||||
/// Parameters:
|
||||
///
|
||||
/// * [String] albumId (required):
|
||||
Future<Response> downloadArchiveWithHttpInfo(String albumId,) async {
|
||||
// ignore: prefer_const_declarations
|
||||
final path = r'/album/{albumId}/download'
|
||||
.replaceAll('{albumId}', albumId);
|
||||
|
||||
// ignore: prefer_final_locals
|
||||
Object? postBody;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
final formParams = <String, String>{};
|
||||
|
||||
const contentTypes = <String>[];
|
||||
|
||||
|
||||
return apiClient.invokeAPI(
|
||||
path,
|
||||
'GET',
|
||||
queryParams,
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentTypes.isEmpty ? null : contentTypes.first,
|
||||
);
|
||||
}
|
||||
|
||||
/// Parameters:
|
||||
///
|
||||
/// * [String] albumId (required):
|
||||
Future<Object?> downloadArchive(String albumId,) async {
|
||||
final response = await downloadArchiveWithHttpInfo(albumId,);
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||
}
|
||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
|
||||
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'Object',) as Object;
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// Performs an HTTP 'GET /album/count-by-user-id' operation and returns the [Response].
|
||||
Future<Response> getAlbumCountByUserIdWithHttpInfo() async {
|
||||
// ignore: prefer_const_declarations
|
||||
|
||||
@@ -2,7 +2,7 @@ name: immich_mobile
|
||||
description: Immich - selfhosted backup media file on mobile phone
|
||||
|
||||
publish_to: "none"
|
||||
version: 1.33.0+52
|
||||
version: 1.34.0+53
|
||||
|
||||
environment:
|
||||
sdk: ">=2.17.0 <3.0.0"
|
||||
|
||||
@@ -26,9 +26,10 @@ RUN mkdir -p /usr/src/app/dist \
|
||||
|
||||
COPY --from=builder /usr/src/app/node_modules ./node_modules
|
||||
COPY --from=builder /usr/src/app/dist ./dist
|
||||
COPY --from=builder /usr/src/app/bin ./bin
|
||||
|
||||
RUN npm prune --production
|
||||
|
||||
VOLUME /usr/src/app/upload
|
||||
|
||||
EXPOSE 3001
|
||||
EXPOSE 3001
|
||||
|
||||
11
server/apps/cli/src/app.module.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { DatabaseModule } from '@app/database';
|
||||
import { UserEntity } from '@app/database/entities/user.entity';
|
||||
import { Module } from '@nestjs/common';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { PromptPasswordQuestions, ResetAdminPasswordCommand } from './commands/reset-admin-password.command';
|
||||
|
||||
@Module({
|
||||
imports: [DatabaseModule, TypeOrmModule.forFeature([UserEntity])],
|
||||
providers: [ResetAdminPasswordCommand, PromptPasswordQuestions],
|
||||
})
|
||||
export class AppModule {}
|
||||
52
server/apps/cli/src/commands/reset-admin-password.command.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
import { UserEntity } from '@app/database/entities/user.entity';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import bcrypt from 'bcrypt';
|
||||
import { Command, CommandRunner, InquirerService, Question, QuestionSet } from 'nest-commander';
|
||||
import { randomBytes } from 'node:crypto';
|
||||
import { Repository } from 'typeorm';
|
||||
|
||||
@Command({
|
||||
name: 'reset-admin-password',
|
||||
description: 'Reset the admin password',
|
||||
})
|
||||
export class ResetAdminPasswordCommand extends CommandRunner {
|
||||
constructor(
|
||||
private readonly inquirer: InquirerService,
|
||||
@InjectRepository(UserEntity) private userRepository: Repository<UserEntity>,
|
||||
) {
|
||||
super();
|
||||
}
|
||||
|
||||
async run(): Promise<void> {
|
||||
let { password } = await this.inquirer.ask<{ password: string }>('prompt-password', undefined);
|
||||
password = password || randomBytes(24).toString('base64').replace(/\W/g, '');
|
||||
|
||||
const salt = await bcrypt.genSalt();
|
||||
const hashedPassword = await bcrypt.hash(password, salt);
|
||||
|
||||
const user = await this.userRepository.findOne({ where: { isAdmin: true } });
|
||||
if (!user) {
|
||||
console.log('Unable to reset password: no admin user.');
|
||||
return;
|
||||
}
|
||||
|
||||
user.salt = salt;
|
||||
user.password = hashedPassword;
|
||||
user.shouldChangePassword = true;
|
||||
|
||||
await this.userRepository.save(user);
|
||||
|
||||
console.log(`New password:\n${password}`);
|
||||
}
|
||||
}
|
||||
|
||||
@QuestionSet({ name: 'prompt-password' })
|
||||
export class PromptPasswordQuestions {
|
||||
@Question({
|
||||
message: 'Please choose a new password (optional)',
|
||||
name: 'password',
|
||||
})
|
||||
parsePassword(val: string) {
|
||||
return val;
|
||||
}
|
||||
}
|
||||
7
server/apps/cli/src/immich.ts
Executable file
@@ -0,0 +1,7 @@
|
||||
import { CommandFactory } from 'nest-commander';
|
||||
import { AppModule } from './app.module';
|
||||
|
||||
async function bootstrap() {
|
||||
await CommandFactory.run(AppModule, ['warn', 'error']);
|
||||
}
|
||||
bootstrap();
|
||||
9
server/apps/cli/tsconfig.app.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"declaration": false,
|
||||
"outDir": "../../dist/apps/cli"
|
||||
},
|
||||
"include": ["src/**/*", "../../libs/**/*"],
|
||||
"exclude": ["node_modules", "dist", "test", "**/*spec.ts"]
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
import { AlbumEntity } from '@app/database/entities/album.entity';
|
||||
import { AssetAlbumEntity } from '@app/database/entities/asset-album.entity';
|
||||
import { UserAlbumEntity } from '@app/database/entities/user-album.entity';
|
||||
import { BadRequestException, Injectable } from '@nestjs/common';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { Repository, SelectQueryBuilder, DataSource } from 'typeorm';
|
||||
import { In, Repository, SelectQueryBuilder, DataSource } from 'typeorm';
|
||||
import { AddAssetsDto } from './dto/add-assets.dto';
|
||||
import { AddUsersDto } from './dto/add-users.dto';
|
||||
import { CreateAlbumDto } from './dto/create-album.dto';
|
||||
@@ -11,7 +11,7 @@ import { GetAlbumsDto } from './dto/get-albums.dto';
|
||||
import { RemoveAssetsDto } from './dto/remove-assets.dto';
|
||||
import { UpdateAlbumDto } from './dto/update-album.dto';
|
||||
import { AlbumCountResponseDto } from './response-dto/album-count-response.dto';
|
||||
import {AddAssetsResponseDto} from "./response-dto/add-assets-response.dto";
|
||||
import { AddAssetsResponseDto } from './response-dto/add-assets-response.dto';
|
||||
|
||||
export interface IAlbumRepository {
|
||||
create(ownerId: string, createAlbumDto: CreateAlbumDto): Promise<AlbumEntity>;
|
||||
@@ -20,7 +20,7 @@ export interface IAlbumRepository {
|
||||
delete(album: AlbumEntity): Promise<void>;
|
||||
addSharedUsers(album: AlbumEntity, addUsersDto: AddUsersDto): Promise<AlbumEntity>;
|
||||
removeUser(album: AlbumEntity, userId: string): Promise<void>;
|
||||
removeAssets(album: AlbumEntity, removeAssets: RemoveAssetsDto): Promise<AlbumEntity>;
|
||||
removeAssets(album: AlbumEntity, removeAssets: RemoveAssetsDto): Promise<number>;
|
||||
addAssets(album: AlbumEntity, addAssetsDto: AddAssetsDto): Promise<AddAssetsResponseDto>;
|
||||
updateAlbum(album: AlbumEntity, updateAlbumDto: UpdateAlbumDto): Promise<AlbumEntity>;
|
||||
getListByAssetId(userId: string, assetId: string): Promise<AlbumEntity[]>;
|
||||
@@ -237,28 +237,13 @@ export class AlbumRepository implements IAlbumRepository {
|
||||
await this.userAlbumRepository.delete({ albumId: album.id, sharedUserId: userId });
|
||||
}
|
||||
|
||||
async removeAssets(album: AlbumEntity, removeAssetsDto: RemoveAssetsDto): Promise<AlbumEntity> {
|
||||
let deleteAssetCount = 0;
|
||||
// TODO: should probably do a single delete query?
|
||||
for (const assetId of removeAssetsDto.assetIds) {
|
||||
const res = await this.assetAlbumRepository.delete({ albumId: album.id, assetId: assetId });
|
||||
if (res.affected == 1) deleteAssetCount++;
|
||||
}
|
||||
async removeAssets(album: AlbumEntity, removeAssetsDto: RemoveAssetsDto): Promise<number> {
|
||||
const res = await this.assetAlbumRepository.delete({
|
||||
albumId: album.id,
|
||||
assetId: In(removeAssetsDto.assetIds),
|
||||
});
|
||||
|
||||
// TODO: No need to return boolean if using a singe delete query
|
||||
if (deleteAssetCount == removeAssetsDto.assetIds.length) {
|
||||
const retAlbum = (await this.get(album.id)) as AlbumEntity;
|
||||
|
||||
if (retAlbum?.assets?.length === 0) {
|
||||
// is empty album
|
||||
await this.albumRepository.update(album.id, { albumThumbnailAssetId: null });
|
||||
retAlbum.albumThumbnailAssetId = null;
|
||||
}
|
||||
|
||||
return retAlbum;
|
||||
} else {
|
||||
throw new BadRequestException('Some assets were not found in the album');
|
||||
}
|
||||
return res.affected || 0;
|
||||
}
|
||||
|
||||
async addAssets(album: AlbumEntity, addAssetsDto: AddAssetsDto): Promise<AddAssetsResponseDto> {
|
||||
@@ -267,7 +252,7 @@ export class AlbumRepository implements IAlbumRepository {
|
||||
|
||||
for (const assetId of addAssetsDto.assetIds) {
|
||||
// Album already contains that asset
|
||||
if (album.assets?.some(a => a.assetId === assetId)) {
|
||||
if (album.assets?.some((a) => a.assetId === assetId)) {
|
||||
alreadyExisting.push(assetId);
|
||||
continue;
|
||||
}
|
||||
@@ -288,7 +273,7 @@ export class AlbumRepository implements IAlbumRepository {
|
||||
|
||||
return {
|
||||
successfullyAdded: newRecords.length,
|
||||
alreadyInAlbum: alreadyExisting
|
||||
alreadyInAlbum: alreadyExisting,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
ParseUUIDPipe,
|
||||
Put,
|
||||
Query,
|
||||
Response,
|
||||
} from '@nestjs/common';
|
||||
import { ParseMeUUIDPipe } from '../validation/parse-me-uuid-pipe';
|
||||
import { AlbumService } from './album.service';
|
||||
@@ -24,7 +25,8 @@ import { GetAlbumsDto } from './dto/get-albums.dto';
|
||||
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
||||
import { AlbumResponseDto } from './response-dto/album-response.dto';
|
||||
import { AlbumCountResponseDto } from './response-dto/album-count-response.dto';
|
||||
import {AddAssetsResponseDto} from "./response-dto/add-assets-response.dto";
|
||||
import { AddAssetsResponseDto } from './response-dto/add-assets-response.dto';
|
||||
import { Response as Res } from 'express';
|
||||
|
||||
// TODO might be worth creating a AlbumParamsDto that validates `albumId` instead of using the pipe.
|
||||
@Authenticated()
|
||||
@@ -58,7 +60,7 @@ export class AlbumController {
|
||||
@GetAuthUser() authUser: AuthUserDto,
|
||||
@Body(ValidationPipe) addAssetsDto: AddAssetsDto,
|
||||
@Param('albumId', new ParseUUIDPipe({ version: '4' })) albumId: string,
|
||||
) : Promise<AddAssetsResponseDto> {
|
||||
): Promise<AddAssetsResponseDto> {
|
||||
return this.albumService.addAssetsToAlbum(authUser, addAssetsDto, albumId);
|
||||
}
|
||||
|
||||
@@ -112,4 +114,16 @@ export class AlbumController {
|
||||
) {
|
||||
return this.albumService.updateAlbumInfo(authUser, updateAlbumInfoDto, albumId);
|
||||
}
|
||||
|
||||
@Get('/:albumId/download')
|
||||
async downloadArchive(
|
||||
@GetAuthUser() authUser: AuthUserDto,
|
||||
@Param('albumId', new ParseUUIDPipe({ version: '4' })) albumId: string,
|
||||
@Response({ passthrough: true }) res: Res,
|
||||
): Promise<any> {
|
||||
const { stream, filename, filesize } = await this.albumService.downloadArchive(authUser, albumId);
|
||||
res.attachment(filename);
|
||||
res.setHeader('X-Immich-Content-Length-Hint', filesize);
|
||||
return stream;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,13 @@
|
||||
import { BadRequestException, Inject, Injectable, NotFoundException, ForbiddenException } from '@nestjs/common';
|
||||
import {
|
||||
BadRequestException,
|
||||
Inject,
|
||||
Injectable,
|
||||
NotFoundException,
|
||||
ForbiddenException,
|
||||
Logger,
|
||||
InternalServerErrorException,
|
||||
StreamableFile,
|
||||
} from '@nestjs/common';
|
||||
import { AuthUserDto } from '../../decorators/auth-user.decorator';
|
||||
import { CreateAlbumDto } from './dto/create-album.dto';
|
||||
import { AlbumEntity } from '@app/database/entities/album.entity';
|
||||
@@ -10,8 +19,10 @@ import { AlbumResponseDto, mapAlbum, mapAlbumExcludeAssetInfo } from './response
|
||||
import { ALBUM_REPOSITORY, IAlbumRepository } from './album-repository';
|
||||
import { AlbumCountResponseDto } from './response-dto/album-count-response.dto';
|
||||
import { ASSET_REPOSITORY, IAssetRepository } from '../asset/asset-repository';
|
||||
import { AddAssetsResponseDto } from "./response-dto/add-assets-response.dto";
|
||||
import {AddAssetsDto} from "./dto/add-assets.dto";
|
||||
import { AddAssetsResponseDto } from './response-dto/add-assets-response.dto';
|
||||
import { AddAssetsDto } from './dto/add-assets.dto';
|
||||
import archiver from 'archiver';
|
||||
import { extname } from 'path';
|
||||
|
||||
@Injectable()
|
||||
export class AlbumService {
|
||||
@@ -54,11 +65,13 @@ export class AlbumService {
|
||||
* @returns All Shared Album And Its Members
|
||||
*/
|
||||
async getAllAlbums(authUser: AuthUserDto, getAlbumsDto: GetAlbumsDto): Promise<AlbumResponseDto[]> {
|
||||
let albums: AlbumEntity[];
|
||||
|
||||
if (typeof getAlbumsDto.assetId === 'string') {
|
||||
const albums = await this._albumRepository.getListByAssetId(authUser.id, getAlbumsDto.assetId);
|
||||
return albums.map(mapAlbumExcludeAssetInfo);
|
||||
albums = await this._albumRepository.getListByAssetId(authUser.id, getAlbumsDto.assetId);
|
||||
} else {
|
||||
albums = await this._albumRepository.getList(authUser.id, getAlbumsDto);
|
||||
}
|
||||
const albums = await this._albumRepository.getList(authUser.id, getAlbumsDto);
|
||||
|
||||
for (const album of albums) {
|
||||
await this._checkValidThumbnail(album);
|
||||
@@ -101,8 +114,18 @@ export class AlbumService {
|
||||
albumId: string,
|
||||
): Promise<AlbumResponseDto> {
|
||||
const album = await this._getAlbum({ authUser, albumId });
|
||||
const updateAlbum = await this._albumRepository.removeAssets(album, removeAssetsDto);
|
||||
return mapAlbum(updateAlbum);
|
||||
const deletedCount = await this._albumRepository.removeAssets(album, removeAssetsDto);
|
||||
const newAlbum = await this._getAlbum({ authUser, albumId });
|
||||
|
||||
if (newAlbum) {
|
||||
await this._checkValidThumbnail(newAlbum);
|
||||
}
|
||||
|
||||
if (deletedCount !== removeAssetsDto.assetIds.length) {
|
||||
throw new BadRequestException('Some assets were not found in the album');
|
||||
}
|
||||
|
||||
return mapAlbum(newAlbum);
|
||||
}
|
||||
|
||||
async addAssetsToAlbum(
|
||||
@@ -116,7 +139,7 @@ export class AlbumService {
|
||||
|
||||
return {
|
||||
...result,
|
||||
album: mapAlbum(newAlbum)
|
||||
album: mapAlbum(newAlbum),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -139,17 +162,48 @@ export class AlbumService {
|
||||
return this._albumRepository.getCountByUserId(authUser.id);
|
||||
}
|
||||
|
||||
async _checkValidThumbnail(album: AlbumEntity): Promise<AlbumEntity> {
|
||||
const assetId = album.albumThumbnailAssetId;
|
||||
if (assetId) {
|
||||
try {
|
||||
await this._assetRepository.getById(assetId);
|
||||
} catch (e) {
|
||||
album.albumThumbnailAssetId = null;
|
||||
return await this._albumRepository.updateAlbum(album, {});
|
||||
}
|
||||
async downloadArchive(authUser: AuthUserDto, albumId: string) {
|
||||
const album = await this._getAlbum({ authUser, albumId, validateIsOwner: false });
|
||||
if (!album.assets || album.assets.length === 0) {
|
||||
throw new BadRequestException('Cannot download an empty album.');
|
||||
}
|
||||
|
||||
return album;
|
||||
try {
|
||||
const archive = archiver('zip', { store: true });
|
||||
const stream = new StreamableFile(archive);
|
||||
let totalSize = 0;
|
||||
|
||||
for (const { assetInfo } of album.assets) {
|
||||
const { originalPath } = assetInfo;
|
||||
const name = `${assetInfo.exifInfo?.imageName || assetInfo.id}${extname(originalPath)}`;
|
||||
archive.file(originalPath, { name });
|
||||
totalSize += Number(assetInfo.exifInfo?.fileSizeInByte || 0);
|
||||
}
|
||||
|
||||
archive.finalize();
|
||||
|
||||
return {
|
||||
stream,
|
||||
filename: `${album.albumName}.zip`,
|
||||
filesize: totalSize,
|
||||
};
|
||||
} catch (e) {
|
||||
Logger.error(`Error downloading album ${e}`, 'downloadArchive');
|
||||
throw new InternalServerErrorException(`Failed to download album ${e}`, 'DownloadArchive');
|
||||
}
|
||||
}
|
||||
|
||||
async _checkValidThumbnail(album: AlbumEntity) {
|
||||
const assets = album.assets || [];
|
||||
const valid = assets.some((asset) => asset.assetId === album.albumThumbnailAssetId);
|
||||
if (!valid) {
|
||||
let dto: UpdateAlbumDto = {};
|
||||
if (assets.length > 0) {
|
||||
const albumThumbnailAssetId = assets[0].assetId;
|
||||
dto = { albumThumbnailAssetId };
|
||||
}
|
||||
await this._albumRepository.updateAlbum(album, dto);
|
||||
album.albumThumbnailAssetId = dto.albumThumbnailAssetId || null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,10 @@ export interface IAssetRepository {
|
||||
getAssetWithNoThumbnail(): Promise<AssetEntity[]>;
|
||||
getAssetWithNoEXIF(): Promise<AssetEntity[]>;
|
||||
getAssetWithNoSmartInfo(): Promise<AssetEntity[]>;
|
||||
getExistingAssets(userId: string, checkDuplicateAssetDto: CheckExistingAssetsDto): Promise<CheckExistingAssetsResponseDto>;
|
||||
getExistingAssets(
|
||||
userId: string,
|
||||
checkDuplicateAssetDto: CheckExistingAssetsDto,
|
||||
): Promise<CheckExistingAssetsResponseDto>;
|
||||
}
|
||||
|
||||
export const ASSET_REPOSITORY = 'ASSET_REPOSITORY';
|
||||
@@ -118,6 +121,7 @@ export class AssetRepository implements IAssetRepository {
|
||||
.select(`COUNT(asset.id)::int`, 'count')
|
||||
.addSelect(`date_trunc('month', "createdAt")`, 'timeBucket')
|
||||
.where('"userId" = :userId', { userId: userId })
|
||||
.andWhere('asset.resizePath is not NULL')
|
||||
.groupBy(`date_trunc('month', "createdAt")`)
|
||||
.orderBy(`date_trunc('month', "createdAt")`, 'DESC')
|
||||
.getRawMany();
|
||||
@@ -127,6 +131,7 @@ export class AssetRepository implements IAssetRepository {
|
||||
.select(`COUNT(asset.id)::int`, 'count')
|
||||
.addSelect(`date_trunc('day', "createdAt")`, 'timeBucket')
|
||||
.where('"userId" = :userId', { userId: userId })
|
||||
.andWhere('asset.resizePath is not NULL')
|
||||
.groupBy(`date_trunc('day', "createdAt")`)
|
||||
.orderBy(`date_trunc('day', "createdAt")`, 'DESC')
|
||||
.getRawMany();
|
||||
@@ -284,16 +289,18 @@ export class AssetRepository implements IAssetRepository {
|
||||
});
|
||||
}
|
||||
|
||||
async getExistingAssets(userId: string, checkDuplicateAssetDto: CheckExistingAssetsDto): Promise<CheckExistingAssetsResponseDto> {
|
||||
async getExistingAssets(
|
||||
userId: string,
|
||||
checkDuplicateAssetDto: CheckExistingAssetsDto,
|
||||
): Promise<CheckExistingAssetsResponseDto> {
|
||||
const existingAssets = await this.assetRepository.find({
|
||||
select: {deviceAssetId: true},
|
||||
select: { deviceAssetId: true },
|
||||
where: {
|
||||
deviceAssetId: In(checkDuplicateAssetDto.deviceAssetIds),
|
||||
deviceId: checkDuplicateAssetDto.deviceId,
|
||||
userId,
|
||||
},
|
||||
});
|
||||
return new CheckExistingAssetsResponseDto(existingAssets.map(a => a.deviceAssetId));
|
||||
return new CheckExistingAssetsResponseDto(existingAssets.map((a) => a.deviceAssetId));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
import { plainToInstance } from 'class-transformer';
|
||||
import { validateSync } from 'class-validator';
|
||||
import { CheckExistingAssetsDto } from './check-existing-assets.dto';
|
||||
|
||||
describe('CheckExistingAssetsDto', () => {
|
||||
it('should fail with an empty list', () => {
|
||||
const dto = plainToInstance(CheckExistingAssetsDto, { deviceAssetIds: [], deviceId: 'test-device' });
|
||||
const errors = validateSync(dto);
|
||||
expect(errors).toHaveLength(1);
|
||||
expect(errors[0].property).toEqual('deviceAssetIds');
|
||||
});
|
||||
|
||||
it('should fail with an empty string', () => {
|
||||
const dto = plainToInstance(CheckExistingAssetsDto, { deviceAssetIds: [''], deviceId: 'test-device' });
|
||||
const errors = validateSync(dto);
|
||||
expect(errors).toHaveLength(1);
|
||||
expect(errors[0].property).toEqual('deviceAssetIds');
|
||||
});
|
||||
|
||||
it('should work with valid asset ids', () => {
|
||||
const dto = plainToInstance(CheckExistingAssetsDto, {
|
||||
deviceAssetIds: ['asset-1', 'asset-2'],
|
||||
deviceId: 'test-device',
|
||||
});
|
||||
const errors = validateSync(dto);
|
||||
expect(errors).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
@@ -1,9 +1,11 @@
|
||||
import { IsNotEmpty } from 'class-validator';
|
||||
import { ArrayNotEmpty, IsNotEmpty, IsString } from 'class-validator';
|
||||
|
||||
export class CheckExistingAssetsDto {
|
||||
@IsNotEmpty()
|
||||
@ArrayNotEmpty()
|
||||
@IsString({ each: true })
|
||||
@IsNotEmpty({ each: true })
|
||||
deviceAssetIds!: string[];
|
||||
|
||||
@IsNotEmpty()
|
||||
deviceId!: string;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
import { plainToInstance } from 'class-transformer';
|
||||
import { validateSync } from 'class-validator';
|
||||
import { LoginCredentialDto } from './login-credential.dto';
|
||||
|
||||
describe('LoginCredentialDto', () => {
|
||||
it('should fail without an email', () => {
|
||||
const dto = plainToInstance(LoginCredentialDto, { password: 'password' });
|
||||
const errors = validateSync(dto);
|
||||
expect(errors).toHaveLength(1);
|
||||
expect(errors[0].property).toEqual('email');
|
||||
});
|
||||
|
||||
it('should fail with an invalid email', () => {
|
||||
const dto = plainToInstance(LoginCredentialDto, { email: 'invalid.com', password: 'password' });
|
||||
const errors = validateSync(dto);
|
||||
expect(errors).toHaveLength(1);
|
||||
expect(errors[0].property).toEqual('email');
|
||||
});
|
||||
|
||||
it('should make the email all lowercase', () => {
|
||||
const dto = plainToInstance(LoginCredentialDto, { email: 'TeSt@ImMiCh.com', password: 'password' });
|
||||
const errors = validateSync(dto);
|
||||
expect(errors).toHaveLength(0);
|
||||
expect(dto.email).toEqual('test@immich.com');
|
||||
});
|
||||
|
||||
it('should fail without a password', () => {
|
||||
const dto = plainToInstance(LoginCredentialDto, { email: 'test@immich.com', password: '' });
|
||||
const errors = validateSync(dto);
|
||||
expect(errors).toHaveLength(1);
|
||||
expect(errors[0].property).toEqual('password');
|
||||
});
|
||||
});
|
||||
@@ -1,13 +1,14 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { Transform } from 'class-transformer';
|
||||
import { IsNotEmpty } from 'class-validator';
|
||||
import { IsEmail, IsNotEmpty, IsString } from 'class-validator';
|
||||
|
||||
export class LoginCredentialDto {
|
||||
@IsNotEmpty()
|
||||
@IsEmail()
|
||||
@ApiProperty({ example: 'testuser@email.com' })
|
||||
@Transform(({ value }) => value?.toLowerCase())
|
||||
@Transform(({ value }) => value.toLowerCase())
|
||||
email!: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@ApiProperty({ example: 'password' })
|
||||
password!: string;
|
||||
|
||||
@@ -1,27 +1,44 @@
|
||||
import { plainToInstance } from 'class-transformer';
|
||||
import { validate } from 'class-validator';
|
||||
import { validateSync } from 'class-validator';
|
||||
import { SignUpDto } from './sign-up.dto';
|
||||
|
||||
describe('sign up DTO', () => {
|
||||
it('validates the email', async () => {
|
||||
const params: Partial<SignUpDto> = {
|
||||
email: undefined,
|
||||
describe('SignUpDto', () => {
|
||||
it('should require all fields', () => {
|
||||
const dto = plainToInstance(SignUpDto, {
|
||||
email: '',
|
||||
password: '',
|
||||
firstName: '',
|
||||
lastName: '',
|
||||
});
|
||||
const errors = validateSync(dto);
|
||||
expect(errors).toHaveLength(4);
|
||||
expect(errors[0].property).toEqual('email');
|
||||
expect(errors[1].property).toEqual('password');
|
||||
expect(errors[2].property).toEqual('firstName');
|
||||
expect(errors[3].property).toEqual('lastName');
|
||||
});
|
||||
|
||||
it('should require a valid email', () => {
|
||||
const dto = plainToInstance(SignUpDto, {
|
||||
email: 'immich.com',
|
||||
password: 'password',
|
||||
firstName: 'first name',
|
||||
lastName: 'last name',
|
||||
};
|
||||
let dto: SignUpDto = plainToInstance(SignUpDto, params);
|
||||
let errors = await validate(dto);
|
||||
});
|
||||
const errors = validateSync(dto);
|
||||
expect(errors).toHaveLength(1);
|
||||
expect(errors[0].property).toEqual('email');
|
||||
});
|
||||
|
||||
params.email = 'invalid email';
|
||||
dto = plainToInstance(SignUpDto, params);
|
||||
errors = await validate(dto);
|
||||
expect(errors).toHaveLength(1);
|
||||
|
||||
params.email = 'valid@email.com';
|
||||
dto = plainToInstance(SignUpDto, params);
|
||||
errors = await validate(dto);
|
||||
it('should make the email all lowercase', () => {
|
||||
const dto = plainToInstance(SignUpDto, {
|
||||
email: 'TeSt@ImMiCh.com',
|
||||
password: 'password',
|
||||
firstName: 'first name',
|
||||
lastName: 'last name',
|
||||
});
|
||||
const errors = validateSync(dto);
|
||||
expect(errors).toHaveLength(0);
|
||||
expect(dto.email).toEqual('test@immich.com');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,21 +1,24 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { Transform } from 'class-transformer';
|
||||
import { IsNotEmpty, IsEmail } from 'class-validator';
|
||||
import { IsEmail, IsNotEmpty, IsString } from 'class-validator';
|
||||
|
||||
export class SignUpDto {
|
||||
@IsEmail()
|
||||
@ApiProperty({ example: 'testuser@email.com' })
|
||||
@Transform(({ value }) => value?.toLowerCase())
|
||||
@Transform(({ value }) => value.toLowerCase())
|
||||
email!: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@ApiProperty({ example: 'password' })
|
||||
password!: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@ApiProperty({ example: 'Admin' })
|
||||
firstName!: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@ApiProperty({ example: 'Doe' })
|
||||
lastName!: string;
|
||||
|
||||
141
server/apps/immich/src/config/asset-upload.config.spec.ts
Normal file
@@ -0,0 +1,141 @@
|
||||
import { Request } from 'express';
|
||||
import * as fs from 'fs';
|
||||
import { multerUtils } from './asset-upload.config';
|
||||
|
||||
const { fileFilter, destination, filename } = multerUtils;
|
||||
|
||||
const mock = {
|
||||
req: {} as Request,
|
||||
userRequest: {
|
||||
user: {
|
||||
id: 'test-user',
|
||||
},
|
||||
body: {
|
||||
deviceId: 'test-device',
|
||||
fileExtension: '.jpg',
|
||||
},
|
||||
} as Request,
|
||||
file: { originalname: 'test.jpg' } as Express.Multer.File,
|
||||
};
|
||||
|
||||
jest.mock('fs');
|
||||
|
||||
describe('assetUploadOption', () => {
|
||||
let callback: jest.Mock;
|
||||
let existsSync: jest.Mock;
|
||||
let mkdirSync: jest.Mock;
|
||||
|
||||
beforeEach(() => {
|
||||
jest.mock('fs');
|
||||
mkdirSync = fs.mkdirSync as jest.Mock;
|
||||
existsSync = fs.existsSync as jest.Mock;
|
||||
callback = jest.fn();
|
||||
|
||||
existsSync.mockImplementation(() => true);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
jest.resetModules();
|
||||
});
|
||||
|
||||
describe('fileFilter', () => {
|
||||
it('should require a user', () => {
|
||||
fileFilter(mock.req, mock.file, callback);
|
||||
|
||||
expect(callback).toHaveBeenCalled();
|
||||
const [error, name] = callback.mock.calls[0];
|
||||
expect(error).toBeDefined();
|
||||
expect(name).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should allow images', async () => {
|
||||
const file = { mimetype: 'image/jpeg', originalname: 'test.jpg' } as any;
|
||||
fileFilter(mock.userRequest, file, callback);
|
||||
expect(callback).toHaveBeenCalledWith(null, true);
|
||||
});
|
||||
|
||||
it('should allow videos', async () => {
|
||||
const file = { mimetype: 'image/mp4', originalname: 'test.mp4' } as any;
|
||||
fileFilter(mock.userRequest, file, callback);
|
||||
expect(callback).toHaveBeenCalledWith(null, true);
|
||||
});
|
||||
|
||||
it('should not allow unknown types', async () => {
|
||||
const file = { mimetype: 'application/html', originalname: 'test.html' } as any;
|
||||
const callback = jest.fn();
|
||||
fileFilter(mock.userRequest, file, callback);
|
||||
|
||||
expect(callback).toHaveBeenCalled();
|
||||
const [error, accepted] = callback.mock.calls[0];
|
||||
expect(error).toBeDefined();
|
||||
expect(accepted).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('destination', () => {
|
||||
it('should require a user', () => {
|
||||
destination(mock.req, mock.file, callback);
|
||||
|
||||
expect(callback).toHaveBeenCalled();
|
||||
const [error, name] = callback.mock.calls[0];
|
||||
expect(error).toBeDefined();
|
||||
expect(name).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should create non-existing directories', () => {
|
||||
existsSync.mockImplementation(() => false);
|
||||
|
||||
destination(mock.userRequest, mock.file, callback);
|
||||
|
||||
expect(existsSync).toHaveBeenCalled();
|
||||
expect(mkdirSync).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should return the destination', () => {
|
||||
destination(mock.userRequest, mock.file, callback);
|
||||
|
||||
expect(mkdirSync).not.toHaveBeenCalled();
|
||||
expect(callback).toHaveBeenCalledWith(null, 'upload/test-user/original/test-device');
|
||||
});
|
||||
|
||||
it('should sanitize the deviceId', () => {
|
||||
const request = { ...mock.userRequest, body: { deviceId: 'test-devi\u0000ce' } } as Request;
|
||||
destination(request, mock.file, callback);
|
||||
|
||||
const [folderName] = existsSync.mock.calls[0];
|
||||
expect(folderName.endsWith('test-device')).toBeTruthy();
|
||||
expect(callback).toHaveBeenCalledWith(null, 'upload/test-user/original/test-device');
|
||||
});
|
||||
});
|
||||
|
||||
describe('filename', () => {
|
||||
it('should require a user', () => {
|
||||
filename(mock.req, mock.file, callback);
|
||||
|
||||
expect(callback).toHaveBeenCalled();
|
||||
const [error, name] = callback.mock.calls[0];
|
||||
expect(error).toBeDefined();
|
||||
expect(name).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should return the filename', () => {
|
||||
filename(mock.userRequest, mock.file, callback);
|
||||
|
||||
expect(callback).toHaveBeenCalled();
|
||||
const [error, name] = callback.mock.calls[0];
|
||||
expect(error).toBeNull();
|
||||
expect(name.endsWith('.jpg')).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should sanitize the filename', () => {
|
||||
const body = { ...mock.userRequest.body, fileExtension: '.jp\u0000g' };
|
||||
const request = { ...mock.userRequest, body } as Request;
|
||||
filename(request, mock.file, callback);
|
||||
|
||||
expect(callback).toHaveBeenCalled();
|
||||
const [error, name] = callback.mock.calls[0];
|
||||
expect(error).toBeNull();
|
||||
expect(name.endsWith(mock.userRequest.body.fileExtension)).toBeTruthy();
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,48 +1,60 @@
|
||||
import { APP_UPLOAD_LOCATION } from '@app/common/constants';
|
||||
import { HttpException, HttpStatus } from '@nestjs/common';
|
||||
import { BadRequestException, UnauthorizedException } from '@nestjs/common';
|
||||
import { MulterOptions } from '@nestjs/platform-express/multer/interfaces/multer-options.interface';
|
||||
import { randomUUID } from 'crypto';
|
||||
import { Request } from 'express';
|
||||
import { existsSync, mkdirSync } from 'fs';
|
||||
import { diskStorage } from 'multer';
|
||||
import { extname, join } from 'path';
|
||||
import { Request } from 'express';
|
||||
import { randomUUID } from 'crypto';
|
||||
import sanitize from 'sanitize-filename';
|
||||
|
||||
export const assetUploadOption: MulterOptions = {
|
||||
fileFilter: (req: Request, file: any, cb: any) => {
|
||||
if (
|
||||
file.mimetype.match(/\/(jpg|jpeg|png|gif|mp4|x-msvideo|quicktime|heic|heif|dng|x-adobe-dng|webp|tiff|3gpp|nef)$/)
|
||||
) {
|
||||
cb(null, true);
|
||||
} else {
|
||||
cb(new HttpException(`Unsupported file type ${extname(file.originalname)}`, HttpStatus.BAD_REQUEST), false);
|
||||
}
|
||||
},
|
||||
|
||||
fileFilter,
|
||||
storage: diskStorage({
|
||||
destination: (req: Request, file: Express.Multer.File, cb: any) => {
|
||||
const basePath = APP_UPLOAD_LOCATION;
|
||||
|
||||
if (!req.user) {
|
||||
return;
|
||||
}
|
||||
|
||||
const sanitizedDeviceId = sanitize(String(req.body['deviceId']));
|
||||
const originalUploadFolder = join(basePath, req.user.id, 'original', sanitizedDeviceId);
|
||||
|
||||
if (!existsSync(originalUploadFolder)) {
|
||||
mkdirSync(originalUploadFolder, { recursive: true });
|
||||
}
|
||||
|
||||
// Save original to disk
|
||||
cb(null, originalUploadFolder);
|
||||
},
|
||||
|
||||
filename: (req: Request, file: Express.Multer.File, cb: any) => {
|
||||
const fileNameUUID = randomUUID();
|
||||
const fileName = `${fileNameUUID}${req.body['fileExtension'].toLowerCase()}`;
|
||||
const sanitizedFileName = sanitize(fileName);
|
||||
cb(null, sanitizedFileName);
|
||||
},
|
||||
destination,
|
||||
filename,
|
||||
}),
|
||||
};
|
||||
|
||||
export const multerUtils = { fileFilter, filename, destination };
|
||||
|
||||
function fileFilter(req: Request, file: any, cb: any) {
|
||||
if (!req.user) {
|
||||
return cb(new UnauthorizedException());
|
||||
}
|
||||
if (
|
||||
file.mimetype.match(/\/(jpg|jpeg|png|gif|mp4|x-msvideo|quicktime|heic|heif|dng|x-adobe-dng|webp|tiff|3gpp|nef)$/)
|
||||
) {
|
||||
cb(null, true);
|
||||
} else {
|
||||
cb(new BadRequestException(`Unsupported file type ${extname(file.originalname)}`), false);
|
||||
}
|
||||
}
|
||||
|
||||
function destination(req: Request, file: Express.Multer.File, cb: any) {
|
||||
if (!req.user) {
|
||||
return cb(new UnauthorizedException());
|
||||
}
|
||||
|
||||
const basePath = APP_UPLOAD_LOCATION;
|
||||
const sanitizedDeviceId = sanitize(String(req.body['deviceId']));
|
||||
const originalUploadFolder = join(basePath, req.user.id, 'original', sanitizedDeviceId);
|
||||
|
||||
if (!existsSync(originalUploadFolder)) {
|
||||
mkdirSync(originalUploadFolder, { recursive: true });
|
||||
}
|
||||
|
||||
// Save original to disk
|
||||
cb(null, originalUploadFolder);
|
||||
}
|
||||
|
||||
function filename(req: Request, file: Express.Multer.File, cb: any) {
|
||||
if (!req.user) {
|
||||
return cb(new UnauthorizedException());
|
||||
}
|
||||
|
||||
const fileNameUUID = randomUUID();
|
||||
const fileName = `${fileNameUUID}${req.body['fileExtension'].toLowerCase()}`;
|
||||
const sanitizedFileName = sanitize(fileName);
|
||||
cb(null, sanitizedFileName);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
import { Request } from 'express';
|
||||
import * as fs from 'fs';
|
||||
import { multerUtils } from './profile-image-upload.config';
|
||||
|
||||
const { fileFilter, destination, filename } = multerUtils;
|
||||
|
||||
const mock = {
|
||||
req: {} as Request,
|
||||
userRequest: {
|
||||
user: {
|
||||
id: 'test-user',
|
||||
},
|
||||
} as Request,
|
||||
file: { originalname: 'test.jpg' } as Express.Multer.File,
|
||||
};
|
||||
|
||||
jest.mock('fs');
|
||||
|
||||
describe('profileImageUploadOption', () => {
|
||||
let callback: jest.Mock;
|
||||
let existsSync: jest.Mock;
|
||||
let mkdirSync: jest.Mock;
|
||||
|
||||
beforeEach(() => {
|
||||
jest.mock('fs');
|
||||
mkdirSync = fs.mkdirSync as jest.Mock;
|
||||
existsSync = fs.existsSync as jest.Mock;
|
||||
callback = jest.fn();
|
||||
|
||||
existsSync.mockImplementation(() => true);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
jest.resetModules();
|
||||
});
|
||||
|
||||
describe('fileFilter', () => {
|
||||
it('should require a user', () => {
|
||||
fileFilter(mock.req, mock.file, callback);
|
||||
|
||||
expect(callback).toHaveBeenCalled();
|
||||
const [error, name] = callback.mock.calls[0];
|
||||
expect(error).toBeDefined();
|
||||
expect(name).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should allow images', async () => {
|
||||
const file = { mimetype: 'image/jpeg', originalname: 'test.jpg' } as any;
|
||||
fileFilter(mock.userRequest, file, callback);
|
||||
expect(callback).toHaveBeenCalledWith(null, true);
|
||||
});
|
||||
|
||||
it('should not allow gifs', async () => {
|
||||
const file = { mimetype: 'image/gif', originalname: 'test.gif' } as any;
|
||||
const callback = jest.fn();
|
||||
fileFilter(mock.userRequest, file, callback);
|
||||
|
||||
expect(callback).toHaveBeenCalled();
|
||||
const [error, accepted] = callback.mock.calls[0];
|
||||
expect(error).toBeDefined();
|
||||
expect(accepted).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('destination', () => {
|
||||
it('should require a user', () => {
|
||||
destination(mock.req, mock.file, callback);
|
||||
|
||||
expect(callback).toHaveBeenCalled();
|
||||
const [error, name] = callback.mock.calls[0];
|
||||
expect(error).toBeDefined();
|
||||
expect(name).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should create non-existing directories', () => {
|
||||
existsSync.mockImplementation(() => false);
|
||||
|
||||
destination(mock.userRequest, mock.file, callback);
|
||||
|
||||
expect(existsSync).toHaveBeenCalled();
|
||||
expect(mkdirSync).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should return the destination', () => {
|
||||
destination(mock.userRequest, mock.file, callback);
|
||||
|
||||
expect(mkdirSync).not.toHaveBeenCalled();
|
||||
expect(callback).toHaveBeenCalledWith(null, './upload/test-user/profile');
|
||||
});
|
||||
});
|
||||
|
||||
describe('filename', () => {
|
||||
it('should require a user', () => {
|
||||
filename(mock.req, mock.file, callback);
|
||||
|
||||
expect(callback).toHaveBeenCalled();
|
||||
const [error, name] = callback.mock.calls[0];
|
||||
expect(error).toBeDefined();
|
||||
expect(name).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should return the filename', () => {
|
||||
filename(mock.userRequest, mock.file, callback);
|
||||
|
||||
expect(mkdirSync).not.toHaveBeenCalled();
|
||||
expect(callback).toHaveBeenCalledWith(null, 'test-user.jpg');
|
||||
});
|
||||
|
||||
it('should sanitize the filename', () => {
|
||||
filename(mock.userRequest, { ...mock.file, originalname: 'test.j\u0000pg' }, callback);
|
||||
expect(callback).toHaveBeenCalledWith(null, 'test-user.jpg');
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,44 +1,56 @@
|
||||
import { APP_UPLOAD_LOCATION } from '@app/common/constants';
|
||||
import { HttpException, HttpStatus } from '@nestjs/common';
|
||||
import { BadRequestException, UnauthorizedException } from '@nestjs/common';
|
||||
import { MulterOptions } from '@nestjs/platform-express/multer/interfaces/multer-options.interface';
|
||||
import { Request } from 'express';
|
||||
import { existsSync, mkdirSync } from 'fs';
|
||||
import { diskStorage } from 'multer';
|
||||
import { extname } from 'path';
|
||||
import { Request } from 'express';
|
||||
import sanitize from 'sanitize-filename';
|
||||
|
||||
export const profileImageUploadOption: MulterOptions = {
|
||||
fileFilter: (req: Request, file: any, cb: any) => {
|
||||
if (file.mimetype.match(/\/(jpg|jpeg|png|heic|heif|dng|webp)$/)) {
|
||||
cb(null, true);
|
||||
} else {
|
||||
cb(new HttpException(`Unsupported file type ${extname(file.originalname)}`, HttpStatus.BAD_REQUEST), false);
|
||||
}
|
||||
},
|
||||
|
||||
fileFilter,
|
||||
storage: diskStorage({
|
||||
destination: (req: Request, file: Express.Multer.File, cb: any) => {
|
||||
if (!req.user) {
|
||||
return;
|
||||
}
|
||||
const basePath = APP_UPLOAD_LOCATION;
|
||||
const profileImageLocation = `${basePath}/${req.user.id}/profile`;
|
||||
|
||||
if (!existsSync(profileImageLocation)) {
|
||||
mkdirSync(profileImageLocation, { recursive: true });
|
||||
}
|
||||
|
||||
cb(null, profileImageLocation);
|
||||
},
|
||||
|
||||
filename: (req: Request, file: Express.Multer.File, cb: any) => {
|
||||
if (!req.user) {
|
||||
return;
|
||||
}
|
||||
const userId = req.user.id;
|
||||
const fileName = `${userId}${extname(file.originalname)}`;
|
||||
|
||||
cb(null, sanitize(String(fileName)));
|
||||
},
|
||||
destination,
|
||||
filename,
|
||||
}),
|
||||
};
|
||||
|
||||
export const multerUtils = { fileFilter, filename, destination };
|
||||
|
||||
function fileFilter(req: Request, file: any, cb: any) {
|
||||
if (!req.user) {
|
||||
return cb(new UnauthorizedException());
|
||||
}
|
||||
|
||||
if (file.mimetype.match(/\/(jpg|jpeg|png|heic|heif|dng|webp)$/)) {
|
||||
cb(null, true);
|
||||
} else {
|
||||
cb(new BadRequestException(`Unsupported file type ${extname(file.originalname)}`), false);
|
||||
}
|
||||
}
|
||||
|
||||
function destination(req: Request, file: Express.Multer.File, cb: any) {
|
||||
if (!req.user) {
|
||||
return cb(new UnauthorizedException());
|
||||
}
|
||||
|
||||
const basePath = APP_UPLOAD_LOCATION;
|
||||
const profileImageLocation = `${basePath}/${req.user.id}/profile`;
|
||||
|
||||
if (!existsSync(profileImageLocation)) {
|
||||
mkdirSync(profileImageLocation, { recursive: true });
|
||||
}
|
||||
|
||||
cb(null, profileImageLocation);
|
||||
}
|
||||
|
||||
function filename(req: Request, file: Express.Multer.File, cb: any) {
|
||||
if (!req.user) {
|
||||
return cb(new UnauthorizedException());
|
||||
}
|
||||
|
||||
const userId = req.user.id;
|
||||
const fileName = `${userId}${extname(file.originalname)}`;
|
||||
|
||||
cb(null, sanitize(String(fileName)));
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ export interface IServerVersion {
|
||||
|
||||
export const serverVersion: IServerVersion = {
|
||||
major: 1,
|
||||
minor: 33,
|
||||
patch: 1,
|
||||
build: 52,
|
||||
minor: 34,
|
||||
patch: 0,
|
||||
build: 53,
|
||||
};
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
import { Logger } from '@nestjs/common';
|
||||
import { JwtService } from '@nestjs/jwt';
|
||||
import { Request } from 'express';
|
||||
import { ImmichJwtService } from './immich-jwt.service';
|
||||
|
||||
describe('ImmichJwtService', () => {
|
||||
let jwtService: JwtService;
|
||||
let service: ImmichJwtService;
|
||||
|
||||
beforeEach(() => {
|
||||
jwtService = new JwtService();
|
||||
service = new ImmichJwtService(jwtService);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
jest.resetModules();
|
||||
});
|
||||
|
||||
describe('generateToken', () => {
|
||||
it('should generate the token', async () => {
|
||||
const spy = jest.spyOn(jwtService, 'sign');
|
||||
spy.mockImplementation((value) => value as string);
|
||||
const dto = { userId: 'test-user', email: 'test-user@immich.com' };
|
||||
const token = await service.generateToken(dto);
|
||||
expect(token).toEqual(dto);
|
||||
});
|
||||
});
|
||||
|
||||
describe('validateToken', () => {
|
||||
it('should validate the token', async () => {
|
||||
const dto = { userId: 'test-user', email: 'test-user@immich.com' };
|
||||
const spy = jest.spyOn(jwtService, 'verifyAsync');
|
||||
spy.mockImplementation(() => dto as any);
|
||||
const response = await service.validateToken('access-token');
|
||||
|
||||
expect(spy).toHaveBeenCalledTimes(1);
|
||||
expect(response).toEqual({ userId: 'test-user', status: true });
|
||||
});
|
||||
|
||||
it('should handle an invalid token', async () => {
|
||||
const verifyAsync = jest.spyOn(jwtService, 'verifyAsync');
|
||||
verifyAsync.mockImplementation(() => {
|
||||
throw new Error('Invalid token!');
|
||||
});
|
||||
|
||||
const error = jest.spyOn(Logger, 'error');
|
||||
error.mockImplementation(() => null);
|
||||
const response = await service.validateToken('access-token');
|
||||
|
||||
expect(verifyAsync).toHaveBeenCalledTimes(1);
|
||||
expect(error).toHaveBeenCalledTimes(1);
|
||||
expect(response).toEqual({ userId: null, status: false });
|
||||
});
|
||||
});
|
||||
|
||||
describe('extractJwtFromHeader', () => {
|
||||
it('should handle no authorization header', () => {
|
||||
const request = {
|
||||
headers: {},
|
||||
} as Request;
|
||||
const token = service.extractJwtFromHeader(request);
|
||||
expect(token).toBe(null);
|
||||
});
|
||||
|
||||
it('should get the token from the authorization header', () => {
|
||||
const upper = {
|
||||
headers: {
|
||||
authorization: 'Bearer token',
|
||||
},
|
||||
} as Request;
|
||||
|
||||
const lower = {
|
||||
headers: {
|
||||
authorization: 'bearer token',
|
||||
},
|
||||
} as Request;
|
||||
|
||||
expect(service.extractJwtFromHeader(upper)).toBe('token');
|
||||
expect(service.extractJwtFromHeader(lower)).toBe('token');
|
||||
});
|
||||
});
|
||||
|
||||
describe('extracJwtFromCookie', () => {
|
||||
it('should handle no cookie', () => {
|
||||
const request = {} as Request;
|
||||
const token = service.extractJwtFromCookie(request);
|
||||
expect(token).toBe(null);
|
||||
});
|
||||
|
||||
it('should get the token from the immich cookie', () => {
|
||||
const request = {
|
||||
cookies: {
|
||||
immich_access_token: 'cookie',
|
||||
},
|
||||
} as Request;
|
||||
const token = service.extractJwtFromCookie(request);
|
||||
expect(token).toBe('cookie');
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -13,8 +13,7 @@ export class JwtStrategy extends PassportStrategy(Strategy, 'jwt') {
|
||||
constructor(
|
||||
@InjectRepository(UserEntity)
|
||||
private usersRepository: Repository<UserEntity>,
|
||||
|
||||
private immichJwtService: ImmichJwtService,
|
||||
immichJwtService: ImmichJwtService,
|
||||
) {
|
||||
super({
|
||||
jwtFromRequest: ExtractJwt.fromExtractors([
|
||||
|
||||
1
server/bin/cli.sh
Executable file
@@ -0,0 +1 @@
|
||||
node ./dist/apps/cli/apps/cli/src/immich "$@"
|
||||
@@ -6,13 +6,15 @@
|
||||
"compilerOptions": {
|
||||
"webpack": false,
|
||||
"tsConfigPath": "apps/immich/tsconfig.app.json",
|
||||
"plugins": [ {
|
||||
"name": "@nestjs/swagger",
|
||||
"options": {
|
||||
"classValidatorShim": false,
|
||||
"introspectComments": true
|
||||
"plugins": [
|
||||
{
|
||||
"name": "@nestjs/swagger",
|
||||
"options": {
|
||||
"classValidatorShim": false,
|
||||
"introspectComments": true
|
||||
}
|
||||
}
|
||||
}]
|
||||
]
|
||||
},
|
||||
"projects": {
|
||||
"immich": {
|
||||
@@ -33,6 +35,15 @@
|
||||
"tsConfigPath": "apps/microservices/tsconfig.app.json"
|
||||
}
|
||||
},
|
||||
"cli": {
|
||||
"type": "application",
|
||||
"root": "apps/cli",
|
||||
"entryFile": "immich",
|
||||
"sourceRoot": "apps/cli/src",
|
||||
"compilerOptions": {
|
||||
"tsConfigPath": "apps/cli/tsconfig.app.json"
|
||||
}
|
||||
},
|
||||
"common": {
|
||||
"type": "library",
|
||||
"root": "libs/common",
|
||||
|
||||