HM-31. Добавлен роутинг для страниц (#9)
This commit is contained in:
28
src/app.js
28
src/app.js
@ -2,22 +2,16 @@ import './app.css';
|
||||
import 'bootstrap/dist/css/bootstrap.min.css';
|
||||
import 'bootstrap';
|
||||
|
||||
// ! TODO: 5-14 строчки удалить, после теста компонента
|
||||
import TestModal from './components/test-modal';
|
||||
import TestButton from './components/test-button';
|
||||
import TableComponent from './components/table-component';
|
||||
import storageApi from './api/StorageServiceAPI';
|
||||
import routeService from './services/RouteService';
|
||||
import routerPagesContainer from './components/router-pages-container';
|
||||
import ApiPage from './components/api-page';
|
||||
import MainPage from './components/main-page';
|
||||
|
||||
const testModal = new TestModal();
|
||||
const testButton = new TestButton();
|
||||
const initStorageListTable = async function () {
|
||||
const list = await storageApi.request();
|
||||
const storageListTable = new TableComponent();
|
||||
return storageListTable.render(list);
|
||||
};
|
||||
// Новые страницы обязательно добавляем тут
|
||||
routerPagesContainer.addRoutes([
|
||||
{url: '/', pageComponent: MainPage},
|
||||
{url: '/api', pageComponent: ApiPage},
|
||||
]);
|
||||
|
||||
initStorageListTable();
|
||||
|
||||
testButton.subscribe('click', () => {
|
||||
testModal.show();
|
||||
});
|
||||
// Этот метод генерит событие Route, чтобы все компоненты получили его после инициализации
|
||||
routeService.init();
|
||||
|
||||
Reference in New Issue
Block a user