mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2025-01-03 14:57:22 +03:00
Catched error when loading servers from a servers.json file
This commit is contained in:
parent
78c34a342d
commit
4c11d9c6d5
4 changed files with 13 additions and 9 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -13,3 +13,4 @@ npm-debug.log*
|
||||||
|
|
||||||
docker-compose.override.yml
|
docker-compose.override.yml
|
||||||
home
|
home
|
||||||
|
public/servers.json*
|
||||||
|
|
|
@ -39,12 +39,13 @@ Official distributable files have been build so that they are served from the ro
|
||||||
If you need to host shlink-web-client yourself and serve it from a subpath, follow these steps:
|
If you need to host shlink-web-client yourself and serve it from a subpath, follow these steps:
|
||||||
|
|
||||||
* Download [node](https://nodejs.org/en/download/package-manager/) 10.15 or later (if you don't have it yet).
|
* Download [node](https://nodejs.org/en/download/package-manager/) 10.15 or later (if you don't have it yet).
|
||||||
* Download shlink-web-client source files for the version you want to build.
|
* Download shlink-web-client source code for the version you want to build.
|
||||||
* For example, if you want to build `v1.0.1`, use this link https://github.com/shlinkio/shlink-web-client/archive/v1.0.1.zip
|
* For example, if you want to build `v1.0.1`, use this link https://github.com/shlinkio/shlink-web-client/archive/v1.0.1.zip
|
||||||
* Replace the `v1.0.1` part in the link with the one of the version you want to build.
|
* Replace the `v1.0.1` part in the link with the one of the version you want to build.
|
||||||
* Decompress the file and `cd` into the resulting folder.
|
* Decompress the file and `cd` into the resulting folder.
|
||||||
* Install project dependencies by running `npm install`.
|
* Install project dependencies by running `npm install`.
|
||||||
* Open the `package.json` file in the root of the project, locate the `homepage` property and replace the value (which should be an empty string) by the path from which you want to serve shlink-web-client.
|
* Open the `package.json` file in the root of the project, locate the `homepage` property and replace the value (which should be an empty string) by the path from which you want to serve shlink-web-client.
|
||||||
* For example: `"homepage": "/my-projects/shlink-web-client",`.
|
* For example: `"homepage": "/my-projects/shlink-web-client",`.
|
||||||
* Build the distributable contents by running `npm run build`.
|
* Build the project:
|
||||||
* Once the command finishes, you will have a `build` folder with all the static assets you need to run shlink-web-client. Just place them wherever you want them to be served from.
|
* For a static distributable file, run `npm run build`. Once the command finishes, you will have a `build` folder with all the static assets you need to run shlink-web-client. Just place them wherever you want them to be served from.
|
||||||
|
* For a docker image, run `docker build . -t shlink-web-client`. Once the command finishes, you will have an image with the name `shlink-web-client`.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { handleActions } from 'redux-actions';
|
import { handleActions } from 'redux-actions';
|
||||||
import { pipe, isEmpty, assoc, map } from 'ramda';
|
import { pipe, isEmpty, assoc, map, prop } from 'ramda';
|
||||||
import { v4 as uuid } from 'uuid';
|
import { v4 as uuid } from 'uuid';
|
||||||
import { homepage } from '../../../package.json';
|
import { homepage } from '../../../package.json';
|
||||||
|
|
||||||
|
@ -31,11 +31,13 @@ export const listServers = ({ listServers, createServers }, { get }) => () => as
|
||||||
}
|
}
|
||||||
|
|
||||||
// If local list is empty, try to fetch it remotely and calculate IDs for every server
|
// If local list is empty, try to fetch it remotely and calculate IDs for every server
|
||||||
const { data: remoteList } = await get(`${homepage}/servers.json`);
|
const remoteList = await get(`${homepage}/servers.json`)
|
||||||
const listWithIds = map(assocId, remoteList);
|
.then(prop('data'))
|
||||||
|
.then(map(assocId))
|
||||||
|
.catch(() => []);
|
||||||
|
|
||||||
createServers(listWithIds);
|
createServers(remoteList);
|
||||||
dispatch({ type: FETCH_SERVERS, list: listWithIds.reduce((map, server) => ({ ...map, [server.id]: server }), {}) });
|
dispatch({ type: FETCH_SERVERS, list: remoteList.reduce((map, server) => ({ ...map, [server.id]: server }), {}) });
|
||||||
};
|
};
|
||||||
|
|
||||||
export const createServer = ({ createServer }, listServersAction) => pipe(createServer, listServersAction);
|
export const createServer = ({ createServer }, listServersAction) => pipe(createServer, listServersAction);
|
||||||
|
|
|
@ -52,4 +52,4 @@ export const useToggle = (initialValue = false) => {
|
||||||
return [ flag, () => setFlag(!flag) ];
|
return [ flag, () => setFlag(!flag) ];
|
||||||
};
|
};
|
||||||
|
|
||||||
export const wait = (seconds) => new Promise((resolve) => setTimeout(resolve, seconds));
|
export const wait = (milliseconds) => new Promise((resolve) => setTimeout(resolve, milliseconds));
|
||||||
|
|
Loading…
Reference in a new issue