mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2024-12-23 01:20:24 +03:00
Added hability to create servers
This commit is contained in:
parent
be30d62f6f
commit
22406d1253
3 changed files with 18 additions and 13 deletions
|
@ -1,6 +1,8 @@
|
||||||
|
import { assoc } from 'ramda';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { createServer } from './reducers/server';
|
import { createServer } from './reducers/server';
|
||||||
|
import { v4 as uuid } from 'uuid';
|
||||||
|
|
||||||
import './CreateServer.scss';
|
import './CreateServer.scss';
|
||||||
|
|
||||||
|
@ -14,7 +16,9 @@ export class CreateServer extends React.Component {
|
||||||
render() {
|
render() {
|
||||||
const submit = e => {
|
const submit = e => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
this.props.createServer(this.state);
|
const server = assoc('id', uuid(), this.state);
|
||||||
|
this.props.createServer(server);
|
||||||
|
this.props.history.push(`/server/${server.id}/list-short-urls/1`)
|
||||||
};
|
};
|
||||||
const renderInputGroup = (id, placeholder, type = 'text') =>
|
const renderInputGroup = (id, placeholder, type = 'text') =>
|
||||||
<div className="form-group row">
|
<div className="form-group row">
|
||||||
|
@ -48,4 +52,4 @@ export class CreateServer extends React.Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default connect(null, { createServer })(CreateServer);
|
export default connect(state => ({ selectedServer: state.selectedServer }), { createServer })(CreateServer);
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
import Storage from '../../utils/Storage';
|
import Storage from '../../utils/Storage';
|
||||||
import { assoc } from 'ramda';
|
|
||||||
import { v4 as uuid } from 'uuid';
|
|
||||||
|
|
||||||
const SERVERS_STORAGE_KEY = 'servers';
|
const SERVERS_STORAGE_KEY = 'servers';
|
||||||
|
|
||||||
|
@ -20,7 +18,6 @@ export class ServersService {
|
||||||
|
|
||||||
createServer = server => {
|
createServer = server => {
|
||||||
const servers = this.listServers();
|
const servers = this.listServers();
|
||||||
server = assoc('id', uuid(), server);
|
|
||||||
servers[server.id] = server;
|
servers[server.id] = server;
|
||||||
this.storage.set(SERVERS_STORAGE_KEY, servers);
|
this.storage.set(SERVERS_STORAGE_KEY, servers);
|
||||||
};
|
};
|
||||||
|
|
|
@ -35,17 +35,21 @@ export class Paginator extends React.Component {
|
||||||
return (
|
return (
|
||||||
<Pagination>
|
<Pagination>
|
||||||
<PaginationItem disabled={currentPage === 1}>
|
<PaginationItem disabled={currentPage === 1}>
|
||||||
<PaginationLink previous
|
<PaginationLink
|
||||||
tag={Link}
|
previous
|
||||||
to={`/server/${serverId}/list-short-urls/${currentPage - 1}`}
|
tag={Link}
|
||||||
onClick={() => this.updatePage(currentPage - 1)} />
|
to={`/server/${serverId}/list-short-urls/${currentPage - 1}`}
|
||||||
|
onClick={() => this.updatePage(currentPage - 1)}
|
||||||
|
/>
|
||||||
</PaginationItem>
|
</PaginationItem>
|
||||||
{renderPages()}
|
{renderPages()}
|
||||||
<PaginationItem disabled={currentPage >= pagesCount}>
|
<PaginationItem disabled={currentPage >= pagesCount}>
|
||||||
<PaginationLink next
|
<PaginationLink
|
||||||
tag={Link}
|
next
|
||||||
to={`/server/${serverId}/list-short-urls/${currentPage + 1}`}
|
tag={Link}
|
||||||
onClick={() => this.updatePage(currentPage + 1)} />
|
to={`/server/${serverId}/list-short-urls/${currentPage + 1}`}
|
||||||
|
onClick={() => this.updatePage(currentPage + 1)}
|
||||||
|
/>
|
||||||
</PaginationItem>
|
</PaginationItem>
|
||||||
</Pagination>
|
</Pagination>
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue