Fix delete urls
This commit is contained in:
parent
fcb31bdd10
commit
e17a4bf627
5 changed files with 10 additions and 26 deletions
|
|
@ -1,7 +1,6 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/gofrs/uuid"
|
||||
"gopkg.in/mgo.v2"
|
||||
"gopkg.in/mgo.v2/bson"
|
||||
"log"
|
||||
|
|
@ -95,19 +94,6 @@ func readSpaceurl() []SpaceUrl {
|
|||
c := session.DB(config.MongoDbDatabase).C("spaceurl")
|
||||
result := []SpaceUrl{}
|
||||
c.Find(bson.M{}).Iter().All(&result)
|
||||
|
||||
for _, spaceUrl := range result {
|
||||
if spaceUrl.Id == "" {
|
||||
generatedUuid, err := uuid.NewV4()
|
||||
|
||||
if err != nil {
|
||||
log.Printf("%v", err)
|
||||
}
|
||||
spaceUrl.Id = generatedUuid.String()
|
||||
updateSpaceurl(spaceUrl)
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ class SpaceApiInput extends React.Component {
|
|||
.set('Content-Type', 'application/json')
|
||||
.end((err) => {
|
||||
if (!err) {
|
||||
this.spaceApiInput.input.value = '';
|
||||
this.spaceApiInput.value = '';
|
||||
this.setState({ open: true });
|
||||
}
|
||||
});
|
||||
|
|
@ -78,16 +78,16 @@ class SpaceApiInput extends React.Component {
|
|||
</p>
|
||||
<div style={style.formContainer}>
|
||||
<TextField
|
||||
hintText={'https://example.com/yourspaceapi.json'}
|
||||
placeholder={'https://example.com/yourspaceapi.json'}
|
||||
name={'spaceapi-input'}
|
||||
onChange={this.handleInputChange}
|
||||
ref={ref => (this.spaceApiInput = ref)}
|
||||
inputRef={ref => (this.spaceApiInput = ref)}
|
||||
style={{ width: '100%', maxWidth: '340px' }}
|
||||
/>
|
||||
<FloatingActionButton
|
||||
style={{ marginLeft: '20px' }}
|
||||
mini
|
||||
onTouchTap={this.handleButtonClick}
|
||||
onClick={this.handleButtonClick}
|
||||
>
|
||||
<ContentAdd />
|
||||
</FloatingActionButton>
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ export class UrlList extends React.Component {
|
|||
};
|
||||
|
||||
deleteSpaceUrl = (spaceUrl) => {
|
||||
this.props.deleteSpaceUrl(spaceUrl.url, this.state.secret);
|
||||
this.props.deleteSpaceUrl(spaceUrl.id, this.state.secret);
|
||||
};
|
||||
|
||||
render() {
|
||||
|
|
|
|||
|
|
@ -35,9 +35,6 @@ export const actions = {
|
|||
fetchCalendars,
|
||||
};
|
||||
|
||||
const formatDate = date => (date.format('DD.MM.YYYY'));
|
||||
const formatTime = date => (date.format('HH:mm'));
|
||||
|
||||
export default handleActions({
|
||||
[CALENDARS_FETCHED]: (state, { payload }) => {
|
||||
const items = flatten(flatten(
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import { createAction, handleActions } from 'redux-actions';
|
|||
import config from '../../api/config';
|
||||
|
||||
export const itemStruct = PropTypes.shape({
|
||||
id: PropTypes.string.isRequired,
|
||||
url: PropTypes.string.isRequired,
|
||||
validated: PropTypes.bool.isRequired,
|
||||
lastUpdated: PropTypes.number.isRequired,
|
||||
|
|
@ -47,14 +48,14 @@ export const validateSpaceUrl = (spaceUrl, secret) => (dispatch) => {
|
|||
);
|
||||
};
|
||||
|
||||
export const deleteSpaceUrl = (spaceUrl, secret) => (dispatch) => {
|
||||
export const deleteSpaceUrl = (spaceUrlId, secret) => (dispatch) => {
|
||||
request
|
||||
.delete(`${config.api.url}/urls/spaceUrl/${secret}`)
|
||||
.delete(`${config.api.url}/urls/${spaceUrlId}/${secret}`)
|
||||
.set('Content-Type', 'application/json')
|
||||
.end(
|
||||
(err) => {
|
||||
if (!err) {
|
||||
dispatch(deleteSpace(spaceUrl));
|
||||
dispatch(deleteSpace(spaceUrlId));
|
||||
}
|
||||
}
|
||||
);
|
||||
|
|
@ -83,5 +84,5 @@ export default handleActions({
|
|||
|
||||
return newState;
|
||||
},
|
||||
[SPACEURL_DELETE]: (state, { payload }) => state.items.filter(ele => ele.url != payload.url),
|
||||
[SPACEURL_DELETE]: (state, { payload }) => state.items.filter(ele => ele.id !== payload),
|
||||
}, { items: [] });
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue