Skip to content

Commit

Permalink
webapp setup: Fix satellite setup
Browse files Browse the repository at this point in the history
If a satellite system uses a switchor unicable, it can be used by two or
more dvb tuners. Cater for this in setup.
  • Loading branch information
bennettpeter committed Nov 9, 2022
1 parent 45f8155 commit 35eccb4
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 57 deletions.
8 changes: 7 additions & 1 deletion mythtv/html/assets/i18n/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,13 @@
"satellite_heading": "Satellite Settings",
"satellite_delete_desc": "This will delete the Satellite device and all downstream devices.",
"satellite_delete_header": "Delete Satellite Devices",
"title": "DVB-T/S/C, ATSC or ISDB-T tuner card"
"title": "DVB-T/S/C, ATSC or ISDB-T tuner card",
"satellite_connect": "Connect Satellite Device",
"satellite_connect_tooltip": "Connect an existing satellite configuration to this tuner",
"satellite_select": "Select Device Tree",
"satellite_disconnect": "Disconnect Satellite from this Tuner",
"satellite_disconnect_warning": "This will disconnect the satellite settings from this tuner. They can still be used with other tuners.",
"satellite_disconnect_error": "Satellite setting is in use on another tuner, cannot be deleted. Use Disconnect Instead."
},
"diseqc": {
"cmdrepeat_label": "Repeat Count",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ <h2>{{ 'settings.ru_sure' | translate }}</h2>
<app-ceton *ngIf="m_CaptureCardsFiltered[ix].CardType == 'CETON'" [card]="m_CaptureCardsFiltered[ix]"
[cardList]="m_CaptureCardList"></app-ceton>
<app-dvb *ngIf="m_CaptureCardsFiltered[ix].CardType == 'DVB'" [card]="m_CaptureCardsFiltered[ix]"
[cardList]="m_CaptureCardList"></app-dvb>
[cardList]="m_CaptureCardList" [diseqcTreeList]="diseqcTreeList" [parent]="this"></app-dvb>
<app-external *ngIf="m_CaptureCardsFiltered[ix].CardType == 'EXTERNAL'"
[card]="m_CaptureCardsFiltered[ix]" [cardList]="m_CaptureCardList"></app-external>
<app-hdhomerun *ngIf="m_CaptureCardsFiltered[ix].CardType == 'HDHOMERUN'"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export class CaptureCardsComponent implements OnInit, CanComponentDeactivate {
m_CaptureCardList!: CaptureCardList;
m_CaptureCardsFiltered!: CardAndInput[];
m_CaptureCardList$!: Observable<CaptureCardList>;
diseqcTreeList!: DiseqcTreeList;
displayModal: boolean = false;
selectedCardType: CardType = { CardType: "", Description: "" };
displayDeleteAllonHost: boolean = false;
Expand Down Expand Up @@ -86,6 +87,21 @@ export class CaptureCardsComponent implements OnInit, CanComponentDeactivate {
}

ngOnInit(): void {
this.loadDiseqc();
}

loadDiseqc() {
// Get DiseqcTree list
this.captureCardService.GetDiseqcTreeList()
.subscribe({
next: data => {
this.diseqcTreeList = data;
},
error: (err: any) => {
console.log("GetDiseqcTreeList", err);
this.errorCount++;
}
})
}

onTabOpen(e: { index: number }) {
Expand Down Expand Up @@ -219,7 +235,7 @@ export class CaptureCardsComponent implements OnInit, CanComponentDeactivate {
}
});
// Delete any diseqc tree attached to the card
this.deleteDiseqc(this.m_CaptureCardsFiltered[index].DiSEqCId);
// this.deleteDiseqc(this.m_CaptureCardsFiltered[index].DiSEqCId);
this.m_CaptureCardsFiltered[index].DiSEqCId = 0;
// Delete this card. Needs to be separate in case this card was added
// during this session, then it would not be in the m_CaptureCardList.
Expand All @@ -229,27 +245,7 @@ export class CaptureCardsComponent implements OnInit, CanComponentDeactivate {
.subscribe(this.delObserver);
}

deleteDiseqc(id: number) {
if (id) {
// Delete this entry
this.expectedCount++;
this.captureCardService.DeleteDiseqcTree(id)
.subscribe({
next: (x: any) => {
if (x.bool)
this.successCount++;
else
this.errorCount++;
},
error: (err: any) => {
console.error(err);
this.errorCount++;
}
})
}
}

deleteAllOnHost() {
deleteAllOnHost() {
// Check if prior is finished by checking counts
if (this.successCount + this.errorCount < this.expectedCount)
return;
Expand All @@ -276,7 +272,7 @@ export class CaptureCardsComponent implements OnInit, CanComponentDeactivate {
this.m_CaptureCardList.CaptureCardList.CaptureCards.forEach(card => {
if (card.HostName != this.m_hostName) {
// Delete any diseqc tree attached to the card
this.deleteDiseqc(card.DiSEqCId);
// this.deleteDiseqc(card.DiSEqCId);
card.DiSEqCId = 0;
console.log("DeleteThis (other host):", card.CardId);
this.expectedCount++;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@
<!-- Satellite Panel -->
<p-fieldset class="mb-4 w-full" legend="{{ 'settings.capture.dvb.satellite_heading' | translate }}"
[toggleable]="true" [collapsed]="true">

<p-button label="{{ 'settings.capture.dvb.newsatellite_button' | translate }}" *ngIf="!diseqcTree"
(onClick)="work.displayNewDiseqc = true" icon="pi pi-plus-circle" styleClass="p-button-plain">
</p-button>
Expand All @@ -135,9 +136,31 @@
</p-button>
</ng-template>
</p-dialog>
&nbsp;
<p-button label="{{ 'settings.capture.dvb.satellite_connect' | translate }}" *ngIf="!diseqcTree"
(onClick)="setupRootTrees() ; work.displayConnectDevice = true" icon="pi pi-plus-circle" styleClass="p-button-plain"
pTooltip="{{ 'settings.capture.dvb.satellite_connect_tooltip' | translate }}">
</p-button>
<p-dialog header="{{ 'settings.capture.dvb.satellite_connect' | translate }}"
[(visible)]="work.displayConnectDevice" [modal]="true" [style]="{width: '50vw'}" [draggable]="false"
[resizable]="false">
<p>{{ 'settings.capture.dvb.satellite_select' | translate }}</p>
<p-listbox [options]="diseqcRootTrees" [(ngModel)]="work.selectedDiseqcTree"
optionLabel="Description" name="diseqcRootTrees" optionValue="DiseqcId"
(onDblClick)="selectDiseqc();"></p-listbox>
<ng-template pTemplate="footer">
<p-button icon="pi pi-times-circle" (onClick)="work.displayConnectDevice=false"
label="{{ 'common.cancel' | translate }}" styleClass="p-button-plain">
</p-button>
<p-button icon="pi pi-check-circle" (onClick)="selectDiseqc();"
label="{{ 'common.ok' | translate }}" styleClass="p-button-plain"
[disabled]="!work.selectedDiseqcTree">
</p-button>
</ng-template>
</p-dialog>

<p-button styleClass="p-button-warning" *ngIf="diseqcTree" label="Delete Satellite Devices"
icon="pi pi-trash" (onClick)="work.displayDeleteDiseqc=true" [disabled]="!diseqcTree">
icon="pi pi-trash" (onClick)="canDeleteDiseqc()">
</p-button>
<p-dialog header="{{ 'settings.capture.dvb.satellite_delete_header' | translate }}"
[(visible)]="work.displayDeleteDiseqc" [modal]="true" [style]="{width: '50vw'}"
Expand All @@ -152,6 +175,25 @@ <h2>{{ 'settings.ru_sure' | translate }}</h2>
label="{{ 'common.yes' | translate }}" styleClass="p-button-plain"></p-button>
</ng-template>
</p-dialog>
&nbsp;
<p-button label="{{ 'settings.capture.dvb.satellite_disconnect' | translate }}" *ngIf="diseqcTree"
(onClick)="work.displayDisconnect = true" icon="pi pi-minus-circle" styleClass="p-button-warning">
</p-button>
<p-dialog header="{{ 'settings.capture.dvb.satellite_disconnect' | translate }}"
[(visible)]="work.displayDisconnect" [modal]="true" [style]="{width: '50vw'}" [draggable]="false"
[resizable]="false">
<h2>{{ 'settings.ru_sure' | translate }}</h2>
<p>{{ 'settings.capture.dvb.satellite_disconnect_warning' | translate }}</p>
<ng-template pTemplate="footer">
<p-button icon="pi pi-times-circle" (click)="work.displayDisconnect=false"
label="{{ 'common.no' | translate }}" styleClass="p-button-plain">
</p-button>
<p-button icon="pi pi-check-circle" (click)="unSelectDiseqc()"
label="{{ 'common.yes' | translate }}" styleClass="p-button-plain"></p-button>
</ng-template>
</p-dialog>
<p-message *ngIf="this.work.diseqcError" severity="error"
text="{{ 'settings.capture.dvb.satellite_disconnect_error' | translate }}"></p-message>

<app-lnb *ngIf="this.diseqcTree && this.diseqcTree.Type == 'lnb'" [diseqcTree]="diseqcTree"
[diseqcTreeList]="diseqcTreeList" (baseEvent)="setDiseqcObject($event)" [dvbComponent]="this">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
import { AfterViewInit, Component, ElementRef, Input, OnInit, ViewChild } from '@angular/core';
import { NgForm } from '@angular/forms';
import { TranslateService } from '@ngx-translate/core';
import { Observer, PartialObserver } from 'rxjs';
import { PartialObserver } from 'rxjs';
import { CaptureCardService } from 'src/app/services/capture-card.service';
import { CaptureCardList, CaptureDevice, CaptureDeviceList, CardAndInput, DiseqcParm, DiseqcTree, DiseqcTreeList } from 'src/app/services/interfaces/capture-card.interface';
import { SetupService } from 'src/app/services/setup.service';
import { CaptureCardsComponent } from '../capture-cards.component';
import { DiseqcSettingBase } from './diseqc-setting-base';

// interface diseqcParm {
// description: string,
// type: string,
// inactive: boolean
// }

@Component({
selector: 'app-dvb',
templateUrl: './dvb.component.html',
Expand All @@ -22,6 +17,8 @@ export class DvbComponent implements OnInit, AfterViewInit {

@Input() card!: CardAndInput;
@Input() cardList!: CaptureCardList;
@Input() diseqcTreeList!: DiseqcTreeList;
@Input() parent!: CaptureCardsComponent;

@ViewChild("dvbform") currentForm!: NgForm;
@ViewChild("top") topElement!: ElementRef;
Expand All @@ -37,6 +34,10 @@ export class DvbComponent implements OnInit, AfterViewInit {
warningMessage: '',
displayNewDiseqc: false,
displayDeleteDiseqc: false,
displayConnectDevice: false,
displayDisconnect: false,
selectedDiseqcTree: 0,
diseqcError: false,
};

captureDeviceList: CaptureDeviceList = {
Expand All @@ -45,21 +46,10 @@ export class DvbComponent implements OnInit, AfterViewInit {
}
};

diseqcTreeList: DiseqcTreeList = {
DiseqcTreeList: {
DiseqcTrees: [],
}
}
diseqcRootTrees: DiseqcTree[] = [];

diseqcTree: DiseqcTree | undefined = undefined;

// diseqcTypes: diseqcParm[] = [
// { description: "Switch", type: "switch", inactive: false },
// { description: "Rotor", type: "rotor", inactive: false },
// { description: "Unicable", type: "scr", inactive: false },
// { description: "LNB", type: "lnb", inactive: false }
// ];

messages = {
devNotExist: 'settings.capture.dvb.devNotExist',
unknownName: 'settings.capture.dvb.unknownName',
Expand Down Expand Up @@ -105,18 +95,7 @@ export class DvbComponent implements OnInit, AfterViewInit {
this.work.errorCount++;
}
});
// Get DiseqcTree list
this.captureCardService.GetDiseqcTreeList()
.subscribe({
next: data => {
this.diseqcTreeList = data;
this.setupDiseqc();
},
error: (err: any) => {
console.log("GetDiseqcTreeList", err);
this.work.errorCount++;
}
})
this.setupDiseqc();
}

ngAfterViewInit(): void {
Expand All @@ -127,16 +106,47 @@ export class DvbComponent implements OnInit, AfterViewInit {
setupDiseqc(): void {
this.diseqcTree = this.diseqcTreeList.DiseqcTreeList.DiseqcTrees.find
(x => x.DiseqcId == this.card.DiSEqCId);
this.work.diseqcError = false;
}

newDiseqc(): void {
this.work.displayNewDiseqc = false;
this.work.diseqcError = false;
this.diseqcTree = <DiseqcTree>{
Type: this.selectedDiseqcType.type,
Description: this.selectedDiseqcType.description,
};
}

setupRootTrees() {
this.diseqcRootTrees = this.diseqcTreeList.DiseqcTreeList.DiseqcTrees.filter(x => !x.ParentId)
}

selectDiseqc() {
this.work.displayConnectDevice = false;
this.work.diseqcError = false;
this.card.DiSEqCId = this.work.selectedDiseqcTree;
this.currentForm.form.markAsDirty();
this.setupDiseqc();
}

unSelectDiseqc() {
this.work.displayDisconnect = false;
this.work.diseqcError = false;
this.card.DiSEqCId = 0;
this.currentForm.form.markAsDirty();
this.diseqcTree = undefined;
}

canDeleteDiseqc() {
this.work.diseqcError = false;
const cards = this.cardList.CaptureCardList.CaptureCards.filter(x => x.DiSEqCId == this.card.DiSEqCId);
if (cards.length > 1)
this.work.diseqcError = true;
else
this.work.displayDeleteDiseqc = true
}

deleteDiseqc(): void {
this.work.displayDeleteDiseqc = false;
this.work.successCount = 0;
Expand All @@ -151,6 +161,8 @@ export class DvbComponent implements OnInit, AfterViewInit {
this.work.errorCount++;
console.log("DeleteDiseqcTree", x)
}
// reload lists
this.parent.loadDiseqc();
},
error: (err: any) => {
console.log("DeleteDiseqcTree", err);
Expand Down Expand Up @@ -272,6 +284,7 @@ export class DvbComponent implements OnInit, AfterViewInit {
saveForm() {
this.work.successCount = 0;
this.work.errorCount = 0;
this.work.diseqcError = false;
// Save diseqcTree
if (this.diseqcTree && this.diseqcComponent) {
this.diseqcComponent.saveForm(0, {
Expand Down

0 comments on commit 35eccb4

Please sign in to comment.