-
Notifications
You must be signed in to change notification settings - Fork 222
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- added misc module - stash highlight - fixed error if ggg api is not reachable first time launching
- Loading branch information
1 parent
10f2bcf
commit ab47ac8
Showing
31 changed files
with
252 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './misc-settings/misc-settings.component'; |
13 changes: 13 additions & 0 deletions
13
src/app/modules/misc/component/misc-settings/misc-settings.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<div class="row"> | ||
<div class="col-md-6"> | ||
<app-card [title]="'misc.highlight' | translate"> | ||
<mat-form-field> | ||
<mat-label>{{'app.hotkey' | translate}}</mat-label> | ||
<input matInput [value]="'misc-stash-highlight' | hotkey" readonly> | ||
<a matSuffix [href]="'misc-stash-highlight' | hotkeyUrl"> | ||
<mat-icon> keyboard </mat-icon> | ||
</a> | ||
</mat-form-field> | ||
</app-card> | ||
</div> | ||
</div> |
Empty file.
25 changes: 25 additions & 0 deletions
25
src/app/modules/misc/component/misc-settings/misc-settings.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { MiscSettingsComponent } from './misc-settings.component'; | ||
|
||
describe('MiscSettingsComponent', () => { | ||
let component: MiscSettingsComponent; | ||
let fixture: ComponentFixture<MiscSettingsComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ MiscSettingsComponent ] | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(MiscSettingsComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
13 changes: 13 additions & 0 deletions
13
src/app/modules/misc/component/misc-settings/misc-settings.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { ChangeDetectionStrategy, Component } from '@angular/core'; | ||
import { FeatureSettingsComponent } from '@app/feature'; | ||
import { MiscFeatureSettings } from '@modules/misc/misc-feature-settings'; | ||
|
||
@Component({ | ||
selector: 'app-misc-settings', | ||
templateUrl: './misc-settings.component.html', | ||
styleUrls: ['./misc-settings.component.scss'], | ||
changeDetection: ChangeDetectionStrategy.OnPush | ||
}) | ||
export class MiscSettingsComponent extends FeatureSettingsComponent<MiscFeatureSettings> { | ||
public load(): void { } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { FeatureSettings } from '@app/feature'; | ||
|
||
export interface MiscFeatureSettings extends FeatureSettings { | ||
todo?: boolean; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { Hotkey } from '@app/config'; | ||
import { Feature, FeatureConfig, FeatureModule, FEATURE_MODULES } from '@app/feature'; | ||
import { SharedModule } from '@shared/shared.module'; | ||
import { MiscSettingsComponent } from './component'; | ||
import { MiscFeatureSettings } from './misc-feature-settings'; | ||
import { MiscStashService } from './service/misc-stash.service'; | ||
|
||
|
||
@NgModule({ | ||
providers: [{ provide: FEATURE_MODULES, useClass: MiscModule, multi: true }], | ||
declarations: [ | ||
MiscSettingsComponent | ||
], | ||
imports: [SharedModule] | ||
}) | ||
export class MiscModule implements FeatureModule<MiscFeatureSettings> { | ||
constructor(private readonly miscStash: MiscStashService) { } | ||
|
||
public getConfig(): FeatureConfig<MiscFeatureSettings> { | ||
const config: FeatureConfig<MiscFeatureSettings> = { | ||
name: 'misc.name', | ||
component: MiscSettingsComponent, | ||
default: {} | ||
}; | ||
return config; | ||
} | ||
|
||
public getFeatures(): Feature[] { | ||
const features: Feature[] = [ | ||
{ hotkey: Hotkey.MiscStasHighlight } | ||
]; | ||
return features; | ||
} | ||
|
||
public onKeyPressed(hotkey: Hotkey): void { | ||
switch (hotkey) { | ||
case Hotkey.MiscStasHighlight: | ||
this.miscStash.highlight().subscribe(); | ||
break; | ||
default: | ||
throw new Error(`Hotkey: '${hotkey}' out of range.`); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { NotificationService } from '@app/notification'; | ||
import { ItemClipboardResultCode, ItemClipboardService } from '@shared/module/poe/item/clipboard'; | ||
import { ItemSectionType } from '@shared/module/poe/item/clipboard/section-parser'; | ||
import { StashService } from '@shared/module/poe/stash'; | ||
import { Observable, of, throwError } from 'rxjs'; | ||
import { flatMap } from 'rxjs/operators'; | ||
|
||
@Injectable({ | ||
providedIn: 'root' | ||
}) | ||
export class MiscStashService { | ||
constructor( | ||
private readonly stash: StashService, | ||
private readonly itemClipboard: ItemClipboardService, | ||
private readonly notification: NotificationService) { } | ||
|
||
public highlight(): Observable<void> { | ||
return this.itemClipboard.copy({ | ||
[ItemSectionType.Rartiy]: true | ||
}).pipe( | ||
flatMap(({ code, item }) => { | ||
switch (code) { | ||
case ItemClipboardResultCode.Success: | ||
if (item.type?.length) { | ||
this.stash.highlight(item.type); | ||
} | ||
break; | ||
case ItemClipboardResultCode.Empty: | ||
this.notification.show('clipboard.empty'); | ||
break; | ||
case ItemClipboardResultCode.ParserError: | ||
this.notification.show('clipboard.parser-error'); | ||
break; | ||
default: | ||
return throwError(`code: '${code}' out of range`); | ||
} | ||
return of(null); | ||
}) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.