mirror of
https://github.com/muerwre/orchidmap-front.git
synced 2025-04-25 11:06:40 +07:00
save: public switch completed
This commit is contained in:
parent
b7f2c7c382
commit
4d126461ea
5 changed files with 18 additions and 12 deletions
|
@ -15,8 +15,7 @@ module.exports = async (req, res) => {
|
||||||
const logo = parseString(body.logo, 16);
|
const logo = parseString(body.logo, 16);
|
||||||
const provider = parseString(body.provider, 16) || 'DEFAULT';
|
const provider = parseString(body.provider, 16) || 'DEFAULT';
|
||||||
const distance = parseNumber(body.distance, 0, 1000);
|
const distance = parseNumber(body.distance, 0, 1000);
|
||||||
|
const is_public = !!body.is_public;
|
||||||
console.log('SAVING PROVIDER?', provider, body.provider);
|
|
||||||
|
|
||||||
if ((!route || route.length <= 0) && (!stickers || stickers.length <= 0)) {
|
if ((!route || route.length <= 0) && (!stickers || stickers.length <= 0)) {
|
||||||
return res.send({ success: false, mode: 'empty' });
|
return res.send({ success: false, mode: 'empty' });
|
||||||
|
@ -29,23 +28,23 @@ module.exports = async (req, res) => {
|
||||||
|
|
||||||
if (exists) {
|
if (exists) {
|
||||||
exists.set({
|
exists.set({
|
||||||
title, route, stickers, logo, distance, updated_at: Date.now(), provider,
|
title, route, stickers, logo, distance, updated_at: Date.now(), provider, is_public,
|
||||||
}).save();
|
}).save();
|
||||||
|
|
||||||
return res.send({
|
return res.send({
|
||||||
success: true, title, address, route, stickers, mode: 'overwrited'
|
success: true, title, address, route, stickers, mode: 'overwrited', is_public,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const created = await Route.create({
|
const created = await Route.create({
|
||||||
_id: address, title, route, stickers, owner, logo, distance, provider,
|
_id: address, title, route, stickers, owner, logo, distance, provider, is_public,
|
||||||
});
|
});
|
||||||
|
|
||||||
await owner.routes.push(created);
|
await owner.routes.push(created);
|
||||||
await owner.save();
|
await owner.save();
|
||||||
|
|
||||||
return res.send({
|
return res.send({
|
||||||
success: true, title, address, route, stickers, provider,
|
success: true, title, address, route, stickers, provider, is_public,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -134,7 +134,7 @@ export class SaveDialog extends React.Component<Props, State> {
|
||||||
<div className="button" onClick={this.onCopy}>Скопировать</div>
|
<div className="button" onClick={this.onCopy}>Скопировать</div>
|
||||||
}
|
}
|
||||||
{ save_finished &&
|
{ save_finished &&
|
||||||
<div className="button success" onClick={this.cancelSaving}>Отлично, спасибо!</div>
|
<div className="button success" onClick={this.cancelSaving}>Отлично!</div>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -17,7 +17,7 @@ import {
|
||||||
setSaveError,
|
setSaveError,
|
||||||
setSaveOverwrite, setSaveSuccess, setTitle,
|
setSaveOverwrite, setSaveSuccess, setTitle,
|
||||||
searchSetTab,
|
searchSetTab,
|
||||||
setUser, setDialog,
|
setUser, setDialog, setPublic,
|
||||||
} from '$redux/user/actions';
|
} from '$redux/user/actions';
|
||||||
import { getUrlData, parseQuery, pushLoaderState, pushNetworkInitError, pushPath, replacePath } from '$utils/history';
|
import { getUrlData, parseQuery, pushLoaderState, pushNetworkInitError, pushPath, replacePath } from '$utils/history';
|
||||||
import { editor } from '$modules/Editor';
|
import { editor } from '$modules/Editor';
|
||||||
|
@ -277,7 +277,7 @@ function* sendSaveRequestSaga({ title, address, force, is_public }) {
|
||||||
if (result && result.mode === 'exists') return yield put(setSaveError(TIPS.SAVE_EXISTS));
|
if (result && result.mode === 'exists') return yield put(setSaveError(TIPS.SAVE_EXISTS));
|
||||||
if (timeout || !result || !result.success || !result.address) return yield put(setSaveError(TIPS.SAVE_TIMED_OUT));
|
if (timeout || !result || !result.success || !result.address) return yield put(setSaveError(TIPS.SAVE_TIMED_OUT));
|
||||||
|
|
||||||
return yield put(setSaveSuccess({ address: result.address, save_error: TIPS.SAVE_SUCCESS, title }));
|
return yield put(setSaveSuccess({ address: result.address, save_error: TIPS.SAVE_SUCCESS, title, is_public: result.is_public }));
|
||||||
}
|
}
|
||||||
|
|
||||||
// function* refreshUserData() {
|
// function* refreshUserData() {
|
||||||
|
@ -478,7 +478,7 @@ function* searchSetTabSaga() {
|
||||||
yield call(searchSetSaga);
|
yield call(searchSetSaga);
|
||||||
}
|
}
|
||||||
|
|
||||||
function* setSaveSuccessSaga({ address, title }) {
|
function* setSaveSuccessSaga({ address, title, is_public }) {
|
||||||
const { id } = yield select(getUser);
|
const { id } = yield select(getUser);
|
||||||
const { dialog_active } = yield select(getState);
|
const { dialog_active } = yield select(getState);
|
||||||
|
|
||||||
|
@ -486,6 +486,7 @@ function* setSaveSuccessSaga({ address, title }) {
|
||||||
|
|
||||||
yield put(setTitle(title));
|
yield put(setTitle(title));
|
||||||
yield put(setAddress(address));
|
yield put(setAddress(address));
|
||||||
|
yield put(setPublic(is_public));
|
||||||
yield put(setChanged(false));
|
yield put(setChanged(false));
|
||||||
|
|
||||||
yield editor.owner = { id };
|
yield editor.owner = { id };
|
||||||
|
|
|
@ -359,6 +359,11 @@
|
||||||
<path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zM4 12c0-4.42 3.58-8 8-8 1.85 0 3.55.63 4.9 1.69L5.69 16.9C4.63 15.55 4 13.85 4 12zm8 8c-1.85 0-3.55-.63-4.9-1.69L18.31 7.1C19.37 8.45 20 10.15 20 12c0 4.42-3.58 8-8 8z" fill="white" stroke="none" stroke-width="0" transform="translate(4 4)"/>
|
<path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zM4 12c0-4.42 3.58-8 8-8 1.85 0 3.55.63 4.9 1.69L5.69 16.9C4.63 15.55 4 13.85 4 12zm8 8c-1.85 0-3.55-.63-4.9-1.69L18.31 7.1C19.37 8.45 20 10.15 20 12c0 4.42-3.58 8-8 8z" fill="white" stroke="none" stroke-width="0" transform="translate(4 4)"/>
|
||||||
</g>
|
</g>
|
||||||
|
|
||||||
|
<g id="icon-edit-1" stroke="none">
|
||||||
|
<path stroke="none" fill="black"/>
|
||||||
|
<path d="M14.06 9.02l.92.92L5.92 19H5v-.92l9.06-9.06M17.66 3c-.25 0-.51.1-.7.29l-1.83 1.83 3.75 3.75 1.83-1.83c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.2-.2-.45-.29-.71-.29zm-3.6 3.19L3 17.25V21h3.75L17.81 9.94l-3.75-3.75z" fill="white" stroke="none" stroke-width="0" transform="translate(4 4)"/>
|
||||||
|
</g>
|
||||||
|
|
||||||
<g id="icon-sad-1" stroke="none">
|
<g id="icon-sad-1" stroke="none">
|
||||||
<path stroke="none" fill="black"/>
|
<path stroke="none" fill="black"/>
|
||||||
<g transform="translate(4 4)">
|
<g transform="translate(4 4)">
|
||||||
|
@ -370,5 +375,5 @@
|
||||||
</svg>
|
</svg>
|
||||||
</defs>
|
</defs>
|
||||||
|
|
||||||
<use xlink:href="#icon-sad-1" />
|
<use xlink:href="#icon-edit-1" />
|
||||||
</svg>
|
</svg>
|
||||||
|
|
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 33 KiB |
|
@ -20,7 +20,7 @@ export const getStoredMap = ({ name }) => axios.get(API.GET_MAP, {
|
||||||
}).then(result => (result && result.data && result.data.success && result.data));
|
}).then(result => (result && result.data && result.data.success && result.data));
|
||||||
|
|
||||||
export const postMap = ({
|
export const postMap = ({
|
||||||
title, address, route, stickers, id, token, force, logo, distance, provider,
|
title, address, route, stickers, id, token, force, logo, distance, provider, is_public,
|
||||||
}) => axios.post(API.POST_MAP, {
|
}) => axios.post(API.POST_MAP, {
|
||||||
title,
|
title,
|
||||||
address,
|
address,
|
||||||
|
@ -32,6 +32,7 @@ export const postMap = ({
|
||||||
logo,
|
logo,
|
||||||
distance,
|
distance,
|
||||||
provider,
|
provider,
|
||||||
|
is_public,
|
||||||
}).then(result => (result && result.data && result.data));
|
}).then(result => (result && result.data && result.data));
|
||||||
|
|
||||||
export const checkIframeToken = ({ viewer_id, auth_key }) => axios.get(API.IFRAME_LOGIN_VK, {
|
export const checkIframeToken = ({ viewer_id, auth_key }) => axios.get(API.IFRAME_LOGIN_VK, {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue