Improve repository list display

Signed-off-by: trivernis <trivernis@protonmail.com>
pull/4/head
trivernis 3 years ago
parent 1982790b26
commit 0d8c971056

@ -95,9 +95,9 @@ version = "0.1.51"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "44318e776df68115a881de9a8fd1b9e53368d7a4a5ce4cc48517da3393233a5e"
dependencies = [
"proc-macro2",
"quote",
"syn",
"proc-macro2 1.0.29",
"quote 1.0.10",
"syn 1.0.80",
]
[[package]]
@ -386,8 +386,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7606b05842fea68ddcc89e8053b8860ebcb2a0ba8d6abfe3a148e5d5a8d3f0c1"
dependencies = [
"com_macros_support",
"proc-macro2",
"syn",
"proc-macro2 1.0.29",
"syn 1.0.80",
]
[[package]]
@ -396,9 +396,9 @@ version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "97e9a6d20f4ac8830e309a455d7e9416e65c6af5a97c88c55fbb4c2012e107da"
dependencies = [
"proc-macro2",
"quote",
"syn",
"proc-macro2 1.0.29",
"quote 1.0.10",
"syn 1.0.80",
]
[[package]]
@ -574,10 +574,10 @@ dependencies = [
"itoa",
"matches",
"phf 0.8.0",
"proc-macro2",
"quote",
"proc-macro2 1.0.29",
"quote 1.0.10",
"smallvec",
"syn",
"syn 1.0.80",
]
[[package]]
@ -586,8 +586,8 @@ version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dfae75de57f2b2e85e8768c3ea840fd159c8f33e2b6522c7835b7abac81be16e"
dependencies = [
"quote",
"syn",
"quote 1.0.10",
"syn 1.0.80",
]
[[package]]
@ -608,10 +608,10 @@ checksum = "f0c960ae2da4de88a91b2d920c2a7233b400bc33cb28453a2987822d8392519b"
dependencies = [
"fnv",
"ident_case",
"proc-macro2",
"quote",
"proc-macro2 1.0.29",
"quote 1.0.10",
"strsim",
"syn",
"syn 1.0.80",
]
[[package]]
@ -621,8 +621,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9b5a2f4ac4969822c62224815d069952656cadc7084fdca9751e6d959189b72"
dependencies = [
"darling_core",
"quote",
"syn",
"quote 1.0.10",
"syn 1.0.80",
]
[[package]]
@ -651,9 +651,9 @@ version = "2.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b"
dependencies = [
"proc-macro2",
"quote",
"syn",
"proc-macro2 1.0.29",
"quote 1.0.10",
"syn 1.0.80",
]
[[package]]
@ -663,10 +663,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "40eebddd2156ce1bb37b20bbe5151340a31828b1f2d22ba4141f3531710e38df"
dependencies = [
"convert_case",
"proc-macro2",
"quote",
"proc-macro2 1.0.29",
"quote 1.0.10",
"rustc_version",
"syn",
"syn 1.0.80",
]
[[package]]
@ -779,9 +779,9 @@ version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "946ee94e3dbf58fdd324f9ce245c7b238d46a66f00e86a020b71996349e46cce"
dependencies = [
"proc-macro2",
"quote",
"syn",
"proc-macro2 1.0.29",
"quote 1.0.10",
"syn 1.0.80",
]
[[package]]
@ -939,9 +939,9 @@ checksum = "18e4a4b95cea4b4ccbcf1c5675ca7c4ee4e9e75eb79944d07defde18068f79bb"
dependencies = [
"autocfg",
"proc-macro-hack",
"proc-macro2",
"quote",
"syn",
"proc-macro2 1.0.29",
"quote 1.0.10",
"syn 1.0.80",
]
[[package]]
@ -1161,9 +1161,9 @@ dependencies = [
"heck",
"proc-macro-crate 1.1.0",
"proc-macro-error",
"proc-macro2",
"quote",
"syn",
"proc-macro2 1.0.29",
"quote 1.0.10",
"syn 1.0.80",
]
[[package]]
@ -1272,9 +1272,9 @@ dependencies = [
"heck",
"proc-macro-crate 1.1.0",
"proc-macro-error",
"proc-macro2",
"quote",
"syn",
"proc-macro2 1.0.29",
"quote 1.0.10",
"syn 1.0.80",
]
[[package]]
@ -1304,9 +1304,9 @@ dependencies = [
"log",
"mac",
"markup5ever",
"proc-macro2",
"quote",
"syn",
"proc-macro2 1.0.29",
"quote 1.0.10",
"syn 1.0.80",
]
[[package]]
@ -1581,7 +1581,7 @@ checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f"
[[package]]
name = "mediarepo-api"
version = "0.1.0"
source = "git+https://github.com/Trivernis/mediarepo-api.git?rev=266b1e7d6e840091b322818517a358fee84b939e#266b1e7d6e840091b322818517a358fee84b939e"
source = "git+https://github.com/Trivernis/mediarepo-api.git?rev=a2154fd1db3f14648935e872d30b043723a812c1#a2154fd1db3f14648935e872d30b043723a812c1"
dependencies = [
"async-trait",
"chrono",
@ -1590,6 +1590,7 @@ dependencies = [
"rmp-ipc",
"serde",
"serde_json",
"serde_piecewise_default",
"tauri",
"thiserror",
"tokio",
@ -1722,9 +1723,9 @@ checksum = "05d1c6307dc424d0f65b9b06e94f88248e6305726b14729fd67a5e47b2dc481d"
dependencies = [
"darling",
"proc-macro-crate 0.1.5",
"proc-macro2",
"quote",
"syn",
"proc-macro2 1.0.29",
"quote 1.0.10",
"syn 1.0.80",
]
[[package]]
@ -1838,9 +1839,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "486ea01961c4a818096de679a8b740b26d9033146ac5291b1c98557658f8cdd9"
dependencies = [
"proc-macro-crate 1.1.0",
"proc-macro2",
"quote",
"syn",
"proc-macro2 1.0.29",
"quote 1.0.10",
"syn 1.0.80",
]
[[package]]
@ -2080,9 +2081,9 @@ dependencies = [
"phf_generator 0.8.0",
"phf_shared 0.8.0",
"proc-macro-hack",
"proc-macro2",
"quote",
"syn",
"proc-macro2 1.0.29",
"quote 1.0.10",
"syn 1.0.80",
]
[[package]]
@ -2094,9 +2095,9 @@ dependencies = [
"phf_generator 0.10.0",
"phf_shared 0.10.0",
"proc-macro-hack",
"proc-macro2",
"quote",
"syn",
"proc-macro2 1.0.29",
"quote 1.0.10",
"syn 1.0.80",
]
[[package]]
@ -2210,9 +2211,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c"
dependencies = [
"proc-macro-error-attr",
"proc-macro2",
"quote",
"syn",
"proc-macro2 1.0.29",
"quote 1.0.10",
"syn 1.0.80",
"version_check",
]
@ -2222,8 +2223,8 @@ version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869"
dependencies = [
"proc-macro2",
"quote",
"proc-macro2 1.0.29",
"quote 1.0.10",
"version_check",
]
@ -2239,13 +2240,31 @@ version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bc881b2c22681370c6a780e47af9840ef841837bc98118431d4e1868bd0c1086"
[[package]]
name = "proc-macro2"
version = "0.4.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759"
dependencies = [
"unicode-xid 0.1.0",
]
[[package]]
name = "proc-macro2"
version = "1.0.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b9f5105d4fdaab20335ca9565e106a5d9b82b6219b5ba735731124ac6711d23d"
dependencies = [
"unicode-xid",
"unicode-xid 0.2.2",
]
[[package]]
name = "quote"
version = "0.6.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1"
dependencies = [
"proc-macro2 0.4.30",
]
[[package]]
@ -2254,7 +2273,7 @@ version = "1.0.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "38bc8cc6a5f2e3655e0899c1b848643b2562f853f114bfec7be120678e3ace05"
dependencies = [
"proc-macro2",
"proc-macro2 1.0.29",
]
[[package]]
@ -2658,9 +2677,9 @@ version = "1.0.130"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d7bc1a1ab1961464eae040d96713baa5a724a8152c1222492465b54322ec508b"
dependencies = [
"proc-macro2",
"quote",
"syn",
"proc-macro2 1.0.29",
"quote 1.0.10",
"syn 1.0.80",
]
[[package]]
@ -2674,15 +2693,37 @@ dependencies = [
"serde",
]
[[package]]
name = "serde_piecewise_default"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d91a44b0f51aedd237f8f25c831e1f629982a187a5045c08ce4bccccce17b4b0"
dependencies = [
"serde",
"serde_piecewise_default_derive",
]
[[package]]
name = "serde_piecewise_default_derive"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "19446953e7b22342c23c79ede938c04b1c12f4eb7513db30cda94193ce30ff2a"
dependencies = [
"proc-macro2 0.4.30",
"quote 0.6.13",
"serde",
"syn 0.15.44",
]
[[package]]
name = "serde_repr"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "98d0516900518c29efa217c298fa1f4e6c6ffc85ae29fd7f4ee48f176e1a9ed5"
dependencies = [
"proc-macro2",
"quote",
"syn",
"proc-macro2 1.0.29",
"quote 1.0.10",
"syn 1.0.80",
]
[[package]]
@ -2820,8 +2861,8 @@ checksum = "f24c8e5e19d22a726626f1a5e16fe15b132dcf21d10177fa5a45ce7962996b97"
dependencies = [
"phf_generator 0.8.0",
"phf_shared 0.8.0",
"proc-macro2",
"quote",
"proc-macro2 1.0.29",
"quote 1.0.10",
]
[[package]]
@ -2852,9 +2893,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "87c85aa3f8ea653bfd3ddf25f7ee357ee4d204731f6aa9ad04002306f6e2774c"
dependencies = [
"heck",
"proc-macro2",
"quote",
"syn",
"proc-macro2 1.0.29",
"quote 1.0.10",
"syn 1.0.80",
]
[[package]]
@ -2864,9 +2905,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d06aaeeee809dbc59eb4556183dd927df67db1540de5be8d3ec0b6636358a5ec"
dependencies = [
"heck",
"proc-macro2",
"quote",
"syn",
"proc-macro2 1.0.29",
"quote 1.0.10",
"syn 1.0.80",
]
[[package]]
name = "syn"
version = "0.15.44"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5"
dependencies = [
"proc-macro2 0.4.30",
"quote 0.6.13",
"unicode-xid 0.1.0",
]
[[package]]
@ -2875,9 +2927,9 @@ version = "1.0.80"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d010a1623fbd906d51d650a9916aaefc05ffa0e4053ff7fe601167f3e715d194"
dependencies = [
"proc-macro2",
"quote",
"unicode-xid",
"proc-macro2 1.0.29",
"quote 1.0.10",
"unicode-xid 0.2.2",
]
[[package]]
@ -3019,8 +3071,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3c9c9a9bea25b9d6f5845b8662e18447e17218f99860cab37e39e2b57a9fcd49"
dependencies = [
"anyhow",
"proc-macro2",
"quote",
"proc-macro2 1.0.29",
"quote 1.0.10",
"serde_json",
"tauri-utils",
"winres",
@ -3034,8 +3086,8 @@ checksum = "1663739ab53e281919676f216fb56a031104d0d2cd1a2dd5b012d279bcdb0ea4"
dependencies = [
"blake3",
"kuchiki",
"proc-macro2",
"quote",
"proc-macro2 1.0.29",
"quote 1.0.10",
"regex",
"serde",
"serde_json",
@ -3051,9 +3103,9 @@ version = "1.0.0-beta.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bddf9f5868402323f35ef94fa6ab1d5d10b29aea9de598d829723aa1db5693b4"
dependencies = [
"proc-macro2",
"quote",
"syn",
"proc-macro2 1.0.29",
"quote 1.0.10",
"syn 1.0.80",
"tauri-codegen",
]
@ -3101,8 +3153,8 @@ dependencies = [
"html5ever",
"kuchiki",
"phf 0.10.0",
"proc-macro2",
"quote",
"proc-macro2 1.0.29",
"quote 1.0.10",
"serde",
"serde_json",
"thiserror",
@ -3156,9 +3208,9 @@ version = "1.0.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa32fd3f627f367fe16f893e2597ae3c05020f8bba2666a4e6ea73d377e5714b"
dependencies = [
"proc-macro2",
"quote",
"syn",
"proc-macro2 1.0.29",
"quote 1.0.10",
"syn 1.0.80",
]
[[package]]
@ -3241,9 +3293,9 @@ version = "0.1.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f4f480b8f81512e825f337ad51e94c1eb5d3bbdf2b363dcd01e2b19a9ffe3f8e"
dependencies = [
"proc-macro2",
"quote",
"syn",
"proc-macro2 1.0.29",
"quote 1.0.10",
"syn 1.0.80",
]
[[package]]
@ -3355,6 +3407,12 @@ version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8895849a949e7845e06bd6dc1aa51731a103c42707010a5b591c0038fb73385b"
[[package]]
name = "unicode-xid"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc"
[[package]]
name = "unicode-xid"
version = "0.2.2"
@ -3467,9 +3525,9 @@ dependencies = [
"bumpalo",
"lazy_static",
"log",
"proc-macro2",
"quote",
"syn",
"proc-macro2 1.0.29",
"quote 1.0.10",
"syn 1.0.80",
"wasm-bindgen-shared",
]
@ -3491,7 +3549,7 @@ version = "0.2.78"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d56146e7c495528bf6587663bea13a8eb588d39b36b679d83972e1a2dbbdacf9"
dependencies = [
"quote",
"quote 1.0.10",
"wasm-bindgen-macro-support",
]
@ -3501,9 +3559,9 @@ version = "0.2.78"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7803e0eea25835f8abdc585cd3021b3deb11543c6fe226dcd30b228857c5c5ab"
dependencies = [
"proc-macro2",
"quote",
"syn",
"proc-macro2 1.0.29",
"quote 1.0.10",
"syn 1.0.80",
"wasm-bindgen-backend",
"wasm-bindgen-shared",
]
@ -3673,7 +3731,7 @@ version = "0.21.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "81cc2357b1b03c19f056cb0e6d06011f80f54beadb4e36aee2ca98493c7cfc3c"
dependencies = [
"syn",
"syn 1.0.80",
"windows_gen",
"windows_quote",
"windows_reader",
@ -3797,9 +3855,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a482c56029e48681b89b92b5db3c446db0915e8dd1052c0328a574eda38d5f93"
dependencies = [
"proc-macro-crate 0.1.5",
"proc-macro2",
"quote",
"syn",
"proc-macro2 1.0.29",
"quote 1.0.10",
"syn 1.0.80",
]
[[package]]
@ -3866,7 +3924,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "46ee71e0e88747ec582d290dbe98ff7907ff28770c7a35f16da41e5e6f1f4fa3"
dependencies = [
"proc-macro-crate 1.1.0",
"proc-macro2",
"quote",
"syn",
"proc-macro2 1.0.29",
"quote 1.0.10",
"syn 1.0.80",
]

@ -30,7 +30,7 @@ features = ["env-filter"]
[dependencies.mediarepo-api]
git = "https://github.com/Trivernis/mediarepo-api.git"
rev = "266b1e7d6e840091b322818517a358fee84b939e"
rev = "a2154fd1db3f14648935e872d30b043723a812c1"
features = ["tauri-plugin"]
[features]

@ -1,7 +1,6 @@
import {Component, OnInit} from '@angular/core';
import {Router} from "@angular/router";
import {RepositoryService} from "./services/repository/repository.service";
import {DataloaderService} from "./services/dataloader/dataloader.service";
import {MatSnackBar} from "@angular/material/snack-bar";
import {ErrorBrokerService} from "./services/error-broker/error-broker.service";

@ -1,7 +1,8 @@
export class Repository {
constructor(
public name: string,
public address: string,
public path: string | undefined
public address: string | undefined,
public path: string | undefined,
public local: boolean,
) {}
}

@ -1,8 +1,8 @@
import {Component, ElementRef, OnInit, ViewChild} from '@angular/core';
import {DataloaderService} from "../../services/dataloader/dataloader.service";
import {Component, OnInit, ViewChild} from '@angular/core';
import {Repository} from "../../models/Repository";
import {RepositoryService} from "../../services/repository/repository.service";
import {MatTabGroup} from "@angular/material/tabs";
import {TagService} from "../../services/tag/tag.service";
@Component({
selector: 'app-home',
@ -15,16 +15,22 @@ export class HomeComponent implements OnInit {
@ViewChild("tabGroup") tabGroup!: MatTabGroup;
constructor(private repoService: RepositoryService, private tagService: TagService) {}
public async ngOnInit(): Promise<void> {
await this.dataloaderService.loadData();
this.selectedRepository = this.repoService.selectedRepository.getValue();
this.repoService.selectedRepository.subscribe((selected) => {
this.repoService.selectedRepository.subscribe(async (selected) => {
this.selectedRepository = selected;
this.updateSelectedTab();
await this.loadRepoData();
});
}
public updateSelectedTab() {
if (!this.tabGroup) {
return;
}
if (!this.selectedRepository) {
this.tabGroup.selectedIndex = 0;
} else if (this.tabGroup.selectedIndex === 0) {
@ -32,5 +38,7 @@ export class HomeComponent implements OnInit {
}
}
constructor(private dataloaderService: DataloaderService, private repoService: RepositoryService) {}
async loadRepoData() {
await this.tagService.loadTags();
}
}

@ -26,7 +26,7 @@ export class RepoFormComponent implements OnInit {
async addRepository() {
let {name, path} = this.repoForm.value;
try {
await this.repoService.addRepository(name, path);
await this.repoService.addRepository(name, path, undefined, true);
} catch(err) {
this.errorBroker.showError(err);
}

@ -1,6 +1,3 @@
<mat-toolbar color="primary">
<span>Repositories</span>
</mat-toolbar>
<div class="repo-page-content">
<div class="add-repo-tools">
<app-repo-form></app-repo-form>

@ -7,10 +7,17 @@
.repo-page-content {
margin: 0 10%;
height: calc(100% - 2em);
}
.add-repo-tools {
margin: 1em 0
margin: 1em 0;
height: 5em;
}
.repository-list {
display: flex;
flex-direction: column;
overflow-y: auto;
height: calc(100% - 5em);
}

@ -1,12 +1,16 @@
<mat-card>
<mat-card-title>{{repository.name}}</mat-card-title>
<div [class]="'repository-status ' + this.getDaemonStatusClass()">
<p>{{this.getDaemonStatusText()}}</p>
</div>
<mat-card-content>
<p class="repository-path" *ngIf="repository.path">{{repository.path!}}</p>
<p class="repository-address" *ngIf="!repository.path">{{repository.address}}</p>
<div *ngIf="daemonRunning" class="daemon-running-info">Running</div>
<p class="repository-path" *ngIf="repository.local">{{repository.path!}}</p>
<p class="repository-address" *ngIf="!repository.local">{{repository.address}}</p>
</mat-card-content>
<mat-action-list>
<button *ngIf="!daemonRunning" mat-flat-button color="primary" (click)="startDaemonAndSelectRepository()">Open</button>
<button *ngIf="daemonRunning" mat-flat-button color="primary" (click)="selectRepository()">Connect</button>
<button *ngIf="!this.isSelectedRepository() && repository.local" mat-flat-button color="primary" (click)="startDaemonAndSelectRepository()">Open</button>
<button *ngIf="!this.isSelectedRepository() && !repository.local" mat-flat-button color="primary" (click)="selectRepository()" [disabled]="!this.daemonRunning">Connect</button>
<button *ngIf="this.isSelectedRepository() && repository.local" mat-flat-button color="primary" (click)="this.repoService.closeSelectedRepository()">Close</button>
<button *ngIf="this.isSelectedRepository() && !repository.local" mat-flat-button color="primary" (click)="this.repoService.disconnectSelectedRepository()" [disabled]="!this.daemonRunning">Disconnect</button>
</mat-action-list>
</mat-card>

@ -8,3 +8,27 @@
color: lightgray;
font-family: "Fira Code Light", Monospaced, Consolas, monospace;
}
.repository-status {
position: absolute;
right: 0;
top: 0;
padding: 0.5em;
width: 3em;
text-align: center;
border-bottom-left-radius: 1em;
p {
margin: auto;
}
}
.status-local {
background-color: #2e237a;
}
.status-offline {
background-color: #8e1e2a;
}
.status-online {
background-color: #1b651b;
}

@ -1,4 +1,4 @@
import {Component, Input, OnInit} from '@angular/core';
import {Component, Input, OnDestroy, OnInit} from '@angular/core';
import {Repository} from "../../../../models/Repository";
import {RepositoryService} from "../../../../services/repository/repository.service";
import {Router} from "@angular/router";
@ -9,36 +9,77 @@ import {ErrorBrokerService} from "../../../../services/error-broker/error-broker
templateUrl: './repository-card.component.html',
styleUrls: ['./repository-card.component.scss']
})
export class RepositoryCardComponent implements OnInit {
export class RepositoryCardComponent implements OnInit, OnDestroy {
@Input() repository!: Repository;
public daemonRunning: boolean = false;
constructor(private repoService: RepositoryService, private router: Router, private errorBroker: ErrorBrokerService) {}
statusRefreshInterval: number | undefined;
constructor(public repoService: RepositoryService, private router: Router, private errorBroker: ErrorBrokerService) {}
public async ngOnInit() {
this.daemonRunning = await this.repoService.checkDaemonRunning(this.repository.address);
if (!this.repository.local) {
await this.checkRemoteRepositoryStatus();
this.statusRefreshInterval = setInterval(async() => await this.checkRemoteRepositoryStatus(), 10000);
}
}
public async ngOnDestroy(): Promise<void> {
if (this.statusRefreshInterval != undefined) {
clearInterval(this.statusRefreshInterval);
}
}
public isSelectedRepository(): boolean {
return this.repoService.selectedRepository.getValue()?.name === this.repository.name
}
public getDaemonStatusText(): string {
if (this.repository.local) {
return "Local";
} else if (this.daemonRunning) {
return "Online";
} else {
return "Offline";
}
}
public getDaemonStatusClass(): string {
if (this.repository.local) {
return "status-local";
} else if (this.daemonRunning) {
return "status-online";
} else {
return "status-offline";
}
}
async startDaemonAndSelectRepository() {
public async startDaemonAndSelectRepository() {
try {
await this.repoService.startDaemon(this.repository.path!);
this.daemonRunning = true;
await new Promise((res, _) => {
setTimeout(res, 2000) // wait for the daemon to start
});
if (!this.daemonRunning) {
await this.repoService.startDaemon(this.repository.path!);
this.daemonRunning = true;
await new Promise((res, _) => {
setTimeout(res, 2000) // wait for the daemon to start
});
}
await this.selectRepository();
} catch (err) {
this.errorBroker.showError(err);
}
}
async selectRepository() {
public async selectRepository() {
try {
await this.repoService.setRepository(this.repository);
} catch(err) {
this.errorBroker.showError(err);
}
}
async checkRemoteRepositoryStatus() {
this.daemonRunning = await this.repoService.checkDaemonRunning(this.repository.address!);
}
}

@ -1,16 +0,0 @@
import { TestBed } from '@angular/core/testing';
import { DataloaderService } from './dataloader.service';
describe('DataloaderService', () => {
let service: DataloaderService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(DataloaderService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});

@ -1,24 +0,0 @@
import { Injectable } from '@angular/core';
import {RepositoryService} from "../repository/repository.service";
import {BehaviorSubject} from "rxjs";
import {ErrorBrokerService} from "../error-broker/error-broker.service";
import {TagService} from "../tag/tag.service";
import {FileService} from "../file/file.service";
@Injectable({
providedIn: 'root'
})
export class DataloaderService {
constructor(
private erroBroker: ErrorBrokerService,
private tagService: TagService) { }
public async loadData() {
try {
await this.tagService.loadTags();
} catch (err) {
this.erroBroker.showError(err);
}
}
}

@ -5,7 +5,6 @@ import {invoke} from "@tauri-apps/api/tauri";
import {listen} from "@tauri-apps/api/event";
import {Info} from "../../models/Info";
import {ErrorBrokerService} from "../error-broker/error-broker.service";
import {DataloaderService} from "../dataloader/dataloader.service";
@Injectable({
providedIn: 'root'
@ -14,7 +13,7 @@ export class RepositoryService {
repositories = new BehaviorSubject<Repository[]>([]);
public selectedRepository = new BehaviorSubject<Repository | undefined>(undefined);
constructor(private errorBroker: ErrorBrokerService, private dataloaderService: DataloaderService) {
constructor(private errorBroker: ErrorBrokerService) {
this.registerListener()
}
@ -31,9 +30,7 @@ export class RepositoryService {
* @returns {Promise<void>}
*/
public async loadRepositories() {
let active_repo = await invoke<Repository | undefined>("plugin:mediarepo|get_active_repository");
this.selectedRepository.next(active_repo);
await this.loadSelectedRepository();
let repos = await invoke<Repository[]>("plugin:mediarepo|get_repositories");
this.repositories.next(repos);
}
@ -45,18 +42,37 @@ export class RepositoryService {
*/
public async setRepository(repo: Repository) {
await invoke("plugin:mediarepo|select_repository", {name: repo.name});
this.selectedRepository.next(repo);
await this.dataloaderService.loadData();
await this.loadRepositories();
}
/**
* Disconnects from a remote repository
* @returns {Promise<void>}
*/
public async disconnectSelectedRepository() {
await invoke("plugin:mediarepo|disconnect_repository");
await this.loadRepositories();
}
/**
* Closes a local selected repository
* @returns {Promise<void>}
*/
public async closeSelectedRepository() {
await invoke("plugin:mediarepo|close_local_repository");
await this.loadRepositories();
}
/**
* Adds a respository to the repository list in the settings
* @param {string} name
* @param {string} path
* @param address
* @param local
* @returns {Promise<void>}
*/
public async addRepository(name: string, path: string) {
let repos = await invoke<Repository[]>("plugin:mediarepo|add_repository", {name, path});
public async addRepository(name: string, path: string | undefined, address: string | undefined, local: boolean) {
let repos = await invoke<Repository[]>("plugin:mediarepo|add_repository", {name, path, address, local});
this.repositories.next(repos);
}
@ -77,4 +93,9 @@ export class RepositoryService {
public async startDaemon(repoPath: string): Promise<void> {
await invoke("plugin:mediarepo|start_daemon", {repoPath})
}
async loadSelectedRepository() {
let active_repo = await invoke<Repository | undefined>("plugin:mediarepo|get_active_repository");
this.selectedRepository.next(active_repo);
}
}

Loading…
Cancel
Save