From a6eea4d0964e3eac0d0f4859a8b6278b7ae6edba Mon Sep 17 00:00:00 2001 From: Zeeshan Khan Date: Sun, 23 Oct 2022 16:54:54 -0500 Subject: [PATCH] feat(web) add asset count stats on admin page (#843) --- mobile/openapi/.openapi-generator/FILES | 4 + mobile/openapi/README.md | Bin 9153 -> 9354 bytes mobile/openapi/doc/AssetCountResponseDto.md | Bin 0 -> 441 bytes mobile/openapi/doc/ServerInfoApi.md | Bin 2790 -> 3623 bytes mobile/openapi/doc/ServerStatsResponseDto.md | Bin 0 -> 619 bytes mobile/openapi/doc/UsageByUserDto.md | Bin 0 -> 550 bytes mobile/openapi/lib/api.dart | Bin 3326 -> 3408 bytes mobile/openapi/lib/api/server_info_api.dart | Bin 4598 -> 5980 bytes mobile/openapi/lib/api_client.dart | Bin 13670 -> 13846 bytes .../lib/model/asset_count_response_dto.dart | Bin 0 -> 3662 bytes .../lib/model/server_stats_response_dto.dart | Bin 0 -> 4655 bytes .../openapi/lib/model/usage_by_user_dto.dart | Bin 0 -> 4414 bytes .../test/asset_count_response_dto_test.dart | Bin 0 -> 674 bytes .../test/server_stats_response_dto_test.dart | Bin 0 -> 896 bytes .../openapi/test/usage_by_user_dto_test.dart | Bin 0 -> 847 bytes .../src/api-v1/asset/asset.controller.ts | 1 + .../immich/src/api-v1/auth/auth.service.ts | 2 +- .../auth/response-dto/logout-response.dto.ts | 12 +- .../response-dto/server-stats-response.dto.ts | 43 ++++++ .../usage-by-user-response.dto.ts | 23 +++ .../server-info/server-info.controller.ts | 6 + .../api-v1/server-info/server-info.module.ts | 3 + .../api-v1/server-info/server-info.service.ts | 70 ++++++++- .../api-v1/user/dto/create-user.dto.spec.ts | 4 +- .../immich/src/api-v1/user/user-repository.ts | 4 +- .../immich/src/api-v1/user/user.module.ts | 4 +- server/immich-openapi-specs.json | 2 +- server/libs/common/src/config/app.config.ts | 18 +-- .../database/src/entities/album.entity.ts | 2 +- .../src/entities/asset-album.entity.ts | 2 +- ...656888591977-RenameAssetAlbumIdSequence.ts | 24 +-- ...6888918620-DropExifTextSearchableColumn.ts | 16 +- ...1566-MatchMigrationsWithTypeORMEntities.ts | 98 +++++++----- .../1661881837496-AddAssetChecksum.ts | 7 +- ...UpdateAssetTableWithNewUniqueConstraint.ts | 7 +- web/src/api/open-api/api.ts | 142 ++++++++++++++++++ .../components/admin-page/server-stats.svelte | 52 +++++++ web/src/lib/models/admin-sidebar-selection.ts | 3 +- web/src/routes/admin/+page.server.ts | 4 +- web/src/routes/admin/+page.svelte | 12 ++ 40 files changed, 475 insertions(+), 90 deletions(-) create mode 100644 mobile/openapi/doc/AssetCountResponseDto.md create mode 100644 mobile/openapi/doc/ServerStatsResponseDto.md create mode 100644 mobile/openapi/doc/UsageByUserDto.md create mode 100644 mobile/openapi/lib/model/asset_count_response_dto.dart create mode 100644 mobile/openapi/lib/model/server_stats_response_dto.dart create mode 100644 mobile/openapi/lib/model/usage_by_user_dto.dart create mode 100644 mobile/openapi/test/asset_count_response_dto_test.dart create mode 100644 mobile/openapi/test/server_stats_response_dto_test.dart create mode 100644 mobile/openapi/test/usage_by_user_dto_test.dart create mode 100644 server/apps/immich/src/api-v1/server-info/response-dto/server-stats-response.dto.ts create mode 100644 server/apps/immich/src/api-v1/server-info/response-dto/usage-by-user-response.dto.ts create mode 100644 web/src/lib/components/admin-page/server-stats.svelte diff --git a/mobile/openapi/.openapi-generator/FILES b/mobile/openapi/.openapi-generator/FILES index 3a8edc0030..4e4d0ac35a 100644 --- a/mobile/openapi/.openapi-generator/FILES +++ b/mobile/openapi/.openapi-generator/FILES @@ -48,6 +48,7 @@ doc/SearchAssetDto.md doc/ServerInfoApi.md doc/ServerInfoResponseDto.md doc/ServerPingResponse.md +doc/ServerStatsResponseDto.md doc/ServerVersionReponseDto.md doc/SignUpDto.md doc/SmartInfoResponseDto.md @@ -56,6 +57,7 @@ doc/TimeGroupEnum.md doc/UpdateAlbumDto.md doc/UpdateDeviceInfoDto.md doc/UpdateUserDto.md +doc/UsageByUserDto.md doc/UserApi.md doc/UserCountResponseDto.md doc/UserResponseDto.md @@ -117,6 +119,7 @@ lib/model/remove_assets_dto.dart lib/model/search_asset_dto.dart lib/model/server_info_response_dto.dart lib/model/server_ping_response.dart +lib/model/server_stats_response_dto.dart lib/model/server_version_reponse_dto.dart lib/model/sign_up_dto.dart lib/model/smart_info_response_dto.dart @@ -125,6 +128,7 @@ lib/model/time_group_enum.dart lib/model/update_album_dto.dart lib/model/update_device_info_dto.dart lib/model/update_user_dto.dart +lib/model/usage_by_user_dto.dart lib/model/user_count_response_dto.dart lib/model/user_response_dto.dart lib/model/validate_access_token_response_dto.dart diff --git a/mobile/openapi/README.md b/mobile/openapi/README.md index 3154654d42e96eaef82b230db6e9b5b72552c705..11325beaf5006c3761981ac9a0a656efb5dd186e 100644 GIT binary patch delta 107 zcmX@;-sQPrswhW#YDsWOVoCAj`Jz%FPBEDCQAC1GAI#ibBf68D1*By1LV02C;MAhB t)FOxuMFo+~`igaoQisYNa&`LP-)`N{hFp~Yaq&9jx%7y)w7CaM4c delta 22 ecmeD3Jm|h*s_5o#q6@e;Us9}K++3zC!UzC&cL^T= diff --git a/mobile/openapi/doc/AssetCountResponseDto.md b/mobile/openapi/doc/AssetCountResponseDto.md new file mode 100644 index 0000000000000000000000000000000000000000..2deedf1cc85385491e7c0fb48a40e0dd7f8dc6f2 GIT binary patch literal 441 zcma)2!Ab)$5WUY=4D6vcko2yn)$KvBr4(E-ha|d%M$ExEJQKW4ag7qeDditf>;OZ$)e+GhQx~e>S6Gz%JaW! zp_JbtVN{BxN?Awk9~Vp=t$|-Ce0hbMer`KNzV<@D|LED07iLMpy6x4#mK>f|5kiZW zN=&-V9@;1oWlV9C~`O`mpIo2GU@yI*9u{aO>HoPZ<_yqZ4 BzI6Zq literal 0 HcmV?d00001 diff --git a/mobile/openapi/doc/UsageByUserDto.md b/mobile/openapi/doc/UsageByUserDto.md new file mode 100644 index 0000000000000000000000000000000000000000..2e6a074c0c9031b2858a142693d7050052eac76d GIT binary patch literal 550 zcma)(K}!QM5QXpg6@fj}E@XSxQ_J>Hu%%RcDus=kv5j^!A(>SQ{&*+rf@`U0F5%^S zd6Ud!5>SeT`jtJRsw$%c3EOxKBuD-E zZJ#$unaMD^OV%!F9T*0(5XDM2AV1{e*{7|9SO@FLqGPo}VuuvD?kKqmocA z(*)$nM%wRhiej>vPs`=JXiR3XZX0l3Z?cyF3{M&Uoa1|A_c1 Kcu{;Tg!lx=Po$av literal 0 HcmV?d00001 diff --git a/mobile/openapi/lib/api.dart b/mobile/openapi/lib/api.dart index 150d878f63ef12603bdc5dcac6987fd822da16c2..56e8941bf7179df4381411e031e6dcee3386ba03 100644 GIT binary patch delta 38 ucmew-c|mG}AQx+KNn%Oy9a`|kK6 zJB^Ypp9U;IY)ibChj-6&WUtrh_2BG}o6+&_!>i%-+0F1AES|;c!plBCJDs@h*bc)6eg>d$|{q#tlZ*`{mS+TfdVG5;LV#yZ{r@{ zsavi!`k>`hsgm}onN=G4{bV%#$_w1RU2=T{{Q>xD7OYGNMH*Lr{P4d(JXVvJFCA2G z7SLmc01WOgdw8_`2vFM6f?HTJvwW{+9HF`J4fTj|k{8?bGB*Bs!VVqgw%aKL* zBlyL?_vv=;A5`dz)j}@7D*q#KMd`M-ZS0fu4@0ZMUiybV$)xLoe`eJiA1j5~1_>^T z0fxUcN@8%|`MHp+g#0VMgFZYkzuUg{we==r-Sru}6SVd}e>U(CoI$Lxrx+2|has0O z(dYS01}10VrENf11GlWKxq-P>s}OMPULpDCXwW5zjIk1v6l7f@1&MEKVVoxRdRl2d zM}azR>$*Uanw;pHqtvY^a-0fFHKQK;7wvj_>wvflhl+cEvD}C$aqx)Eh$_AZ@Qnz4 za3)#7jD66N#0!r~is*;Z)S9DgnZ*wdD^>w+!7^07d(kNS8{Zfj1Hti1Sq`sGolPhq z5xHxjSn}cTF_f?Q;@Y^7vs|rI2i4&&e z%pgEqI|wisPB?9ohKmF(;{8Z)5yFra%OpYYyGoH+aHVo(alh!|3{&V{hp7(e2rt?t zbckz{7ld;qjG=uIhv4$d=ql@CktvP;+efJuIOPTjl`n-x(?<`V!f-KX7x z(synF{MIE8@My!0-h*^L2_$wa?!j9qaq$8>aZf}Z>76@77Fw;@w8X&-b5&Uy-orvf0{?V{ePD;Yh`c0{YO^n?fSJT3ABNdPHOc z@}l)tzNGN)q>M54neu=jO5dZGK;!*^)g1O4tPeU5J?G|_FD+clyFc^lw$aKtB7FCk2VWj!rcgG`T zIhM0^Uk0o|WAYy4J%2|XA9s$A;m!5c=-KbX^WnvttKk{EefM$LgR>EwkFMa;=BWPBU4^g)Ch!?$x5w#H>|5n1_uam~&;l{SB=eo2`lrB?Kyim=QG+y1dURJ15+N{v!EsD9h zD6?OF&hoi1w$s7u9OxP7N|vHhDgJ-i>Ewm57A~dvCe5W2&R$4c;hpl#X}IeE9Ag+R zq+6QOf`C%4VB9V}0p(52Wr}L;G6|gs5CZ{ju54P(wbQoO!uf_yw{!H(XPLWJrKJ_O z@V3T46E2-mP61?@4N!FH@#1v`k1p^NCRFG9ENQ+yG`t{+Gd9^5I-)r1!7!CqF%R%)cgncd!3l7 zaKxUNQPOUugSoKt-}F>sl)R&LLsK7@GMCm0v!*`8)|yMJtQSi-;b~Mqf}fbqj_=Zg z!@G>==N`@;GJCaQ?$ku6DyMmo_%i6Wcifnr=^utJ3)$-*vNKpN+)4ezus}=;4b(r3 zt3V5cuwyd=jW?67xAl{#PT8~`OxFl@Dj$H;@2xJ;R)&C?Dn$X=XQW~0?TFvqzvS9v zk+JEr{oM&l^YWnpJLCm;`A{G@=q1AXp-6Pt%fwBq&_<$_&GFa>@t#GEM^ko;DE9<3 z{{m(~lvCizV?j9!-$b#L7G_2-!ii%~LS&wyK$ie~jLDhwpj;LRD}*5{Wj$awnxisu zhV#S2p;_h#JT@ap%5V}nm1j7#=6Xua!h}6w|H@n9vmUB|EsQ0AMkU@pf+#dA(gC<_}A|G!kcuaQH{ULR19lPT*YfgnI0Jk!wpsDkz?7C*k>t zmkBW>Na#Aq=Q95yr+^OtvRzG;Tf>c9YmEGjBxo;n`HX`3@VFOr9Qu_L{@}00Nl;aI zlqzxj6;fC<5P1i|44lH!xTNk6GA-Ksfy_k{h9aLQ2^znN6o~~@3RfEaMHMgDgYHFm zbpR^DlRYSLh|I|oGIXJ=CC8|W;Qi(3JndqX=^p;qxNS^IaM1VF^n*7cxYBci$}rSG zxqBN8;dpQ88fTU=67Q3vO#uXcyMIZ23}eR$6~`acE~DAix{{|jG6o4num?5N93AjW zfh=G|d0Z_3P*W|y%;S0ymzs(Zdmh(}Qr#WZ9X)QHjgMY+SC4V(1g^K9C~1MumbX|C zzL_aZ2+00~h;thQLdx!a#6waj%{9^m%X4S{cF@66xcOAA6XwO-_+&)-kIo?Uc09rytL*KQ8sP(8$%_WEq1tW<`&# z_}nI#ijWtR8-KS_jjDB*q4T&UjPU-rzj;4N;cN=$(@Xd;J$v)| zuLBe#$(M6s-1yn(>9YZC)orPb%of^Y3suMysLR^Qc_s_FlBG-IUacx^++Gb)ti{G= zRqZk(ztqa0dMQ@;w-N?_oir8?H+H{zu1o7g=`uCP3)MnN8mg#Vup26-W@g)1v=q=dN@}}i-gyLOZLMH%3hrunC9bx3mn|Zp2qi;UR+}VAsujsel%c+*y?dR0w z&4pO+JJ0ioaesu~1AKHwmAAmQd5S7AOl(lIXDga5U)^lueV))9h&Fh_OZ`FdipUe-UW6l;#M=r@(2>MUha<(#ZMtjaQ&{lJ)qpk0|p)kn!l?5_H+Y zG2+K%SAabwepq$c>^ZT+s>_a%;QKiXJqx@@!{3PzMgLYhSPHxRUC$-P#JkrtBlTb@ zb7`$G8|oo!i>0*6da;BPIg08>@DtO6x4R5>bC=Hk?b4%*-{EY@JFbPwaGDp1&-d`E z(|R+ue|#94C1z=S7#v7LUdD%Pcp4HhK4gOtl0x;<8KDoD76{ivZ`lV?{mO=%Iv4g@w_paMH|^ z5Ih$sFeGf9VJfauDC+{Tfq-DGtjE+=%~wV)5YqiLFm;aTVKc&&42OeLd4_Xjspr%K zOz7e93vYqXZOAoS788xeB;GE<7c?i*0k{N01$dEBF09+Bg@oahP#?{nl(se!VP81> zBVi>fK--Lr=WcVyMmgYxLJl9Ub(-SWfVn-c5bdWD){#nieXEE8X=E`m0Ms74l z{6-Rnm%4mHLF^y*jE+OUa)J~5wFvoDg-59pCsZMYMFWv{5X``VD2+>+E+EsQz3<3e zG+`q0Ws;!r+endEP^EB*rs~|LhPvGkl5-)NNFoFa6GIRaHg%saPqKP zK%cf+#G8i|qttLmbw`hJdF!HAZRv&F-1`uR=uqY`T?kw6*%_DdcZ|lat_!{MRq}#y3>79qD h`0D1lIgIl#Y{QrfyD+`Nt_~jv!}i{9@MVuU_BR0@bqoLi literal 0 HcmV?d00001 diff --git a/mobile/openapi/test/asset_count_response_dto_test.dart b/mobile/openapi/test/asset_count_response_dto_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..e0ec0d9d7e18fbba5d2cf6fda3bbf89492a59ca0 GIT binary patch literal 674 zcma)&O;5r=5Qgvl72~OpAXQEVLL#xnkSI+E9y~3ZGPE1p-F0`0A%_3%v=uM*z@gin zb3k4$9U-(b`;a+KjYTc3iufBh zTZglM2%)E_IW9mG+RPsKNnqhU(vzt*ZO~gTiZPksXw)7msq|n7-vIzi4ob@sRJ%!r zFz;6mhO>bA+?m=A!X~Dl3rFy4-I^;+U<*UWvl!ZXtTychs6eoeS9NrPU5D*D1L;pX hYa2E)Zn;h4w6!>QMgH86{PtJ4ci46AoYSV9gCA-=+NuBm literal 0 HcmV?d00001 diff --git a/mobile/openapi/test/server_stats_response_dto_test.dart b/mobile/openapi/test/server_stats_response_dto_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..04443aed6cdad8ca26ba6a6ede572b6e4be677cb GIT binary patch literal 896 zcmb7>K~LL25QXpl71L9Kl;Xmv0wERTfRI{TL2~G6S?o!&#o67?j8jDw|DD-2^w0(Y z2d_P=_q};DF3X}U;dDN$KVD3)rq`#lX$9w(U#AnOYPhOr@U5;c&wqSSSyFy!Ey>B@ z{=s39O1JcZ&@2L(h3oJLdfzj)20L7%m&tSO)-jOmBy9KFZrQ|M4B@Zdk>cL2^^BJE zEl8~9#Jlk(coyr$xKx{o9Ty5LDfDqXN{wC+jwbMAp6#6%h^ruhm4=*9@sK}2RtS-FT9Pf? z4zk<9!1C5NIb*^!=d7;kZ1FH8`Rl&X^}oS=kiFYI-2KExUJw7Idzb&5^=E%anllo# Zj_>mYpKa5{tLyp~cw1|=%?o@e9sx3f9M}K= literal 0 HcmV?d00001 diff --git a/mobile/openapi/test/usage_by_user_dto_test.dart b/mobile/openapi/test/usage_by_user_dto_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..52a3ddfc3c9819f1db38398768b44d1867bc6038 GIT binary patch literal 847 zcmb7>K~KUk6vyxT6wecoAX838LLz2hNR%Z64xUQg-bQt6XWK!D;k*0V!39Z>!@73) z{eSQEEewM&gwb*l-@c4z_Zz|-`IK^PhyC7tKX6Bp zOQn%zO0!H9_z1PE4WhMqp5vpcQ1VKI z^z_`VTZ2D{MPoy^906C~;}%7O2Ng352et`RCt_tJI;t0TB-B;4#| z;`?$z>TMB6v6t+dF8oJXm!LjAF|p=ifdhB7e?z}gUDh|))pk+Rd@kD??0 { return this.assetService.getAssetCountByUserId(authUser); } + /** * Get all AssetEntity belong to the user */ diff --git a/server/apps/immich/src/api-v1/auth/auth.service.ts b/server/apps/immich/src/api-v1/auth/auth.service.ts index f3e5afd682..dac6f8b4d4 100644 --- a/server/apps/immich/src/api-v1/auth/auth.service.ts +++ b/server/apps/immich/src/api-v1/auth/auth.service.ts @@ -54,7 +54,7 @@ export class AuthService { const validatedUser = await this.validateUser(loginCredential); if (!validatedUser) { - Logger.warn(`Failed login attempt for user ${loginCredential.email} from ip address ${clientIp}`) + Logger.warn(`Failed login attempt for user ${loginCredential.email} from ip address ${clientIp}`); throw new BadRequestException('Incorrect email or password'); } diff --git a/server/apps/immich/src/api-v1/auth/response-dto/logout-response.dto.ts b/server/apps/immich/src/api-v1/auth/response-dto/logout-response.dto.ts index 47d688ac10..4a9484fbdb 100644 --- a/server/apps/immich/src/api-v1/auth/response-dto/logout-response.dto.ts +++ b/server/apps/immich/src/api-v1/auth/response-dto/logout-response.dto.ts @@ -1,10 +1,10 @@ import { ApiResponseProperty } from '@nestjs/swagger'; export class LogoutResponseDto { - constructor (successful: boolean) { - this.successful = successful; - } + constructor(successful: boolean) { + this.successful = successful; + } - @ApiResponseProperty() - successful!: boolean; -}; \ No newline at end of file + @ApiResponseProperty() + successful!: boolean; +} diff --git a/server/apps/immich/src/api-v1/server-info/response-dto/server-stats-response.dto.ts b/server/apps/immich/src/api-v1/server-info/response-dto/server-stats-response.dto.ts new file mode 100644 index 0000000000..aef4acd118 --- /dev/null +++ b/server/apps/immich/src/api-v1/server-info/response-dto/server-stats-response.dto.ts @@ -0,0 +1,43 @@ +import { ApiProperty } from '@nestjs/swagger'; +import { UsageByUserDto } from './usage-by-user-response.dto'; + +export class ServerStatsResponseDto { + constructor() { + this.photos = 0; + this.videos = 0; + this.objects = 0; + this.usageByUser = []; + this.usageRaw = 0; + this.usage = ''; + } + + @ApiProperty({ type: 'integer' }) + photos!: number; + + @ApiProperty({ type: 'integer' }) + videos!: number; + + @ApiProperty({ type: 'integer' }) + objects!: number; + + @ApiProperty({ type: 'integer', format: 'int64' }) + usageRaw!: number; + + @ApiProperty({ type: 'string' }) + usage!: string; + + @ApiProperty({ + isArray: true, + type: UsageByUserDto, + title: 'Array of usage for each user', + example: [ + { + photos: 1, + videos: 1, + objects: 1, + diskUsageRaw: 1, + }, + ], + }) + usageByUser!: UsageByUserDto[]; +} diff --git a/server/apps/immich/src/api-v1/server-info/response-dto/usage-by-user-response.dto.ts b/server/apps/immich/src/api-v1/server-info/response-dto/usage-by-user-response.dto.ts new file mode 100644 index 0000000000..863c77af9d --- /dev/null +++ b/server/apps/immich/src/api-v1/server-info/response-dto/usage-by-user-response.dto.ts @@ -0,0 +1,23 @@ +import { ApiProperty } from '@nestjs/swagger'; + +export class UsageByUserDto { + constructor(userId: string) { + this.userId = userId; + this.objects = 0; + this.videos = 0; + this.photos = 0; + } + + @ApiProperty({ type: 'string' }) + userId: string; + @ApiProperty({ type: 'integer' }) + objects: number; + @ApiProperty({ type: 'integer' }) + videos: number; + @ApiProperty({ type: 'integer' }) + photos: number; + @ApiProperty({ type: 'integer', format: 'int64' }) + usageRaw!: number; + @ApiProperty({ type: 'string' }) + usage!: string; +} diff --git a/server/apps/immich/src/api-v1/server-info/server-info.controller.ts b/server/apps/immich/src/api-v1/server-info/server-info.controller.ts index 51b3d0a336..0c5b196188 100644 --- a/server/apps/immich/src/api-v1/server-info/server-info.controller.ts +++ b/server/apps/immich/src/api-v1/server-info/server-info.controller.ts @@ -5,6 +5,7 @@ import { ApiTags } from '@nestjs/swagger'; import { ServerPingResponse } from './response-dto/server-ping-response.dto'; import { ServerVersionReponseDto } from './response-dto/server-version-response.dto'; import { ServerInfoResponseDto } from './response-dto/server-info-response.dto'; +import { ServerStatsResponseDto } from './response-dto/server-stats-response.dto'; @ApiTags('Server Info') @Controller('server-info') @@ -25,4 +26,9 @@ export class ServerInfoController { async getServerVersion(): Promise { return serverVersion; } + + @Get('/stats') + async getStats(): Promise { + return await this.serverInfoService.getStats(); + } } diff --git a/server/apps/immich/src/api-v1/server-info/server-info.module.ts b/server/apps/immich/src/api-v1/server-info/server-info.module.ts index 455b402145..619886dcb0 100644 --- a/server/apps/immich/src/api-v1/server-info/server-info.module.ts +++ b/server/apps/immich/src/api-v1/server-info/server-info.module.ts @@ -1,8 +1,11 @@ import { Module } from '@nestjs/common'; import { ServerInfoService } from './server-info.service'; import { ServerInfoController } from './server-info.controller'; +import { AssetEntity } from '@app/database/entities/asset.entity'; +import { TypeOrmModule } from '@nestjs/typeorm'; @Module({ + imports: [TypeOrmModule.forFeature([AssetEntity])], controllers: [ServerInfoController], providers: [ServerInfoService], }) diff --git a/server/apps/immich/src/api-v1/server-info/server-info.service.ts b/server/apps/immich/src/api-v1/server-info/server-info.service.ts index 6d88932f1a..171233ed02 100644 --- a/server/apps/immich/src/api-v1/server-info/server-info.service.ts +++ b/server/apps/immich/src/api-v1/server-info/server-info.service.ts @@ -2,9 +2,21 @@ import { APP_UPLOAD_LOCATION } from '@app/common/constants'; import { Injectable } from '@nestjs/common'; import { ServerInfoResponseDto } from './response-dto/server-info-response.dto'; import diskusage from 'diskusage'; +import { ServerStatsResponseDto } from './response-dto/server-stats-response.dto'; +import { UsageByUserDto } from './response-dto/usage-by-user-response.dto'; +import { AssetEntity } from '@app/database/entities/asset.entity'; +import { Repository } from 'typeorm'; +import { InjectRepository } from '@nestjs/typeorm'; +import path from 'path'; +import { readdirSync, statSync } from 'fs'; @Injectable() export class ServerInfoService { + constructor( + @InjectRepository(AssetEntity) + private assetRepository: Repository, + ) {} + async getServerInfo(): Promise { const diskInfo = await diskusage.check(APP_UPLOAD_LOCATION); @@ -18,7 +30,6 @@ export class ServerInfoService { serverInfo.diskSizeRaw = diskInfo.total; serverInfo.diskUseRaw = diskInfo.total - diskInfo.free; serverInfo.diskUsagePercentage = parseFloat(usagePercentage); - return serverInfo; } @@ -48,4 +59,61 @@ export class ServerInfoService { return `${sizeInByte}B`; } } + + async getStats(): Promise { + const res = await this.assetRepository + .createQueryBuilder('asset') + .select(`COUNT(asset.id)`, 'count') + .addSelect(`asset.type`, 'type') + .addSelect(`asset.userId`, 'userId') + .groupBy('asset.type, asset.userId') + .addGroupBy('asset.type') + .getRawMany(); + + const serverStats = new ServerStatsResponseDto(); + const tmpMap = new Map(); + const getUsageByUser = (id: string) => tmpMap.get(id) || new UsageByUserDto(id); + res.map((item) => { + const usage: UsageByUserDto = getUsageByUser(item.userId); + if (item.type === 'IMAGE') { + usage.photos = parseInt(item.count); + serverStats.photos += usage.photos; + } else if (item.type === 'VIDEO') { + usage.videos = parseInt(item.count); + serverStats.videos += usage.videos; + } + tmpMap.set(item.userId, usage); + }); + + for (const userId of tmpMap.keys()) { + const usage = getUsageByUser(userId); + const userDiskUsage = await ServerInfoService.getDirectoryStats(path.join(APP_UPLOAD_LOCATION, userId)); + usage.usageRaw = userDiskUsage.size; + usage.objects = userDiskUsage.fileCount; + usage.usage = ServerInfoService.getHumanReadableString(usage.usageRaw); + serverStats.usageRaw += usage.usageRaw; + serverStats.objects += usage.objects; + } + serverStats.usage = ServerInfoService.getHumanReadableString(serverStats.usageRaw); + serverStats.usageByUser = Array.from(tmpMap.values()); + return serverStats; + } + + private static async getDirectoryStats(dirPath: string) { + let size = 0; + let fileCount = 0; + for (const filename of readdirSync(dirPath)) { + const absFilename = path.join(dirPath, filename); + const fileStat = statSync(absFilename); + if (fileStat.isFile()) { + size += fileStat.size; + fileCount += 1; + } else if (fileStat.isDirectory()) { + const subDirStat = await ServerInfoService.getDirectoryStats(absFilename); + size += subDirStat.size; + fileCount += subDirStat.fileCount; + } + } + return { size, fileCount }; + } } diff --git a/server/apps/immich/src/api-v1/user/dto/create-user.dto.spec.ts b/server/apps/immich/src/api-v1/user/dto/create-user.dto.spec.ts index c71609b083..45f3335674 100644 --- a/server/apps/immich/src/api-v1/user/dto/create-user.dto.spec.ts +++ b/server/apps/immich/src/api-v1/user/dto/create-user.dto.spec.ts @@ -3,13 +3,13 @@ import { validate } from 'class-validator'; import { CreateUserDto } from './create-user.dto'; describe('create user DTO', () => { - it('validates the email', async() => { + it('validates the email', async () => { const params: Partial = { email: undefined, password: 'password', firstName: 'first name', lastName: 'last name', - } + }; let dto: CreateUserDto = plainToInstance(CreateUserDto, params); let errors = await validate(dto); expect(errors).toHaveLength(1); diff --git a/server/apps/immich/src/api-v1/user/user-repository.ts b/server/apps/immich/src/api-v1/user/user-repository.ts index 4c5401bd52..b2bfbae4ab 100644 --- a/server/apps/immich/src/api-v1/user/user-repository.ts +++ b/server/apps/immich/src/api-v1/user/user-repository.ts @@ -4,7 +4,7 @@ import { InjectRepository } from '@nestjs/typeorm'; import { Not, Repository } from 'typeorm'; import { CreateUserDto } from './dto/create-user.dto'; import * as bcrypt from 'bcrypt'; -import { UpdateUserDto } from './dto/update-user.dto' +import { UpdateUserDto } from './dto/update-user.dto'; export interface IUserRepository { get(userId: string): Promise; @@ -92,4 +92,4 @@ export class UserRepository implements IUserRepository { user.profileImagePath = fileInfo.path; return this.userRepository.save(user); } -} \ No newline at end of file +} diff --git a/server/apps/immich/src/api-v1/user/user.module.ts b/server/apps/immich/src/api-v1/user/user.module.ts index cfa92cd73d..65a153377a 100644 --- a/server/apps/immich/src/api-v1/user/user.module.ts +++ b/server/apps/immich/src/api-v1/user/user.module.ts @@ -17,8 +17,8 @@ import { UserRepository, USER_REPOSITORY } from './user-repository'; ImmichJwtService, { provide: USER_REPOSITORY, - useClass: UserRepository - } + useClass: UserRepository, + }, ], }) export class UserModule {} diff --git a/server/immich-openapi-specs.json b/server/immich-openapi-specs.json index 59cc9b6a83..95bf47651f 100644 --- a/server/immich-openapi-specs.json +++ b/server/immich-openapi-specs.json @@ -1 +1 @@ -{"openapi":"3.0.0","paths":{"/user":{"get":{"operationId":"getAllUsers","parameters":[{"name":"isAll","required":true,"in":"query","schema":{"type":"boolean"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/UserResponseDto"}}}}}},"tags":["User"],"security":[{"bearer":[]}]},"post":{"operationId":"createUser","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateUserDto"}}}},"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserResponseDto"}}}}},"tags":["User"],"security":[{"bearer":[]}]},"put":{"operationId":"updateUser","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateUserDto"}}}},"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserResponseDto"}}}}},"tags":["User"],"security":[{"bearer":[]}]}},"/user/info/{userId}":{"get":{"operationId":"getUserById","parameters":[{"name":"userId","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserResponseDto"}}}}},"tags":["User"]}},"/user/me":{"get":{"operationId":"getMyUserInfo","parameters":[],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserResponseDto"}}}}},"tags":["User"],"security":[{"bearer":[]}]}},"/user/count":{"get":{"operationId":"getUserCount","parameters":[],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserCountResponseDto"}}}}},"tags":["User"]}},"/user/profile-image":{"post":{"operationId":"createProfileImage","parameters":[],"requestBody":{"required":true,"description":"A new avatar for the user","content":{"multipart/form-data":{"schema":{"$ref":"#/components/schemas/CreateProfileImageDto"}}}},"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateProfileImageResponseDto"}}}}},"tags":["User"],"security":[{"bearer":[]}]}},"/user/profile-image/{userId}":{"get":{"operationId":"getProfileImage","parameters":[{"name":"userId","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"object"}}}}},"tags":["User"]}},"/asset/upload":{"post":{"operationId":"uploadFile","parameters":[],"requestBody":{"required":true,"description":"Asset Upload Information","content":{"multipart/form-data":{"schema":{"$ref":"#/components/schemas/AssetFileUploadDto"}}}},"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AssetFileUploadResponseDto"}}}}},"tags":["Asset"],"security":[{"bearer":[]}]}},"/asset/download":{"get":{"operationId":"downloadFile","parameters":[{"name":"aid","required":true,"in":"query","schema":{"title":"Device Asset ID","type":"string"}},{"name":"did","required":true,"in":"query","schema":{"title":"Device ID","type":"string"}},{"name":"isThumb","required":false,"in":"query","schema":{"title":"Is serve thumbnail (resize) file","type":"boolean"}},{"name":"isWeb","required":false,"in":"query","schema":{"title":"Is request made from web","type":"boolean"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"object"}}}}},"tags":["Asset"],"security":[{"bearer":[]}]}},"/asset/file":{"get":{"operationId":"serveFile","parameters":[{"name":"aid","required":true,"in":"query","schema":{"title":"Device Asset ID","type":"string"}},{"name":"did","required":true,"in":"query","schema":{"title":"Device ID","type":"string"}},{"name":"isThumb","required":false,"in":"query","schema":{"title":"Is serve thumbnail (resize) file","type":"boolean"}},{"name":"isWeb","required":false,"in":"query","schema":{"title":"Is request made from web","type":"boolean"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"object"}}}}},"tags":["Asset"],"security":[{"bearer":[]}]}},"/asset/thumbnail/{assetId}":{"get":{"operationId":"getAssetThumbnail","parameters":[{"name":"assetId","required":true,"in":"path","schema":{"type":"string"}},{"name":"format","required":false,"in":"query","schema":{"$ref":"#/components/schemas/ThumbnailFormat"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"object"}}}}},"tags":["Asset"],"security":[{"bearer":[]}]}},"/asset/curated-objects":{"get":{"operationId":"getCuratedObjects","parameters":[],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/CuratedObjectsResponseDto"}}}}}},"tags":["Asset"],"security":[{"bearer":[]}]}},"/asset/curated-locations":{"get":{"operationId":"getCuratedLocations","parameters":[],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/CuratedLocationsResponseDto"}}}}}},"tags":["Asset"],"security":[{"bearer":[]}]}},"/asset/search-terms":{"get":{"operationId":"getAssetSearchTerms","parameters":[],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"array","items":{"type":"string"}}}}}},"tags":["Asset"],"security":[{"bearer":[]}]}},"/asset/search":{"post":{"operationId":"searchAsset","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SearchAssetDto"}}}},"responses":{"201":{"description":"","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/AssetResponseDto"}}}}}},"tags":["Asset"],"security":[{"bearer":[]}]}},"/asset/count-by-time-bucket":{"post":{"operationId":"getAssetCountByTimeBucket","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/GetAssetCountByTimeBucketDto"}}}},"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AssetCountByTimeBucketResponseDto"}}}}},"tags":["Asset"],"security":[{"bearer":[]}]}},"/asset/count-by-user-id":{"get":{"operationId":"getAssetCountByUserId","parameters":[],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AssetCountByUserIdResponseDto"}}}}},"tags":["Asset"],"security":[{"bearer":[]}]}},"/asset":{"get":{"operationId":"getAllAssets","summary":"","description":"Get all AssetEntity belong to the user","parameters":[],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/AssetResponseDto"}}}}}},"tags":["Asset"],"security":[{"bearer":[]}]},"delete":{"operationId":"deleteAsset","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DeleteAssetDto"}}}},"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/DeleteAssetResponseDto"}}}}}},"tags":["Asset"],"security":[{"bearer":[]}]}},"/asset/time-bucket":{"post":{"operationId":"getAssetByTimeBucket","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/GetAssetByTimeBucketDto"}}}},"responses":{"201":{"description":"","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/AssetResponseDto"}}}}}},"tags":["Asset"],"security":[{"bearer":[]}]}},"/asset/{deviceId}":{"get":{"operationId":"getUserAssetsByDeviceId","summary":"","description":"Get all asset of a device that are in the database, ID only.","parameters":[{"name":"deviceId","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"array","items":{"type":"string"}}}}}},"tags":["Asset"],"security":[{"bearer":[]}]}},"/asset/assetById/{assetId}":{"get":{"operationId":"getAssetById","summary":"","description":"Get a single asset's information","parameters":[{"name":"assetId","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AssetResponseDto"}}}}},"tags":["Asset"],"security":[{"bearer":[]}]}},"/asset/check":{"post":{"operationId":"checkDuplicateAsset","summary":"","description":"Check duplicated asset before uploading - for Web upload used","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CheckDuplicateAssetDto"}}}},"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CheckDuplicateAssetResponseDto"}}}}},"tags":["Asset"],"security":[{"bearer":[]}]}},"/auth/login":{"post":{"operationId":"login","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/LoginCredentialDto"}}}},"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LoginResponseDto"}}}}},"tags":["Authentication"]}},"/auth/admin-sign-up":{"post":{"operationId":"adminSignUp","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SignUpDto"}}}},"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminSignupResponseDto"}}}},"400":{"description":"The server already has an admin"}},"tags":["Authentication"]}},"/auth/validateToken":{"post":{"operationId":"validateAccessToken","parameters":[],"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidateAccessTokenResponseDto"}}}}},"tags":["Authentication"],"security":[{"bearer":[]}]}},"/auth/logout":{"post":{"operationId":"logout","parameters":[],"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LogoutResponseDto"}}}}},"tags":["Authentication"]}},"/device-info":{"post":{"operationId":"createDeviceInfo","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateDeviceInfoDto"}}}},"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DeviceInfoResponseDto"}}}}},"tags":["Device Info"],"security":[{"bearer":[]}]},"patch":{"operationId":"updateDeviceInfo","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateDeviceInfoDto"}}}},"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DeviceInfoResponseDto"}}}}},"tags":["Device Info"],"security":[{"bearer":[]}]}},"/server-info":{"get":{"operationId":"getServerInfo","parameters":[],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ServerInfoResponseDto"}}}}},"tags":["Server Info"]}},"/server-info/ping":{"get":{"operationId":"pingServer","parameters":[],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ServerPingResponse"}}}}},"tags":["Server Info"]}},"/server-info/version":{"get":{"operationId":"getServerVersion","parameters":[],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ServerVersionReponseDto"}}}}},"tags":["Server Info"]}},"/album/count-by-user-id":{"get":{"operationId":"getAlbumCountByUserId","parameters":[],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlbumCountResponseDto"}}}}},"tags":["Album"],"security":[{"bearer":[]}]}},"/album":{"post":{"operationId":"createAlbum","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateAlbumDto"}}}},"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlbumResponseDto"}}}}},"tags":["Album"],"security":[{"bearer":[]}]},"get":{"operationId":"getAllAlbums","parameters":[{"name":"shared","required":false,"in":"query","schema":{"type":"boolean"}},{"name":"assetId","required":false,"in":"query","description":"Only returns albums that contain the asset\nIgnores the shared parameter\nundefined: get all albums","schema":{"type":"string"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/AlbumResponseDto"}}}}}},"tags":["Album"],"security":[{"bearer":[]}]}},"/album/{albumId}/users":{"put":{"operationId":"addUsersToAlbum","parameters":[{"name":"albumId","required":true,"in":"path","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AddUsersDto"}}}},"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlbumResponseDto"}}}}},"tags":["Album"],"security":[{"bearer":[]}]}},"/album/{albumId}/assets":{"put":{"operationId":"addAssetsToAlbum","parameters":[{"name":"albumId","required":true,"in":"path","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AddAssetsDto"}}}},"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlbumResponseDto"}}}}},"tags":["Album"],"security":[{"bearer":[]}]},"delete":{"operationId":"removeAssetFromAlbum","parameters":[{"name":"albumId","required":true,"in":"path","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RemoveAssetsDto"}}}},"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlbumResponseDto"}}}}},"tags":["Album"],"security":[{"bearer":[]}]}},"/album/{albumId}":{"get":{"operationId":"getAlbumInfo","parameters":[{"name":"albumId","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlbumResponseDto"}}}}},"tags":["Album"],"security":[{"bearer":[]}]},"delete":{"operationId":"deleteAlbum","parameters":[{"name":"albumId","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"200":{"description":""}},"tags":["Album"],"security":[{"bearer":[]}]},"patch":{"operationId":"updateAlbumInfo","parameters":[{"name":"albumId","required":true,"in":"path","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateAlbumDto"}}}},"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlbumResponseDto"}}}}},"tags":["Album"],"security":[{"bearer":[]}]}},"/album/{albumId}/user/{userId}":{"delete":{"operationId":"removeUserFromAlbum","parameters":[{"name":"albumId","required":true,"in":"path","schema":{"type":"string"}},{"name":"userId","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"200":{"description":""}},"tags":["Album"],"security":[{"bearer":[]}]}},"/jobs":{"get":{"operationId":"getAllJobsStatus","parameters":[],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AllJobStatusResponseDto"}}}}},"tags":["Job"],"security":[{"bearer":[]}]}},"/jobs/{jobId}":{"get":{"operationId":"getJobStatus","parameters":[{"name":"jobId","required":true,"in":"path","schema":{"$ref":"#/components/schemas/JobId"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/JobStatusResponseDto"}}}}},"tags":["Job"],"security":[{"bearer":[]}]},"put":{"operationId":"sendJobCommand","parameters":[{"name":"jobId","required":true,"in":"path","schema":{"$ref":"#/components/schemas/JobId"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/JobCommandDto"}}}},"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"number"}}}}},"tags":["Job"],"security":[{"bearer":[]}]}}},"info":{"title":"Immich","description":"Immich API","version":"1.17.0","contact":{}},"tags":[],"servers":[{"url":"/api"}],"components":{"securitySchemes":{"bearer":{"scheme":"Bearer","bearerFormat":"JWT","type":"http","name":"JWT","description":"Enter JWT token","in":"header"}},"schemas":{"UserResponseDto":{"type":"object","properties":{"id":{"type":"string"},"email":{"type":"string"},"firstName":{"type":"string"},"lastName":{"type":"string"},"createdAt":{"type":"string"},"profileImagePath":{"type":"string"},"shouldChangePassword":{"type":"boolean"},"isAdmin":{"type":"boolean"}},"required":["id","email","firstName","lastName","createdAt","profileImagePath","shouldChangePassword","isAdmin"]},"CreateUserDto":{"type":"object","properties":{"email":{"type":"string","example":"testuser@email.com"},"password":{"type":"string","example":"password"},"firstName":{"type":"string","example":"John"},"lastName":{"type":"string","example":"Doe"}},"required":["email","password","firstName","lastName"]},"UserCountResponseDto":{"type":"object","properties":{"userCount":{"type":"integer"}},"required":["userCount"]},"UpdateUserDto":{"type":"object","properties":{"id":{"type":"string"},"password":{"type":"string"},"firstName":{"type":"string"},"lastName":{"type":"string"},"isAdmin":{"type":"boolean"},"shouldChangePassword":{"type":"boolean"},"profileImagePath":{"type":"string"}},"required":["id"]},"CreateProfileImageDto":{"type":"object","properties":{"file":{"type":"string","format":"binary"}},"required":["file"]},"CreateProfileImageResponseDto":{"type":"object","properties":{"userId":{"type":"string"},"profileImagePath":{"type":"string"}},"required":["userId","profileImagePath"]},"AssetFileUploadDto":{"type":"object","properties":{"assetData":{"type":"string","format":"binary"}},"required":["assetData"]},"AssetFileUploadResponseDto":{"type":"object","properties":{"id":{"type":"string"}},"required":["id"]},"ThumbnailFormat":{"type":"string","enum":["JPEG","WEBP"]},"CuratedObjectsResponseDto":{"type":"object","properties":{"id":{"type":"string"},"object":{"type":"string"},"resizePath":{"type":"string"},"deviceAssetId":{"type":"string"},"deviceId":{"type":"string"}},"required":["id","object","resizePath","deviceAssetId","deviceId"]},"CuratedLocationsResponseDto":{"type":"object","properties":{"id":{"type":"string"},"city":{"type":"string"},"resizePath":{"type":"string"},"deviceAssetId":{"type":"string"},"deviceId":{"type":"string"}},"required":["id","city","resizePath","deviceAssetId","deviceId"]},"SearchAssetDto":{"type":"object","properties":{"searchTerm":{"type":"string"}},"required":["searchTerm"]},"AssetTypeEnum":{"type":"string","enum":["IMAGE","VIDEO","AUDIO","OTHER"]},"ExifResponseDto":{"type":"object","properties":{"id":{"type":"integer","nullable":true,"default":null,"format":"int64"},"fileSizeInByte":{"type":"integer","nullable":true,"default":null,"format":"int64"},"make":{"type":"string","nullable":true,"default":null},"model":{"type":"string","nullable":true,"default":null},"imageName":{"type":"string","nullable":true,"default":null},"exifImageWidth":{"type":"number","nullable":true,"default":null},"exifImageHeight":{"type":"number","nullable":true,"default":null},"orientation":{"type":"string","nullable":true,"default":null},"dateTimeOriginal":{"format":"date-time","type":"string","nullable":true,"default":null},"modifyDate":{"format":"date-time","type":"string","nullable":true,"default":null},"lensModel":{"type":"string","nullable":true,"default":null},"fNumber":{"type":"number","nullable":true,"default":null},"focalLength":{"type":"number","nullable":true,"default":null},"iso":{"type":"number","nullable":true,"default":null},"exposureTime":{"type":"number","nullable":true,"default":null},"latitude":{"type":"number","nullable":true,"default":null},"longitude":{"type":"number","nullable":true,"default":null},"city":{"type":"string","nullable":true,"default":null},"state":{"type":"string","nullable":true,"default":null},"country":{"type":"string","nullable":true,"default":null}}},"SmartInfoResponseDto":{"type":"object","properties":{"id":{"type":"string"},"tags":{"nullable":true,"type":"array","items":{"type":"string"}},"objects":{"nullable":true,"type":"array","items":{"type":"string"}}}},"AssetResponseDto":{"type":"object","properties":{"type":{"$ref":"#/components/schemas/AssetTypeEnum"},"id":{"type":"string"},"deviceAssetId":{"type":"string"},"ownerId":{"type":"string"},"deviceId":{"type":"string"},"originalPath":{"type":"string"},"resizePath":{"type":"string","nullable":true},"createdAt":{"type":"string"},"modifiedAt":{"type":"string"},"isFavorite":{"type":"boolean"},"mimeType":{"type":"string","nullable":true},"duration":{"type":"string"},"webpPath":{"type":"string","nullable":true},"encodedVideoPath":{"type":"string","nullable":true},"exifInfo":{"$ref":"#/components/schemas/ExifResponseDto"},"smartInfo":{"$ref":"#/components/schemas/SmartInfoResponseDto"}},"required":["type","id","deviceAssetId","ownerId","deviceId","originalPath","resizePath","createdAt","modifiedAt","isFavorite","mimeType","duration","webpPath","encodedVideoPath"]},"TimeGroupEnum":{"type":"string","enum":["day","month"]},"GetAssetCountByTimeBucketDto":{"type":"object","properties":{"timeGroup":{"$ref":"#/components/schemas/TimeGroupEnum"}},"required":["timeGroup"]},"AssetCountByTimeBucket":{"type":"object","properties":{"timeBucket":{"type":"string"},"count":{"type":"integer"}},"required":["timeBucket","count"]},"AssetCountByTimeBucketResponseDto":{"type":"object","properties":{"totalCount":{"type":"integer"},"buckets":{"type":"array","items":{"$ref":"#/components/schemas/AssetCountByTimeBucket"}}},"required":["totalCount","buckets"]},"AssetCountByUserIdResponseDto":{"type":"object","properties":{"photos":{"type":"integer"},"videos":{"type":"integer"}},"required":["photos","videos"]},"GetAssetByTimeBucketDto":{"type":"object","properties":{"timeBucket":{"title":"Array of date time buckets","example":["2015-06-01T00:00:00.000Z","2016-02-01T00:00:00.000Z","2016-03-01T00:00:00.000Z"],"type":"array","items":{"type":"string"}}},"required":["timeBucket"]},"DeleteAssetDto":{"type":"object","properties":{"ids":{"title":"Array of asset IDs to delete","example":["bf973405-3f2a-48d2-a687-2ed4167164be","dd41870b-5d00-46d2-924e-1d8489a0aa0f","fad77c3f-deef-4e7e-9608-14c1aa4e559a"],"type":"array","items":{"type":"string"}}},"required":["ids"]},"DeleteAssetStatus":{"type":"string","enum":["SUCCESS","FAILED"]},"DeleteAssetResponseDto":{"type":"object","properties":{"status":{"$ref":"#/components/schemas/DeleteAssetStatus"},"id":{"type":"string"}},"required":["status","id"]},"CheckDuplicateAssetDto":{"type":"object","properties":{"deviceAssetId":{"type":"string"},"deviceId":{"type":"string"}},"required":["deviceAssetId","deviceId"]},"CheckDuplicateAssetResponseDto":{"type":"object","properties":{"isExist":{"type":"boolean"},"id":{"type":"string"}},"required":["isExist"]},"LoginCredentialDto":{"type":"object","properties":{"email":{"type":"string","example":"testuser@email.com"},"password":{"type":"string","example":"password"}},"required":["email","password"]},"LoginResponseDto":{"type":"object","properties":{"accessToken":{"type":"string","readOnly":true},"userId":{"type":"string","readOnly":true},"userEmail":{"type":"string","readOnly":true},"firstName":{"type":"string","readOnly":true},"lastName":{"type":"string","readOnly":true},"profileImagePath":{"type":"string","readOnly":true},"isAdmin":{"type":"boolean","readOnly":true},"shouldChangePassword":{"type":"boolean","readOnly":true}},"required":["accessToken","userId","userEmail","firstName","lastName","profileImagePath","isAdmin","shouldChangePassword"]},"SignUpDto":{"type":"object","properties":{"email":{"type":"string","example":"testuser@email.com"},"password":{"type":"string","example":"password"},"firstName":{"type":"string","example":"Admin"},"lastName":{"type":"string","example":"Doe"}},"required":["email","password","firstName","lastName"]},"AdminSignupResponseDto":{"type":"object","properties":{"id":{"type":"string"},"email":{"type":"string"},"firstName":{"type":"string"},"lastName":{"type":"string"},"createdAt":{"type":"string"}},"required":["id","email","firstName","lastName","createdAt"]},"ValidateAccessTokenResponseDto":{"type":"object","properties":{"authStatus":{"type":"boolean"}},"required":["authStatus"]},"LogoutResponseDto":{"type":"object","properties":{"successful":{"type":"boolean","readOnly":true}},"required":["successful"]},"DeviceTypeEnum":{"type":"string","enum":["IOS","ANDROID","WEB"]},"CreateDeviceInfoDto":{"type":"object","properties":{"deviceType":{"$ref":"#/components/schemas/DeviceTypeEnum"},"deviceId":{"type":"string"},"isAutoBackup":{"type":"boolean"}},"required":["deviceType","deviceId"]},"DeviceInfoResponseDto":{"type":"object","properties":{"id":{"type":"integer"},"deviceType":{"$ref":"#/components/schemas/DeviceTypeEnum"},"userId":{"type":"string"},"deviceId":{"type":"string"},"createdAt":{"type":"string"},"isAutoBackup":{"type":"boolean"}},"required":["id","deviceType","userId","deviceId","createdAt","isAutoBackup"]},"UpdateDeviceInfoDto":{"type":"object","properties":{"deviceType":{"$ref":"#/components/schemas/DeviceTypeEnum"},"deviceId":{"type":"string"},"isAutoBackup":{"type":"boolean"}},"required":["deviceType","deviceId"]},"ServerInfoResponseDto":{"type":"object","properties":{"diskSizeRaw":{"type":"integer","format":"int64"},"diskUseRaw":{"type":"integer","format":"int64"},"diskAvailableRaw":{"type":"integer","format":"int64"},"diskUsagePercentage":{"type":"number","format":"float"},"diskSize":{"type":"string"},"diskUse":{"type":"string"},"diskAvailable":{"type":"string"}},"required":["diskSizeRaw","diskUseRaw","diskAvailableRaw","diskUsagePercentage","diskSize","diskUse","diskAvailable"]},"ServerPingResponse":{"type":"object","properties":{"res":{"type":"string","readOnly":true,"example":"pong"}},"required":["res"]},"ServerVersionReponseDto":{"type":"object","properties":{"major":{"type":"integer"},"minor":{"type":"integer"},"patch":{"type":"integer"},"build":{"type":"integer"}},"required":["major","minor","patch","build"]},"AlbumCountResponseDto":{"type":"object","properties":{"owned":{"type":"integer"},"shared":{"type":"integer"},"sharing":{"type":"integer"}},"required":["owned","shared","sharing"]},"CreateAlbumDto":{"type":"object","properties":{"albumName":{"type":"string"},"sharedWithUserIds":{"type":"array","items":{"type":"string"}},"assetIds":{"type":"array","items":{"type":"string"}}},"required":["albumName"]},"AlbumResponseDto":{"type":"object","properties":{"assetCount":{"type":"integer"},"id":{"type":"string"},"ownerId":{"type":"string"},"albumName":{"type":"string"},"createdAt":{"type":"string"},"albumThumbnailAssetId":{"type":"string","nullable":true},"shared":{"type":"boolean"},"sharedUsers":{"type":"array","items":{"$ref":"#/components/schemas/UserResponseDto"}},"assets":{"type":"array","items":{"$ref":"#/components/schemas/AssetResponseDto"}}},"required":["assetCount","id","ownerId","albumName","createdAt","albumThumbnailAssetId","shared","sharedUsers","assets"]},"AddUsersDto":{"type":"object","properties":{"sharedUserIds":{"type":"array","items":{"type":"string"}}},"required":["sharedUserIds"]},"AddAssetsDto":{"type":"object","properties":{"assetIds":{"type":"array","items":{"type":"string"}}},"required":["assetIds"]},"RemoveAssetsDto":{"type":"object","properties":{"assetIds":{"type":"array","items":{"type":"string"}}},"required":["assetIds"]},"UpdateAlbumDto":{"type":"object","properties":{"albumName":{"type":"string"},"albumThumbnailAssetId":{"type":"string"}}},"JobCounts":{"type":"object","properties":{"active":{"type":"integer"},"completed":{"type":"integer"},"failed":{"type":"integer"},"delayed":{"type":"integer"},"waiting":{"type":"integer"}},"required":["active","completed","failed","delayed","waiting"]},"AllJobStatusResponseDto":{"type":"object","properties":{"thumbnailGenerationQueueCount":{"$ref":"#/components/schemas/JobCounts"},"metadataExtractionQueueCount":{"$ref":"#/components/schemas/JobCounts"},"videoConversionQueueCount":{"$ref":"#/components/schemas/JobCounts"},"machineLearningQueueCount":{"$ref":"#/components/schemas/JobCounts"},"isThumbnailGenerationActive":{"type":"boolean"},"isMetadataExtractionActive":{"type":"boolean"},"isVideoConversionActive":{"type":"boolean"},"isMachineLearningActive":{"type":"boolean"}},"required":["thumbnailGenerationQueueCount","metadataExtractionQueueCount","videoConversionQueueCount","machineLearningQueueCount","isThumbnailGenerationActive","isMetadataExtractionActive","isVideoConversionActive","isMachineLearningActive"]},"JobId":{"type":"string","enum":["thumbnail-generation","metadata-extraction","video-conversion","machine-learning"]},"JobStatusResponseDto":{"type":"object","properties":{"isActive":{"type":"boolean"},"queueCount":{"type":"object"}},"required":["isActive","queueCount"]},"JobCommand":{"type":"string","enum":["start","stop"]},"JobCommandDto":{"type":"object","properties":{"command":{"$ref":"#/components/schemas/JobCommand"}},"required":["command"]}}}} \ No newline at end of file +{"openapi":"3.0.0","paths":{"/user":{"get":{"operationId":"getAllUsers","parameters":[{"name":"isAll","required":true,"in":"query","schema":{"type":"boolean"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/UserResponseDto"}}}}}},"tags":["User"],"security":[{"bearer":[]}]},"post":{"operationId":"createUser","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateUserDto"}}}},"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserResponseDto"}}}}},"tags":["User"],"security":[{"bearer":[]}]},"put":{"operationId":"updateUser","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateUserDto"}}}},"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserResponseDto"}}}}},"tags":["User"],"security":[{"bearer":[]}]}},"/user/info/{userId}":{"get":{"operationId":"getUserById","parameters":[{"name":"userId","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserResponseDto"}}}}},"tags":["User"]}},"/user/me":{"get":{"operationId":"getMyUserInfo","parameters":[],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserResponseDto"}}}}},"tags":["User"],"security":[{"bearer":[]}]}},"/user/count":{"get":{"operationId":"getUserCount","parameters":[],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserCountResponseDto"}}}}},"tags":["User"]}},"/user/profile-image":{"post":{"operationId":"createProfileImage","parameters":[],"requestBody":{"required":true,"description":"A new avatar for the user","content":{"multipart/form-data":{"schema":{"$ref":"#/components/schemas/CreateProfileImageDto"}}}},"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateProfileImageResponseDto"}}}}},"tags":["User"],"security":[{"bearer":[]}]}},"/user/profile-image/{userId}":{"get":{"operationId":"getProfileImage","parameters":[{"name":"userId","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"object"}}}}},"tags":["User"]}},"/asset/upload":{"post":{"operationId":"uploadFile","parameters":[],"requestBody":{"required":true,"description":"Asset Upload Information","content":{"multipart/form-data":{"schema":{"$ref":"#/components/schemas/AssetFileUploadDto"}}}},"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AssetFileUploadResponseDto"}}}}},"tags":["Asset"],"security":[{"bearer":[]}]}},"/asset/download":{"get":{"operationId":"downloadFile","parameters":[{"name":"aid","required":true,"in":"query","schema":{"title":"Device Asset ID","type":"string"}},{"name":"did","required":true,"in":"query","schema":{"title":"Device ID","type":"string"}},{"name":"isThumb","required":false,"in":"query","schema":{"title":"Is serve thumbnail (resize) file","type":"boolean"}},{"name":"isWeb","required":false,"in":"query","schema":{"title":"Is request made from web","type":"boolean"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"object"}}}}},"tags":["Asset"],"security":[{"bearer":[]}]}},"/asset/file":{"get":{"operationId":"serveFile","parameters":[{"name":"aid","required":true,"in":"query","schema":{"title":"Device Asset ID","type":"string"}},{"name":"did","required":true,"in":"query","schema":{"title":"Device ID","type":"string"}},{"name":"isThumb","required":false,"in":"query","schema":{"title":"Is serve thumbnail (resize) file","type":"boolean"}},{"name":"isWeb","required":false,"in":"query","schema":{"title":"Is request made from web","type":"boolean"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"object"}}}}},"tags":["Asset"],"security":[{"bearer":[]}]}},"/asset/thumbnail/{assetId}":{"get":{"operationId":"getAssetThumbnail","parameters":[{"name":"assetId","required":true,"in":"path","schema":{"type":"string"}},{"name":"format","required":false,"in":"query","schema":{"$ref":"#/components/schemas/ThumbnailFormat"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"object"}}}}},"tags":["Asset"],"security":[{"bearer":[]}]}},"/asset/curated-objects":{"get":{"operationId":"getCuratedObjects","parameters":[],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/CuratedObjectsResponseDto"}}}}}},"tags":["Asset"],"security":[{"bearer":[]}]}},"/asset/curated-locations":{"get":{"operationId":"getCuratedLocations","parameters":[],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/CuratedLocationsResponseDto"}}}}}},"tags":["Asset"],"security":[{"bearer":[]}]}},"/asset/search-terms":{"get":{"operationId":"getAssetSearchTerms","parameters":[],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"array","items":{"type":"string"}}}}}},"tags":["Asset"],"security":[{"bearer":[]}]}},"/asset/search":{"post":{"operationId":"searchAsset","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SearchAssetDto"}}}},"responses":{"201":{"description":"","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/AssetResponseDto"}}}}}},"tags":["Asset"],"security":[{"bearer":[]}]}},"/asset/count-by-time-bucket":{"post":{"operationId":"getAssetCountByTimeBucket","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/GetAssetCountByTimeBucketDto"}}}},"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AssetCountByTimeBucketResponseDto"}}}}},"tags":["Asset"],"security":[{"bearer":[]}]}},"/asset/count-by-user-id":{"get":{"operationId":"getAssetCountByUserId","parameters":[],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AssetCountByUserIdResponseDto"}}}}},"tags":["Asset"],"security":[{"bearer":[]}]}},"/asset":{"get":{"operationId":"getAllAssets","summary":"","description":"Get all AssetEntity belong to the user","parameters":[],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/AssetResponseDto"}}}}}},"tags":["Asset"],"security":[{"bearer":[]}]},"delete":{"operationId":"deleteAsset","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DeleteAssetDto"}}}},"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/DeleteAssetResponseDto"}}}}}},"tags":["Asset"],"security":[{"bearer":[]}]}},"/asset/time-bucket":{"post":{"operationId":"getAssetByTimeBucket","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/GetAssetByTimeBucketDto"}}}},"responses":{"201":{"description":"","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/AssetResponseDto"}}}}}},"tags":["Asset"],"security":[{"bearer":[]}]}},"/asset/{deviceId}":{"get":{"operationId":"getUserAssetsByDeviceId","summary":"","description":"Get all asset of a device that are in the database, ID only.","parameters":[{"name":"deviceId","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"array","items":{"type":"string"}}}}}},"tags":["Asset"],"security":[{"bearer":[]}]}},"/asset/assetById/{assetId}":{"get":{"operationId":"getAssetById","summary":"","description":"Get a single asset's information","parameters":[{"name":"assetId","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AssetResponseDto"}}}}},"tags":["Asset"],"security":[{"bearer":[]}]}},"/asset/check":{"post":{"operationId":"checkDuplicateAsset","summary":"","description":"Check duplicated asset before uploading - for Web upload used","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CheckDuplicateAssetDto"}}}},"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CheckDuplicateAssetResponseDto"}}}}},"tags":["Asset"],"security":[{"bearer":[]}]}},"/auth/login":{"post":{"operationId":"login","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/LoginCredentialDto"}}}},"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LoginResponseDto"}}}}},"tags":["Authentication"]}},"/auth/admin-sign-up":{"post":{"operationId":"adminSignUp","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SignUpDto"}}}},"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminSignupResponseDto"}}}},"400":{"description":"The server already has an admin"}},"tags":["Authentication"]}},"/auth/validateToken":{"post":{"operationId":"validateAccessToken","parameters":[],"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidateAccessTokenResponseDto"}}}}},"tags":["Authentication"],"security":[{"bearer":[]}]}},"/auth/logout":{"post":{"operationId":"logout","parameters":[],"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LogoutResponseDto"}}}}},"tags":["Authentication"]}},"/device-info":{"post":{"operationId":"createDeviceInfo","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateDeviceInfoDto"}}}},"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DeviceInfoResponseDto"}}}}},"tags":["Device Info"],"security":[{"bearer":[]}]},"patch":{"operationId":"updateDeviceInfo","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateDeviceInfoDto"}}}},"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DeviceInfoResponseDto"}}}}},"tags":["Device Info"],"security":[{"bearer":[]}]}},"/server-info":{"get":{"operationId":"getServerInfo","parameters":[],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ServerInfoResponseDto"}}}}},"tags":["Server Info"]}},"/server-info/ping":{"get":{"operationId":"pingServer","parameters":[],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ServerPingResponse"}}}}},"tags":["Server Info"]}},"/server-info/version":{"get":{"operationId":"getServerVersion","parameters":[],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ServerVersionReponseDto"}}}}},"tags":["Server Info"]}},"/server-info/stats":{"get":{"operationId":"getStats","parameters":[],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ServerStatsResponseDto"}}}}},"tags":["Server Info"]}},"/album/count-by-user-id":{"get":{"operationId":"getAlbumCountByUserId","parameters":[],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlbumCountResponseDto"}}}}},"tags":["Album"],"security":[{"bearer":[]}]}},"/album":{"post":{"operationId":"createAlbum","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateAlbumDto"}}}},"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlbumResponseDto"}}}}},"tags":["Album"],"security":[{"bearer":[]}]},"get":{"operationId":"getAllAlbums","parameters":[{"name":"shared","required":false,"in":"query","schema":{"type":"boolean"}},{"name":"assetId","required":false,"in":"query","description":"Only returns albums that contain the asset\nIgnores the shared parameter\nundefined: get all albums","schema":{"type":"string"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/AlbumResponseDto"}}}}}},"tags":["Album"],"security":[{"bearer":[]}]}},"/album/{albumId}/users":{"put":{"operationId":"addUsersToAlbum","parameters":[{"name":"albumId","required":true,"in":"path","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AddUsersDto"}}}},"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlbumResponseDto"}}}}},"tags":["Album"],"security":[{"bearer":[]}]}},"/album/{albumId}/assets":{"put":{"operationId":"addAssetsToAlbum","parameters":[{"name":"albumId","required":true,"in":"path","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AddAssetsDto"}}}},"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlbumResponseDto"}}}}},"tags":["Album"],"security":[{"bearer":[]}]},"delete":{"operationId":"removeAssetFromAlbum","parameters":[{"name":"albumId","required":true,"in":"path","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RemoveAssetsDto"}}}},"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlbumResponseDto"}}}}},"tags":["Album"],"security":[{"bearer":[]}]}},"/album/{albumId}":{"get":{"operationId":"getAlbumInfo","parameters":[{"name":"albumId","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlbumResponseDto"}}}}},"tags":["Album"],"security":[{"bearer":[]}]},"delete":{"operationId":"deleteAlbum","parameters":[{"name":"albumId","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"200":{"description":""}},"tags":["Album"],"security":[{"bearer":[]}]},"patch":{"operationId":"updateAlbumInfo","parameters":[{"name":"albumId","required":true,"in":"path","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateAlbumDto"}}}},"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlbumResponseDto"}}}}},"tags":["Album"],"security":[{"bearer":[]}]}},"/album/{albumId}/user/{userId}":{"delete":{"operationId":"removeUserFromAlbum","parameters":[{"name":"albumId","required":true,"in":"path","schema":{"type":"string"}},{"name":"userId","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"200":{"description":""}},"tags":["Album"],"security":[{"bearer":[]}]}},"/jobs":{"get":{"operationId":"getAllJobsStatus","parameters":[],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AllJobStatusResponseDto"}}}}},"tags":["Job"],"security":[{"bearer":[]}]}},"/jobs/{jobId}":{"get":{"operationId":"getJobStatus","parameters":[{"name":"jobId","required":true,"in":"path","schema":{"$ref":"#/components/schemas/JobId"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/JobStatusResponseDto"}}}}},"tags":["Job"],"security":[{"bearer":[]}]},"put":{"operationId":"sendJobCommand","parameters":[{"name":"jobId","required":true,"in":"path","schema":{"$ref":"#/components/schemas/JobId"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/JobCommandDto"}}}},"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"number"}}}}},"tags":["Job"],"security":[{"bearer":[]}]}}},"info":{"title":"Immich","description":"Immich API","version":"1.17.0","contact":{}},"tags":[],"servers":[{"url":"/api"}],"components":{"securitySchemes":{"bearer":{"scheme":"Bearer","bearerFormat":"JWT","type":"http","name":"JWT","description":"Enter JWT token","in":"header"}},"schemas":{"UserResponseDto":{"type":"object","properties":{"id":{"type":"string"},"email":{"type":"string"},"firstName":{"type":"string"},"lastName":{"type":"string"},"createdAt":{"type":"string"},"profileImagePath":{"type":"string"},"shouldChangePassword":{"type":"boolean"},"isAdmin":{"type":"boolean"}},"required":["id","email","firstName","lastName","createdAt","profileImagePath","shouldChangePassword","isAdmin"]},"CreateUserDto":{"type":"object","properties":{"email":{"type":"string","example":"testuser@email.com"},"password":{"type":"string","example":"password"},"firstName":{"type":"string","example":"John"},"lastName":{"type":"string","example":"Doe"}},"required":["email","password","firstName","lastName"]},"UserCountResponseDto":{"type":"object","properties":{"userCount":{"type":"integer"}},"required":["userCount"]},"UpdateUserDto":{"type":"object","properties":{"id":{"type":"string"},"password":{"type":"string"},"firstName":{"type":"string"},"lastName":{"type":"string"},"isAdmin":{"type":"boolean"},"shouldChangePassword":{"type":"boolean"},"profileImagePath":{"type":"string"}},"required":["id"]},"CreateProfileImageDto":{"type":"object","properties":{"file":{"type":"string","format":"binary"}},"required":["file"]},"CreateProfileImageResponseDto":{"type":"object","properties":{"userId":{"type":"string"},"profileImagePath":{"type":"string"}},"required":["userId","profileImagePath"]},"AssetFileUploadDto":{"type":"object","properties":{"assetData":{"type":"string","format":"binary"}},"required":["assetData"]},"AssetFileUploadResponseDto":{"type":"object","properties":{"id":{"type":"string"}},"required":["id"]},"ThumbnailFormat":{"type":"string","enum":["JPEG","WEBP"]},"CuratedObjectsResponseDto":{"type":"object","properties":{"id":{"type":"string"},"object":{"type":"string"},"resizePath":{"type":"string"},"deviceAssetId":{"type":"string"},"deviceId":{"type":"string"}},"required":["id","object","resizePath","deviceAssetId","deviceId"]},"CuratedLocationsResponseDto":{"type":"object","properties":{"id":{"type":"string"},"city":{"type":"string"},"resizePath":{"type":"string"},"deviceAssetId":{"type":"string"},"deviceId":{"type":"string"}},"required":["id","city","resizePath","deviceAssetId","deviceId"]},"SearchAssetDto":{"type":"object","properties":{"searchTerm":{"type":"string"}},"required":["searchTerm"]},"AssetTypeEnum":{"type":"string","enum":["IMAGE","VIDEO","AUDIO","OTHER"]},"ExifResponseDto":{"type":"object","properties":{"id":{"type":"integer","nullable":true,"default":null,"format":"int64"},"fileSizeInByte":{"type":"integer","nullable":true,"default":null,"format":"int64"},"make":{"type":"string","nullable":true,"default":null},"model":{"type":"string","nullable":true,"default":null},"imageName":{"type":"string","nullable":true,"default":null},"exifImageWidth":{"type":"number","nullable":true,"default":null},"exifImageHeight":{"type":"number","nullable":true,"default":null},"orientation":{"type":"string","nullable":true,"default":null},"dateTimeOriginal":{"format":"date-time","type":"string","nullable":true,"default":null},"modifyDate":{"format":"date-time","type":"string","nullable":true,"default":null},"lensModel":{"type":"string","nullable":true,"default":null},"fNumber":{"type":"number","nullable":true,"default":null},"focalLength":{"type":"number","nullable":true,"default":null},"iso":{"type":"number","nullable":true,"default":null},"exposureTime":{"type":"number","nullable":true,"default":null},"latitude":{"type":"number","nullable":true,"default":null},"longitude":{"type":"number","nullable":true,"default":null},"city":{"type":"string","nullable":true,"default":null},"state":{"type":"string","nullable":true,"default":null},"country":{"type":"string","nullable":true,"default":null}}},"SmartInfoResponseDto":{"type":"object","properties":{"id":{"type":"string"},"tags":{"nullable":true,"type":"array","items":{"type":"string"}},"objects":{"nullable":true,"type":"array","items":{"type":"string"}}}},"AssetResponseDto":{"type":"object","properties":{"type":{"$ref":"#/components/schemas/AssetTypeEnum"},"id":{"type":"string"},"deviceAssetId":{"type":"string"},"ownerId":{"type":"string"},"deviceId":{"type":"string"},"originalPath":{"type":"string"},"resizePath":{"type":"string","nullable":true},"createdAt":{"type":"string"},"modifiedAt":{"type":"string"},"isFavorite":{"type":"boolean"},"mimeType":{"type":"string","nullable":true},"duration":{"type":"string"},"webpPath":{"type":"string","nullable":true},"encodedVideoPath":{"type":"string","nullable":true},"exifInfo":{"$ref":"#/components/schemas/ExifResponseDto"},"smartInfo":{"$ref":"#/components/schemas/SmartInfoResponseDto"}},"required":["type","id","deviceAssetId","ownerId","deviceId","originalPath","resizePath","createdAt","modifiedAt","isFavorite","mimeType","duration","webpPath","encodedVideoPath"]},"TimeGroupEnum":{"type":"string","enum":["day","month"]},"GetAssetCountByTimeBucketDto":{"type":"object","properties":{"timeGroup":{"$ref":"#/components/schemas/TimeGroupEnum"}},"required":["timeGroup"]},"AssetCountByTimeBucket":{"type":"object","properties":{"timeBucket":{"type":"string"},"count":{"type":"integer"}},"required":["timeBucket","count"]},"AssetCountByTimeBucketResponseDto":{"type":"object","properties":{"totalCount":{"type":"integer"},"buckets":{"type":"array","items":{"$ref":"#/components/schemas/AssetCountByTimeBucket"}}},"required":["totalCount","buckets"]},"AssetCountByUserIdResponseDto":{"type":"object","properties":{"photos":{"type":"integer"},"videos":{"type":"integer"}},"required":["photos","videos"]},"GetAssetByTimeBucketDto":{"type":"object","properties":{"timeBucket":{"title":"Array of date time buckets","example":["2015-06-01T00:00:00.000Z","2016-02-01T00:00:00.000Z","2016-03-01T00:00:00.000Z"],"type":"array","items":{"type":"string"}}},"required":["timeBucket"]},"DeleteAssetDto":{"type":"object","properties":{"ids":{"title":"Array of asset IDs to delete","example":["bf973405-3f2a-48d2-a687-2ed4167164be","dd41870b-5d00-46d2-924e-1d8489a0aa0f","fad77c3f-deef-4e7e-9608-14c1aa4e559a"],"type":"array","items":{"type":"string"}}},"required":["ids"]},"DeleteAssetStatus":{"type":"string","enum":["SUCCESS","FAILED"]},"DeleteAssetResponseDto":{"type":"object","properties":{"status":{"$ref":"#/components/schemas/DeleteAssetStatus"},"id":{"type":"string"}},"required":["status","id"]},"CheckDuplicateAssetDto":{"type":"object","properties":{"deviceAssetId":{"type":"string"},"deviceId":{"type":"string"}},"required":["deviceAssetId","deviceId"]},"CheckDuplicateAssetResponseDto":{"type":"object","properties":{"isExist":{"type":"boolean"},"id":{"type":"string"}},"required":["isExist"]},"LoginCredentialDto":{"type":"object","properties":{"email":{"type":"string","example":"testuser@email.com"},"password":{"type":"string","example":"password"}},"required":["email","password"]},"LoginResponseDto":{"type":"object","properties":{"accessToken":{"type":"string","readOnly":true},"userId":{"type":"string","readOnly":true},"userEmail":{"type":"string","readOnly":true},"firstName":{"type":"string","readOnly":true},"lastName":{"type":"string","readOnly":true},"profileImagePath":{"type":"string","readOnly":true},"isAdmin":{"type":"boolean","readOnly":true},"shouldChangePassword":{"type":"boolean","readOnly":true}},"required":["accessToken","userId","userEmail","firstName","lastName","profileImagePath","isAdmin","shouldChangePassword"]},"SignUpDto":{"type":"object","properties":{"email":{"type":"string","example":"testuser@email.com"},"password":{"type":"string","example":"password"},"firstName":{"type":"string","example":"Admin"},"lastName":{"type":"string","example":"Doe"}},"required":["email","password","firstName","lastName"]},"AdminSignupResponseDto":{"type":"object","properties":{"id":{"type":"string"},"email":{"type":"string"},"firstName":{"type":"string"},"lastName":{"type":"string"},"createdAt":{"type":"string"}},"required":["id","email","firstName","lastName","createdAt"]},"ValidateAccessTokenResponseDto":{"type":"object","properties":{"authStatus":{"type":"boolean"}},"required":["authStatus"]},"LogoutResponseDto":{"type":"object","properties":{"successful":{"type":"boolean","readOnly":true}},"required":["successful"]},"DeviceTypeEnum":{"type":"string","enum":["IOS","ANDROID","WEB"]},"CreateDeviceInfoDto":{"type":"object","properties":{"deviceType":{"$ref":"#/components/schemas/DeviceTypeEnum"},"deviceId":{"type":"string"},"isAutoBackup":{"type":"boolean"}},"required":["deviceType","deviceId"]},"DeviceInfoResponseDto":{"type":"object","properties":{"id":{"type":"integer"},"deviceType":{"$ref":"#/components/schemas/DeviceTypeEnum"},"userId":{"type":"string"},"deviceId":{"type":"string"},"createdAt":{"type":"string"},"isAutoBackup":{"type":"boolean"}},"required":["id","deviceType","userId","deviceId","createdAt","isAutoBackup"]},"UpdateDeviceInfoDto":{"type":"object","properties":{"deviceType":{"$ref":"#/components/schemas/DeviceTypeEnum"},"deviceId":{"type":"string"},"isAutoBackup":{"type":"boolean"}},"required":["deviceType","deviceId"]},"ServerInfoResponseDto":{"type":"object","properties":{"diskSizeRaw":{"type":"integer","format":"int64"},"diskUseRaw":{"type":"integer","format":"int64"},"diskAvailableRaw":{"type":"integer","format":"int64"},"diskUsagePercentage":{"type":"number","format":"float"},"diskSize":{"type":"string"},"diskUse":{"type":"string"},"diskAvailable":{"type":"string"}},"required":["diskSizeRaw","diskUseRaw","diskAvailableRaw","diskUsagePercentage","diskSize","diskUse","diskAvailable"]},"ServerPingResponse":{"type":"object","properties":{"res":{"type":"string","readOnly":true,"example":"pong"}},"required":["res"]},"ServerVersionReponseDto":{"type":"object","properties":{"major":{"type":"integer"},"minor":{"type":"integer"},"patch":{"type":"integer"},"build":{"type":"integer"}},"required":["major","minor","patch","build"]},"UsageByUserDto":{"type":"object","properties":{"userId":{"type":"string"},"objects":{"type":"integer"},"videos":{"type":"integer"},"photos":{"type":"integer"},"usageRaw":{"type":"integer","format":"int64"},"usage":{"type":"string"}},"required":["userId","objects","videos","photos","usageRaw","usage"]},"ServerStatsResponseDto":{"type":"object","properties":{"photos":{"type":"integer"},"videos":{"type":"integer"},"objects":{"type":"integer"},"usageRaw":{"type":"integer","format":"int64"},"usage":{"type":"string"},"usageByUser":{"title":"Array of usage for each user","example":[{"photos":1,"videos":1,"objects":1,"diskUsageRaw":1}],"type":"array","items":{"$ref":"#/components/schemas/UsageByUserDto"}}},"required":["photos","videos","objects","usageRaw","usage","usageByUser"]},"AlbumCountResponseDto":{"type":"object","properties":{"owned":{"type":"integer"},"shared":{"type":"integer"},"sharing":{"type":"integer"}},"required":["owned","shared","sharing"]},"CreateAlbumDto":{"type":"object","properties":{"albumName":{"type":"string"},"sharedWithUserIds":{"type":"array","items":{"type":"string"}},"assetIds":{"type":"array","items":{"type":"string"}}},"required":["albumName"]},"AlbumResponseDto":{"type":"object","properties":{"assetCount":{"type":"integer"},"id":{"type":"string"},"ownerId":{"type":"string"},"albumName":{"type":"string"},"createdAt":{"type":"string"},"albumThumbnailAssetId":{"type":"string","nullable":true},"shared":{"type":"boolean"},"sharedUsers":{"type":"array","items":{"$ref":"#/components/schemas/UserResponseDto"}},"assets":{"type":"array","items":{"$ref":"#/components/schemas/AssetResponseDto"}}},"required":["assetCount","id","ownerId","albumName","createdAt","albumThumbnailAssetId","shared","sharedUsers","assets"]},"AddUsersDto":{"type":"object","properties":{"sharedUserIds":{"type":"array","items":{"type":"string"}}},"required":["sharedUserIds"]},"AddAssetsDto":{"type":"object","properties":{"assetIds":{"type":"array","items":{"type":"string"}}},"required":["assetIds"]},"RemoveAssetsDto":{"type":"object","properties":{"assetIds":{"type":"array","items":{"type":"string"}}},"required":["assetIds"]},"UpdateAlbumDto":{"type":"object","properties":{"albumName":{"type":"string"},"albumThumbnailAssetId":{"type":"string"}}},"JobCounts":{"type":"object","properties":{"active":{"type":"integer"},"completed":{"type":"integer"},"failed":{"type":"integer"},"delayed":{"type":"integer"},"waiting":{"type":"integer"}},"required":["active","completed","failed","delayed","waiting"]},"AllJobStatusResponseDto":{"type":"object","properties":{"thumbnailGenerationQueueCount":{"$ref":"#/components/schemas/JobCounts"},"metadataExtractionQueueCount":{"$ref":"#/components/schemas/JobCounts"},"videoConversionQueueCount":{"$ref":"#/components/schemas/JobCounts"},"machineLearningQueueCount":{"$ref":"#/components/schemas/JobCounts"},"isThumbnailGenerationActive":{"type":"boolean"},"isMetadataExtractionActive":{"type":"boolean"},"isVideoConversionActive":{"type":"boolean"},"isMachineLearningActive":{"type":"boolean"}},"required":["thumbnailGenerationQueueCount","metadataExtractionQueueCount","videoConversionQueueCount","machineLearningQueueCount","isThumbnailGenerationActive","isMetadataExtractionActive","isVideoConversionActive","isMachineLearningActive"]},"JobId":{"type":"string","enum":["thumbnail-generation","metadata-extraction","video-conversion","machine-learning"]},"JobStatusResponseDto":{"type":"object","properties":{"isActive":{"type":"boolean"},"queueCount":{"type":"object"}},"required":["isActive","queueCount"]},"JobCommand":{"type":"string","enum":["start","stop"]},"JobCommandDto":{"type":"object","properties":{"command":{"$ref":"#/components/schemas/JobCommand"}},"required":["command"]}}}} \ No newline at end of file diff --git a/server/libs/common/src/config/app.config.ts b/server/libs/common/src/config/app.config.ts index 04aae2733e..44f58975bf 100644 --- a/server/libs/common/src/config/app.config.ts +++ b/server/libs/common/src/config/app.config.ts @@ -1,20 +1,20 @@ import { Logger } from '@nestjs/common'; import { ConfigModuleOptions } from '@nestjs/config'; import Joi from 'joi'; -import { createSecretKey, generateKeySync } from 'node:crypto' +import { createSecretKey, generateKeySync } from 'node:crypto'; -const jwtSecretValidator: Joi.CustomValidator = (value, ) => { - const key = createSecretKey(value, "base64") - const keySizeBits = (key.symmetricKeySize ?? 0) * 8 +const jwtSecretValidator: Joi.CustomValidator = (value) => { + const key = createSecretKey(value, 'base64'); + const keySizeBits = (key.symmetricKeySize ?? 0) * 8; if (keySizeBits < 128) { - const newKey = generateKeySync('hmac', { length: 256 }).export().toString('base64') - Logger.warn("The current JWT_SECRET key is insecure. It should be at least 128 bits long!") - Logger.warn(`Here is a new, securely generated key that you can use instead: ${newKey}`) + const newKey = generateKeySync('hmac', { length: 256 }).export().toString('base64'); + Logger.warn('The current JWT_SECRET key is insecure. It should be at least 128 bits long!'); + Logger.warn(`Here is a new, securely generated key that you can use instead: ${newKey}`); } return value; -} +}; export const immichAppConfig: ConfigModuleOptions = { envFilePath: '.env', @@ -26,7 +26,7 @@ export const immichAppConfig: ConfigModuleOptions = { DB_DATABASE_NAME: Joi.string().required(), JWT_SECRET: Joi.string().required().custom(jwtSecretValidator), DISABLE_REVERSE_GEOCODING: Joi.boolean().optional().valid(true, false).default(false), - REVERSE_GEOCODING_PRECISION: Joi.number().optional().valid(0,1,2,3).default(3), + REVERSE_GEOCODING_PRECISION: Joi.number().optional().valid(0, 1, 2, 3).default(3), LOG_LEVEL: Joi.string().optional().valid('simple', 'verbose').default('simple'), }), }; diff --git a/server/libs/database/src/entities/album.entity.ts b/server/libs/database/src/entities/album.entity.ts index 55dbe3a83a..e113f269a0 100644 --- a/server/libs/database/src/entities/album.entity.ts +++ b/server/libs/database/src/entities/album.entity.ts @@ -16,7 +16,7 @@ export class AlbumEntity { @CreateDateColumn({ type: 'timestamptz' }) createdAt!: string; - @Column({ comment: 'Asset ID to be used as thumbnail', type: 'varchar', nullable: true}) + @Column({ comment: 'Asset ID to be used as thumbnail', type: 'varchar', nullable: true }) albumThumbnailAssetId!: string | null; @OneToMany(() => UserAlbumEntity, (userAlbums) => userAlbums.albumInfo) diff --git a/server/libs/database/src/entities/asset-album.entity.ts b/server/libs/database/src/entities/asset-album.entity.ts index f4dc19e113..37dd7f7fea 100644 --- a/server/libs/database/src/entities/asset-album.entity.ts +++ b/server/libs/database/src/entities/asset-album.entity.ts @@ -1,4 +1,4 @@ -import {Column, Entity, JoinColumn, ManyToOne, OneToOne, PrimaryGeneratedColumn, Unique} from 'typeorm'; +import { Column, Entity, JoinColumn, ManyToOne, OneToOne, PrimaryGeneratedColumn, Unique } from 'typeorm'; import { AlbumEntity } from './album.entity'; import { AssetEntity } from './asset.entity'; diff --git a/server/libs/database/src/migrations/1656888591977-RenameAssetAlbumIdSequence.ts b/server/libs/database/src/migrations/1656888591977-RenameAssetAlbumIdSequence.ts index 82646234a7..07d5592f53 100644 --- a/server/libs/database/src/migrations/1656888591977-RenameAssetAlbumIdSequence.ts +++ b/server/libs/database/src/migrations/1656888591977-RenameAssetAlbumIdSequence.ts @@ -1,15 +1,17 @@ -import { MigrationInterface, QueryRunner } from "typeorm" +import { MigrationInterface, QueryRunner } from 'typeorm'; export class RenameAssetAlbumIdSequence1656888591977 implements MigrationInterface { + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`alter sequence asset_shared_album_id_seq rename to asset_album_id_seq;`); + await queryRunner.query( + `alter table asset_album alter column id set default nextval('asset_album_id_seq'::regclass);`, + ); + } - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`alter sequence asset_shared_album_id_seq rename to asset_album_id_seq;`); - await queryRunner.query(`alter table asset_album alter column id set default nextval('asset_album_id_seq'::regclass);`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`alter sequence asset_album_id_seq rename to asset_shared_album_id_seq;`); - await queryRunner.query(`alter table asset_album alter column id set default nextval('asset_shared_album_id_seq'::regclass);`); - } - + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`alter sequence asset_album_id_seq rename to asset_shared_album_id_seq;`); + await queryRunner.query( + `alter table asset_album alter column id set default nextval('asset_shared_album_id_seq'::regclass);`, + ); + } } diff --git a/server/libs/database/src/migrations/1656888918620-DropExifTextSearchableColumn.ts b/server/libs/database/src/migrations/1656888918620-DropExifTextSearchableColumn.ts index cbe2339395..305b67ee84 100644 --- a/server/libs/database/src/migrations/1656888918620-DropExifTextSearchableColumn.ts +++ b/server/libs/database/src/migrations/1656888918620-DropExifTextSearchableColumn.ts @@ -1,13 +1,12 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; +import { MigrationInterface, QueryRunner } from 'typeorm'; export class DropExifTextSearchableColumns1656888918620 implements MigrationInterface { + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "exif" DROP COLUMN "exif_text_searchable_column"`); + } - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "exif" DROP COLUMN "exif_text_searchable_column"`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(` + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(` ALTER TABLE exif DROP COLUMN IF EXISTS exif_text_searchable_column; @@ -29,6 +28,5 @@ export class DropExifTextSearchableColumns1656888918620 implements MigrationInte ON exif USING GIN (exif_text_searchable_column); `); - } - + } } diff --git a/server/libs/database/src/migrations/1656889061566-MatchMigrationsWithTypeORMEntities.ts b/server/libs/database/src/migrations/1656889061566-MatchMigrationsWithTypeORMEntities.ts index 8e7074a8de..6bc1e56250 100644 --- a/server/libs/database/src/migrations/1656889061566-MatchMigrationsWithTypeORMEntities.ts +++ b/server/libs/database/src/migrations/1656889061566-MatchMigrationsWithTypeORMEntities.ts @@ -1,9 +1,8 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; +import { MigrationInterface, QueryRunner } from 'typeorm'; export class MatchMigrationsWithTypeORMEntities1656889061566 implements MigrationInterface { - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "exif" ADD "exifTextSearchableColumn" tsvector GENERATED ALWAYS AS (TO_TSVECTOR('english', + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "exif" ADD "exifTextSearchableColumn" tsvector GENERATED ALWAYS AS (TO_TSVECTOR('english', COALESCE(make, '') || ' ' || COALESCE(model, '') || ' ' || COALESCE(orientation, '') || ' ' || @@ -11,36 +10,63 @@ export class MatchMigrationsWithTypeORMEntities1656889061566 implements Migratio COALESCE("city", '') || ' ' || COALESCE("state", '') || ' ' || COALESCE("country", ''))) STORED`); - await queryRunner.query(`ALTER TABLE "exif" ALTER COLUMN "exifTextSearchableColumn" SET NOT NULL`); - await queryRunner.query(`DELETE FROM "typeorm_metadata" WHERE "type" = $1 AND "name" = $2 AND "database" = $3 AND "schema" = $4 AND "table" = $5`, ["GENERATED_COLUMN","exifTextSearchableColumn","postgres","public","exif"]); - await queryRunner.query(`INSERT INTO "typeorm_metadata"("database", "schema", "table", "type", "name", "value") VALUES ($1, $2, $3, $4, $5, $6)`, ["postgres","public","exif","GENERATED_COLUMN","exifTextSearchableColumn","TO_TSVECTOR('english',\n COALESCE(make, '') || ' ' ||\n COALESCE(model, '') || ' ' ||\n COALESCE(orientation, '') || ' ' ||\n COALESCE(\"lensModel\", '') || ' ' ||\n COALESCE(\"city\", '') || ' ' ||\n COALESCE(\"state\", '') || ' ' ||\n COALESCE(\"country\", ''))"]); - await queryRunner.query(`ALTER TABLE "users" ALTER COLUMN "firstName" SET NOT NULL`); - await queryRunner.query(`ALTER TABLE "users" ALTER COLUMN "lastName" SET NOT NULL`); - await queryRunner.query(`ALTER TABLE "users" ALTER COLUMN "isAdmin" SET NOT NULL`); - await queryRunner.query(`ALTER TABLE "users" ALTER COLUMN "profileImagePath" SET NOT NULL`); - await queryRunner.query(`ALTER TABLE "users" ALTER COLUMN "shouldChangePassword" SET NOT NULL`); - await queryRunner.query(`ALTER TABLE "asset_album" DROP CONSTRAINT "FK_a8b79a84996cef6ba6a3662825d"`); - await queryRunner.query(`ALTER TABLE "asset_album" DROP CONSTRAINT "FK_64f2e7d68d1d1d8417acc844a4a"`); - await queryRunner.query(`ALTER TABLE "asset_album" DROP CONSTRAINT "UQ_a1e2734a1ce361e7a26f6b28288"`); - await queryRunner.query(`ALTER TABLE "asset_album" ADD CONSTRAINT "UQ_unique_asset_in_album" UNIQUE ("albumId", "assetId")`); - await queryRunner.query(`ALTER TABLE "asset_album" ADD CONSTRAINT "FK_256a30a03a4a0aff0394051397d" FOREIGN KEY ("albumId") REFERENCES "albums"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "asset_album" ADD CONSTRAINT "FK_7ae4e03729895bf87e056d7b598" FOREIGN KEY ("assetId") REFERENCES "assets"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - } + await queryRunner.query(`ALTER TABLE "exif" ALTER COLUMN "exifTextSearchableColumn" SET NOT NULL`); + await queryRunner.query( + `DELETE FROM "typeorm_metadata" WHERE "type" = $1 AND "name" = $2 AND "database" = $3 AND "schema" = $4 AND "table" = $5`, + ['GENERATED_COLUMN', 'exifTextSearchableColumn', 'postgres', 'public', 'exif'], + ); + await queryRunner.query( + `INSERT INTO "typeorm_metadata"("database", "schema", "table", "type", "name", "value") VALUES ($1, $2, $3, $4, $5, $6)`, + [ + 'postgres', + 'public', + 'exif', + 'GENERATED_COLUMN', + 'exifTextSearchableColumn', + "TO_TSVECTOR('english',\n COALESCE(make, '') || ' ' ||\n COALESCE(model, '') || ' ' ||\n COALESCE(orientation, '') || ' ' ||\n COALESCE(\"lensModel\", '') || ' ' ||\n COALESCE(\"city\", '') || ' ' ||\n COALESCE(\"state\", '') || ' ' ||\n COALESCE(\"country\", ''))", + ], + ); + await queryRunner.query(`ALTER TABLE "users" ALTER COLUMN "firstName" SET NOT NULL`); + await queryRunner.query(`ALTER TABLE "users" ALTER COLUMN "lastName" SET NOT NULL`); + await queryRunner.query(`ALTER TABLE "users" ALTER COLUMN "isAdmin" SET NOT NULL`); + await queryRunner.query(`ALTER TABLE "users" ALTER COLUMN "profileImagePath" SET NOT NULL`); + await queryRunner.query(`ALTER TABLE "users" ALTER COLUMN "shouldChangePassword" SET NOT NULL`); + await queryRunner.query(`ALTER TABLE "asset_album" DROP CONSTRAINT "FK_a8b79a84996cef6ba6a3662825d"`); + await queryRunner.query(`ALTER TABLE "asset_album" DROP CONSTRAINT "FK_64f2e7d68d1d1d8417acc844a4a"`); + await queryRunner.query(`ALTER TABLE "asset_album" DROP CONSTRAINT "UQ_a1e2734a1ce361e7a26f6b28288"`); + await queryRunner.query( + `ALTER TABLE "asset_album" ADD CONSTRAINT "UQ_unique_asset_in_album" UNIQUE ("albumId", "assetId")`, + ); + await queryRunner.query( + `ALTER TABLE "asset_album" ADD CONSTRAINT "FK_256a30a03a4a0aff0394051397d" FOREIGN KEY ("albumId") REFERENCES "albums"("id") ON DELETE CASCADE ON UPDATE NO ACTION`, + ); + await queryRunner.query( + `ALTER TABLE "asset_album" ADD CONSTRAINT "FK_7ae4e03729895bf87e056d7b598" FOREIGN KEY ("assetId") REFERENCES "assets"("id") ON DELETE CASCADE ON UPDATE NO ACTION`, + ); + } - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "users" ALTER COLUMN "shouldChangePassword" DROP NOT NULL`); - await queryRunner.query(`ALTER TABLE "users" ALTER COLUMN "profileImagePath" DROP NOT NULL`); - await queryRunner.query(`ALTER TABLE "users" ALTER COLUMN "isAdmin" DROP NOT NULL`); - await queryRunner.query(`ALTER TABLE "users" ALTER COLUMN "lastName" DROP NOT NULL`); - await queryRunner.query(`ALTER TABLE "users" ALTER COLUMN "firstName" DROP NOT NULL`); - await queryRunner.query(`DELETE FROM "typeorm_metadata" WHERE "type" = $1 AND "name" = $2 AND "database" = $3 AND "schema" = $4 AND "table" = $5`, ["GENERATED_COLUMN","exifTextSearchableColumn","immich","public","exif"]); - await queryRunner.query(`ALTER TABLE "exif" DROP COLUMN "exifTextSearchableColumn"`); - await queryRunner.query(`ALTER TABLE "asset_album" DROP CONSTRAINT "FK_7ae4e03729895bf87e056d7b598"`); - await queryRunner.query(`ALTER TABLE "asset_album" DROP CONSTRAINT "FK_256a30a03a4a0aff0394051397d"`); - await queryRunner.query(`ALTER TABLE "asset_album" DROP CONSTRAINT "UQ_unique_asset_in_album"`); - await queryRunner.query(`ALTER TABLE "asset_album" ADD CONSTRAINT "UQ_a1e2734a1ce361e7a26f6b28288" UNIQUE ("albumId", "assetId")`); - await queryRunner.query(`ALTER TABLE "asset_album" ADD CONSTRAINT "FK_64f2e7d68d1d1d8417acc844a4a" FOREIGN KEY ("assetId") REFERENCES "assets"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "asset_album" ADD CONSTRAINT "FK_a8b79a84996cef6ba6a3662825d" FOREIGN KEY ("albumId") REFERENCES "albums"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - } - -} \ No newline at end of file + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "users" ALTER COLUMN "shouldChangePassword" DROP NOT NULL`); + await queryRunner.query(`ALTER TABLE "users" ALTER COLUMN "profileImagePath" DROP NOT NULL`); + await queryRunner.query(`ALTER TABLE "users" ALTER COLUMN "isAdmin" DROP NOT NULL`); + await queryRunner.query(`ALTER TABLE "users" ALTER COLUMN "lastName" DROP NOT NULL`); + await queryRunner.query(`ALTER TABLE "users" ALTER COLUMN "firstName" DROP NOT NULL`); + await queryRunner.query( + `DELETE FROM "typeorm_metadata" WHERE "type" = $1 AND "name" = $2 AND "database" = $3 AND "schema" = $4 AND "table" = $5`, + ['GENERATED_COLUMN', 'exifTextSearchableColumn', 'immich', 'public', 'exif'], + ); + await queryRunner.query(`ALTER TABLE "exif" DROP COLUMN "exifTextSearchableColumn"`); + await queryRunner.query(`ALTER TABLE "asset_album" DROP CONSTRAINT "FK_7ae4e03729895bf87e056d7b598"`); + await queryRunner.query(`ALTER TABLE "asset_album" DROP CONSTRAINT "FK_256a30a03a4a0aff0394051397d"`); + await queryRunner.query(`ALTER TABLE "asset_album" DROP CONSTRAINT "UQ_unique_asset_in_album"`); + await queryRunner.query( + `ALTER TABLE "asset_album" ADD CONSTRAINT "UQ_a1e2734a1ce361e7a26f6b28288" UNIQUE ("albumId", "assetId")`, + ); + await queryRunner.query( + `ALTER TABLE "asset_album" ADD CONSTRAINT "FK_64f2e7d68d1d1d8417acc844a4a" FOREIGN KEY ("assetId") REFERENCES "assets"("id") ON DELETE CASCADE ON UPDATE NO ACTION`, + ); + await queryRunner.query( + `ALTER TABLE "asset_album" ADD CONSTRAINT "FK_a8b79a84996cef6ba6a3662825d" FOREIGN KEY ("albumId") REFERENCES "albums"("id") ON DELETE CASCADE ON UPDATE NO ACTION`, + ); + } +} diff --git a/server/libs/database/src/migrations/1661881837496-AddAssetChecksum.ts b/server/libs/database/src/migrations/1661881837496-AddAssetChecksum.ts index 5126961d1d..231aeecca7 100644 --- a/server/libs/database/src/migrations/1661881837496-AddAssetChecksum.ts +++ b/server/libs/database/src/migrations/1661881837496-AddAssetChecksum.ts @@ -1,16 +1,17 @@ import { MigrationInterface, QueryRunner } from 'typeorm'; export class AddAssetChecksum1661881837496 implements MigrationInterface { - name = 'AddAssetChecksum1661881837496' + name = 'AddAssetChecksum1661881837496'; public async up(queryRunner: QueryRunner): Promise { await queryRunner.query(`ALTER TABLE "assets" ADD "checksum" bytea`); - await queryRunner.query(`CREATE INDEX "IDX_64c507300988dd1764f9a6530c" ON "assets" ("checksum") WHERE 'checksum' IS NOT NULL`); + await queryRunner.query( + `CREATE INDEX "IDX_64c507300988dd1764f9a6530c" ON "assets" ("checksum") WHERE 'checksum' IS NOT NULL`, + ); } public async down(queryRunner: QueryRunner): Promise { await queryRunner.query(`DROP INDEX "public"."IDX_64c507300988dd1764f9a6530c"`); await queryRunner.query(`ALTER TABLE "assets" DROP COLUMN "checksum"`); } - } diff --git a/server/libs/database/src/migrations/1661971370662-UpdateAssetTableWithNewUniqueConstraint.ts b/server/libs/database/src/migrations/1661971370662-UpdateAssetTableWithNewUniqueConstraint.ts index 75cc3f6021..15fa467878 100644 --- a/server/libs/database/src/migrations/1661971370662-UpdateAssetTableWithNewUniqueConstraint.ts +++ b/server/libs/database/src/migrations/1661971370662-UpdateAssetTableWithNewUniqueConstraint.ts @@ -1,7 +1,7 @@ import { MigrationInterface, QueryRunner } from 'typeorm'; export class UpdateAssetTableWithNewUniqueConstraint1661971370662 implements MigrationInterface { - name = 'UpdateAssetTableWithNewUniqueConstraint1661971370662' + name = 'UpdateAssetTableWithNewUniqueConstraint1661971370662'; public async up(queryRunner: QueryRunner): Promise { await queryRunner.query(`ALTER TABLE "assets" DROP CONSTRAINT "UQ_b599ab0bd9574958acb0b30a90e"`); @@ -10,7 +10,8 @@ export class UpdateAssetTableWithNewUniqueConstraint1661971370662 implements Mig public async down(queryRunner: QueryRunner): Promise { await queryRunner.query(`ALTER TABLE "assets" DROP CONSTRAINT "UQ_userid_checksum"`); - await queryRunner.query(`ALTER TABLE "assets" ADD CONSTRAINT "UQ_b599ab0bd9574958acb0b30a90e" UNIQUE ("deviceAssetId", "userId", "deviceId")`); + await queryRunner.query( + `ALTER TABLE "assets" ADD CONSTRAINT "UQ_b599ab0bd9574958acb0b30a90e" UNIQUE ("deviceAssetId", "userId", "deviceId")`, + ); } - } diff --git a/web/src/api/open-api/api.ts b/web/src/api/open-api/api.ts index 6654d9a328..5f43f44947 100644 --- a/web/src/api/open-api/api.ts +++ b/web/src/api/open-api/api.ts @@ -1157,6 +1157,49 @@ export interface ServerPingResponse { */ 'res': string; } +/** + * + * @export + * @interface ServerStatsResponseDto + */ +export interface ServerStatsResponseDto { + /** + * + * @type {number} + * @memberof ServerStatsResponseDto + */ + 'photos': number; + /** + * + * @type {number} + * @memberof ServerStatsResponseDto + */ + 'videos': number; + /** + * + * @type {number} + * @memberof ServerStatsResponseDto + */ + 'objects': number; + /** + * + * @type {number} + * @memberof ServerStatsResponseDto + */ + 'usageRaw': number; + /** + * + * @type {string} + * @memberof ServerStatsResponseDto + */ + 'usage': string; + /** + * + * @type {Array} + * @memberof ServerStatsResponseDto + */ + 'usageByUser': Array; +} /** * * @export @@ -1365,6 +1408,49 @@ export interface UpdateUserDto { */ 'profileImagePath'?: string; } +/** + * + * @export + * @interface UsageByUserDto + */ +export interface UsageByUserDto { + /** + * + * @type {string} + * @memberof UsageByUserDto + */ + 'userId': string; + /** + * + * @type {number} + * @memberof UsageByUserDto + */ + 'objects': number; + /** + * + * @type {number} + * @memberof UsageByUserDto + */ + 'videos': number; + /** + * + * @type {number} + * @memberof UsageByUserDto + */ + 'photos': number; + /** + * + * @type {number} + * @memberof UsageByUserDto + */ + 'usageRaw': number; + /** + * + * @type {string} + * @memberof UsageByUserDto + */ + 'usage': string; +} /** * * @export @@ -4132,6 +4218,35 @@ export const ServerInfoApiAxiosParamCreator = function (configuration?: Configur + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + getStats: async (options: AxiosRequestConfig = {}): Promise => { + const localVarPath = `/server-info/stats`; + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + + setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; @@ -4198,6 +4313,15 @@ export const ServerInfoApiFp = function(configuration?: Configuration) { const localVarAxiosArgs = await localVarAxiosParamCreator.getServerVersion(options); return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); }, + /** + * + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async getStats(options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.getStats(options); + return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); + }, /** * * @param {*} [options] Override http request option. @@ -4233,6 +4357,14 @@ export const ServerInfoApiFactory = function (configuration?: Configuration, bas getServerVersion(options?: any): AxiosPromise { return localVarFp.getServerVersion(options).then((request) => request(axios, basePath)); }, + /** + * + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + getStats(options?: any): AxiosPromise { + return localVarFp.getStats(options).then((request) => request(axios, basePath)); + }, /** * * @param {*} [options] Override http request option. @@ -4271,6 +4403,16 @@ export class ServerInfoApi extends BaseAPI { return ServerInfoApiFp(this.configuration).getServerVersion(options).then((request) => request(this.axios, this.basePath)); } + /** + * + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof ServerInfoApi + */ + public getStats(options?: AxiosRequestConfig) { + return ServerInfoApiFp(this.configuration).getStats(options).then((request) => request(this.axios, this.basePath)); + } + /** * * @param {*} [options] Override http request option. diff --git a/web/src/lib/components/admin-page/server-stats.svelte b/web/src/lib/components/admin-page/server-stats.svelte new file mode 100644 index 0000000000..0408da6acd --- /dev/null +++ b/web/src/lib/components/admin-page/server-stats.svelte @@ -0,0 +1,52 @@ + + +
+
+

Server Usage

+
+

Photos: {stats.photos}

+

Videos: {stats.videos}

+

Objects: {stats.objects}

+

Size: {stats.usage}

+
+
+ +
+

Usage by User

+ + + + + + + + + + + + + {#each stats.usageByUser as user} + + + + + + + + {/each} + +
UserPhotosVideosObjectsSize
{getFullName(user.userId)}{user.photos}{user.videos}{user.objects}{user.usage}
+
+
diff --git a/web/src/lib/models/admin-sidebar-selection.ts b/web/src/lib/models/admin-sidebar-selection.ts index 6ffe6ef4e1..a1b977e90e 100644 --- a/web/src/lib/models/admin-sidebar-selection.ts +++ b/web/src/lib/models/admin-sidebar-selection.ts @@ -1,7 +1,8 @@ export enum AdminSideBarSelection { USER_MANAGEMENT = 'User management', JOBS = 'Jobs', - SETTINGS = 'Settings' + SETTINGS = 'Settings', + STATS = 'Server Stats' } export enum AppSideBarSelection { diff --git a/web/src/routes/admin/+page.server.ts b/web/src/routes/admin/+page.server.ts index d03b1f0e61..27270ed9d0 100644 --- a/web/src/routes/admin/+page.server.ts +++ b/web/src/routes/admin/+page.server.ts @@ -12,8 +12,10 @@ export const load: PageServerLoad = async ({ parent }) => { } const { data: allUsers } = await serverApi.userApi.getAllUsers(false); + const { data: stats } = await serverApi.serverInfoApi.getStats(); return { user: user, - allUsers: allUsers + allUsers: allUsers, + stats: stats }; }; diff --git a/web/src/routes/admin/+page.svelte b/web/src/routes/admin/+page.svelte index 5bde9cadfa..0978cda8ce 100644 --- a/web/src/routes/admin/+page.svelte +++ b/web/src/routes/admin/+page.svelte @@ -5,6 +5,7 @@ import SideBarButton from '$lib/components/shared-components/side-bar/side-bar-button.svelte'; import AccountMultipleOutline from 'svelte-material-icons/AccountMultipleOutline.svelte'; import Cog from 'svelte-material-icons/Cog.svelte'; + import Server from 'svelte-material-icons/Server.svelte'; import NavigationBar from '$lib/components/shared-components/navigation-bar.svelte'; import UserManagement from '$lib/components/admin-page/user-management.svelte'; import FullScreenModal from '$lib/components/shared-components/full-screen-modal.svelte'; @@ -14,6 +15,7 @@ import type { PageData } from './$types'; import { api, UserResponseDto } from '@api'; import JobsPanel from '$lib/components/admin-page/jobs/jobs-panel.svelte'; + import ServerStats from '$lib/components/admin-page/server-stats.svelte'; let selectedAction: AdminSideBarSelection = AdminSideBarSelection.USER_MANAGEMENT; @@ -121,6 +123,13 @@ isSelected={selectedAction === AdminSideBarSelection.JOBS} on:selected={onButtonClicked} /> +
@@ -144,6 +153,9 @@ {#if selectedAction === AdminSideBarSelection.JOBS} {/if} + {#if selectedAction === AdminSideBarSelection.STATS} + + {/if}