Add daemon download prompt when it's not installed

TG-43 ready-for-test
TG-38 ready-for-test

Signed-off-by: trivernis <trivernis@protonmail.com>
pull/4/head
trivernis 3 years ago
parent 0ddc50d2a0
commit 481114052e

@ -1492,7 +1492,7 @@ checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f"
[[package]]
name = "mediarepo-api"
version = "0.14.0"
source = "git+https://github.com/Trivernis/mediarepo-api.git?rev=14f2675f5fe1a11ea3302a623d040e77dcc78080#14f2675f5fe1a11ea3302a623d040e77dcc78080"
source = "git+https://github.com/Trivernis/mediarepo-api.git?rev=5991f5d3038386c921a901a05c4a72e4ce00b418#5991f5d3038386c921a901a05c4a72e4ce00b418"
dependencies = [
"async-trait",
"bromine",
@ -1501,6 +1501,7 @@ dependencies = [
"futures",
"mime_guess",
"parking_lot",
"pathsearch",
"serde",
"serde_json",
"serde_piecewise_default",
@ -1766,6 +1767,16 @@ version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "692fcb63b64b1758029e0a96ee63e049ce8c5948587f2f7208df04625e5f6b56"
[[package]]
name = "open"
version = "2.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "176ee4b630d174d2da8241336763bb459281dddc0f4d87f72c3b1efc9a6109b7"
dependencies = [
"pathdiff",
"winapi",
]
[[package]]
name = "openssl"
version = "0.10.36"
@ -1855,6 +1866,22 @@ dependencies = [
"winapi",
]
[[package]]
name = "pathdiff"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd"
[[package]]
name = "pathsearch"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "da983bc5e582ab17179c190b4b66c7d76c5943a69c6d34df2a2b6bf8a2977b05"
dependencies = [
"anyhow",
"libc",
]
[[package]]
name = "percent-encoding"
version = "2.1.0"
@ -2778,6 +2805,7 @@ dependencies = [
"http",
"ignore",
"once_cell",
"open",
"percent-encoding",
"rand 0.8.4",
"raw-window-handle",

@ -15,7 +15,7 @@ tauri-build = { version = "1.0.0-beta.4" }
[dependencies]
serde_json = "1.0"
serde = { version = "1.0", features = [ "derive" ] }
tauri = { version = "1.0.0-beta.8", features = ["dialog-all", "path-all"] }
tauri = { version = "1.0.0-beta.8", features = ["dialog-all", "path-all", "shell-open"] }
thiserror = "1.0.30"
typemap_rev = "0.1.5"
@ -25,7 +25,7 @@ features = [ "env-filter" ]
[dependencies.mediarepo-api]
git = "https://github.com/Trivernis/mediarepo-api.git"
rev = "14f2675f5fe1a11ea3302a623d040e77dcc78080"
rev = "5991f5d3038386c921a901a05c4a72e4ce00b418"
features = [ "tauri-plugin" ]
[features]

@ -53,6 +53,9 @@
},
"path": {
"all": true
},
"shell": {
"open": true
}
},
"windows": [

@ -35,6 +35,7 @@ import {MatInputModule} from "@angular/material/input";
import {TagModule} from "../shared/tag/tag.module";
import { RepositoryFormComponent } from './repositories-tab/repository-form/repository-form.component';
import { EditRepositoryDialogComponent } from './repositories-tab/edit-repository-dialog/edit-repository-dialog.component';
import { DownloadDaemonDialogComponent } from './repositories-tab/download-daemon-dialog/download-daemon-dialog.component';
@NgModule({
@ -49,6 +50,7 @@ import { EditRepositoryDialogComponent } from './repositories-tab/edit-repositor
AddRepositoryDialogComponent,
RepositoryFormComponent,
EditRepositoryDialogComponent,
DownloadDaemonDialogComponent,
],
exports: [
CoreComponent,

@ -0,0 +1,12 @@
<h1 mat-dialog-title>
Download daemon
</h1>
<div mat-dialog-content>
No daemon could be found on the system. Please download and install a daemon executable.
<br>
<button class="download-button" mat-flat-button color="primary" (click)="this.onClickDownloadDaemon()">Download</button>
</div>
<div class="download-dialog-actions" mat-dialog-actions>
<button (click)="closeDialog(false)" color="accent" mat-stroked-button>Cancel</button>
<button (click)="closeDialog(true)" color="primary" mat-flat-button>Ok</button>
</div>

@ -0,0 +1,15 @@
.download-dialog-actions {
display: block;
button {
float: right;
margin-left: 1em;
}
}
button.download-button {
margin: 2em auto auto;
align-self: center;
display: flex;
}

@ -0,0 +1,25 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { DownloadDaemonDialogComponent } from './download-daemon-dialog.component';
describe('DownloadDaemonDialogComponent', () => {
let component: DownloadDaemonDialogComponent;
let fixture: ComponentFixture<DownloadDaemonDialogComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ DownloadDaemonDialogComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(DownloadDaemonDialogComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

@ -0,0 +1,25 @@
import {Component, Inject} from "@angular/core";
import {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material/dialog";
import {shell} from "@tauri-apps/api";
@Component({
selector: "app-download-daemon-dialog",
templateUrl: "./download-daemon-dialog.component.html",
styleUrls: ["./download-daemon-dialog.component.scss"]
})
export class DownloadDaemonDialogComponent {
constructor(public dialogRef: MatDialogRef<DownloadDaemonDialogComponent>,
@Inject(
MAT_DIALOG_DATA) data: any) {
}
public async onClickDownloadDaemon() {
await shell.open("https://github.com/Trivernis/mediarepo-daemon");
}
closeDialog(result: boolean) {
this.dialogRef.close(result)
}
}

@ -1,16 +1,21 @@
import {Component, OnInit} from "@angular/core";
import {AfterViewInit, Component, OnInit} from "@angular/core";
import {Repository} from "../../../models/Repository";
import {RepositoryService} from "../../../services/repository/repository.service";
import {MatDialog} from "@angular/material/dialog";
import {AddRepositoryDialogComponent} from "./add-repository-dialog/add-repository-dialog.component";
import {
ConfirmDialogComponent
} from "../../shared/app-common/confirm-dialog/confirm-dialog.component";
import {
DownloadDaemonDialogComponent
} from "./download-daemon-dialog/download-daemon-dialog.component";
@Component({
selector: "app-repositories-tab",
templateUrl: "./repositories-tab.component.html",
styleUrls: ["./repositories-tab.component.scss"]
})
export class RepositoriesTabComponent implements OnInit {
export class RepositoriesTabComponent implements OnInit, AfterViewInit {
repositories: Repository[] = [];
constructor(
@ -27,6 +32,11 @@ export class RepositoriesTabComponent implements OnInit {
});
}
public async ngAfterViewInit() {
await this.checkAndPromptDaemonExecutable();
}
public openAddRepositoryDialog() {
this.dialog.open(AddRepositoryDialogComponent, {
disableClose: true,
@ -34,4 +44,16 @@ export class RepositoriesTabComponent implements OnInit {
minHeight: "30%",
});
}
private async checkAndPromptDaemonExecutable() {
if (!await this.repoService.checkDameonConfigured()) {
const result = await this.dialog.open(DownloadDaemonDialogComponent, {
disableClose: true,
}).afterClosed().toPromise();
if (result) {
// recursion avoidance
setTimeout(async () => await this.checkAndPromptDaemonExecutable(), 0);
}
}
}
}

@ -19,7 +19,7 @@ export class ConfirmDialogComponent {
constructor(
public dialogRef: MatDialogRef<ConfirmDialogComponent>,
@Inject(
MAT_DIALOG_DATA) data: { title: string, message: string, confirmAction: string, denyAction?: string, confirmColor?: ThemePalette, denyColor?: ThemePalette }
MAT_DIALOG_DATA) data: { title: string, message: string, confirmAction: string, denyAction?: string, confirmColor?: ThemePalette, denyColor?: ThemePalette}
) {
this.title = data.title;
this.message = data.message;

@ -26,6 +26,14 @@ export class RepositoryService {
});
}
/**
* Checks if a daemon is configured in the settings or can be found on the system
* @returns {Promise<boolean>}
*/
public async checkDameonConfigured(): Promise<boolean> {
return await invoke<boolean>("plugin:mediarepo|has_executable");
}
/**
* Loads all repositories stored in the settings
* @returns {Promise<void>}

Loading…
Cancel
Save