RootPage.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. const BasePage = require('./BasePage');
  2. const AuthorPage = require('./AuthorPage');
  3. const SeriesPage = require('./SeriesPage');
  4. const TitlePage = require('./TitlePage');
  5. const GenrePage = require('./GenrePage');
  6. class RootPage extends BasePage {
  7. constructor(config) {
  8. super(config);
  9. this.id = 'root';
  10. this.title = '';
  11. this.authorPage = new AuthorPage(config);
  12. this.seriesPage = new SeriesPage(config);
  13. this.titlePage = new TitlePage(config);
  14. this.genrePage = new GenrePage(config);
  15. }
  16. async body(req) {
  17. const result = {};
  18. if (!this.title) {
  19. const dbConfig = await this.webWorker.dbConfig();
  20. const collection = dbConfig.inpxInfo.collection.split('\n');
  21. this.title = collection[0].trim();
  22. if (!this.title)
  23. this.title = 'Неизвестная коллекция';
  24. }
  25. result.entry = [
  26. this.authorPage.myEntry(),
  27. this.seriesPage.myEntry(),
  28. this.titlePage.myEntry(),
  29. this.genrePage.myEntry(),
  30. ];
  31. return this.makeBody(result, req);
  32. }
  33. }
  34. module.exports = RootPage;