Restructure entities

This commit is contained in:
Chris Witterholt 2024-10-29 16:48:00 +00:00
parent 9a8db9619a
commit 92e343a57a
39 changed files with 160 additions and 163 deletions

View File

@ -3,15 +3,19 @@ import { MatBottomSheet } from '@angular/material/bottom-sheet';
import { TranslateService } from '@ngx-translate/core';
import { State, Display, DisplayMode } from './responses';
import { OpenLPService, WebSocketStatus } from './services/openlp.service';
import { State } from './models/state';
import { Display } from './models/display';
import { DisplayMode } from './enums/display-mode.enum';
import { OpenLPService } from './services/openlp.service';
import { WebSocketStatus } from './enums/web-socket-status.enum';
import { WindowRef } from './services/window-ref.service';
import { PageTitleService } from './services/page-title.service';
import { fromEvent } from 'rxjs';
import { debounceTime } from 'rxjs/operators';
import { DisplayModeSelectorComponent } from './components/display-mode-selector/display-mode-selector.component';
import { Shortcuts, ShortcutsService } from './services/shortcuts.service';
import { ShortcutPipe } from './components/pipes/shortcut.pipe';
import { Shortcuts } from './models/shortcuts';
import { ShortcutsService } from './services/shortcuts.service';
import { ShortcutPipe } from './pipes/shortcut.pipe';
import { SettingsService } from './services/settings.service';
import * as supportedBrowsers from '../assets/supportedBrowsers';

View File

@ -40,9 +40,9 @@ import { SearchOptionsComponent } from './components/search/search-options/searc
import { SlidesComponent } from './components/slides/slides.component';
import { ChordViewComponent } from './components/chord-view/chord-view.component';
import { StageViewComponent } from './components/stage-view/stage-view.component';
import { Nl2BrPipe } from './components/pipes/nl2br.pipe';
import { Nl2BrPipe } from './pipes/nl2br.pipe';
import { MainViewComponent } from './components/main-view/main-view.component';
import { ChordProPipe } from './components/pipes/chordpro.pipe';
import { ChordProPipe } from './pipes/chordpro.pipe';
import { LoginComponent } from './components/login/login.component';
import { ThemesComponent } from './components/themes/themes.component';
import { SlideListComponent } from './components/slides/slide-list/slide-list.component';
@ -53,7 +53,7 @@ import { ServiceListComponent } from './components/service/service-list/service-
import { ChordViewItemComponent } from './components/chord-view/chord-view-item/chord-view-item.component';
import { StageViewItemComponent } from './components/stage-view/stage-view-item/stage-view-item.component';
import { DisplayModeSelectorComponent } from './components/display-mode-selector/display-mode-selector.component';
import { SentenceCasePipe } from './components/pipes/sentence-case.pipe';
import { SentenceCasePipe } from './pipes/sentence-case.pipe';
import { SettingsComponent } from './components/settings/settings.component';
import { StageChordPreviewComponent } from './components/settings/stage-chord-preview/stage-chord-preview.component';

View File

@ -1,5 +1,5 @@
import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
import { Slide } from '../../../responses';
import { Slide } from '../../../interfaces/slide.interface';
@Component({
selector: 'app-chord-view-item',

View File

@ -1,5 +1,5 @@
import { Component, ViewEncapsulation } from '@angular/core';
import { Slide } from '../../responses';
import { Slide } from '../../interfaces/slide.interface';
import { StageViewComponent } from '../stage-view/stage-view.component';
@Component({

View File

@ -1,6 +1,7 @@
import { Component, Inject } from '@angular/core';
import { MatBottomSheetRef, MAT_BOTTOM_SHEET_DATA } from '@angular/material/bottom-sheet';
import { Display, DisplayMode } from 'src/app/responses';
import { Display } from '../../models/display';
import { DisplayMode } from '../../enums/display-mode.enum';
@Component({
selector: 'openlp-display-mode-sheet',

View File

@ -3,7 +3,8 @@ import { ActivatedRoute } from '@angular/router';
import { Subscription } from 'rxjs';
import { SettingsService } from '../../services/settings.service';
import { OpenLPService } from '../../services/openlp.service';
import { ServiceItem, Slide } from '../../responses';
import { ServiceItem } from '../../interfaces/service-item.interface';
import { Slide } from '../../interfaces/slide.interface';
@Component({
selector: 'app-lower-third',

View File

@ -3,7 +3,7 @@ import { TranslateService } from '@ngx-translate/core';
import { OpenLPService } from '../../services/openlp.service';
import { PageTitleService } from '../../services/page-title.service';
import { PluginDescription } from '../../responses';
import { PluginDescription } from '../../interfaces/plugin-description.interface';
import { SearchOptionsComponent } from './search-options/search-options.component';
@Component({

View File

@ -3,7 +3,7 @@ import { MatDialog } from '@angular/material/dialog';
import { DeleteConfirmationComponent } from './delete-confirmation/delete-confirmation.component';
import { OpenLPService } from '../../../services/openlp.service';
import { ServiceItem } from '../../../responses';
import { ServiceItem } from '../../../interfaces/service-item.interface';
@Component({
selector: 'openlp-service-item',

View File

@ -2,7 +2,7 @@ import { Component, EventEmitter, OnDestroy, OnInit, Output } from '@angular/cor
import { Subscription } from 'rxjs';
import { OpenLPService } from '../../../services/openlp.service';
import { ServiceItem } from '../../../responses';
import { ServiceItem } from '../../../interfaces/service-item.interface';
@Component({
selector: 'openlp-service-list',

View File

@ -4,7 +4,7 @@ import { TranslateService } from '@ngx-translate/core';
import { OpenLPService } from '../../services/openlp.service';
import { PageTitleService } from '../../services/page-title.service';
import { ServiceItem } from '../../responses';
import { ServiceItem } from '../../interfaces/service-item.interface';
@Component({
selector: 'openlp-service',

View File

@ -1,5 +1,5 @@
import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output } from '@angular/core';
import { Slide } from '../../../responses';
import { Slide } from '../../../interfaces/slide.interface';
@Component({
selector: 'openlp-slide-item',

View File

@ -1,7 +1,7 @@
import { Component, EventEmitter, OnDestroy, OnInit, Output } from '@angular/core';
import { Subscription } from 'rxjs';
import { Slide } from '../../../responses';
import { Slide } from '../../../interfaces/slide.interface';
import { OpenLPService } from '../../../services/openlp.service';
@Component({

View File

@ -1,5 +1,5 @@
import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
import { Slide } from '../../../responses';
import { Slide } from '../../../interfaces/slide.interface';
@Component({
selector: 'app-stage-view-item',

View File

@ -3,7 +3,8 @@ import { ActivatedRoute } from '@angular/router';
import { Subscription } from 'rxjs';
import { SettingsProperties, SettingsService } from '../../services/settings.service';
import { OpenLPService } from '../../services/openlp.service';
import { ServiceItem, Slide } from '../../responses';
import { ServiceItem } from '../../interfaces/service-item.interface';
import { Slide } from '../../interfaces/slide.interface';
interface Tag {
text: string;

View File

@ -3,7 +3,7 @@ import { TranslateService } from '@ngx-translate/core';
import { OpenLPService } from '../../services/openlp.service';
import { PageTitleService } from '../../services/page-title.service';
import { Theme } from '../../responses';
import { Theme } from '../../interfaces/theme.interface';
@Component({
selector: 'openlp-themes',

View File

@ -0,0 +1,6 @@
export enum DisplayMode {
Blank,
Theme,
Desktop,
Presentation
}

View File

@ -0,0 +1,4 @@
export enum WebSocketStatus {
Open,
Closed
}

View File

@ -0,0 +1,3 @@
export interface AuthToken {
token: string;
}

View File

@ -0,0 +1,4 @@
export interface Credentials {
username: string;
password: string;
}

View File

@ -0,0 +1,3 @@
export interface Language {
language: string;
}

View File

@ -0,0 +1,3 @@
export interface MainView {
binary_image: string;
}

View File

@ -0,0 +1,5 @@
export interface MessageType {
plugin: string;
key: string;
value: any;
}

View File

@ -0,0 +1,4 @@
export interface PluginDescription {
key: string;
name: string;
}

View File

@ -0,0 +1,9 @@
export interface ServiceItem {
id: string;
notes: string;
plugin: string;
selected: boolean;
title: string;
is_valid: boolean;
slides: object[];
}

View File

@ -0,0 +1,4 @@
export interface Shortcut {
action: string;
shortcut: string[];
}

View File

@ -0,0 +1,10 @@
export interface Slide {
selected: boolean;
html: string;
tag: string;
text: string;
chords: string;
lines: string[];
first_slide_of_tag: boolean;
img: string;
}

View File

@ -0,0 +1,6 @@
export interface SystemInformation {
websocket_port: number;
login_required: boolean;
api_version?: number;
api_revision?: number;
}

View File

@ -0,0 +1,5 @@
export interface Theme {
name: string;
selected: boolean;
thumbnail: object;
}

View File

@ -0,0 +1,7 @@
import { DisplayMode } from '../enums/display-mode.enum';
export class Display {
bigDisplayButtons: boolean;
darkTheme: boolean;
displayMode: DisplayMode;
}

View File

@ -0,0 +1,7 @@
import { MessageType } from '../interfaces/message-type.interface';
export class Message<T extends MessageType> {
plugin: T['plugin'];
key: T['key'];
value: T['value'];
}

View File

@ -0,0 +1,10 @@
export class Shortcuts {
previousSlide = ['Up', 'PgUp'];
nextSlide = ['Down', 'PgDown'];
previousItem = ['Left'];
nextItem = ['Right'];
showDisplay = ['Space'];
themeDisplay = ['t'];
blankDisplay = ['.'];
desktopDisplay = ['d'];
}

27
src/app/models/state.ts Normal file
View File

@ -0,0 +1,27 @@
import { DisplayMode } from '../enums/display-mode.enum';
export class State {
isAuthorized: boolean;
version: number;
slide: number;
display: boolean;
isSecure: boolean;
blank: boolean;
twelve: boolean;
theme: boolean;
item: string;
live = () => !(this.blank || this.display || this.theme);
get displayMode() {
if (this.blank) {
return DisplayMode.Blank;
} else if (this.display) {
return DisplayMode.Desktop;
} else if (this.theme) {
return DisplayMode.Theme;
} else {
return DisplayMode.Presentation;
}
}
}

View File

@ -1,111 +0,0 @@
export interface PluginDescription {
key: string;
name: string;
}
export class State {
isAuthorized: boolean;
version: number;
slide: number;
display: boolean;
isSecure: boolean;
blank: boolean;
twelve: boolean;
theme: boolean;
item: string;
live = () => !(this.blank || this.display || this.theme);
get displayMode() {
if (this.blank) {
return DisplayMode.Blank;
} else if (this.display) {
return DisplayMode.Desktop;
} else if (this.theme) {
return DisplayMode.Theme;
} else {
return DisplayMode.Presentation;
}
}
}
export class Display {
bigDisplayButtons: boolean;
darkTheme: boolean;
displayMode: DisplayMode;
}
export enum DisplayMode {
Blank,
Theme,
Desktop,
Presentation
}
export interface Slide {
selected: boolean;
html: string;
tag: string;
text: string;
chords: string;
lines: string[];
first_slide_of_tag: boolean;
img: string;
}
export interface ServiceItem {
id: string;
notes: string;
plugin: string;
selected: boolean;
title: string;
is_valid: boolean;
slides: object[];
}
export interface Theme {
name: string;
selected: boolean;
thumbnail: object;
}
export interface Language {
language: string;
}
export interface MainView {
binary_image: string;
}
export interface Shortcut {
action: string;
shortcut: string[];
}
export interface SystemInformation {
websocket_port: number;
login_required: boolean;
api_version?: number;
api_revision?: number;
}
export interface Credentials {
username: string;
password: string;
}
export interface AuthToken {
token: string;
}
export class Message<T extends MessageType> {
plugin: T['plugin'];
key: T['key'];
value: T['value'];
}
export interface MessageType {
plugin: string;
key: string;
value: any;
}

View File

@ -6,24 +6,22 @@ import { TitleCasePipe } from '@angular/common';
import { TranslateService } from '@ngx-translate/core';
import { Observable, of, Subscription } from 'rxjs';
import { catchError, finalize, shareReplay, tap } from 'rxjs/operators';
import { SentenceCasePipe } from '../components/pipes/sentence-case.pipe';
import { SentenceCasePipe } from '../pipes/sentence-case.pipe';
import { LoginComponent } from '../components/login/login.component';
import {
PluginDescription,
State,
Slide,
ServiceItem,
Theme,
Language,
MainView,
Shortcut,
SystemInformation,
Credentials,
AuthToken,
Message,
MessageType
} from '../responses';
import { PluginDescription } from '../interfaces/plugin-description.interface';
import { State } from '../models/state';
import { Slide } from '../interfaces/slide.interface';
import { ServiceItem } from '../interfaces/service-item.interface'
import { Theme } from '../interfaces/theme.interface';
import { Language } from '../interfaces/language.interface';
import { MainView } from '../interfaces/main-view.interface';
import { Shortcut } from '../interfaces/shortcut.interface';
import { SystemInformation } from '../interfaces/system-information.interface';
import { Credentials } from '../interfaces/credentials.interface';
import { AuthToken } from '../interfaces/auth-token.interface';
import { Message } from '../models/message';
import { MessageType } from '../interfaces/message-type.interface';
import { WebSocketStatus } from '../enums/web-socket-status.enum';
import { environment } from '../../environments/environment';
import { createWebSocket } from '../openlp-websocket';
import { deserialize } from '../utils';
@ -37,10 +35,6 @@ const httpOptions = {
const WEBSOCKET_RECONNECT_TIMEOUT = 5 * 1000;
export enum WebSocketStatus {
Open, Closed
}
@Injectable()
export class OpenLPService {
private apiURL: string;

View File

@ -3,17 +3,7 @@ import { EventEmitter, Inject, Injectable } from '@angular/core';
import { EventManager } from '@angular/platform-browser';
import { Observable } from 'rxjs';
import { OpenLPService } from './openlp.service';
export class Shortcuts {
previousSlide = ['Up', 'PgUp'];
nextSlide = ['Down', 'PgDown'];
previousItem = ['Left'];
nextItem = ['Right'];
showDisplay = ['Space'];
themeDisplay = ['t'];
blankDisplay = ['.'];
desktopDisplay = ['d'];
}
import { Shortcuts } from '../models/shortcuts';
interface Options {
element: any;