feat(api): add rudimentary web control panel (#183)

This commit is contained in:
Mark Dietzer
2020-10-25 06:36:02 -07:00
committed by GitHub
parent 83f82d66d9
commit 373d1a9738
9 changed files with 395 additions and 40 deletions
+15 -24
View File
@@ -42,13 +42,10 @@ import {ProshopDE} from './proshop-de';
import {ProshopDK} from './proshop-dk';
import {Saturn} from './saturn';
import {Scan} from './scan';
import {Store} from './store';
import {Very} from './very';
import {Zotac} from './zotac';
import {config} from '../../config';
import {logger} from '../../logger';
const masterList = new Map([
export const storeList = new Map([
[Adorama.name, Adorama],
[Alternate.name, Alternate],
[AlternateNL.name, AlternateNL],
@@ -97,33 +94,27 @@ const masterList = new Map([
[Zotac.name, Zotac]
]);
const list = new Map();
for (const storeData of config.store.stores) {
if (masterList.has(storeData.name)) {
list.set(storeData.name, {...masterList.get(storeData.name), ...storeData});
} else {
const logString = `No store named ${storeData.name}, skipping.`;
logger.warn(logString);
const brands = new Set();
const series = new Set();
const models = new Set();
for (const store of storeList.values()) {
for (const link of store.links) {
brands.add(link.brand);
series.add(link.series);
models.add(link.model);
}
}
logger.info(` selected stores: ${Array.from(list.keys()).join(', ')}`);
if (config.store.showOnlyBrands.length > 0) {
logger.info(` selected brands: ${config.store.showOnlyBrands.join(', ')}`);
export function getAllBrands() {
return Array.from(brands);
}
if (config.store.showOnlyModels.length > 0) {
logger.info(` selected models: ${config.store.showOnlyModels.map(entry => {
return entry.series ? entry.name + ' (' + entry.series + ')' : entry.name;
}).join(', ')}`);
export function getAllSeries() {
return Array.from(series);
}
if (config.store.showOnlySeries.length > 0) {
logger.info(` selected series: ${config.store.showOnlySeries.join(', ')}`);
export function getAllModels() {
return Array.from(models);
}
export const Stores = Array.from(list.values()) as Store[];
export * from './store';