diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 0075765..cde9b21 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -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'; diff --git a/src/app/app.module.ts b/src/app/app.module.ts index bc434da..4b5cc64 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -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'; diff --git a/src/app/components/chord-view/chord-view-item/chord-view-item.component.ts b/src/app/components/chord-view/chord-view-item/chord-view-item.component.ts index c8f49ee..4c160a6 100644 --- a/src/app/components/chord-view/chord-view-item/chord-view-item.component.ts +++ b/src/app/components/chord-view/chord-view-item/chord-view-item.component.ts @@ -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', diff --git a/src/app/components/chord-view/chord-view.component.ts b/src/app/components/chord-view/chord-view.component.ts index 3178b76..6e57031 100644 --- a/src/app/components/chord-view/chord-view.component.ts +++ b/src/app/components/chord-view/chord-view.component.ts @@ -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({ diff --git a/src/app/components/display-mode-selector/display-mode-selector.component.ts b/src/app/components/display-mode-selector/display-mode-selector.component.ts index 18f6b79..2815d81 100644 --- a/src/app/components/display-mode-selector/display-mode-selector.component.ts +++ b/src/app/components/display-mode-selector/display-mode-selector.component.ts @@ -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', diff --git a/src/app/components/lower-third/lower-third.component.ts b/src/app/components/lower-third/lower-third.component.ts index d453418..99f85cb 100644 --- a/src/app/components/lower-third/lower-third.component.ts +++ b/src/app/components/lower-third/lower-third.component.ts @@ -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', diff --git a/src/app/components/search/search.component.ts b/src/app/components/search/search.component.ts index b6c6d05..68f6dd6 100644 --- a/src/app/components/search/search.component.ts +++ b/src/app/components/search/search.component.ts @@ -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({ diff --git a/src/app/components/service/service-item/service-item.component.ts b/src/app/components/service/service-item/service-item.component.ts index a200c44..67ac114 100644 --- a/src/app/components/service/service-item/service-item.component.ts +++ b/src/app/components/service/service-item/service-item.component.ts @@ -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', diff --git a/src/app/components/service/service-list/service-list.component.ts b/src/app/components/service/service-list/service-list.component.ts index 98bbd7c..1d1a63a 100644 --- a/src/app/components/service/service-list/service-list.component.ts +++ b/src/app/components/service/service-list/service-list.component.ts @@ -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', diff --git a/src/app/components/service/service.component.ts b/src/app/components/service/service.component.ts index c5a0a62..8902852 100644 --- a/src/app/components/service/service.component.ts +++ b/src/app/components/service/service.component.ts @@ -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', diff --git a/src/app/components/slides/slide-item/slide-item.component.ts b/src/app/components/slides/slide-item/slide-item.component.ts index 84b8727..abeedba 100644 --- a/src/app/components/slides/slide-item/slide-item.component.ts +++ b/src/app/components/slides/slide-item/slide-item.component.ts @@ -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', diff --git a/src/app/components/slides/slide-list/slide-list.component.ts b/src/app/components/slides/slide-list/slide-list.component.ts index a8eb3ea..b0e5325 100644 --- a/src/app/components/slides/slide-list/slide-list.component.ts +++ b/src/app/components/slides/slide-list/slide-list.component.ts @@ -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({ diff --git a/src/app/components/stage-view/stage-view-item/stage-view-item.component.ts b/src/app/components/stage-view/stage-view-item/stage-view-item.component.ts index c27de91..8b637b5 100644 --- a/src/app/components/stage-view/stage-view-item/stage-view-item.component.ts +++ b/src/app/components/stage-view/stage-view-item/stage-view-item.component.ts @@ -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', diff --git a/src/app/components/stage-view/stage-view.component.ts b/src/app/components/stage-view/stage-view.component.ts index 8904b29..53f64fe 100644 --- a/src/app/components/stage-view/stage-view.component.ts +++ b/src/app/components/stage-view/stage-view.component.ts @@ -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; diff --git a/src/app/components/themes/themes.component.ts b/src/app/components/themes/themes.component.ts index 4f5f138..9b7c020 100644 --- a/src/app/components/themes/themes.component.ts +++ b/src/app/components/themes/themes.component.ts @@ -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', diff --git a/src/app/enums/display-mode.enum.ts b/src/app/enums/display-mode.enum.ts new file mode 100644 index 0000000..2493327 --- /dev/null +++ b/src/app/enums/display-mode.enum.ts @@ -0,0 +1,6 @@ +export enum DisplayMode { + Blank, + Theme, + Desktop, + Presentation +} diff --git a/src/app/enums/web-socket-status.enum.ts b/src/app/enums/web-socket-status.enum.ts new file mode 100644 index 0000000..089300d --- /dev/null +++ b/src/app/enums/web-socket-status.enum.ts @@ -0,0 +1,4 @@ +export enum WebSocketStatus { + Open, + Closed +} diff --git a/src/app/interfaces/auth-token.interface.ts b/src/app/interfaces/auth-token.interface.ts new file mode 100644 index 0000000..86cafd1 --- /dev/null +++ b/src/app/interfaces/auth-token.interface.ts @@ -0,0 +1,3 @@ +export interface AuthToken { + token: string; +} diff --git a/src/app/interfaces/credentials.interface.ts b/src/app/interfaces/credentials.interface.ts new file mode 100644 index 0000000..279aabe --- /dev/null +++ b/src/app/interfaces/credentials.interface.ts @@ -0,0 +1,4 @@ +export interface Credentials { + username: string; + password: string; +} diff --git a/src/app/interfaces/language.interface.ts b/src/app/interfaces/language.interface.ts new file mode 100644 index 0000000..06cf679 --- /dev/null +++ b/src/app/interfaces/language.interface.ts @@ -0,0 +1,3 @@ +export interface Language { + language: string; +} diff --git a/src/app/interfaces/main-view.interface.ts b/src/app/interfaces/main-view.interface.ts new file mode 100644 index 0000000..8828f92 --- /dev/null +++ b/src/app/interfaces/main-view.interface.ts @@ -0,0 +1,3 @@ +export interface MainView { + binary_image: string; +} diff --git a/src/app/interfaces/message-type.interface.ts b/src/app/interfaces/message-type.interface.ts new file mode 100644 index 0000000..3eb0a2c --- /dev/null +++ b/src/app/interfaces/message-type.interface.ts @@ -0,0 +1,5 @@ +export interface MessageType { + plugin: string; + key: string; + value: any; +} diff --git a/src/app/interfaces/plugin-description.interface.ts b/src/app/interfaces/plugin-description.interface.ts new file mode 100644 index 0000000..c08935d --- /dev/null +++ b/src/app/interfaces/plugin-description.interface.ts @@ -0,0 +1,4 @@ +export interface PluginDescription { + key: string; + name: string; +} diff --git a/src/app/interfaces/service-item.interface.ts b/src/app/interfaces/service-item.interface.ts new file mode 100644 index 0000000..37babed --- /dev/null +++ b/src/app/interfaces/service-item.interface.ts @@ -0,0 +1,9 @@ +export interface ServiceItem { + id: string; + notes: string; + plugin: string; + selected: boolean; + title: string; + is_valid: boolean; + slides: object[]; +} diff --git a/src/app/interfaces/shortcut.interface.ts b/src/app/interfaces/shortcut.interface.ts new file mode 100644 index 0000000..8d379fd --- /dev/null +++ b/src/app/interfaces/shortcut.interface.ts @@ -0,0 +1,4 @@ +export interface Shortcut { + action: string; + shortcut: string[]; +} diff --git a/src/app/interfaces/slide.interface.ts b/src/app/interfaces/slide.interface.ts new file mode 100644 index 0000000..44990dc --- /dev/null +++ b/src/app/interfaces/slide.interface.ts @@ -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; +} diff --git a/src/app/interfaces/system-information.interface.ts b/src/app/interfaces/system-information.interface.ts new file mode 100644 index 0000000..d129b9f --- /dev/null +++ b/src/app/interfaces/system-information.interface.ts @@ -0,0 +1,6 @@ +export interface SystemInformation { + websocket_port: number; + login_required: boolean; + api_version?: number; + api_revision?: number; +} diff --git a/src/app/interfaces/theme.interface.ts b/src/app/interfaces/theme.interface.ts new file mode 100644 index 0000000..c20b4a6 --- /dev/null +++ b/src/app/interfaces/theme.interface.ts @@ -0,0 +1,5 @@ +export interface Theme { + name: string; + selected: boolean; + thumbnail: object; +} diff --git a/src/app/models/display.ts b/src/app/models/display.ts new file mode 100644 index 0000000..42a7fba --- /dev/null +++ b/src/app/models/display.ts @@ -0,0 +1,7 @@ +import { DisplayMode } from '../enums/display-mode.enum'; + +export class Display { + bigDisplayButtons: boolean; + darkTheme: boolean; + displayMode: DisplayMode; +} diff --git a/src/app/models/message.ts b/src/app/models/message.ts new file mode 100644 index 0000000..ae5650c --- /dev/null +++ b/src/app/models/message.ts @@ -0,0 +1,7 @@ +import { MessageType } from '../interfaces/message-type.interface'; + +export class Message { + plugin: T['plugin']; + key: T['key']; + value: T['value']; +} diff --git a/src/app/models/shortcuts.ts b/src/app/models/shortcuts.ts new file mode 100644 index 0000000..dedb109 --- /dev/null +++ b/src/app/models/shortcuts.ts @@ -0,0 +1,10 @@ +export class Shortcuts { + previousSlide = ['Up', 'PgUp']; + nextSlide = ['Down', 'PgDown']; + previousItem = ['Left']; + nextItem = ['Right']; + showDisplay = ['Space']; + themeDisplay = ['t']; + blankDisplay = ['.']; + desktopDisplay = ['d']; +} diff --git a/src/app/models/state.ts b/src/app/models/state.ts new file mode 100644 index 0000000..b9c9b12 --- /dev/null +++ b/src/app/models/state.ts @@ -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; + } + } +} diff --git a/src/app/components/pipes/chordpro.pipe.ts b/src/app/pipes/chordpro.pipe.ts similarity index 100% rename from src/app/components/pipes/chordpro.pipe.ts rename to src/app/pipes/chordpro.pipe.ts diff --git a/src/app/components/pipes/nl2br.pipe.ts b/src/app/pipes/nl2br.pipe.ts similarity index 100% rename from src/app/components/pipes/nl2br.pipe.ts rename to src/app/pipes/nl2br.pipe.ts diff --git a/src/app/components/pipes/sentence-case.pipe.ts b/src/app/pipes/sentence-case.pipe.ts similarity index 100% rename from src/app/components/pipes/sentence-case.pipe.ts rename to src/app/pipes/sentence-case.pipe.ts diff --git a/src/app/components/pipes/shortcut.pipe.ts b/src/app/pipes/shortcut.pipe.ts similarity index 100% rename from src/app/components/pipes/shortcut.pipe.ts rename to src/app/pipes/shortcut.pipe.ts diff --git a/src/app/responses.ts b/src/app/responses.ts deleted file mode 100644 index 01db0b6..0000000 --- a/src/app/responses.ts +++ /dev/null @@ -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 { - plugin: T['plugin']; - key: T['key']; - value: T['value']; -} - -export interface MessageType { - plugin: string; - key: string; - value: any; -} diff --git a/src/app/services/openlp.service.ts b/src/app/services/openlp.service.ts index 9b3a271..f1841de 100644 --- a/src/app/services/openlp.service.ts +++ b/src/app/services/openlp.service.ts @@ -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; diff --git a/src/app/services/shortcuts.service.ts b/src/app/services/shortcuts.service.ts index 0191b8a..fb137a9 100644 --- a/src/app/services/shortcuts.service.ts +++ b/src/app/services/shortcuts.service.ts @@ -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;