1
1
mirror of https://github.com/bitgapp/eqMac.git synced 2024-11-22 04:33:53 +03:00

added eslint to the monorepo and fixed UI linting errors

This commit is contained in:
Nodeful 2021-03-24 16:42:45 +02:00
parent decf2673b1
commit c7419165b2
90 changed files with 2317 additions and 341 deletions

2
.eslintignore Normal file
View File

@ -0,0 +1,2 @@
node_modules
dist

40
.eslintrc.js Normal file
View File

@ -0,0 +1,40 @@
module.exports = {
extends: 'standard-with-typescript',
parserOptions: {
tsconfigRootDir: __dirname,
project: [
'./ui/tsconfig.eslint.json'
]
},
overrides: [{
files: ['*.ts'],
rules: {
radix: 'off',
'accessor-pairs': 'off',
'return-undefined': 'off',
'no-throw-literal': 'off',
'import-first': 'off',
'@typescript-eslint/array-type': 'off',
'@typescript-eslint/consistent-type-assertions': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-empty-interface': 'off',
'@typescript-eslint/no-extraneous-class': 'off',
'@typescript-eslint/no-floating-promises': 'off',
'@typescript-eslint/no-unused-vars': [2, { args: 'none' }],
'@typescript-eslint/require-await': 'off',
'@typescript-eslint/restrict-template-expressions': 'off',
'@typescript-eslint/promise-function-async': 'off',
'@typescript-eslint/no-misused-promises': 'off',
'array-bracket-spacing': ['error', 'always'],
'@typescript-eslint/quotes': ['error', 'single', { avoidEscape: true }],
'@typescript-eslint/strict-boolean-expressions': 'off',
'@typescript-eslint/return-await': 'off',
'node/no-callback-literal': 'off',
'no-async-promise-executor': 'off',
'@typescript-eslint/no-dynamic-delete': 'off'
}
}],
env: {
node: true
}
}

1948
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

30
package.json Normal file
View File

@ -0,0 +1,30 @@
{
"name": "eqmac",
"version": "1.0.0",
"description": "eqMac Monorepo",
"main": ".eslintrc.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/bitgapp/eqMac.git"
},
"author": "Roman Kisil <Nodeful>",
"license": "ISC",
"bugs": {
"url": "https://github.com/bitgapp/eqMac/issues"
},
"homepage": "https://github.com/bitgapp/eqMac#readme",
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^4.19.0",
"eslint": "^7.22.0",
"eslint-config-standard-with-typescript": "^20.0.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^4.3.1"
},
"dependencies": {
"typescript": "^4.2.3"
}
}

2
ui/.eslintignore Normal file
View File

@ -0,0 +1,2 @@
node_modules
dist

3
ui/.eslintrc.js Normal file
View File

@ -0,0 +1,3 @@
module.exports = {
extends: '../.eslintrc.js'
}

2
ui/package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "eqmac", "name": "eqmac",
"version": "1.2.2", "version": "1.3.0",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

View File

@ -9,7 +9,7 @@ const cf = Cloudflare({
}) })
;(async () => { ;(async () => {
const [ major, minor ] = version.split('.') const [ major ] = version.split('.')
const domain = `https://ui-v${major}.eqmac.app` const domain = `https://ui-v${major}.eqmac.app`
await cf.zones.purgeCache(process.env.CLOUDFLARE_ZONE_ID, { await cf.zones.purgeCache(process.env.CLOUDFLARE_ZONE_ID, {
files: [ domain ] files: [ domain ]

View File

@ -16,8 +16,8 @@ import { SettingsService, IconMode } from './sections/settings/settings.service'
@Component({ @Component({
selector: 'app-root', selector: 'app-root',
templateUrl: './app.component.html', templateUrl: './app.component.html',
styleUrls: ['./app.component.scss'], styleUrls: [ './app.component.scss' ],
animations: [FadeInOutAnimation, FromTopAnimation] animations: [ FadeInOutAnimation, FromTopAnimation ]
}) })
export class AppComponent implements OnInit, AfterContentInit { export class AppComponent implements OnInit, AfterContentInit {
@ -75,7 +75,7 @@ export class AppComponent implements OnInit, AfterContentInit {
async syncHeight (dimensions?: UIDimensions) { async syncHeight (dimensions?: UIDimensions) {
await this.utils.delay(10) await this.utils.delay(10)
let height = this.container.nativeElement.offsetHeight let height: number = this.container.nativeElement.offsetHeight
if (dimensions) { if (dimensions) {
if (dimensions.heightDiff) { if (dimensions.heightDiff) {
height += dimensions.heightDiff height += dimensions.heightDiff
@ -88,7 +88,7 @@ export class AppComponent implements OnInit, AfterContentInit {
async syncWidth (dimensions?: UIDimensions) { async syncWidth (dimensions?: UIDimensions) {
await this.utils.delay(10) await this.utils.delay(10)
let width = this.container.nativeElement.offsetWidth let width: number = this.container.nativeElement.offsetWidth
if (dimensions) { if (dimensions) {
if (dimensions.widthDiff) { if (dimensions.widthDiff) {
width += dimensions.widthDiff width += dimensions.widthDiff
@ -100,8 +100,8 @@ export class AppComponent implements OnInit, AfterContentInit {
} }
startDimensionsSync () { startDimensionsSync () {
this.ui.dimensionsChanged.subscribe(dimensions => this.syncDimensions(dimensions)) this.ui.dimensionsChanged.subscribe(async dimensions => await this.syncDimensions(dimensions))
setInterval(() => this.syncDimensions(), 1000) setInterval(async () => await this.syncDimensions(), 1000)
} }
toggleDropdownSection (section: string) { toggleDropdownSection (section: string) {
@ -123,7 +123,7 @@ export class AppComponent implements OnInit, AfterContentInit {
closeDropdownSection (section: string, event?: any) { closeDropdownSection (section: string, event?: any) {
// if (event && event.target && ['backdrop', 'mat-dialog'].some(e => event.target.className.includes(e))) return // if (event && event.target && ['backdrop', 'mat-dialog'].some(e => event.target.className.includes(e))) return
if (this.matDialog.openDialogs.length) return if (this.matDialog.openDialogs.length > 0) return
if (section in this.showDropdownSections) { if (section in this.showDropdownSections) {
this.showDropdownSections[section] = false this.showDropdownSections[section] = false
} }

View File

@ -9,10 +9,6 @@ import {
AppComponent AppComponent
} from './app.component' } from './app.component'
import {
environment
} from '../environments/environment'
import { import {
FlexLayoutModule FlexLayoutModule
} from '@angular/flex-layout' } from '@angular/flex-layout'
@ -70,9 +66,6 @@ import {
import { import {
VolumeBoosterBalanceComponent VolumeBoosterBalanceComponent
} from './sections/volume/booster-balance/volume-booster-balance.component' } from './sections/volume/booster-balance/volume-booster-balance.component'
import {
VolumeMixerComponent
} from './sections/volume/volume-mixer/volume-mixer.component'
import { BrowserAnimationsModule } from '@angular/platform-browser/animations' import { BrowserAnimationsModule } from '@angular/platform-browser/animations'
import { SettingsComponent } from './sections/settings/settings.component' import { SettingsComponent } from './sections/settings/settings.component'
@ -115,7 +108,6 @@ import { OptionsDialogComponent } from './components/options-dialog/options-dial
BasicEqualizerComponent, BasicEqualizerComponent,
AdvancedEqualizerComponent, AdvancedEqualizerComponent,
VolumeBoosterBalanceComponent, VolumeBoosterBalanceComponent,
VolumeMixerComponent,
SettingsComponent, SettingsComponent,
OptionsComponent, OptionsComponent,
HelpComponent, HelpComponent,
@ -125,6 +117,6 @@ import { OptionsDialogComponent } from './components/options-dialog/options-dial
OptionsDialogComponent OptionsDialogComponent
], ],
providers: [], providers: [],
bootstrap: [AppComponent] bootstrap: [ AppComponent ]
}) })
export class AppModule {} export class AppModule {}

View File

@ -10,7 +10,7 @@ export interface ConfirmDialogData {
@Component({ @Component({
selector: 'eqm-confirm-dialog', selector: 'eqm-confirm-dialog',
templateUrl: './confirm-dialog.component.html', templateUrl: './confirm-dialog.component.html',
styleUrls: ['./confirm-dialog.component.scss'] styleUrls: [ './confirm-dialog.component.scss' ]
}) })
export class ConfirmDialogComponent implements OnInit { export class ConfirmDialogComponent implements OnInit {
@Input() text: string @Input() text: string
@ -26,7 +26,7 @@ export class ConfirmDialogComponent implements OnInit {
ngOnInit () { ngOnInit () {
if (this.data) { if (this.data) {
for (const [key, value] of Object.entries(this.data)) { for (const [ key, value ] of Object.entries(this.data)) {
this[key] = value || this[key] this[key] = value || this[key]
} }
} }
@ -43,5 +43,4 @@ export class ConfirmDialogComponent implements OnInit {
this.dialogRef.close(true) this.dialogRef.close(true)
} }
} }
} }

View File

@ -9,7 +9,7 @@ export interface OptionsDialogData {
@Component({ @Component({
selector: 'eqm-options-dialog', selector: 'eqm-options-dialog',
templateUrl: './options-dialog.component.html', templateUrl: './options-dialog.component.html',
styleUrls: ['./options-dialog.component.scss'] styleUrls: [ './options-dialog.component.scss' ]
}) })
export class OptionsDialogComponent implements OnInit { export class OptionsDialogComponent implements OnInit {
@Input() options: Options @Input() options: Options
@ -22,10 +22,9 @@ export class OptionsDialogComponent implements OnInit {
ngOnInit () { ngOnInit () {
if (this.data) { if (this.data) {
for (const [key, value] of Object.entries(this.data)) { for (const [ key, value ] of Object.entries(this.data)) {
this[key] = value || this[key] this[key] = value || this[key]
} }
} }
} }
} }

View File

@ -74,8 +74,8 @@ export interface BreadcrumbsOption extends BaseOptions {
} }
export interface InputOption extends BaseOptions { export interface InputOption extends BaseOptions {
type: 'input', type: 'input'
value?: string, value?: string
placeholder?: string placeholder?: string
changed?: (value: string) => any changed?: (value: string) => any
enter?: () => any enter?: () => any
@ -117,7 +117,7 @@ export interface ValueScreenOption extends BaseOptions {
clicked?: () => any clicked?: () => any
} }
export type Option = ButtonOption | CheckboxOption | SelectOption export type Option = ButtonOption | CheckboxOption | SelectOption
| DividerOption | LabelOption | HTMLOption | DropdownOption | DividerOption | LabelOption | HTMLOption | DropdownOption
| BreadcrumbsOption | InputOption | FlatSliderOption | SkeuomorphSliderOption | BreadcrumbsOption | InputOption | FlatSliderOption | SkeuomorphSliderOption
| ValueScreenOption | ValueScreenOption
@ -126,7 +126,7 @@ export type Options = Option[][]
@Component({ @Component({
selector: 'eqm-options', selector: 'eqm-options',
templateUrl: './options.component.html', templateUrl: './options.component.html',
styleUrls: ['./options.component.scss'] styleUrls: [ './options.component.scss' ]
}) })
export class OptionsComponent { export class OptionsComponent {
@Input() options: Options = [] @Input() options: Options = []
@ -135,10 +135,10 @@ export class OptionsComponent {
constructor ( constructor (
public app: ApplicationService, public app: ApplicationService,
public ref: ChangeDetectorRef public ref: ChangeDetectorRef
) {} ) {}
getOptionStyle (option: Option, row: Option[]) { getOptionStyle (option: Option, row: Option[]) {
let style = option.style || {} const style = option.style || {}
if (!style.width) { if (!style.width) {
style.width = `${100 / row.length}%` style.width = `${100 / row.length}%`
} }
@ -146,7 +146,7 @@ export class OptionsComponent {
style.width = '100%' style.width = '100%'
} }
if (!!option.isEnabled && option.isEnabled() === false) { if (!!option.isEnabled && !option.isEnabled()) {
style.filter = 'grayscale(1)' style.filter = 'grayscale(1)'
} }
@ -154,7 +154,7 @@ export class OptionsComponent {
} }
toggleCheckbox (checkbox: CheckboxOption) { toggleCheckbox (checkbox: CheckboxOption) {
if (!!checkbox.isEnabled && checkbox.isEnabled() === false) { if (!!checkbox.isEnabled && !checkbox.isEnabled()) {
return return
} }
checkbox.value = !checkbox.value checkbox.value = !checkbox.value
@ -163,7 +163,7 @@ export class OptionsComponent {
} }
selectedOption (option: SelectOption, selectOption: SelectOptionOption) { selectedOption (option: SelectOption, selectOption: SelectOptionOption) {
if (!!option.isEnabled && option.isEnabled() === false) { if (!!option.isEnabled && !option.isEnabled()) {
return return
} }
if (option.selectedId !== selectOption.id) { if (option.selectedId !== selectOption.id) {

View File

@ -10,7 +10,7 @@ export interface PromptDialogData extends ConfirmDialogData {
@Component({ @Component({
selector: 'eqm-prompt-dialog', selector: 'eqm-prompt-dialog',
templateUrl: './prompt-dialog.component.html', templateUrl: './prompt-dialog.component.html',
styleUrls: ['./prompt-dialog.component.scss'] styleUrls: [ './prompt-dialog.component.scss' ]
}) })
export class PromptDialogComponent extends ConfirmDialogComponent { export class PromptDialogComponent extends ConfirmDialogComponent {
@Input() prompt @Input() prompt

View File

@ -1,13 +1,13 @@
import { trigger, style, animate, transition, state } from '@angular/animations' import { trigger, style, animate, transition } from '@angular/animations'
const DURATION = 100 const DURATION = 100
export const FadeInOutAnimation = trigger('FadeInOut', [ export const FadeInOutAnimation = trigger('FadeInOut', [
transition(':enter', [ // :enter is alias to 'void => *' transition(':enter', [ // :enter is alias to 'void => *'
style({ opacity: 0 }), style({ opacity: 0 }),
animate(DURATION, style({ opacity: 1 })) animate(DURATION, style({ opacity: 1 }))
]), ]),
transition(':leave', [ // :leave is alias to '* => void' transition(':leave', [ // :leave is alias to '* => void'
animate(DURATION, style({ opacity: 0 })) animate(DURATION, style({ opacity: 0 }))
]) ])
]) ])

View File

@ -11,11 +11,11 @@ const END_FRAME_STATE = {
} }
export const FromTopAnimation = trigger('FromTop', [ export const FromTopAnimation = trigger('FromTop', [
transition(':enter', [ // :enter is alias to 'void => *' transition(':enter', [ // :enter is alias to 'void => *'
style(INITIAL_STATE), style(INITIAL_STATE),
animate(DURATION, style(END_FRAME_STATE)) animate(DURATION, style(END_FRAME_STATE))
]), ]),
transition(':leave', [ // :leave is alias to '* => void' transition(':leave', [ // :leave is alias to '* => void'
animate(DURATION, style(INITIAL_STATE)) animate(DURATION, style(INITIAL_STATE))
]) ])
]) ])

View File

@ -8,7 +8,7 @@ import {
@Component({ @Component({
selector: 'eqm-analyzer', selector: 'eqm-analyzer',
templateUrl: './analyzer.component.html', templateUrl: './analyzer.component.html',
styleUrls: ['./analyzer.component.scss'] styleUrls: [ './analyzer.component.scss' ]
}) })
export class AnalyzerComponent implements OnInit { export class AnalyzerComponent implements OnInit {
@ -32,8 +32,8 @@ export class AnalyzerComponent implements OnInit {
// Get canvas context // Get canvas context
const gridCanvas: HTMLCanvasElement = this.gridCanvas.nativeElement const gridCanvas: HTMLCanvasElement = this.gridCanvas.nativeElement
gridCanvas.style.height = this.container.nativeElement.offsetHeight + 'px' gridCanvas.style.height = `${parseInt(this.container.nativeElement.offsetHeight)}px`
gridCanvas.style.width = this.container.nativeElement.offsetWidth + 'px' gridCanvas.style.width = `${parseInt(this.container.nativeElement.offsetWidth)}px`
this.width = gridCanvas.offsetWidth this.width = gridCanvas.offsetWidth
this.height = gridCanvas.offsetHeight this.height = gridCanvas.offsetHeight

View File

@ -1,17 +1,15 @@
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'
@Component({ @Component({
selector: 'eqm-breadcrumbs', selector: 'eqm-breadcrumbs',
templateUrl: './breadcrumbs.component.html', templateUrl: './breadcrumbs.component.html',
styleUrls: ['./breadcrumbs.component.scss'] styleUrls: [ './breadcrumbs.component.scss' ]
}) })
export class BreadcrumbsComponent implements OnInit { export class BreadcrumbsComponent implements OnInit {
@Input() crumbs: string[] @Input() crumbs: string[]
@Input() underline = true @Input() underline = true
@Output() crumbClicked = new EventEmitter<{ crumb: string, index: number }>() @Output() crumbClicked = new EventEmitter<{ crumb: string, index: number }>()
constructor() { }
ngOnInit(): void { ngOnInit (): void {
} }
} }

View File

@ -3,7 +3,7 @@ import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'
@Component({ @Component({
selector: 'eqm-button', selector: 'eqm-button',
templateUrl: './button.component.html', templateUrl: './button.component.html',
styleUrls: ['./button.component.scss'] styleUrls: [ './button.component.scss' ]
}) })
export class ButtonComponent implements OnInit { export class ButtonComponent implements OnInit {
@Input() type: 'large' | 'narrow' | 'square' | 'circle' | 'transparent' = 'large' @Input() type: 'large' | 'narrow' | 'square' | 'circle' | 'transparent' = 'large'
@ -15,7 +15,6 @@ export class ButtonComponent implements OnInit {
@Input() hoverable = true @Input() hoverable = true
@Input() disabled = false @Input() disabled = false
@Output() pressed = new EventEmitter() @Output() pressed = new EventEmitter()
constructor () { }
ngOnInit () { ngOnInit () {
} }
@ -55,5 +54,4 @@ export class ButtonComponent implements OnInit {
this.pressed.emit() this.pressed.emit()
} }
} }
} }

View File

@ -1,5 +1,5 @@
import { Component, ContentChildren, QueryList, Directive, ViewChild, ElementRef, Input, TemplateRef, ViewContainerRef, AfterViewInit, Output, EventEmitter, HostBinding, ViewChildren, OnDestroy } from '@angular/core' import { Component, ContentChildren, QueryList, Directive, ViewChild, ElementRef, Input, TemplateRef, AfterViewInit, Output, EventEmitter, ViewChildren, OnDestroy } from '@angular/core'
import { AnimationPlayer, AnimationFactory, animate, style, AnimationBuilder } from '@angular/animations' import { AnimationFactory, animate, style, AnimationBuilder } from '@angular/animations'
@Directive({ @Directive({
selector: '[eqmCarouselItem]' selector: '[eqmCarouselItem]'
@ -23,7 +23,7 @@ export class CarouselItemElement {
@Component({ @Component({
selector: 'eqm-carousel', selector: 'eqm-carousel',
templateUrl: './carousel.component.html', templateUrl: './carousel.component.html',
styleUrls: ['./carousel.component.scss'] styleUrls: [ './carousel.component.scss' ]
}) })
export class CarouselComponent implements AfterViewInit, OnDestroy { export class CarouselComponent implements AfterViewInit, OnDestroy {
@ContentChildren(CarouselItemDirective) items: QueryList<CarouselItemDirective> @ContentChildren(CarouselItemDirective) items: QueryList<CarouselItemDirective>
@ -41,6 +41,7 @@ export class CarouselComponent implements AfterViewInit, OnDestroy {
this.heightDiff.emit(diff) this.heightDiff.emit(diff)
} }
} }
@Output() heightDiff = new EventEmitter<number>() @Output() heightDiff = new EventEmitter<number>()
@Output() heightChange = new EventEmitter<number>() @Output() heightChange = new EventEmitter<number>()
public recalculateHeightTimer public recalculateHeightTimer
@ -54,6 +55,7 @@ export class CarouselComponent implements AfterViewInit, OnDestroy {
this.recalculateHeight() this.recalculateHeight()
this.itemCameIntoView.emit(this.selectedItemId) this.itemCameIntoView.emit(this.selectedItemId)
} }
get selectedItemId () { return this._selectedItemId } get selectedItemId () { return this._selectedItemId }
@Output() selectedItemIdChange = new EventEmitter<string>() @Output() selectedItemIdChange = new EventEmitter<string>()
@Output() animationCompleted = new EventEmitter<string>() @Output() animationCompleted = new EventEmitter<string>()
@ -75,13 +77,13 @@ export class CarouselComponent implements AfterViewInit, OnDestroy {
ngAfterViewInit () { ngAfterViewInit () {
for (const item of this.items.toArray()) { for (const item of this.items.toArray()) {
if (!item.eqmCarouselItem || typeof item.eqmCarouselItem !== 'string') { if (!item.eqmCarouselItem || typeof item.eqmCarouselItem !== 'string') {
throw new Error(`eqmCarouselItem directive was not provided an item ID`) throw new Error('eqmCarouselItem directive was not provided an item ID')
} }
} }
this.animate() this.animate()
this.recalculateHeight() this.recalculateHeight()
this.recalculateHeightTimer = setInterval(this.recalculateHeight.bind(this), 1000) this.recalculateHeightTimer = setInterval(() => this.recalculateHeight(), 1000)
} }
ngOnDestroy () { ngOnDestroy () {
@ -127,8 +129,7 @@ export class CarouselComponent implements AfterViewInit, OnDestroy {
} }
public recalculateHeight () { public recalculateHeight () {
const itemEl = this.itemElems && this.itemElems.toArray()[this.currentIndex].nativeElement.nextElementSibling const itemEl = this.itemElems?.toArray()[this.currentIndex].nativeElement.nextElementSibling
itemEl && itemEl.offsetHeight && (this.height = itemEl.offsetHeight) itemEl?.offsetHeight && (this.height = itemEl.offsetHeight)
} }
} }

View File

@ -1,9 +1,9 @@
import { Component, OnInit, Input, Output, EventEmitter, HostBinding } from '@angular/core' import { Component, Input, Output, EventEmitter, HostBinding } from '@angular/core'
@Component({ @Component({
selector: 'eqm-checkbox', selector: 'eqm-checkbox',
templateUrl: './checkbox.component.html', templateUrl: './checkbox.component.html',
styleUrls: ['./checkbox.component.scss'] styleUrls: [ './checkbox.component.scss' ]
}) })
export class CheckboxComponent { export class CheckboxComponent {
@Input() interactive: boolean = true @Input() interactive: boolean = true

View File

@ -3,13 +3,11 @@ import { Component, OnInit, HostBinding, Input } from '@angular/core'
@Component({ @Component({
selector: 'eqm-container', selector: 'eqm-container',
templateUrl: './container.component.html', templateUrl: './container.component.html',
styleUrls: ['./container.component.scss'] styleUrls: [ './container.component.scss' ]
}) })
export class ContainerComponent implements OnInit { export class ContainerComponent implements OnInit {
@HostBinding('class.disabled') @Input() disabled = false @HostBinding('class.disabled') @Input() disabled = false
constructor () { }
ngOnInit () { ngOnInit () {
} }
} }

View File

@ -1,9 +1,9 @@
import { Component, OnInit, Input, ElementRef, HostBinding } from '@angular/core' import { Component, Input, ElementRef, HostBinding } from '@angular/core'
@Component({ @Component({
selector: 'eqm-divider', selector: 'eqm-divider',
templateUrl: './divider.component.html', templateUrl: './divider.component.html',
styleUrls: ['./divider.component.scss'] styleUrls: [ './divider.component.scss' ]
}) })
export class DividerComponent { export class DividerComponent {
@Input() orientation: 'vertical' | 'horizontal' = 'horizontal' @Input() orientation: 'vertical' | 'horizontal' = 'horizontal'
@ -41,5 +41,4 @@ export class DividerComponent {
get bottomtBorder () { get bottomtBorder () {
return this.orientation === 'horizontal' ? '1px solid rgb(96, 97, 101)' : undefined return this.orientation === 'horizontal' ? '1px solid rgb(96, 97, 101)' : undefined
} }
} }

View File

@ -1,34 +1,35 @@
import { Component, OnInit, Input, ViewChild, ElementRef, EventEmitter, Output, NgZone, HostBinding, HostListener } from '@angular/core' import { Component, OnInit, Input, ViewChild, ElementRef, EventEmitter, Output, NgZone, HostBinding, HostListener } from '@angular/core'
import { SelectBoxComponent } from '../select-box/select-box.component' import { SelectBoxComponent } from '../select-box/select-box.component'
import { UtilitiesService } from '../../services/utilities.service' import { UtilitiesService } from '../../services/utilities.service'
import { InputFieldComponent } from '../input-field/input-field.component'
import { FadeInOutAnimation } from 'src/app/modules/animations' import { FadeInOutAnimation } from 'src/app/modules/animations'
@Component({ @Component({
selector: 'eqm-dropdown', selector: 'eqm-dropdown',
templateUrl: './dropdown.component.html', templateUrl: './dropdown.component.html',
styleUrls: ['./dropdown.component.scss'], styleUrls: [ './dropdown.component.scss' ],
animations: [ FadeInOutAnimation ] animations: [ FadeInOutAnimation ]
}) })
export class DropdownComponent implements OnInit { export class DropdownComponent implements OnInit {
constructor ( constructor (
public utils: UtilitiesService, public utils: UtilitiesService,
public zone: NgZone, public zone: NgZone,
public ref: ElementRef public ref: ElementRef
) { ) {
} }
public _items: any[] = [] public _items: any[] = []
@Input() editable = false @Input() editable = false
@Input() @Input()
get items () { get items () {
return this._items return this._items
} }
set items (newItems) { set items (newItems) {
if (!newItems || !Array.isArray(newItems)) return if (!newItems || !Array.isArray(newItems)) return
this.searchText = null this.searchText = null
this._items = newItems this._items = newItems
} }
@Output() refChanged = new EventEmitter<DropdownComponent>() @Output() refChanged = new EventEmitter<DropdownComponent>()
@HostBinding('class.disabled') @Input() disabled = false @HostBinding('class.disabled') @Input() disabled = false
@Input() selectedItem = null @Input() selectedItem = null
@ -54,7 +55,8 @@ export class DropdownComponent implements OnInit {
if (!this.items) this.items = [] if (!this.items) this.items = []
this.setDimensions() this.setDimensions()
this.calculateYCoordinate() this.calculateYCoordinate()
for (let _ in [...Array(3)]) { // eslint-disable-next-line @typescript-eslint/no-unused-vars
for (const _ of [ ...Array(3) ]) {
await this.utils.delay(100) await this.utils.delay(100)
this.calculateYCoordinate() this.calculateYCoordinate()
} }
@ -78,19 +80,19 @@ export class DropdownComponent implements OnInit {
this.direction = preferredDirection this.direction = preferredDirection
const inputEl = this.container.nativeElement const inputEl = this.container.nativeElement
const inputHeight = inputEl.offsetHeight const inputHeight = parseInt(inputEl.offsetHeight)
const inputPosition = inputEl.getBoundingClientRect() const inputPosition = inputEl.getBoundingClientRect()
const boxHeight = this.boxComponent.height const boxHeight = this.boxComponent.height
const downY = inputPosition.y + inputHeight + this.padding / 2 const downY = parseInt(inputPosition.y) + inputHeight + this.padding / 2
const downSpaceLeft = viewHeight - (downY + boxHeight) const downSpaceLeft = viewHeight - (downY + boxHeight)
const upY = inputPosition.top - boxHeight - this.padding const upY = inputPosition.top - boxHeight - this.padding
const upSpaceLeft = upY const upSpaceLeft = upY
this.direction = this.forceDirection ?? (downSpaceLeft > upSpaceLeft ? 'down' : 'up') this.direction = this.forceDirection ?? (downSpaceLeft > upSpaceLeft ? 'down' : 'up')
let y = this.direction === 'down' ? downY : upY const y = this.direction === 'down' ? downY : upY
this.yCoordinate = y this.yCoordinate = y
} }
@ -128,7 +130,7 @@ export class DropdownComponent implements OnInit {
} }
searchText: string searchText: string
@HostListener('document:keypress', ['$event']) @HostListener('document:keypress', [ '$event' ])
keypress (event: KeyboardEvent) { keypress (event: KeyboardEvent) {
if (!this.disabled && this.shown && this.searchable) { if (!this.disabled && this.shown && this.searchable) {
switch (event.key) { switch (event.key) {

View File

@ -1,6 +1,5 @@
import { import {
Component, Component,
OnInit,
ViewChild, ViewChild,
Input, Input,
Output, Output,
@ -13,7 +12,7 @@ import {
UtilitiesService UtilitiesService
} from '../../services/utilities.service' } from '../../services/utilities.service'
import { FadeInOutAnimation } from '../../../animations' import { FadeInOutAnimation } from '../../../animations'
import { SafeStyle, DomSanitizer } from '@angular/platform-browser' import { DomSanitizer } from '@angular/platform-browser'
export interface FlatSliderValueChangedEvent { export interface FlatSliderValueChangedEvent {
value: number value: number
@ -23,8 +22,8 @@ export interface FlatSliderValueChangedEvent {
@Component({ @Component({
selector: 'eqm-flat-slider', selector: 'eqm-flat-slider',
templateUrl: './flat-slider.component.html', templateUrl: './flat-slider.component.html',
styleUrls: ['./flat-slider.component.scss'], styleUrls: [ './flat-slider.component.scss' ],
animations: [FadeInOutAnimation] animations: [ FadeInOutAnimation ]
}) })
export class FlatSliderComponent { export class FlatSliderComponent {
constructor ( constructor (
@ -61,6 +60,7 @@ export class FlatSliderComponent {
this._enabled = shouldBeEnabled this._enabled = shouldBeEnabled
this._color = this._enabled ? this.defaultColor : '#777' this._color = this._enabled ? this.defaultColor : '#777'
} }
get enabled () { return this._enabled } get enabled () { return this._enabled }
public _color = this.defaultColor public _color = this.defaultColor
@ -69,6 +69,7 @@ export class FlatSliderComponent {
this.defaultColor = newColor this.defaultColor = newColor
this._color = this._enabled ? this.defaultColor : '#777' this._color = this._enabled ? this.defaultColor : '#777'
} }
get color () { get color () {
return this._color return this._color
} }
@ -85,7 +86,7 @@ export class FlatSliderComponent {
public dragging = false public dragging = false
public thumbRadius = 4 public thumbRadius = 4
public _value = .5 public _value = 0.5
@Input() @Input()
set value (newValue) { set value (newValue) {
let value = this.clampValue(newValue) let value = this.clampValue(newValue)
@ -98,10 +99,10 @@ export class FlatSliderComponent {
diffFromMiddle *= -1 diffFromMiddle *= -1
} }
const percFromMiddle = this.mapValue({ const percFromMiddle = this.mapValue({
value: diffFromMiddle, value: diffFromMiddle,
inMin: 0, inMin: 0,
inMax: this.max - middleValue, inMax: this.max - middleValue,
outMin: 0, outMin: 0,
outMax: 100 outMax: 100
}) })
if ((this._value).toFixed(2) === (middleValue).toFixed(2) && percFromMiddle < 5) { if ((this._value).toFixed(2) === (middleValue).toFixed(2) && percFromMiddle < 5) {
@ -116,6 +117,7 @@ export class FlatSliderComponent {
this._value = this.clampValue(value) this._value = this.clampValue(value)
this.valueChange.emit(this._value) this.valueChange.emit(this._value)
} }
get value () { return this._value } get value () { return this._value }
@Output() valueChange = new EventEmitter() @Output() valueChange = new EventEmitter()
@ -128,13 +130,14 @@ export class FlatSliderComponent {
get width () { get width () {
return this.containerRef.nativeElement.offsetWidth return this.containerRef.nativeElement.offsetWidth
} }
public clampValue (value) { public clampValue (value) {
if (value < this.min) return this.min if (value < this.min) return this.min
if (value > this.max) return this.max if (value > this.max) return this.max
return value return value
} }
@HostListener('mousewheel', ['$event']) @HostListener('mousewheel', [ '$event' ])
mouseWheel (event: MouseWheelEvent) { mouseWheel (event: MouseWheelEvent) {
if (this.enabled && this.scrollEnabled) { if (this.enabled && this.scrollEnabled) {
// const multiplier = (this.max - this.min) / 1000 // const multiplier = (this.max - this.min) / 1000
@ -165,7 +168,8 @@ export class FlatSliderComponent {
if (progress > inMax) progress = inMax if (progress > inMax) progress = inMax
return this.mapValue({ return this.mapValue({
value: progress, value: progress,
inMin, inMax, inMin,
inMax,
outMin: this.min, outMin: this.min,
outMax: this.max outMax: this.max
}) })
@ -173,7 +177,7 @@ export class FlatSliderComponent {
return value return value
} }
@HostListener('mousedown', ['$event']) @HostListener('mousedown', [ '$event' ])
mousedown (event: MouseEvent) { mousedown (event: MouseEvent) {
if (this.enabled) { if (this.enabled) {
this.dragging = true this.dragging = true
@ -182,7 +186,7 @@ export class FlatSliderComponent {
} }
} }
@HostListener('mousemove', ['$event']) @HostListener('mousemove', [ '$event' ])
mousemove (event: MouseEvent) { mousemove (event: MouseEvent) {
if (this.enabled && this.dragging) { if (this.enabled && this.dragging) {
this.value = this.getValueFromMouseEvent(event) this.value = this.getValueFromMouseEvent(event)
@ -195,6 +199,7 @@ export class FlatSliderComponent {
onMouseEnter (): void { onMouseEnter (): void {
this.mouseInside = true this.mouseInside = true
} }
@HostListener('mouseleave') @HostListener('mouseleave')
onMouseLeave (): void { onMouseLeave (): void {
this.mouseInside = false this.mouseInside = false
@ -229,13 +234,13 @@ export class FlatSliderComponent {
value += step value += step
this.value = value this.value = value
} }
return
} }
@HostListener('mouseup', ['$event']) @HostListener('mouseup', [ '$event' ])
onMouseUp () { onMouseUp () {
this.dragging = false this.dragging = false
} }
mouseup (event) { mouseup (event) {
this.dragging = false this.dragging = false
} }
@ -259,10 +264,10 @@ export class FlatSliderComponent {
const styles: { [style: string]: string } = {} const styles: { [style: string]: string } = {}
const narrow = this.thumbRadius * 2 + 2 const narrow = this.thumbRadius * 2 + 2
if (this.orientation === 'horizontal') { if (this.orientation === 'horizontal') {
styles.width = `100%` styles.width = '100%'
styles.height = `${narrow}px` styles.height = `${narrow}px`
} else { } else {
styles.height = `100%` styles.height = '100%'
styles.width = `${narrow}px` styles.width = `${narrow}px`
} }
@ -329,20 +334,20 @@ export class FlatSliderComponent {
style.borderRadius = '100%' style.borderRadius = '100%'
if (this.orientation === 'horizontal') { if (this.orientation === 'horizontal') {
const left = this.mapValue({ const left = this.mapValue({
value: this.value, value: this.value,
inMin: this.min, inMin: this.min,
inMax: this.max, inMax: this.max,
outMin: -borderSize, outMin: -borderSize,
outMax: this.width - this.thumbRadius * 2 - borderSize, outMax: this.width - this.thumbRadius * 2 - borderSize,
logInverse: true logInverse: true
}) })
style.left = `${left}px` style.left = `${left}px`
} else { } else {
style.bottom = `${this.mapValue({ style.bottom = `${this.mapValue({
value: this.value, value: this.value,
inMin: this.min, inMin: this.min,
inMax: this.max, inMax: this.max,
outMin: -borderSize, outMin: -borderSize,
outMax: this.height - this.thumbRadius * 2 - borderSize, outMax: this.height - this.thumbRadius * 2 - borderSize,
logInverse: true logInverse: true
})}px` })}px`
@ -351,13 +356,16 @@ export class FlatSliderComponent {
} }
private mapValue ({ value, inMin, inMax, outMin, outMax, logInverse }: { private mapValue ({ value, inMin, inMax, outMin, outMax, logInverse }: {
value: number, inMin: number, inMax: number, outMin: number, outMax: number value: number
inMin: number
inMax: number
outMin: number
outMax: number
logInverse?: boolean logInverse?: boolean
}) { }) {
switch (this.scale) { switch (this.scale) {
case 'linear': return this.utils.mapValue(value, inMin, inMax, outMin, outMax) case 'linear': return this.utils.mapValue(value, inMin, inMax, outMin, outMax)
case 'logarithmic': return (logInverse ? this.utils.logMapValueInverse : this.utils.logMapValue) case 'logarithmic': return (logInverse ? this.utils.logMapValueInverse : this.utils.logMapValue)({ value, inMin, inMax, outMin, outMax })
({ value, inMin, inMax, outMin, outMax })
} }
} }
} }

View File

@ -10,7 +10,7 @@ import { DomSanitizer, SafeHtml } from '@angular/platform-browser'
@Component({ @Component({
selector: 'eqm-icon', selector: 'eqm-icon',
templateUrl: './icon.component.html', templateUrl: './icon.component.html',
styleUrls: ['./icon.component.scss'], styleUrls: [ './icon.component.scss' ],
encapsulation: ViewEncapsulation.ShadowDom encapsulation: ViewEncapsulation.ShadowDom
}) })
export class IconComponent implements OnInit { export class IconComponent implements OnInit {
@ -18,10 +18,12 @@ export class IconComponent implements OnInit {
@Input() height = 20 @Input() height = 20
svg: SafeHtml svg: SafeHtml
icons = svgs icons = svgs
@Input() set size (newSize) { @Input() set size (newSize) {
this.width = newSize this.width = newSize
this.height = newSize this.height = newSize
} }
_color = '#979aa0' _color = '#979aa0'
@Input() @Input()
set color (newColor) { set color (newColor) {
@ -47,6 +49,7 @@ export class IconComponent implements OnInit {
get rotate () { get rotate () {
return this._rotate return this._rotate
} }
set rotate (angle: number) { set rotate (angle: number) {
this._rotate = angle this._rotate = angle
} }
@ -57,6 +60,7 @@ export class IconComponent implements OnInit {
this._name = iconName this._name = iconName
this.svg = this.sanitizer.bypassSecurityTrustHtml(this.icons[this.name]) this.svg = this.sanitizer.bypassSecurityTrustHtml(this.icons[this.name])
} }
get name () { return this._name } get name () { return this._name }
@Input() stroke: number = 0 @Input() stroke: number = 0

View File

@ -3,7 +3,7 @@ import { Component, OnInit, Input, EventEmitter, Output, ViewChild, HostBinding
@Component({ @Component({
selector: 'eqm-input-field', selector: 'eqm-input-field',
templateUrl: './input-field.component.html', templateUrl: './input-field.component.html',
styleUrls: ['./input-field.component.scss'] styleUrls: [ './input-field.component.scss' ]
}) })
export class InputFieldComponent implements OnInit { export class InputFieldComponent implements OnInit {
@Input() text: string @Input() text: string
@ -14,7 +14,6 @@ export class InputFieldComponent implements OnInit {
@HostBinding('class.disabled') @Input() disabled = false @HostBinding('class.disabled') @Input() disabled = false
@Input() fontSize = 12 @Input() fontSize = 12
@ViewChild('container', { static: true }) container @ViewChild('container', { static: true }) container
constructor () { }
ngOnInit () { ngOnInit () {
} }
@ -26,5 +25,4 @@ export class InputFieldComponent implements OnInit {
enterPressed () { enterPressed () {
this.enter.emit() this.enter.emit()
} }
} }

View File

@ -19,7 +19,7 @@ export interface KnobValueChangedEvent {
@Component({ @Component({
selector: 'eqm-knob', selector: 'eqm-knob',
templateUrl: './knob.component.html', templateUrl: './knob.component.html',
styleUrls: ['./knob.component.scss'] styleUrls: [ './knob.component.scss' ]
}) })
export class KnobComponent implements OnInit { export class KnobComponent implements OnInit {
@Input() size: 'large' | 'medium' | 'small' = 'medium' @Input() size: 'large' | 'medium' | 'small' = 'medium'
@ -59,7 +59,6 @@ export class KnobComponent implements OnInit {
if (this._value === newValue || typeof newValue !== 'number') return if (this._value === newValue || typeof newValue !== 'number') return
let value = newValue let value = newValue
if (this.stickToMiddle) { if (this.stickToMiddle) {
let diffFromMiddle = this.middleValue - value let diffFromMiddle = this.middleValue - value
if (diffFromMiddle < 0) { if (diffFromMiddle < 0) {
diffFromMiddle *= -1 diffFromMiddle *= -1
@ -77,6 +76,7 @@ export class KnobComponent implements OnInit {
this._value = this.clampValue(value) this._value = this.clampValue(value)
this.valueChange.emit(this._value) this.valueChange.emit(this._value)
} }
get value () { get value () {
return this._value return this._value
} }
@ -116,7 +116,7 @@ export class KnobComponent implements OnInit {
this.dragging = false this.dragging = false
} }
@HostListener('gesturechange', ['$event']) @HostListener('gesturechange', [ '$event' ])
onGestureChange (event) { onGestureChange (event) {
if (!this.disabled) { if (!this.disabled) {
try { try {
@ -133,7 +133,6 @@ export class KnobComponent implements OnInit {
mousemove (event) { mousemove (event) {
if (!this.disabled) { if (!this.disabled) {
if (this.setDraggingFalseTimeout) { if (this.setDraggingFalseTimeout) {
window.clearTimeout(this.setDraggingFalseTimeout) window.clearTimeout(this.setDraggingFalseTimeout)
} }
@ -236,7 +235,6 @@ export class KnobComponent implements OnInit {
} }
} }
this.continueAnimation = false this.continueAnimation = false
return
} }
public getDegreesFromEvent (event) { public getDegreesFromEvent (event) {

View File

@ -1,15 +1,14 @@
import { Component, OnInit, Input, HostBinding } from '@angular/core' import { Component, Input, HostBinding } from '@angular/core'
@Component({ @Component({
selector: 'eqm-label', selector: 'eqm-label',
templateUrl: './label.component.html', templateUrl: './label.component.html',
styleUrls: ['./label.component.scss'] styleUrls: [ './label.component.scss' ]
}) })
export class LabelComponent { export class LabelComponent {
@Input() fontSize: number @Input() fontSize: number
@Input() color: string @Input() color: string
@Input() clickable = false @Input() clickable = false
constructor () { }
get style () { get style () {
return { return {

View File

@ -1,15 +1,16 @@
import { Component, ViewChild, ElementRef, OnInit, AfterViewInit } from '@angular/core' import { Component, ViewChild, ElementRef, AfterViewInit } from '@angular/core'
@Component({ @Component({
selector: 'eqm-loading', selector: 'eqm-loading',
templateUrl: './loading.component.html', templateUrl: './loading.component.html',
styleUrls: ['./loading.component.scss'] styleUrls: [ './loading.component.scss' ]
}) })
export class LoadingComponent implements AfterViewInit { export class LoadingComponent implements AfterViewInit {
@ViewChild('wave', { static: true }) wave: ElementRef @ViewChild('wave', { static: true }) wave: ElementRef
ngAfterViewInit () { ngAfterViewInit () {
const path = this.wave.nativeElement const path = this.wave.nativeElement
// eslint-disable-next-line no-loss-of-precision
const m = 0.512286623256592433 const m = 0.512286623256592433
const w = 90 const w = 90
const h = 60 const h = 60

View File

@ -3,13 +3,9 @@ import { Component, OnInit } from '@angular/core'
@Component({ @Component({
selector: 'eqm-prompt', selector: 'eqm-prompt',
templateUrl: './prompt.component.html', templateUrl: './prompt.component.html',
styleUrls: ['./prompt.component.scss'] styleUrls: [ './prompt.component.scss' ]
}) })
export class PromptComponent implements OnInit { export class PromptComponent implements OnInit {
constructor () { }
ngOnInit () { ngOnInit () {
} }
} }

View File

@ -1,13 +1,11 @@
import { Component, OnInit, Input } from '@angular/core' import { Component, OnInit } from '@angular/core'
@Component({ @Component({
selector: 'eqm-question', selector: 'eqm-question',
template: '<eqm-icon stroke="0" color="#c9cdd0" width="8" height="8" name="help"></eqm-icon>', template: '<eqm-icon stroke="0" color="#c9cdd0" width="8" height="8" name="help"></eqm-icon>',
styles: [':host { height: 12px; width: 12px; display: flex; align-items: center; justify-content: center; border-radius: 50%; background-color: #2c2c2e; }'] styles: [ ':host { height: 12px; width: 12px; display: flex; align-items: center; justify-content: center; border-radius: 50%; background-color: #2c2c2e; }' ]
}) })
export class QuestionComponent implements OnInit { export class QuestionComponent implements OnInit {
constructor () { }
ngOnInit () { ngOnInit () {
} }
} }

View File

@ -3,13 +3,9 @@ import { Component, OnInit } from '@angular/core'
@Component({ @Component({
selector: 'eqm-screw', selector: 'eqm-screw',
templateUrl: './screw.component.html', templateUrl: './screw.component.html',
styleUrls: ['./screw.component.scss'] styleUrls: [ './screw.component.scss' ]
}) })
export class ScrewComponent implements OnInit { export class ScrewComponent implements OnInit {
constructor () { }
ngOnInit () { ngOnInit () {
} }
} }

View File

@ -3,16 +3,16 @@ import { Component, OnInit, Input, Output, EventEmitter, ViewChild, ElementRef }
@Component({ @Component({
selector: 'eqm-select-box', selector: 'eqm-select-box',
templateUrl: './select-box.component.html', templateUrl: './select-box.component.html',
styleUrls: ['./select-box.component.scss'] styleUrls: [ './select-box.component.scss' ]
}) })
export class SelectBoxComponent implements OnInit { export class SelectBoxComponent implements OnInit {
_items: any[] = [] _items: any[] = []
@Input() @Input()
set items (newItems: any[]) { set items (newItems: any[]) {
this._items = newItems this._items = newItems
this.setHeight() this.setHeight()
} }
get items () { get items () {
return this._items return this._items
} }
@ -67,5 +67,4 @@ export class SelectBoxComponent implements OnInit {
this.selectedItem = item this.selectedItem = item
this.itemSelected.emit(item) this.itemSelected.emit(item)
} }
} }

View File

@ -21,10 +21,9 @@ export interface SkeuomorphSliderValueChangedEvent {
@Component({ @Component({
selector: 'eqm-skeuomorph-slider', selector: 'eqm-skeuomorph-slider',
templateUrl: './skeuomorph-slider.component.html', templateUrl: './skeuomorph-slider.component.html',
styleUrls: ['./skeuomorph-slider.component.scss'] styleUrls: [ './skeuomorph-slider.component.scss' ]
}) })
export class SkeuomorphSliderComponent implements OnInit { export class SkeuomorphSliderComponent implements OnInit {
constructor (public utils: UtilitiesService, public elRef: ElementRef) {} constructor (public utils: UtilitiesService, public elRef: ElementRef) {}
@Input() min: number = 0 @Input() min: number = 0
@ -50,7 +49,7 @@ export class SkeuomorphSliderComponent implements OnInit {
@HostBinding('class.disabled') @Input() disabled = false @HostBinding('class.disabled') @Input() disabled = false
public _value = .5 public _value = 0.5
@Input() @Input()
set value (newValue) { set value (newValue) {
let value = this.clampValue(newValue) let value = this.clampValue(newValue)
@ -74,11 +73,11 @@ export class SkeuomorphSliderComponent implements OnInit {
} }
this._value = this.clampValue(value) this._value = this.clampValue(value)
this.valueChange.emit(this._value) this.valueChange.emit(this._value)
} }
get value () { return this._value } get value () { return this._value }
@HostListener('mousewheel', ['$event']) @HostListener('mousewheel', [ '$event' ])
onMouseWheel (event): void { onMouseWheel (event): void {
if (!this.disabled && this.scrollEnabled) { if (!this.disabled && this.scrollEnabled) {
this.value += -event.deltaY / 100 this.value += -event.deltaY / 100
@ -105,7 +104,7 @@ export class SkeuomorphSliderComponent implements OnInit {
} }
} }
@HostListener('mousedown', ['$event']) @HostListener('mousedown', [ '$event' ])
onMouseDown (event) { onMouseDown (event) {
if (!this.disabled) { if (!this.disabled) {
this.dragging = true this.dragging = true
@ -119,7 +118,7 @@ export class SkeuomorphSliderComponent implements OnInit {
} }
} }
@HostListener('mousemove', ['$event']) @HostListener('mousemove', [ '$event' ])
onMouseMove (event) { onMouseMove (event) {
if (!this.disabled && this.dragging) { if (!this.disabled && this.dragging) {
this.value = this.getValueFromMouseEvent(event) this.value = this.getValueFromMouseEvent(event)
@ -127,7 +126,7 @@ export class SkeuomorphSliderComponent implements OnInit {
} }
} }
@HostListener('mouseup', ['$event']) @HostListener('mouseup', [ '$event' ])
onMouseUp () { onMouseUp () {
this.dragging = false this.dragging = false
} }
@ -154,7 +153,7 @@ export class SkeuomorphSliderComponent implements OnInit {
ngOnInit () { ngOnInit () {
if (this.showNotches) { if (this.showNotches) {
this.drawNotches() this.drawNotches()
setTimeout(this.drawNotches.bind(this)) setTimeout(() => this.drawNotches())
} }
} }
@ -171,7 +170,6 @@ export class SkeuomorphSliderComponent implements OnInit {
value += step value += step
this.value = value this.value = value
} }
return
} }
@HostListener('window:resize') @HostListener('window:resize')
@ -186,9 +184,9 @@ export class SkeuomorphSliderComponent implements OnInit {
const gap = (height - padding * 2) / 10 const gap = (height - padding * 2) / 10
ctx.strokeStyle = '#559e7d' ctx.strokeStyle = '#559e7d'
for (let i = 0; i <= 10; i++) { for (let i = 0; i <= 10; i++) {
const y = Math.round(padding + gap * i) - .5 const y = Math.round(padding + gap * i) - 0.5
ctx.beginPath() ctx.beginPath()
const lineWidth = [0, 5, 10].includes(i) ? width : (width * 0.9) const lineWidth = [ 0, 5, 10 ].includes(i) ? width : (width * 0.9)
ctx.moveTo((width - lineWidth) / 1, y) ctx.moveTo((width - lineWidth) / 1, y)
ctx.lineTo(lineWidth, y) ctx.lineTo(lineWidth, y)
ctx.stroke() ctx.stroke()
@ -198,6 +196,6 @@ export class SkeuomorphSliderComponent implements OnInit {
} }
calculateTop () { calculateTop () {
return this.utils.mapValue(this._value, this.min, this.max, this.elRef.nativeElement.offsetHeight - 25, 0) + 'px' return `${this.utils.mapValue(this._value, this.min, this.max, parseInt(this.elRef.nativeElement.offsetHeight) - 25, 0)}px`
} }
} }

View File

@ -3,12 +3,9 @@ import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'
@Component({ @Component({
selector: 'eqm-toggle', selector: 'eqm-toggle',
templateUrl: './toggle.component.html', templateUrl: './toggle.component.html',
styleUrls: ['./toggle.component.scss'] styleUrls: [ './toggle.component.scss' ]
}) })
export class ToggleComponent implements OnInit { export class ToggleComponent implements OnInit {
constructor () { }
@Input() state = false @Input() state = false
@Output() stateChange = new EventEmitter() @Output() stateChange = new EventEmitter()

View File

@ -16,10 +16,8 @@ import { FadeInOutAnimation } from '../../../animations/fade-in-out'
</eqm-tooltip> </eqm-tooltip>
</div> </div>
`, `,
animations: [FadeInOutAnimation] animations: [ FadeInOutAnimation ]
}) })
export class TooltipContainerComponent { export class TooltipContainerComponent {
constructor (public tooltipService: TooltipService) {} constructor (public tooltipService: TooltipService) {}
} }

View File

@ -6,13 +6,13 @@ import {
ViewChild ViewChild
} from '@angular/core' } from '@angular/core'
import { UtilitiesService } from '../../services/utilities.service' import { UtilitiesService } from '../../services/utilities.service'
import { SafeStyle, DomSanitizer } from '@angular/platform-browser' import { DomSanitizer } from '@angular/platform-browser'
export type TooltipPositionSide = 'top' | 'bottom' | 'left' | 'right' export type TooltipPositionSide = 'top' | 'bottom' | 'left' | 'right'
@Component({ @Component({
selector: 'eqm-tooltip', selector: 'eqm-tooltip',
templateUrl: './tooltip.component.html', templateUrl: './tooltip.component.html',
styleUrls: ['./tooltip.component.scss'] styleUrls: [ './tooltip.component.scss' ]
}) })
export class TooltipComponent implements OnInit { export class TooltipComponent implements OnInit {
@Input() text: string @Input() text: string
@ -49,12 +49,11 @@ export class TooltipComponent implements OnInit {
const viewHeight = Math.max(body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight) const viewHeight = Math.max(body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight)
const viewWidth = Math.max(body.scrollWidth, body.offsetWidth, html.clientWidth, html.scrollWidth, html.offsetWidth) const viewWidth = Math.max(body.scrollWidth, body.offsetWidth, html.clientWidth, html.scrollWidth, html.offsetWidth)
const tooltipEl = this.tooltip.nativeElement const tooltipEl = this.tooltip.nativeElement
const tooltipWidth = tooltipEl.offsetWidth + 3 const tooltipWidth = parseInt(tooltipEl.offsetWidth) + 3
const tooltipHeight = tooltipEl.offsetHeight + 2 const tooltipHeight = parseInt(tooltipEl.offsetHeight) + 2
const parentEl = this.parent.nativeElement const parentEl = this.parent.nativeElement
const parentPosition = this.utils.getElementPosition(parentEl) const parentPosition = this.utils.getElementPosition(parentEl)
const parentWidth = parentEl.offsetWidth const parentHeight = parseInt(parentEl.offsetHeight)
const parentHeight = parentEl.offsetHeight
x = parentPosition.x x = parentPosition.x
y = parentPosition.y y = parentPosition.y
@ -98,14 +97,12 @@ export class TooltipComponent implements OnInit {
let angle = 0 let angle = 0
const style: { [style: string]: string } = {} const style: { [style: string]: string } = {}
const tooltipEl = this.tooltip.nativeElement const tooltipEl = this.tooltip.nativeElement
const tooltipWidth = tooltipEl.offsetWidth
const tooltipHeight = tooltipEl.offsetHeight const tooltipHeight = tooltipEl.offsetHeight
const tooltipPosition = this.utils.getElementPosition(tooltipEl) const tooltipPosition = this.utils.getElementPosition(tooltipEl)
const parentEl = this.parent.nativeElement const parentEl = this.parent.nativeElement
const parentPosition = this.utils.getElementPosition(parentEl) const parentPosition = this.utils.getElementPosition(parentEl)
const parentWidth = parentEl.offsetWidth const parentWidth = parentEl.offsetWidth
const parentHeight = parentEl.offsetHeight
x = parentPosition.x + parentWidth / 2 - tooltipPosition.x - arrowSize / 2 + 3 x = parentPosition.x + parentWidth / 2 - tooltipPosition.x - arrowSize / 2 + 3
if (this.positionSide === 'top') { if (this.positionSide === 'top') {
@ -126,5 +123,4 @@ export class TooltipComponent implements OnInit {
return style return style
} }
} }

View File

@ -51,5 +51,4 @@ export class TooltipDirective implements OnDestroy {
destroy (): void { destroy (): void {
this.tooltipService.components = [] this.tooltipService.components = []
} }
} }

View File

@ -4,6 +4,5 @@ import { Injectable } from '@angular/core'
providedIn: 'root' providedIn: 'root'
}) })
export class TooltipService { export class TooltipService {
components: any[] = [] components: any[] = []
} }

View File

@ -1,20 +1,17 @@
import { import {
Component, Component,
OnInit, OnInit,
Input, Input
HostBinding
} from '@angular/core' } from '@angular/core'
@Component({ @Component({
selector: 'eqm-value-screen', selector: 'eqm-value-screen',
templateUrl: './value-screen.component.html', templateUrl: './value-screen.component.html',
styleUrls: ['./value-screen.component.scss'] styleUrls: [ './value-screen.component.scss' ]
}) })
export class ValueScreenComponent implements OnInit { export class ValueScreenComponent implements OnInit {
@Input() fontSize = 10 @Input() fontSize = 10
@Input() disabled = false @Input() disabled = false
constructor () {}
ngOnInit () {} ngOnInit () {}
} }

View File

@ -3,11 +3,9 @@ import { Component, OnInit } from '@angular/core'
@Component({ @Component({
selector: 'eqm-vent', selector: 'eqm-vent',
template: '', template: '',
styleUrls: ['./vent.component.scss'] styleUrls: [ './vent.component.scss' ]
}) })
export class VentComponent implements OnInit { export class VentComponent implements OnInit {
constructor () { }
ngOnInit () { ngOnInit () {
} }
} }

View File

@ -1,6 +1,6 @@
import { Component, Directive, EventEmitter, HostListener, Output } from "@angular/core"; import { Directive, EventEmitter, HostListener, Output } from '@angular/core'
@Directive({ selector: `[clickedOutside]` }) @Directive({ selector: '[clickedOutside]' })
export class ClickedOutsideDirective { export class ClickedOutsideDirective {
@Output() clickedOutside = new EventEmitter() @Output() clickedOutside = new EventEmitter()
@ -9,6 +9,7 @@ export class ClickedOutsideDirective {
insideClick () { insideClick () {
this.inside = true this.inside = true
} }
@HostListener('document:click') @HostListener('document:click')
outsideClick () { outsideClick () {
if (!this.inside) { if (!this.inside) {
@ -16,4 +17,4 @@ export class ClickedOutsideDirective {
} }
this.inside = false this.inside = false
} }
} }

View File

@ -4,21 +4,20 @@ import { Directive, Output, HostListener, EventEmitter } from '@angular/core'
export class MouseWheelDirective { export class MouseWheelDirective {
@Output() mouseWheel = new EventEmitter() @Output() mouseWheel = new EventEmitter()
@HostListener('mousewheel', ['$event']) onMouseWheelChrome (event: any) { @HostListener('mousewheel', [ '$event' ]) onMouseWheelChrome (event: any) {
this.mouseWheelFunc(event) this.mouseWheelFunc(event)
} }
@HostListener('DOMMouseScroll', ['$event']) onMouseWheelFirefox (event: any) { @HostListener('DOMMouseScroll', [ '$event' ]) onMouseWheelFirefox (event: any) {
this.mouseWheelFunc(event) this.mouseWheelFunc(event)
} }
@HostListener('onmousewheel', ['$event']) onMouseWheelIE (event: any) { @HostListener('onmousewheel', [ '$event' ]) onMouseWheelIE (event: any) {
this.mouseWheelFunc(event) this.mouseWheelFunc(event)
} }
mouseWheelFunc (event: any) { mouseWheelFunc (event: any) {
event = window.event || event // old IE support event = window.event || event // old IE support
const delta = Math.max(-1, Math.min(1, (event.wheelDelta || -event.detail)))
this.mouseWheel.emit(event) this.mouseWheel.emit(event)
// for IE // for IE
event.returnValue = false event.returnValue = false
@ -27,5 +26,4 @@ export class MouseWheelDirective {
event.preventDefault() event.preventDefault()
} }
} }
} }

View File

@ -1,5 +1,5 @@
import { import {
NgModule, TemplateRef NgModule
} from '@angular/core' } from '@angular/core'
import { import {
CommonModule CommonModule
@ -46,7 +46,7 @@ import { BrowserAnimationsModule } from '@angular/platform-browser/animations'
import { CarouselComponent, CarouselItemDirective, CarouselItemElement } from './components/carousel/carousel.component' import { CarouselComponent, CarouselItemDirective, CarouselItemElement } from './components/carousel/carousel.component'
import { QuestionComponent } from './components/question/question.component' import { QuestionComponent } from './components/question/question.component'
import { ClickedOutsideDirective } from './directives/clicked-outside.directive' import { ClickedOutsideDirective } from './directives/clicked-outside.directive'
import { ScrollingModule } from '@angular/cdk/scrolling'; import { ScrollingModule } from '@angular/cdk/scrolling'
import { BreadcrumbsComponent } from './components/breadcrumbs/breadcrumbs.component' import { BreadcrumbsComponent } from './components/breadcrumbs/breadcrumbs.component'
@NgModule({ @NgModule({

View File

@ -2,14 +2,16 @@ import { Injectable } from '@angular/core'
@Injectable() @Injectable()
export class UtilitiesService { export class UtilitiesService {
constructor () { }
mapValue (value: number, inMin: number, inMax: number, outMin: number, outMax: number): number { mapValue (value: number, inMin: number, inMax: number, outMin: number, outMax: number): number {
return (value - inMin) * (outMax - outMin) / (inMax - inMin) + outMin return (value - inMin) * (outMax - outMin) / (inMax - inMin) + outMin
} }
logMapValue ({ value, inMin, inMax, outMin, outMax }: { logMapValue ({ value, inMin, inMax, outMin, outMax }: {
value: number, inMin: number, inMax: number, outMin: number, outMax: number value: number
inMin: number
inMax: number
outMin: number
outMax: number
}) { }) {
outMin = Math.log(outMin) outMin = Math.log(outMin)
outMax = Math.log(outMax) outMax = Math.log(outMax)
@ -18,7 +20,11 @@ export class UtilitiesService {
} }
logMapValueInverse ({ value, inMin, inMax, outMin, outMax }: { logMapValueInverse ({ value, inMin, inMax, outMin, outMax }: {
value: number, inMin: number, inMax: number, outMin: number, outMax: number value: number
inMin: number
inMax: number
outMin: number
outMax: number
}) { }) {
inMin = Math.log(inMin || 1) inMin = Math.log(inMin || 1)
inMax = Math.log(inMax) inMax = Math.log(inMax)
@ -31,7 +37,7 @@ export class UtilitiesService {
getImageFromSrcWhenLoaded (src) { getImageFromSrcWhenLoaded (src) {
return new Promise<HTMLImageElement>((resolve, reject) => { return new Promise<HTMLImageElement>((resolve, reject) => {
const image = new Image() const image = new Image()
image.crossOrigin = 'anonymous' // This enables CORS image.crossOrigin = 'anonymous' // This enables CORS
image.onload = () => resolve(image) image.onload = () => resolve(image)
image.onerror = () => reject(image) image.onerror = () => reject(image)
image.src = src image.src = src
@ -52,12 +58,12 @@ export class UtilitiesService {
return this.getImageFromSrcWhenLoaded(this.getBackgroundImageSrcFromClass(className)) return this.getImageFromSrcWhenLoaded(this.getBackgroundImageSrcFromClass(className))
} }
getRandomFloatInRange (min, max) { getRandomFloatInRange (min: number, max: number) {
return (Math.random() * (max - min) + min) return (Math.random() * (max - min) + min)
} }
getCoordinatesInsideElementFromEvent (event: MouseEvent, element?) { getCoordinatesInsideElementFromEvent (event: MouseEvent, element?) {
let el = element || event.target const el = element || event.target
const rect = el.getBoundingClientRect() const rect = el.getBoundingClientRect()
return { return {
x: event.clientX - rect.left, x: event.clientX - rect.left,
@ -75,7 +81,7 @@ export class UtilitiesService {
const rect = el.getBoundingClientRect() const rect = el.getBoundingClientRect()
const scrollLeft = window.pageXOffset || document.documentElement.scrollLeft const scrollLeft = window.pageXOffset || document.documentElement.scrollLeft
const scrollTop = window.pageYOffset || document.documentElement.scrollTop const scrollTop = window.pageYOffset || document.documentElement.scrollTop
return { y: rect.top + scrollTop, x: rect.left + scrollLeft } return { y: parseInt(rect.top) + scrollTop, x: parseInt(rect.left) + scrollLeft }
} }
hexToRgb (hex: string) { hexToRgb (hex: string) {
@ -86,7 +92,7 @@ export class UtilitiesService {
g: result[2], g: result[2],
b: result[3] b: result[3]
} }
for (const [color, hex] of Object.entries(rgb)) { for (const [ color, hex ] of Object.entries(rgb)) {
if ((hex as string).length < 2) rgb[color] = `${hex}${hex}` if ((hex as string).length < 2) rgb[color] = `${hex}${hex}`
rgb[color] = parseInt(rgb[color], 16) rgb[color] = parseInt(rgb[color], 16)
} }
@ -99,5 +105,4 @@ export class UtilitiesService {
rgbToHex ({ r, g, b }: { r: number, g: number, b: number }) { rgbToHex ({ r, g, b }: { r: number, g: number, b: number }) {
return '#' + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1) return '#' + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1)
} }
} }

View File

@ -4,11 +4,9 @@ import { Pipe, PipeTransform } from '@angular/core'
name: 'clipValue' name: 'clipValue'
}) })
export class ClipValuePipe implements PipeTransform { export class ClipValuePipe implements PipeTransform {
transform (value: number, min: number, max: number): number { transform (value: number, min: number, max: number): number {
if (value < min) { return min } if (value < min) { return min }
if (value > max) { return max } if (value > max) { return max }
return value return value
} }
} }

View File

@ -4,7 +4,6 @@ import { Pipe, PipeTransform } from '@angular/core'
name: 'fixFloat' name: 'fixFloat'
}) })
export class FixFloatPipe implements PipeTransform { export class FixFloatPipe implements PipeTransform {
transform (value: number, fixTo: number, showZeros = true) { transform (value: number, fixTo: number, showZeros = true) {
let fixedValue: any = value.toFixed(fixTo) let fixedValue: any = value.toFixed(fixTo)
if (!showZeros) { if (!showZeros) {
@ -12,5 +11,4 @@ export class FixFloatPipe implements PipeTransform {
} }
return fixedValue return fixedValue
} }
} }

View File

@ -4,9 +4,7 @@ import { Pipe, PipeTransform } from '@angular/core'
name: 'mapValue' name: 'mapValue'
}) })
export class MapValuePipe implements PipeTransform { export class MapValuePipe implements PipeTransform {
constructor () {}
transform (value: number, inMin: number, inMax: number, outMin: number, outMax: number): number { transform (value: number, inMin: number, inMax: number, outMin: number, outMax: number): number {
return (value - inMin) * (outMax - outMin) / (inMax - inMin) + outMin return (value - inMin) * (outMax - outMin) / (inMax - inMin) + outMin
} }
} }

View File

@ -17,6 +17,6 @@ export class EffectService extends DataService {
} }
onEnabledChanged (callback: (enabled: boolean) => void) { onEnabledChanged (callback: (enabled: boolean) => void) {
this.on(`/enabled`, ({ enabled }) => callback(enabled)) this.on('/enabled', ({ enabled }) => callback(enabled))
} }
} }

View File

@ -15,7 +15,7 @@ import { ApplicationService } from '../../../../services/app.service'
@Component({ @Component({
selector: 'eqm-advanced-equalizer', selector: 'eqm-advanced-equalizer',
templateUrl: './advanced-equalizer.component.html', templateUrl: './advanced-equalizer.component.html',
styleUrls: ['./advanced-equalizer.component.scss'] styleUrls: [ './advanced-equalizer.component.scss' ]
}) })
export class AdvancedEqualizerComponent extends EqualizerComponent implements OnInit { export class AdvancedEqualizerComponent extends EqualizerComponent implements OnInit {
@Input() enabled = true @Input() enabled = true
@ -26,7 +26,8 @@ export class AdvancedEqualizerComponent extends EqualizerComponent implements On
value: false, value: false,
toggled: (show) => this.service.setShowDefaultPresets(show) toggled: (show) => this.service.setShowDefaultPresets(show)
} }
settings: Options = [[
settings: Options = [ [
{ {
type: 'button', type: 'button',
label: 'Import Presets', label: 'Import Presets',
@ -38,7 +39,8 @@ export class AdvancedEqualizerComponent extends EqualizerComponent implements On
} }
], [ ], [
this.ShowDefaultPresetsCheckbox this.ShowDefaultPresetsCheckbox
]] ] ]
public _presets: AdvancedEqualizerPreset[] public _presets: AdvancedEqualizerPreset[]
@Output() presetsChange = new EventEmitter<AdvancedEqualizerPreset[]>() @Output() presetsChange = new EventEmitter<AdvancedEqualizerPreset[]>()
set presets (newPresets: AdvancedEqualizerPreset[]) { set presets (newPresets: AdvancedEqualizerPreset[]) {
@ -46,10 +48,11 @@ export class AdvancedEqualizerComponent extends EqualizerComponent implements On
[ [
newPresets.find(p => p.id === 'manual'), newPresets.find(p => p.id === 'manual'),
newPresets.find(p => p.id === 'flat'), newPresets.find(p => p.id === 'flat'),
...newPresets.filter(p => !['manual', 'flat'].includes(p.id)).sort((a, b) => a.name > b.name ? 1 : -1) ...newPresets.filter(p => ![ 'manual', 'flat' ].includes(p.id)).sort((a, b) => a.name > b.name ? 1 : -1)
] ]
this.presetsChange.emit(this.presets) this.presetsChange.emit(this.presets)
} }
get presets () { return this._presets } get presets () { return this._presets }
public _selectedPreset: AdvancedEqualizerPreset public _selectedPreset: AdvancedEqualizerPreset
@ -58,10 +61,11 @@ export class AdvancedEqualizerComponent extends EqualizerComponent implements On
this._selectedPreset = newSelectedPreset this._selectedPreset = newSelectedPreset
this.selectedPresetChange.emit(this.selectedPreset) this.selectedPresetChange.emit(this.selectedPreset)
} }
get selectedPreset () { return this._selectedPreset }
bandFrequencyLabels = ['32', '64', '125', '250', '500', '1K', '2K', '4K', '8K', '16K']
bands = [...Array(10)].map(() => 0) get selectedPreset () { return this._selectedPreset }
bandFrequencyLabels = [ '32', '64', '125', '250', '500', '1K', '2K', '4K', '8K', '16K' ]
bands = [ ...Array(10) ].map(() => 0)
global = 0 global = 0
stickSlidersToMiddle = true stickSlidersToMiddle = true
@ -80,7 +84,7 @@ export class AdvancedEqualizerComponent extends EqualizerComponent implements On
this.change.detectChanges() this.change.detectChanges()
}) })
} }
for (const [i, gain] of this.selectedPreset.gains.bands.entries()) { for (const [ i, gain ] of this.selectedPreset.gains.bands.entries()) {
const currentGain = this.bands[i] const currentGain = this.bands[i]
if (currentGain !== gain) { if (currentGain !== gain) {
this.stickSlidersToMiddle = false this.stickSlidersToMiddle = false
@ -101,7 +105,7 @@ export class AdvancedEqualizerComponent extends EqualizerComponent implements On
public transition: TransitionService, public transition: TransitionService,
public change: ChangeDetectorRef, public change: ChangeDetectorRef,
public app: ApplicationService public app: ApplicationService
) { ) {
super() super()
this.getImportLegacyAvailable() this.getImportLegacyAvailable()
} }
@ -134,6 +138,7 @@ export class AdvancedEqualizerComponent extends EqualizerComponent implements On
) )
} }
} }
public async syncPresets () { public async syncPresets () {
const [ presets, selectedPreset ] = await Promise.all([ const [ presets, selectedPreset ] = await Promise.all([
this.service.getPresets(), this.service.getPresets(),

View File

@ -24,27 +24,27 @@ export class AdvancedEqualizerService extends EqualizersService {
} }
createPreset (preset: AdvancedEqualizerPreset, select: boolean = false) { createPreset (preset: AdvancedEqualizerPreset, select: boolean = false) {
return this.request({ method: 'POST', endpoint: `/presets`, data: { ...preset, select } }) return this.request({ method: 'POST', endpoint: '/presets', data: { ...preset, select } })
} }
updatePreset (preset: AdvancedEqualizerPreset, opts?: { select?: boolean, transition?: boolean }) { updatePreset (preset: AdvancedEqualizerPreset, opts?: { select?: boolean, transition?: boolean }) {
return this.request({ return this.request({
method: 'POST', method: 'POST',
endpoint: `/presets`, endpoint: '/presets',
data: { data: {
...preset, // ...preset,
select: opts && opts.select, select: opts?.select,
transition: opts && opts.transition transition: opts?.transition
} }
}) })
} }
selectPreset (preset: AdvancedEqualizerPreset) { selectPreset (preset: AdvancedEqualizerPreset) {
return this.request({ method: 'POST', endpoint: `/presets/select`, data: { ...preset } }) return this.request({ method: 'POST', endpoint: '/presets/select', data: { ...preset } })
} }
deletePreset (preset: AdvancedEqualizerPreset) { deletePreset (preset: AdvancedEqualizerPreset) {
return this.request({ method: 'DELETE', endpoint: `/presets`, data: { ...preset } }) return this.request({ method: 'DELETE', endpoint: '/presets', data: { ...preset } })
} }
async getImportLegacyAvailable () { async getImportLegacyAvailable () {
@ -81,10 +81,10 @@ export class AdvancedEqualizerService extends EqualizersService {
} }
onPresetsChanged (callback: (presets: AdvancedEqualizerPreset[]) => void) { onPresetsChanged (callback: (presets: AdvancedEqualizerPreset[]) => void) {
this.on(`/presets`, (presets) => callback(presets)) this.on('/presets', (presets) => callback(presets))
} }
onSelectedPresetChanged (callback: (preset: AdvancedEqualizerPreset) => void) { onSelectedPresetChanged (callback: (preset: AdvancedEqualizerPreset) => void) {
this.on(`/presets/selected`, (preset) => callback(preset)) this.on('/presets/selected', (preset) => callback(preset))
} }
} }

View File

@ -1,16 +1,15 @@
import { Component, OnInit, Input, Output, EventEmitter, ChangeDetectorRef } from '@angular/core' import { Component, OnInit, Input, Output, EventEmitter, ChangeDetectorRef } from '@angular/core'
import { BasicEqualizerService, BasicEqualizerPreset, BasicEqualizerBand, BasicEqualizerPresetGains } from './basic-equalizer.service' import { BasicEqualizerService, BasicEqualizerPreset, BasicEqualizerBand, BasicEqualizerPresetGains } from './basic-equalizer.service'
import { BridgeService } from '../../../../services/bridge.service'
import { EqualizerComponent } from '../equalizer.component' import { EqualizerComponent } from '../equalizer.component'
import { KnobValueChangedEvent } from '../../../../modules/eqmac-components/components/knob/knob.component' import { KnobValueChangedEvent } from '../../../../modules/eqmac-components/components/knob/knob.component'
import { TransitionService } from '../../../../services/transitions.service' import { TransitionService } from '../../../../services/transitions.service'
import { ApplicationService } from '../../../../services/app.service' import { ApplicationService } from '../../../../services/app.service'
import { UISettings, UIService } from '../../../../services/ui.service' import { UIService } from '../../../../services/ui.service'
@Component({ @Component({
selector: 'eqm-basic-equalizer', selector: 'eqm-basic-equalizer',
templateUrl: './basic-equalizer.component.html', templateUrl: './basic-equalizer.component.html',
styleUrls: ['./basic-equalizer.component.scss'] styleUrls: [ './basic-equalizer.component.scss' ]
}) })
export class BasicEqualizerComponent extends EqualizerComponent implements OnInit { export class BasicEqualizerComponent extends EqualizerComponent implements OnInit {
@Input() enabled = true @Input() enabled = true
@ -20,6 +19,7 @@ export class BasicEqualizerComponent extends EqualizerComponent implements OnIni
mid: 0, mid: 0,
treble: 0 treble: 0
} }
peakLimiter = false peakLimiter = false
replaceKnobsWithSliders = false replaceKnobsWithSliders = false
@ -31,10 +31,11 @@ export class BasicEqualizerComponent extends EqualizerComponent implements OnIni
[ [
newPresets.find(p => p.id === 'manual'), newPresets.find(p => p.id === 'manual'),
newPresets.find(p => p.id === 'flat'), newPresets.find(p => p.id === 'flat'),
...newPresets.filter(p => !['manual', 'flat'].includes(p.id)).sort((a, b) => a.name > b.name ? 1 : -1) ...newPresets.filter(p => ![ 'manual', 'flat' ].includes(p.id)).sort((a, b) => a.name > b.name ? 1 : -1)
] ]
this.presetsChange.emit(this.presets) this.presetsChange.emit(this.presets)
} }
get presets () { return this._presets } get presets () { return this._presets }
public _selectedPreset: BasicEqualizerPreset public _selectedPreset: BasicEqualizerPreset
@ -43,6 +44,7 @@ export class BasicEqualizerComponent extends EqualizerComponent implements OnIni
this._selectedPreset = newSelectedPreset this._selectedPreset = newSelectedPreset
this.selectedPresetChange.emit(this.selectedPreset) this.selectedPresetChange.emit(this.selectedPreset)
} }
get selectedPreset () { return this._selectedPreset } get selectedPreset () { return this._selectedPreset }
settings = [] settings = []
@ -108,8 +110,8 @@ export class BasicEqualizerComponent extends EqualizerComponent implements OnIni
// TODO: Refactor this bollocks // TODO: Refactor this bollocks
this.peakLimiter = this.selectedPreset.peakLimiter || false this.peakLimiter = this.selectedPreset.peakLimiter || false
for (const [type, gain] of Object.entries(this.selectedPreset.gains)) { for (const [ type, gain ] of Object.entries(this.selectedPreset.gains)) {
const currentGain: number = this.gains[type] const currentGain = this.gains[type] as number
if (currentGain !== gain) { if (currentGain !== gain) {
this.stickSlidersToMiddle = false this.stickSlidersToMiddle = false
this.change.detectChanges() this.change.detectChanges()

View File

@ -1,9 +1,8 @@
import { Injectable } from '@angular/core' import { Injectable } from '@angular/core'
import { EqualizersService } from '../equalizers.service' import { EqualizersService } from '../equalizers.service'
import { EqualizerPreset } from '../presets/equalizer-presets.component' import { EqualizerPreset } from '../presets/equalizer-presets.component'
import { JSONEncodable, JSONData } from '../../../../services/data.service'
export type BasicEqualizerPresetGains = { export interface BasicEqualizerPresetGains {
bass: number bass: number
mid: number mid: number
treble: number treble: number
@ -31,34 +30,34 @@ export class BasicEqualizerService extends EqualizersService {
} }
createPreset (preset: BasicEqualizerPreset, select: boolean = false) { createPreset (preset: BasicEqualizerPreset, select: boolean = false) {
return this.request({ method: 'POST', endpoint: `/presets`, data: { ...preset, select } }) return this.request({ method: 'POST', endpoint: '/presets', data: { ...preset, select } as any })
} }
updatePreset (preset: BasicEqualizerPreset, opts?: { select?: boolean, transition?: boolean }) { updatePreset (preset: BasicEqualizerPreset, opts?: { select?: boolean, transition?: boolean }) {
return this.request({ return this.request({
method: 'POST', method: 'POST',
endpoint: `/presets`, endpoint: '/presets',
data: { data: {
...preset, ...preset,
select: opts && opts.select, select: opts?.select,
transition: opts && opts.transition transition: opts?.transition
} } as any
}) })
} }
selectPreset (preset: BasicEqualizerPreset) { selectPreset (preset: BasicEqualizerPreset) {
return this.request({ method: 'POST', endpoint: `/presets/select`, data: { ...preset } }) return this.request({ method: 'POST', endpoint: '/presets/select', data: { ...preset } as any })
} }
deletePreset (preset: BasicEqualizerPreset) { deletePreset (preset: BasicEqualizerPreset) {
return this.request({ method: 'DELETE', endpoint: `/presets`, data: { ...preset } }) return this.request({ method: 'DELETE', endpoint: '/presets', data: { ...preset } as any })
} }
onPresetsChanged (callback: (presets: BasicEqualizerPreset[]) => void) { onPresetsChanged (callback: (presets: BasicEqualizerPreset[]) => void) {
this.on(`/presets`, (presets) => callback(presets)) this.on('/presets', (presets) => callback(presets))
} }
onSelectedPresetChanged (callback: (preset: BasicEqualizerPreset) => void) { onSelectedPresetChanged (callback: (preset: BasicEqualizerPreset) => void) {
this.on(`/presets/selected`, (preset) => callback(preset)) this.on('/presets/selected', (preset) => callback(preset))
} }
} }

View File

@ -1,9 +1,10 @@
import { Option, Options } from 'src/app/components/options/options.component' import { Options } from 'src/app/components/options/options.component'
import { AdditionalPresetOption, EqualizerPreset } from './presets/equalizer-presets.component' import { AdditionalPresetOption, EqualizerPreset } from './presets/equalizer-presets.component'
import { Input } from '@angular/core' import { Component, Input } from '@angular/core'
import { MatDialogRef } from '@angular/material/dialog' import { MatDialogRef } from '@angular/material/dialog'
import { OptionsDialogComponent } from '../../../components/options-dialog/options-dialog.component' import { OptionsDialogComponent } from '../../../components/options-dialog/options-dialog.component'
@Component({ template: '' })
export abstract class EqualizerComponent { export abstract class EqualizerComponent {
@Input() animationDuration = 500 @Input() animationDuration = 500
@Input() animationFps = 30 @Input() animationFps = 30

View File

@ -12,7 +12,7 @@ import { UIService } from '../../../services/ui.service'
@Component({ @Component({
selector: 'eqm-equalizers', selector: 'eqm-equalizers',
templateUrl: './equalizers.component.html', templateUrl: './equalizers.component.html',
styleUrls: ['./equalizers.component.scss'], styleUrls: [ './equalizers.component.scss' ],
animations: [ FadeInOutAnimation ] animations: [ FadeInOutAnimation ]
}) })
export class EqualizersComponent implements OnInit { export class EqualizersComponent implements OnInit {
@ -38,6 +38,7 @@ export class EqualizersComponent implements OnInit {
this.changeRef.detectChanges() this.changeRef.detectChanges()
this.activeEqualizer = this.getEqualizerFromType(this.type) this.activeEqualizer = this.getEqualizerFromType(this.type)
} }
get type () { return this._type } get type () { return this._type }
gain: number = 0 gain: number = 0
@ -48,8 +49,8 @@ export class EqualizersComponent implements OnInit {
public equalizersService: EqualizersService, public equalizersService: EqualizersService,
public dialog: MatDialog, public dialog: MatDialog,
public ui: UIService, public ui: UIService,
private changeRef: ChangeDetectorRef private readonly changeRef: ChangeDetectorRef
) { } ) { }
async ngOnInit () { async ngOnInit () {
await this.sync() await this.sync()
@ -132,5 +133,4 @@ export class EqualizersComponent implements OnInit {
selectPreset (preset: EqualizerPreset) { selectPreset (preset: EqualizerPreset) {
return this.activeEqualizer.selectPreset(preset) return this.activeEqualizer.selectPreset(preset)
} }
} }

View File

@ -20,7 +20,7 @@ export interface AdditionalPresetOption {
@Component({ @Component({
selector: 'eqm-equalizer-presets', selector: 'eqm-equalizer-presets',
templateUrl: './equalizer-presets.component.html', templateUrl: './equalizer-presets.component.html',
styleUrls: ['./equalizer-presets.component.scss'] styleUrls: [ './equalizer-presets.component.scss' ]
}) })
export class EqualizerPresetsComponent implements OnInit { export class EqualizerPresetsComponent implements OnInit {
@Input() presets: EqualizerPreset[] @Input() presets: EqualizerPreset[]
@ -62,7 +62,7 @@ export class EqualizerPresetsComponent implements OnInit {
data: { data: {
confirmText: 'Yes, save', confirmText: 'Yes, save',
cancelText: 'No, cancel', cancelText: 'No, cancel',
text: `A Default preset with this name already exists. Would you like to use this name anyway? You might see Duplicate names in the Preset list.` text: 'A Default preset with this name already exists. Would you like to use this name anyway? You might see Duplicate names in the Preset list.'
} }
}).afterClosed().toPromise() }).afterClosed().toPromise()
if (!saveAnyway) return this.savePreset(presetName) if (!saveAnyway) return this.savePreset(presetName)
@ -73,7 +73,7 @@ export class EqualizerPresetsComponent implements OnInit {
data: { data: {
confirmText: 'Yes, overwrite', confirmText: 'Yes, overwrite',
cancelText: 'No, cancel', cancelText: 'No, cancel',
text: `A preset with this name already exists. Would you like to overwrite it?` text: 'A preset with this name already exists. Would you like to overwrite it?'
} }
}).afterClosed().toPromise() }).afterClosed().toPromise()
if (!overwrite) return this.savePreset(presetName) if (!overwrite) return this.savePreset(presetName)
@ -90,7 +90,7 @@ export class EqualizerPresetsComponent implements OnInit {
data: { data: {
confirmText: 'Yes, remove', confirmText: 'Yes, remove',
cancelText: 'No, cancel', cancelText: 'No, cancel',
text: `Are you sure you want to remove this Preset?` text: 'Are you sure you want to remove this Preset?'
} }
}).afterClosed().toPromise() }).afterClosed().toPromise()
@ -98,5 +98,4 @@ export class EqualizerPresetsComponent implements OnInit {
this.presetDeleted.emit() this.presetDeleted.emit()
} }
} }
} }

View File

@ -11,7 +11,7 @@ import {
@Component({ @Component({
selector: 'eqm-reverb', selector: 'eqm-reverb',
templateUrl: './reverb.component.html', templateUrl: './reverb.component.html',
styleUrls: ['./reverb.component.scss'] styleUrls: [ './reverb.component.scss' ]
}) })
export class ReverbComponent implements OnInit { export class ReverbComponent implements OnInit {
presets = [] presets = []
@ -51,7 +51,6 @@ export class ReverbComponent implements OnInit {
this.getSelectedPreset() this.getSelectedPreset()
this.getMix() this.getMix()
this.getEnabled() this.getEnabled()
} }
async getPresets () { async getPresets () {
@ -87,5 +86,4 @@ export class ReverbComponent implements OnInit {
this.hide = !this.hide this.hide = !this.hide
this.visibilityToggled.emit() this.visibilityToggled.emit()
} }
} }

View File

@ -9,7 +9,7 @@ import { SettingsService, IconMode } from '../settings/settings.service'
@Component({ @Component({
selector: 'eqm-header', selector: 'eqm-header',
templateUrl: './header.component.html', templateUrl: './header.component.html',
styleUrls: ['./header.component.scss'], styleUrls: [ './header.component.scss' ],
animations: [ FadeInOutAnimation ] animations: [ FadeInOutAnimation ]
}) })
export class HeaderComponent implements OnInit { export class HeaderComponent implements OnInit {
@ -25,7 +25,7 @@ export class HeaderComponent implements OnInit {
public ui: UIService, public ui: UIService,
public dialog: MatDialog, public dialog: MatDialog,
public settings: SettingsService public settings: SettingsService
) { } ) { }
async ngOnInit () { async ngOnInit () {
await this.sync() await this.sync()
@ -41,8 +41,8 @@ export class HeaderComponent implements OnInit {
this.uiMode = await this.ui.getMode() this.uiMode = await this.ui.getMode()
} }
setShowBoolean (name, bool) { setShowBoolean (name: string, bool: boolean) {
if (this.showBooleanDebouncers.hasOwnProperty(name)) { if (name in this.showBooleanDebouncers) {
clearTimeout(this.showBooleanDebouncers[name]) clearTimeout(this.showBooleanDebouncers[name])
delete this.showBooleanDebouncers[name] delete this.showBooleanDebouncers[name]
this[name] = bool this[name] = bool
@ -104,5 +104,4 @@ export class HeaderComponent implements OnInit {
// this.mode = this.mode === 'window' ? 'popover' : 'window' // this.mode = this.mode === 'window' ? 'popover' : 'window'
// return this.ui.setMode(this.mode) // return this.ui.setMode(this.mode)
// } // }
} }

View File

@ -1,5 +1,5 @@
import { Component, OnInit } from '@angular/core' import { Component, OnInit } from '@angular/core'
import { Option, Options } from 'src/app/components/options/options.component' import { Options } from 'src/app/components/options/options.component'
import { ApplicationService, MacInfo } from 'src/app/services/app.service' import { ApplicationService, MacInfo } from 'src/app/services/app.service'
import { ConstantsService } from 'src/app/services/constants.service' import { ConstantsService } from 'src/app/services/constants.service'
import { version } from '../../../../package.json' import { version } from '../../../../package.json'
@ -8,7 +8,7 @@ import { UIService } from '../../services/ui.service.js'
@Component({ @Component({
selector: 'eqm-help', selector: 'eqm-help',
templateUrl: './help.component.html', templateUrl: './help.component.html',
styleUrls: ['./help.component.scss'] styleUrls: [ './help.component.scss' ]
}) })
export class HelpComponent implements OnInit { export class HelpComponent implements OnInit {
options: Options = [ options: Options = [

View File

@ -4,7 +4,7 @@ import { OutputsService, Output } from './outputs.service'
@Component({ @Component({
selector: 'eqm-outputs', selector: 'eqm-outputs',
templateUrl: './outputs.component.html', templateUrl: './outputs.component.html',
styleUrls: ['./outputs.component.scss'] styleUrls: [ './outputs.component.scss' ]
}) })
export class OutputsComponent implements OnInit { export class OutputsComponent implements OnInit {
outputs: Output[] outputs: Output[]

View File

@ -18,7 +18,7 @@ export type DeviceTransportType =
export interface Output { export interface Output {
id: number id: number
name: string name: string
transportType: DeviceTransportType, transportType: DeviceTransportType
icon?: IconName icon?: IconName
} }
@Injectable({ @Injectable({

View File

@ -4,7 +4,7 @@ import { UtilitiesService } from '../../services/utilities.service'
@Component({ @Component({
selector: 'eqm-recorder', selector: 'eqm-recorder',
templateUrl: './recorder.component.html', templateUrl: './recorder.component.html',
styleUrls: ['./recorder.component.scss'] styleUrls: [ './recorder.component.scss' ]
}) })
export class RecorderComponent implements OnInit { export class RecorderComponent implements OnInit {
recording = false recording = false
@ -29,5 +29,4 @@ export class RecorderComponent implements OnInit {
}, 1000) }, 1000)
} }
} }
} }

View File

@ -1,5 +1,5 @@
import { Component, OnInit } from '@angular/core' import { Component, OnInit } from '@angular/core'
import { Option, CheckboxOption, ButtonOption, Options, SelectOption } from 'src/app/components/options/options.component' import { CheckboxOption, ButtonOption, Options, SelectOption } from 'src/app/components/options/options.component'
import { SettingsService, IconMode } from './settings.service' import { SettingsService, IconMode } from './settings.service'
import { ApplicationService } from '../../services/app.service' import { ApplicationService } from '../../services/app.service'
import { MatDialog } from '@angular/material/dialog' import { MatDialog } from '@angular/material/dialog'
@ -9,7 +9,7 @@ import { UIService } from '../../services/ui.service'
@Component({ @Component({
selector: 'eqm-settings', selector: 'eqm-settings',
templateUrl: './settings.component.html', templateUrl: './settings.component.html',
styleUrls: ['./settings.component.scss'] styleUrls: [ './settings.component.scss' ]
}) })
export class SettingsComponent implements OnInit { export class SettingsComponent implements OnInit {
launchOnStartupOption: CheckboxOption = { launchOnStartupOption: CheckboxOption = {
@ -29,7 +29,7 @@ export class SettingsComponent implements OnInit {
iconModeOption: SelectOption = { iconModeOption: SelectOption = {
type: 'select', type: 'select',
label: 'Show Icon', label: 'Show Icon',
options: [{ options: [ {
id: IconMode.dock, id: IconMode.dock,
label: 'Dock' label: 'Dock'
}, { }, {
@ -38,7 +38,7 @@ export class SettingsComponent implements OnInit {
}, { }, {
id: IconMode.statusBar, id: IconMode.statusBar,
label: 'Status Bar' label: 'Status Bar'
}], } ],
selectedId: IconMode.both, selectedId: IconMode.both,
selected: async iconMode => { selected: async iconMode => {
const uiMode = await this.ui.getMode() const uiMode = await this.ui.getMode()
@ -48,6 +48,7 @@ export class SettingsComponent implements OnInit {
await this.settingsService.setIconMode(iconMode as IconMode) await this.settingsService.setIconMode(iconMode as IconMode)
} }
} }
uninstallOption: ButtonOption = { uninstallOption: ButtonOption = {
type: 'button', type: 'button',
label: 'Uninstall eqMac', label: 'Uninstall eqMac',

View File

@ -31,7 +31,7 @@ export class SettingsService extends DataService {
return this.request({ method: 'POST', endpoint: '/icon-mode', data: { mode } }) return this.request({ method: 'POST', endpoint: '/icon-mode', data: { mode } })
} }
// async getMode () { // async getMode () {
// const { mode } = await this.request({ method: 'GET', endpoint: '/mode' }) // const { mode } = await this.request({ method: 'GET', endpoint: '/mode' })
// return mode as UIMode // return mode as UIMode
// } // }

View File

@ -19,7 +19,7 @@ interface FileMeta {
@Component({ @Component({
selector: 'eqm-file', selector: 'eqm-file',
templateUrl: './file.component.html', templateUrl: './file.component.html',
styleUrls: ['./file.component.scss'] styleUrls: [ './file.component.scss' ]
}) })
export class FileComponent implements OnInit, OnDestroy { export class FileComponent implements OnInit, OnDestroy {
@ -27,6 +27,7 @@ export class FileComponent implements OnInit, OnDestroy {
name: null, name: null,
duration: 0 duration: 0
} }
public syncedOnce = false public syncedOnce = false
public progressProjectionInterval = null public progressProjectionInterval = null
public progressSetDebouncer = null public progressSetDebouncer = null
@ -95,14 +96,13 @@ export class FileComponent implements OnInit, OnDestroy {
] ]
if (this.selected || !this.syncedOnce) { if (this.selected || !this.syncedOnce) {
thingsToSync.push( thingsToSync.push(
this.getFile(), this.getFile(),
this.getProgress(), this.getProgress(),
this.getPlaybackState() this.getPlaybackState()
) )
} }
await Promise.all(thingsToSync) await Promise.all(thingsToSync)
this.syncedOnce = true this.syncedOnce = true
} }
async getSelected () { async getSelected () {
@ -112,6 +112,7 @@ export class FileComponent implements OnInit, OnDestroy {
this.selected = false this.selected = false
} }
} }
async getFile () { async getFile () {
try { try {
this.meta = await this.fileService.getMeta() this.meta = await this.fileService.getMeta()

View File

@ -46,10 +46,10 @@ export class FileService extends SourceService {
} }
onPlayingChanged (callback: (playing: boolean) => void) { onPlayingChanged (callback: (playing: boolean) => void) {
this.on(`/playing`, ({ playing }) => callback(playing)) this.on('/playing', ({ playing }) => callback(playing))
} }
onProgressChanged (callback: (progress: number) => void) { onProgressChanged (callback: (progress: number) => void) {
this.on(`/progress`, ({ progress }) => callback(progress)) this.on('/progress', ({ progress }) => callback(progress))
} }
} }

View File

@ -10,10 +10,9 @@ export interface InputDevice {
@Component({ @Component({
selector: 'eqm-input', selector: 'eqm-input',
templateUrl: './input.component.html', templateUrl: './input.component.html',
styleUrls: ['./input.component.scss'] styleUrls: [ './input.component.scss' ]
}) })
export class InputComponent implements OnInit { export class InputComponent implements OnInit {
constructor (public inputService: InputService) { } constructor (public inputService: InputService) { }
devices: InputDevice[] = [] devices: InputDevice[] = []
@ -36,7 +35,7 @@ export class InputComponent implements OnInit {
} }
async syncSelectedDevice () { async syncSelectedDevice () {
const selectedDevice = await this.inputService.getDevice() await this.inputService.getDevice()
} }
protected setupEvents () { protected setupEvents () {

View File

@ -4,10 +4,9 @@ import { SourceService, SourceType } from './source.service'
@Component({ @Component({
selector: 'eqm-source', selector: 'eqm-source',
templateUrl: './source.component.html', templateUrl: './source.component.html',
styleUrls: ['./source.component.scss'] styleUrls: [ './source.component.scss' ]
}) })
export class SourceComponent implements OnInit { export class SourceComponent implements OnInit {
source: SourceType = 'File' source: SourceType = 'File'
constructor (public sourceService: SourceService) { } constructor (public sourceService: SourceService) { }
@ -27,5 +26,4 @@ export class SourceComponent implements OnInit {
this.sourceService.setSource(this.source) this.sourceService.setSource(this.source)
} }
} }
} }

View File

@ -3,13 +3,9 @@ import { Component, OnInit } from '@angular/core'
@Component({ @Component({
selector: 'eqm-system', selector: 'eqm-system',
templateUrl: './system.component.html', templateUrl: './system.component.html',
styleUrls: ['./system.component.scss'] styleUrls: [ './system.component.scss' ]
}) })
export class SystemComponent implements OnInit { export class SystemComponent implements OnInit {
constructor () { }
ngOnInit () { ngOnInit () {
} }
} }

View File

@ -3,12 +3,12 @@ import { BalanceService } from './balance.service'
import { ApplicationService } from '../../../../services/app.service' import { ApplicationService } from '../../../../services/app.service'
import { KnobValueChangedEvent } from '../../../../modules/eqmac-components/components/knob/knob.component' import { KnobValueChangedEvent } from '../../../../modules/eqmac-components/components/knob/knob.component'
import { FlatSliderValueChangedEvent } from '../../../../modules/eqmac-components/components/flat-slider/flat-slider.component' import { FlatSliderValueChangedEvent } from '../../../../modules/eqmac-components/components/flat-slider/flat-slider.component'
import { UIService, UISettings } from '../../../../services/ui.service' import { UIService } from '../../../../services/ui.service'
@Component({ @Component({
selector: 'eqm-balance', selector: 'eqm-balance',
templateUrl: './balance.component.html', templateUrl: './balance.component.html',
styleUrls: ['./balance.component.scss'] styleUrls: [ './balance.component.scss' ]
}) })
export class BalanceComponent implements OnInit { export class BalanceComponent implements OnInit {
balance = 0 balance = 0

View File

@ -5,7 +5,6 @@ import { VolumeService } from '../../../../services/volume.service'
providedIn: 'root' providedIn: 'root'
}) })
export class BalanceService extends VolumeService { export class BalanceService extends VolumeService {
async getBalance () { async getBalance () {
const resp = await this.request({ method: 'GET', endpoint: '/balance' }) const resp = await this.request({ method: 'GET', endpoint: '/balance' })
return resp.balance return resp.balance

View File

@ -7,12 +7,12 @@ import {
import { BoosterService } from './booster.service' import { BoosterService } from './booster.service'
import { ApplicationService } from '../../../../services/app.service' import { ApplicationService } from '../../../../services/app.service'
import { UIService, UISettings } from '../../../../services/ui.service' import { UIService } from '../../../../services/ui.service'
@Component({ @Component({
selector: 'eqm-booster', selector: 'eqm-booster',
templateUrl: './booster.component.html', templateUrl: './booster.component.html',
styleUrls: ['./booster.component.scss'] styleUrls: [ './booster.component.scss' ]
}) })
export class BoosterComponent implements OnInit { export class BoosterComponent implements OnInit {
gain = 1 gain = 1

View File

@ -4,7 +4,7 @@ import { UIService } from '../../../services/ui.service'
@Component({ @Component({
selector: 'eqm-volume-booster-balance', selector: 'eqm-volume-booster-balance',
templateUrl: './volume-booster-balance.component.html', templateUrl: './volume-booster-balance.component.html',
styleUrls: ['./volume-booster-balance.component.scss'] styleUrls: [ './volume-booster-balance.component.scss' ]
}) })
export class VolumeBoosterBalanceComponent implements OnInit { export class VolumeBoosterBalanceComponent implements OnInit {
hide = false hide = false
@ -34,5 +34,4 @@ export class VolumeBoosterBalanceComponent implements OnInit {
this.hide = !this.hide this.hide = !this.hide
this.visibilityToggled.emit() this.visibilityToggled.emit()
} }
} }

View File

@ -1,3 +0,0 @@
<p>
volume-mixer works!
</p>

View File

@ -1,15 +0,0 @@
import { Component, OnInit } from '@angular/core'
@Component({
selector: 'eqm-volume-mixer',
templateUrl: './volume-mixer.component.html',
styleUrls: ['./volume-mixer.component.scss']
})
export class VolumeMixerComponent implements OnInit {
constructor () { }
ngOnInit () {
}
}

View File

@ -47,7 +47,7 @@ export class BridgeService {
if (window[bridgeCallbacksKey]) { if (window[bridgeCallbacksKey]) {
return window[bridgeCallbacksKey].push(resolve) return window[bridgeCallbacksKey].push(resolve)
} }
window[bridgeCallbacksKey] = [resolve] window[bridgeCallbacksKey] = [ resolve ]
const WVJBIframe = document.createElement('iframe') const WVJBIframe = document.createElement('iframe')
WVJBIframe.style.display = 'none' WVJBIframe.style.display = 'none'
@ -78,6 +78,7 @@ export class BridgeService {
bridge.registerHandler(event, async (data, cb) => { bridge.registerHandler(event, async (data, cb) => {
const handleError = (err: string | Error) => { const handleError = (err: string | Error) => {
console.error(err) console.error(err)
// eslint-disable-next-line @typescript-eslint/no-base-to-string
cb({ error: err.toString() }) cb({ error: err.toString() })
} }
try { try {

View File

@ -7,6 +7,6 @@ export class ConstantsService {
readonly DOMAIN = 'eqmac.app' readonly DOMAIN = 'eqmac.app'
readonly FAQ_URL = new URL(`https://${this.DOMAIN}/faq`) readonly FAQ_URL = new URL(`https://${this.DOMAIN}/faq`)
readonly BUG_REPORT_URL = new URL(`https://${this.DOMAIN}/report-bug`) readonly BUG_REPORT_URL = new URL(`https://${this.DOMAIN}/report-bug`)
readonly LOCAL_API_URL = `https://127.0.0.1` readonly LOCAL_API_URL = 'https://127.0.0.1'
readonly REMOTE_API_URL = `https://api.${this.DOMAIN}` readonly REMOTE_API_URL = `https://api.${this.DOMAIN}`
} }

View File

@ -10,6 +10,7 @@ export class CookiesService {
constructor ( constructor (
public CONST: ConstantsService public CONST: ConstantsService
) {} ) {}
set (key: string, value: any) { set (key: string, value: any) {
if (typeof value !== 'string') { if (typeof value !== 'string') {
value = JSON.stringify(value) value = JSON.stringify(value)

View File

@ -1,6 +1,5 @@
import { Injectable } from '@angular/core' import { Injectable } from '@angular/core'
import { BridgeService } from './bridge.service' import { BridgeService } from './bridge.service'
import { Logger } from './logger.service'
import { CookiesService } from './cookies.service' import { CookiesService } from './cookies.service'
export type JSONEncodable = null | boolean | number | string | JSONData export type JSONEncodable = null | boolean | number | string | JSONData
@ -27,7 +26,7 @@ export class DataService {
async request (opts: RequestOptions): Promise<any> { async request (opts: RequestOptions): Promise<any> {
if (opts.endpoint && opts.endpoint[0] !== '/') opts.endpoint = `/${opts.endpoint}` if (opts.endpoint && opts.endpoint[0] !== '/') opts.endpoint = `/${opts.endpoint}`
const args: [string, any?] = [`${opts.method} ${this.route}${opts.endpoint || ''}`, opts.data] const args: [string, any?] = [ `${opts.method} ${this.route}${opts.endpoint || ''}`, opts.data ]
const resp = await this.bridge.call(...args) const resp = await this.bridge.call(...args)
return resp return resp
} }

View File

@ -5,7 +5,7 @@ export class Logger {
this.console('log', ...something) this.console('log', ...something)
} }
public static console (func: 'log' , ...something: any[]) { public static console (func: 'log', ...something: any[]) {
if (!environment.production) { if (!environment.production) {
console[func](...something) console[func](...something)
} }

View File

@ -36,9 +36,9 @@ export class TransitionService extends DataService {
perform (from: number, to: number, cb: (value: number) => any) { perform (from: number, to: number, cb: (value: number) => any) {
const distance = to - from const distance = to - from
const step = distance / this.FRAME_COUNT const step = distance / this.FRAME_COUNT
const frames = [...Array(this.FRAME_COUNT)].map((_, i) => i + 1) const frames = [ ...Array(this.FRAME_COUNT) ].map((_, i) => i + 1)
for (const frame of frames) { for (const frame of frames) {
let delay = Math.round(this.FRAME_DURATION * frame) const delay = Math.round(this.FRAME_DURATION * frame)
setTimeout(() => { setTimeout(() => {
cb(from + step * frame) cb(from + step * frame)
}, delay) }, delay)

View File

@ -1,8 +1,8 @@
import { Injectable, EventEmitter } from '@angular/core' import { Injectable } from '@angular/core'
import { DataService } from './data.service' import { DataService } from './data.service'
import { Observable, Subject } from 'rxjs' import { Subject } from 'rxjs'
export type UISettings = { export interface UISettings {
replaceKnobsWithSliders?: boolean replaceKnobsWithSliders?: boolean
} }
@ -24,12 +24,12 @@ export class UIService extends DataService {
settingsChanged = new Subject<UISettings>() settingsChanged = new Subject<UISettings>()
readonly colors = { readonly colors = {
'accent': '#4f8d71', accent: '#4f8d71',
'warning': '#e80415', warning: '#e80415',
'gradient-start': '#5a5b5f', 'gradient-start': '#5a5b5f',
'gradient-end': '#2c2c2e', 'gradient-end': '#2c2c2e',
'light': '#c9cdd0', light: '#c9cdd0',
'dark': '#16191c' dark: '#16191c'
} }
get isLocal () { get isLocal () {
@ -84,5 +84,4 @@ export class UIService extends DataService {
settings = await this.request({ method: 'POST', endpoint: '/settings', data: settings }) settings = await this.request({ method: 'POST', endpoint: '/settings', data: settings })
this.settingsChanged.next(settings) this.settingsChanged.next(settings)
} }
} }

View File

@ -10,11 +10,11 @@ if (environment.production) {
} }
platformBrowserDynamic() platformBrowserDynamic()
.bootstrapModule(AppModule) .bootstrapModule(AppModule)
.then(() => { .then(() => {
if ('serviceWorker' in navigator) { if ('serviceWorker' in navigator) {
navigator.serviceWorker.getRegistration('ngsw-worker.js') navigator.serviceWorker.getRegistration('ngsw-worker.js')
.then(registration => registration && registration.unregister()) .then(async registration => await registration?.unregister())
} }
}) })
.catch(err => console.error(err)) .catch(err => console.error(err))

View File

@ -52,18 +52,18 @@
* Only required if AnimationBuilder is used within the application and using IE/Edge or Safari. * Only required if AnimationBuilder is used within the application and using IE/Edge or Safari.
* Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0). * Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0).
**/ **/
import 'web-animations-js' // Run `npm install --save web-animations-js`. import 'web-animations-js' // Run `npm install --save web-animations-js`.
/** /**
* By default, zone.js will patch all possible macroTask and DomEvents * By default, zone.js will patch all possible macroTask and DomEvents
* user can disable parts of macroTask/DomEvents patch by setting following flags * user can disable parts of macroTask/DomEvents patch by setting following flags
*/ */
// (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame // (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame
// (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick // (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick
// (window as any).__zone_symbol__BLACK_LISTED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames // (window as any).__zone_symbol__BLACK_LISTED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames
/* /*
* in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js
* with the following flag, it will bypass `zone.js` patch for IE/Edge * with the following flag, it will bypass `zone.js` patch for IE/Edge
*/ */
@ -72,8 +72,7 @@ import 'web-animations-js' // Run `npm install --save web-animations-js`.
/*************************************************************************************************** /***************************************************************************************************
* Zone JS is required by default for Angular itself. * Zone JS is required by default for Angular itself.
*/ */
import 'zone.js/dist/zone'; // Included with Angular CLI. import 'zone.js/dist/zone' // Included with Angular CLI.
/*************************************************************************************************** /***************************************************************************************************
* APPLICATION IMPORTS * APPLICATION IMPORTS

View File

@ -6,7 +6,8 @@
"resolveJsonModule": true "resolveJsonModule": true
}, },
"angularCompilerOptions": { "angularCompilerOptions": {
"enableIvy": false "enableIvy": true,
"strictTemplates": true
}, },
"exclude": [] "exclude": []
} }

17
ui/tsconfig.eslint.json Normal file
View File

@ -0,0 +1,17 @@
{
// extend your base config to share compilerOptions, etc
"extends": "./tsconfig.json",
"compilerOptions": {
// ensure that nobody can accidentally use this config for a build
"noEmit": true
},
"include": [
// whatever paths you intend to lint
"src",
"scripts"
],
"exclude": [
"node_modules",
"dist"
]
}

View File

@ -18,6 +18,6 @@
"lib": [ "lib": [
"es2018", "es2018",
"dom" "dom"
] ],
} }
} }

View File

@ -1,6 +0,0 @@
{
"extends": "tslint-config-standard",
"rules": {
"no-empty": false
}
}