mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2025-12-10 14:16:59 -06:00
Consolidate all service definitions in one module
This commit is contained in:
parent
373f0dbbbb
commit
4b655761c6
@ -1,6 +0,0 @@
|
||||
import type Bottle from 'bottlejs';
|
||||
import { buildShlinkApiClient } from './ShlinkApiClientBuilder';
|
||||
|
||||
export const provideServices = (bottle: Bottle) => {
|
||||
bottle.serviceFactory('buildShlinkApiClient', buildShlinkApiClient, 'HttpClient');
|
||||
};
|
||||
@ -1,7 +0,0 @@
|
||||
import type Bottle from 'bottlejs';
|
||||
import { AppFactory } from '../App';
|
||||
|
||||
export const provideServices = (bottle: Bottle) => {
|
||||
// Components
|
||||
bottle.factory('App', AppFactory);
|
||||
};
|
||||
@ -1,18 +0,0 @@
|
||||
import { FetchHttpClient } from '@shlinkio/shlink-js-sdk/fetch';
|
||||
import type Bottle from 'bottlejs';
|
||||
import { withoutSelectedServer } from '../../servers/helpers/withoutSelectedServer';
|
||||
import { Home } from '../Home';
|
||||
import { ShlinkWebComponentContainerFactory } from '../ShlinkWebComponentContainer';
|
||||
|
||||
export const provideServices = (bottle: Bottle) => {
|
||||
// Services
|
||||
bottle.constant('window', window);
|
||||
bottle.constant('console', console);
|
||||
bottle.constant('fetch', window.fetch.bind(window));
|
||||
bottle.service('HttpClient', FetchHttpClient, 'fetch');
|
||||
|
||||
bottle.serviceFactory('Home', () => Home);
|
||||
bottle.decorator('Home', withoutSelectedServer);
|
||||
|
||||
bottle.factory('ShlinkWebComponentContainer', ShlinkWebComponentContainerFactory);
|
||||
};
|
||||
@ -1,16 +1,56 @@
|
||||
import { useTimeoutToggle } from '@shlinkio/shlink-frontend-kit';
|
||||
import { FetchHttpClient } from '@shlinkio/shlink-js-sdk/fetch';
|
||||
import Bottle from 'bottlejs';
|
||||
import { provideServices as provideApiServices } from '../api/services/provideServices';
|
||||
import { provideServices as provideAppServices } from '../app/services/provideServices';
|
||||
import { provideServices as provideCommonServices } from '../common/services/provideServices';
|
||||
import { provideServices as provideServersServices } from '../servers/services/provideServices';
|
||||
import { provideServices as provideUtilsServices } from '../utils/services/provideServices';
|
||||
import { buildShlinkApiClient } from '../api/services/ShlinkApiClientBuilder';
|
||||
import { AppFactory } from '../app/App';
|
||||
import { Home } from '../common/Home';
|
||||
import { ShlinkWebComponentContainerFactory } from '../common/ShlinkWebComponentContainer';
|
||||
import { CreateServerFactory } from '../servers/CreateServer';
|
||||
import { ImportServersBtnFactory } from '../servers/helpers/ImportServersBtn';
|
||||
import { withoutSelectedServer } from '../servers/helpers/withoutSelectedServer';
|
||||
import { ManageServersFactory } from '../servers/ManageServers';
|
||||
import { ServersExporter } from '../servers/services/ServersExporter';
|
||||
import { ServersImporter } from '../servers/services/ServersImporter';
|
||||
import { csvToJson, jsonToCsv } from '../utils/helpers/csvjson';
|
||||
import { LocalStorage } from '../utils/services/LocalStorage';
|
||||
import { TagColorsStorage } from '../utils/services/TagColorsStorage';
|
||||
|
||||
const bottle = new Bottle();
|
||||
|
||||
export const { container } = bottle;
|
||||
|
||||
provideAppServices(bottle);
|
||||
provideCommonServices(bottle);
|
||||
provideApiServices(bottle);
|
||||
provideServersServices(bottle);
|
||||
provideUtilsServices(bottle);
|
||||
bottle.constant('window', window);
|
||||
bottle.constant('console', console);
|
||||
bottle.constant('fetch', window.fetch.bind(window));
|
||||
bottle.service('HttpClient', FetchHttpClient, 'fetch');
|
||||
|
||||
bottle.constant('localStorage', window.localStorage);
|
||||
bottle.service('Storage', LocalStorage, 'localStorage');
|
||||
bottle.service('TagColorsStorage', TagColorsStorage, 'Storage');
|
||||
|
||||
bottle.constant('csvToJson', csvToJson);
|
||||
bottle.constant('jsonToCsv', jsonToCsv);
|
||||
|
||||
bottle.serviceFactory('useTimeoutToggle', () => useTimeoutToggle);
|
||||
|
||||
bottle.serviceFactory('buildShlinkApiClient', buildShlinkApiClient, 'HttpClient');
|
||||
|
||||
// Components
|
||||
bottle.factory('App', AppFactory);
|
||||
|
||||
bottle.serviceFactory('Home', () => Home);
|
||||
bottle.decorator('Home', withoutSelectedServer);
|
||||
|
||||
bottle.factory('ShlinkWebComponentContainer', ShlinkWebComponentContainerFactory);
|
||||
|
||||
bottle.factory('ManageServers', ManageServersFactory);
|
||||
bottle.decorator('ManageServers', withoutSelectedServer);
|
||||
|
||||
bottle.factory('CreateServer', CreateServerFactory);
|
||||
bottle.decorator('CreateServer', withoutSelectedServer);
|
||||
|
||||
bottle.factory('ImportServersBtn', ImportServersBtnFactory);
|
||||
|
||||
// Services
|
||||
bottle.service('ServersImporter', ServersImporter, 'csvToJson');
|
||||
bottle.service('ServersExporter', ServersExporter, 'Storage', 'window', 'jsonToCsv');
|
||||
|
||||
@ -1,22 +0,0 @@
|
||||
import type Bottle from 'bottlejs';
|
||||
import { CreateServerFactory } from '../CreateServer';
|
||||
import { ImportServersBtnFactory } from '../helpers/ImportServersBtn';
|
||||
import { withoutSelectedServer } from '../helpers/withoutSelectedServer';
|
||||
import { ManageServersFactory } from '../ManageServers';
|
||||
import { ServersExporter } from './ServersExporter';
|
||||
import { ServersImporter } from './ServersImporter';
|
||||
|
||||
export const provideServices = (bottle: Bottle) => {
|
||||
// Components
|
||||
bottle.factory('ManageServers', ManageServersFactory);
|
||||
bottle.decorator('ManageServers', withoutSelectedServer);
|
||||
|
||||
bottle.factory('CreateServer', CreateServerFactory);
|
||||
bottle.decorator('CreateServer', withoutSelectedServer);
|
||||
|
||||
bottle.factory('ImportServersBtn', ImportServersBtnFactory);
|
||||
|
||||
// Services
|
||||
bottle.service('ServersImporter', ServersImporter, 'csvToJson');
|
||||
bottle.service('ServersExporter', ServersExporter, 'Storage', 'window', 'jsonToCsv');
|
||||
};
|
||||
@ -1,16 +0,0 @@
|
||||
import { useTimeoutToggle } from '@shlinkio/shlink-frontend-kit';
|
||||
import type Bottle from 'bottlejs';
|
||||
import { csvToJson, jsonToCsv } from '../helpers/csvjson';
|
||||
import { LocalStorage } from './LocalStorage';
|
||||
import { TagColorsStorage } from './TagColorsStorage';
|
||||
|
||||
export const provideServices = (bottle: Bottle) => {
|
||||
bottle.constant('localStorage', window.localStorage);
|
||||
bottle.service('Storage', LocalStorage, 'localStorage');
|
||||
bottle.service('TagColorsStorage', TagColorsStorage, 'Storage');
|
||||
|
||||
bottle.constant('csvToJson', csvToJson);
|
||||
bottle.constant('jsonToCsv', jsonToCsv);
|
||||
|
||||
bottle.serviceFactory('useTimeoutToggle', () => useTimeoutToggle);
|
||||
};
|
||||
Loading…
x
Reference in New Issue
Block a user