Skip to content

Commit

Permalink
feat: display items in loots + use temp cache in mysql (#517)
Browse files Browse the repository at this point in the history
  • Loading branch information
FrancescoBorzi committed Mar 24, 2020
1 parent 8f14b67 commit 9a758f1
Show file tree
Hide file tree
Showing 69 changed files with 182 additions and 105 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class ConditionsService extends SingleRowComplexKeyEditorService<Conditio
/* istanbul ignore next */ // because of: https://github.com/gotwarlost/istanbul/issues/690
constructor(
protected handlerService: ConditionsHandlerService,
protected queryService: MysqlQueryService,
public readonly queryService: MysqlQueryService,
protected toastrService: ToastrService,
) {
super(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class CreatureEquipTemplateService extends SingleRowEditorService<Creatur
/* istanbul ignore next */ // because of: https://github.com/gotwarlost/istanbul/issues/690
constructor(
protected handlerService: CreatureHandlerService,
protected queryService: MysqlQueryService,
public readonly queryService: MysqlQueryService,
protected toastrService: ToastrService,
) {
super(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ describe('CreatureLootTemplate integration tests', () => {
queryService = TestBed.inject(MysqlQueryService);
querySpy = spyOn(queryService, 'query').and.returnValue(of());
spyOn(queryService, 'queryValue').and.returnValue(of());
const itemNamePromise = of(`MockItemName`).toPromise();
spyOn(queryService, 'getItemNameById').and.returnValue(itemNamePromise);

spyOn(queryService, 'selectAll').and.returnValue(of(
creatingNew ? [] : [originalRow0, originalRow1, originalRow2]
Expand Down Expand Up @@ -91,6 +93,13 @@ describe('CreatureLootTemplate integration tests', () => {
expect(page.getEditorTableRowsCount()).toBe(0);
});

it('should reflect the item names', async () => {
page.addNewRow();
page.detectChanges();
await page.whenReady();
expect(page.getDatatableCell(page.EDITOR_DT_SELECTOR, 0, 3).innerText).toContain('MockItemName');
});

it('adding new rows and executing the query should correctly work', () => {
const expectedQuery = 'DELETE FROM `creature_loot_template` WHERE (`Entry` = 1234) AND (`Item` IN (0, 1, 2));\n' +
'INSERT INTO `creature_loot_template` (`Entry`, `Item`, `Reference`, `Chance`, `QuestRequired`, `LootMode`, `GroupId`, ' +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class CreatureLootTemplateService extends LootEditorService<CreatureLootT
/* istanbul ignore next */ // because of: https://github.com/gotwarlost/istanbul/issues/690
constructor(
protected handlerService: CreatureHandlerService,
protected queryService: MysqlQueryService,
public readonly queryService: MysqlQueryService,
protected toastrService: ToastrService,
) {
super(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class CreatureOnkillReputationService extends SingleRowEditorService<Crea
/* istanbul ignore next */ // because of: https://github.com/gotwarlost/istanbul/issues/690
constructor(
protected handlerService: CreatureHandlerService,
protected queryService: MysqlQueryService,
public readonly queryService: MysqlQueryService,
protected toastrService: ToastrService,
) {
super(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class CreatureQuestitemService extends MultiRowEditorService<CreatureQues
/* istanbul ignore next */ // because of: https://github.com/gotwarlost/istanbul/issues/690
constructor(
protected handlerService: CreatureHandlerService,
protected queryService: MysqlQueryService,
public readonly queryService: MysqlQueryService,
protected toastrService: ToastrService,
) {
super(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class CreatureSpawnAddonService extends MultiRowExternalEditorService<Cre
/* istanbul ignore next */ // because of: https://github.com/gotwarlost/istanbul/issues/690
constructor(
protected handlerService: CreatureHandlerService,
protected queryService: MysqlQueryService,
public readonly queryService: MysqlQueryService,
protected toastrService: ToastrService,
) {
super(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class CreatureSpawnService extends MultiRowEditorService<CreatureSpawn> {
/* istanbul ignore next */ // because of: https://github.com/gotwarlost/istanbul/issues/690
constructor(
protected handlerService: CreatureHandlerService,
protected queryService: MysqlQueryService,
public readonly queryService: MysqlQueryService,
protected toastrService: ToastrService,
) {
super(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class CreatureTemplateAddonService extends SingleRowEditorService<Creatur
/* istanbul ignore next */ // because of: https://github.com/gotwarlost/istanbul/issues/690
constructor(
protected handlerService: CreatureHandlerService,
protected queryService: MysqlQueryService,
public readonly queryService: MysqlQueryService,
protected toastrService: ToastrService,
) {
super(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class CreatureTemplateService extends SingleRowEditorService<CreatureTemp
/* istanbul ignore next */ // because of: https://github.com/gotwarlost/istanbul/issues/690
constructor(
protected handlerService: CreatureHandlerService,
protected queryService: MysqlQueryService,
public readonly queryService: MysqlQueryService,
protected toastrService: ToastrService,
) {
super(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class NpcTrainerService extends MultiRowEditorService<NpcTrainer> {
/* istanbul ignore next */ // because of: https://github.com/gotwarlost/istanbul/issues/690
constructor(
protected handlerService: CreatureHandlerService,
protected queryService: MysqlQueryService,
public readonly queryService: MysqlQueryService,
protected toastrService: ToastrService,
) {
super(
Expand Down
2 changes: 1 addition & 1 deletion src/app/features/creature/npc-vendor/npc-vendor.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class NpcVendorService extends MultiRowEditorService<NpcVendor> {
/* istanbul ignore next */ // because of: https://github.com/gotwarlost/istanbul/issues/690
constructor(
protected handlerService: CreatureHandlerService,
protected queryService: MysqlQueryService,
public readonly queryService: MysqlQueryService,
protected toastrService: ToastrService,
) {
super(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class PickpocketingLootTemplateService extends LootEditorService<Pickpock
/* istanbul ignore next */ // because of: https://github.com/gotwarlost/istanbul/issues/690
constructor(
protected handlerService: CreatureHandlerService,
protected queryService: MysqlQueryService,
public readonly queryService: MysqlQueryService,
protected toastrService: ToastrService,
) {
super(
Expand Down
2 changes: 1 addition & 1 deletion src/app/features/creature/sai-creature-handler.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export class SaiCreatureHandlerService extends SaiHandlerService {
/* istanbul ignore next */ // because of: https://github.com/gotwarlost/istanbul/issues/690
constructor(
protected router: Router,
protected queryService: MysqlQueryService,
public readonly queryService: MysqlQueryService,
) {
super(
router,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { SaiCommentGeneratorService } from '@keira-shared/modules/sai-editor/sai
export class SaiCreatureEditorService extends SaiEditorService {
constructor(
protected handlerService: SaiCreatureHandlerService,
protected queryService: MysqlQueryService,
public readonly queryService: MysqlQueryService,
protected toastrService: ToastrService,
protected saiCommentGeneratorService: SaiCommentGeneratorService,
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { CreatureHandlerService } from '../creature-handler.service';
export class SelectCreatureService extends SelectService<CreatureTemplate> {
/* istanbul ignore next */ // because of: https://github.com/gotwarlost/istanbul/issues/690
constructor(
protected queryService: MysqlQueryService,
public readonly queryService: MysqlQueryService,
public handlerService: CreatureHandlerService,
) {
super(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class SkinningLootTemplateService extends LootEditorService<SkinningLootT
/* istanbul ignore next */ // because of: https://github.com/gotwarlost/istanbul/issues/690
constructor(
protected handlerService: CreatureHandlerService,
protected queryService: MysqlQueryService,
public readonly queryService: MysqlQueryService,
protected toastrService: ToastrService,
) {
super(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,11 @@
</ng-template>
</ngx-datatable-column>
<ngx-datatable-column name="Item" prop="Item" [minWidth]="80"></ngx-datatable-column>
<ngx-datatable-column name="Name" [minWidth]="200">
<ng-template let-row="row" ngx-datatable-cell-template>
{{ editorService.queryService.getItemNameById(row.Item) | async }}
</ng-template>
</ngx-datatable-column>
<ngx-datatable-column name="Reference" prop="Reference"></ngx-datatable-column>
<ngx-datatable-column name="Chance" prop="Chance"></ngx-datatable-column>
<ngx-datatable-column name="QuestRequired" prop="QuestRequired"></ngx-datatable-column>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export class GameobjectLootTemplateComponent extends LootTemplateComponent<Gameo
}

ngOnInit() {
this.editorService.clearCache();
this.checkTemplateType();
this.checkTemplateLootId();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class GameobjectLootTemplateService extends LootEditorService<GameobjectL
/* istanbul ignore next */ // because of: https://github.com/gotwarlost/istanbul/issues/690
constructor(
protected handlerService: GameobjectHandlerService,
protected queryService: MysqlQueryService,
public readonly queryService: MysqlQueryService,
protected toastrService: ToastrService,
) {
super(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class GameobjectQuestitemService extends MultiRowEditorService<Gameobject
/* istanbul ignore next */ // because of: https://github.com/gotwarlost/istanbul/issues/690
constructor(
protected handlerService: GameobjectHandlerService,
protected queryService: MysqlQueryService,
public readonly queryService: MysqlQueryService,
protected toastrService: ToastrService,
) {
super(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class GameobjectSpawnService extends MultiRowEditorService<GameobjectSpaw
/* istanbul ignore next */ // because of: https://github.com/gotwarlost/istanbul/issues/690
constructor(
protected handlerService: GameobjectHandlerService,
protected queryService: MysqlQueryService,
public readonly queryService: MysqlQueryService,
protected toastrService: ToastrService,
) {
super(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class GameobjectTemplateAddonService extends SingleRowEditorService<Gameo
/* istanbul ignore next */ // because of: https://github.com/gotwarlost/istanbul/issues/690
constructor(
protected handlerService: GameobjectHandlerService,
protected queryService: MysqlQueryService,
public readonly queryService: MysqlQueryService,
protected toastrService: ToastrService,
) {
super(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class GameobjectTemplateService extends SingleRowEditorService<Gameobject
/* istanbul ignore next */ // because of: https://github.com/gotwarlost/istanbul/issues/690
constructor(
protected handlerService: GameobjectHandlerService,
protected queryService: MysqlQueryService,
public readonly queryService: MysqlQueryService,
protected toastrService: ToastrService,
) {
super(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export class SaiGameobjectHandlerService extends SaiHandlerService {
/* istanbul ignore next */ // because of: https://github.com/gotwarlost/istanbul/issues/690
constructor(
protected router: Router,
protected queryService: MysqlQueryService,
public readonly queryService: MysqlQueryService,
) {
super(
router,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { SaiCommentGeneratorService } from '@keira-shared/modules/sai-editor/sai
export class SaiGameobjectEditorService extends SaiEditorService {
constructor(
protected handlerService: SaiGameobjectHandlerService,
protected queryService: MysqlQueryService,
public readonly queryService: MysqlQueryService,
protected toastrService: ToastrService,
protected saiCommentGeneratorService: SaiCommentGeneratorService,
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { GameobjectHandlerService } from '../gameobject-handler.service';
export class SelectGameobjectService extends SelectService<GameobjectTemplate> {
/* istanbul ignore next */ // because of: https://github.com/gotwarlost/istanbul/issues/690
constructor(
protected queryService: MysqlQueryService,
public readonly queryService: MysqlQueryService,
public handlerService: GameobjectHandlerService,
) {
super(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class GossipMenuOptionService extends MultiRowEditorService<GossipMenuOpt
/* istanbul ignore next */ // because of: https://github.com/gotwarlost/istanbul/issues/690
constructor(
protected handlerService: GossipHandlerService,
protected queryService: MysqlQueryService,
public readonly queryService: MysqlQueryService,
protected toastrService: ToastrService,
) {
super(
Expand Down
2 changes: 1 addition & 1 deletion src/app/features/gossip/gossip-menu/gossip-menu.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class GossipMenuService extends MultiRowEditorService<GossipMenu> {
/* istanbul ignore next */ // because of: https://github.com/gotwarlost/istanbul/issues/690
constructor(
protected handlerService: GossipHandlerService,
protected queryService: MysqlQueryService,
public readonly queryService: MysqlQueryService,
protected toastrService: ToastrService,
) {
super(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { GossipHandlerService } from '../gossip-handler.service';
export class SelectGossipService extends SelectService<GossipMenu> {
/* istanbul ignore next */ // because of: https://github.com/gotwarlost/istanbul/issues/690
constructor(
protected queryService: MysqlQueryService,
public readonly queryService: MysqlQueryService,
public handlerService: GossipHandlerService,
) {
super(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class DisenchantLootTemplateService extends LootEditorService<DisenchantL
/* istanbul ignore next */ // because of: https://github.com/gotwarlost/istanbul/issues/690
constructor(
protected handlerService: ItemHandlerService,
protected queryService: MysqlQueryService,
public readonly queryService: MysqlQueryService,
protected toastrService: ToastrService,
) {
super(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class ItemEnchantmentTemplateService extends MultiRowEditorService<ItemEn
/* istanbul ignore next */ // because of: https://github.com/gotwarlost/istanbul/issues/690
constructor(
protected handlerService: ItemHandlerService,
protected queryService: MysqlQueryService,
public readonly queryService: MysqlQueryService,
protected toastrService: ToastrService,
) {
super(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,11 @@
</ng-template>
</ngx-datatable-column>
<ngx-datatable-column name="Item" prop="Item" [minWidth]="80"></ngx-datatable-column>
<ngx-datatable-column name="Name" [minWidth]="200">
<ng-template let-row="row" ngx-datatable-cell-template>
{{ editorService.queryService.getItemNameById(row.Item) | async }}
</ng-template>
</ngx-datatable-column>
<ngx-datatable-column name="Reference" prop="Reference"></ngx-datatable-column>
<ngx-datatable-column name="Chance" prop="Chance"></ngx-datatable-column>
<ngx-datatable-column name="QuestRequired" prop="QuestRequired"></ngx-datatable-column>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class ItemLootTemplateService extends MultiRowEditorService<ItemLootTempl
/* istanbul ignore next */ // because of: https://github.com/gotwarlost/istanbul/issues/690
constructor(
protected handlerService: ItemHandlerService,
protected queryService: MysqlQueryService,
public readonly queryService: MysqlQueryService,
protected toastrService: ToastrService,
) {
super(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class ItemTemplateService extends SingleRowEditorService<ItemTemplate> {
/* istanbul ignore next */ // because of: https://github.com/gotwarlost/istanbul/issues/690
constructor(
protected handlerService: ItemHandlerService,
protected queryService: MysqlQueryService,
public readonly queryService: MysqlQueryService,
protected toastrService: ToastrService,
) {
super(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class MillingLootTemplateService extends MultiRowEditorService<MillingLoo
/* istanbul ignore next */ // because of: https://github.com/gotwarlost/istanbul/issues/690
constructor(
protected handlerService: ItemHandlerService,
protected queryService: MysqlQueryService,
public readonly queryService: MysqlQueryService,
protected toastrService: ToastrService,
) {
super(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class ProspectingLootTemplateService extends MultiRowEditorService<Prospe
/* istanbul ignore next */ // because of: https://github.com/gotwarlost/istanbul/issues/690
constructor(
protected handlerService: ItemHandlerService,
protected queryService: MysqlQueryService,
public readonly queryService: MysqlQueryService,
protected toastrService: ToastrService,
) {
super(
Expand Down
2 changes: 1 addition & 1 deletion src/app/features/item/select-item/select-item.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { IconService } from '@keira-shared/modules/icon/icon.service';
export class SelectItemService extends SelectService<ItemTemplate> {
/* istanbul ignore next */ // because of: https://github.com/gotwarlost/istanbul/issues/690
constructor(
protected queryService: MysqlQueryService,
public readonly queryService: MysqlQueryService,
public handlerService: ItemHandlerService,
private itemIconService: IconService,
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class CreatureQuestenderService extends MultiRowEditorService<CreatureQue
/* istanbul ignore next */ // because of: https://github.com/gotwarlost/istanbul/issues/690
constructor(
protected handlerService: QuestHandlerService,
protected queryService: MysqlQueryService,
public readonly queryService: MysqlQueryService,
protected toastrService: ToastrService,
) {
super(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class CreatureQueststarterService extends MultiRowEditorService<CreatureQ
/* istanbul ignore next */ // because of: https://github.com/gotwarlost/istanbul/issues/690
constructor(
protected handlerService: QuestHandlerService,
protected queryService: MysqlQueryService,
public readonly queryService: MysqlQueryService,
protected toastrService: ToastrService,
) {
super(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class GameobjectQuestenderService extends MultiRowEditorService<Gameobjec
/* istanbul ignore next */ // because of: https://github.com/gotwarlost/istanbul/issues/690
constructor(
protected handlerService: QuestHandlerService,
protected queryService: MysqlQueryService,
public readonly queryService: MysqlQueryService,
protected toastrService: ToastrService,
) {
super(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class GameobjectQueststarterService extends MultiRowEditorService<Gameobj
/* istanbul ignore next */ // because of: https://github.com/gotwarlost/istanbul/issues/690
constructor(
protected handlerService: QuestHandlerService,
protected queryService: MysqlQueryService,
public readonly queryService: MysqlQueryService,
protected toastrService: ToastrService,
) {
super(
Expand Down
Loading

0 comments on commit 9a758f1

Please sign in to comment.