mirror of
https://github.com/RetroShare/RSNewWebUI.git
synced 2026-09-14 11:05:47 +05:00
feat: add alert if same path is entered twice and success and failure message after adding
This commit is contained in:
parent
7e5e6e3a63
commit
54ebaf6c13
@ -5,16 +5,33 @@ const futil = require('files/files_util');
|
||||
const cutil = require('config/config_util');
|
||||
|
||||
const shareManagerInfo = `
|
||||
This is a list of shared folders. You can add and remove folders using the buttons at the bottom.
|
||||
When you add a new folder, initially all files in that folder are shared. You can separately
|
||||
share flags for each shared directory.
|
||||
`;
|
||||
This is a list of shared folders. You can add and remove folders using the buttons at the bottom.
|
||||
When you add a new folder, initially all files in that folder are shared. You can separately share
|
||||
flags for each shared directory.
|
||||
`;
|
||||
|
||||
const SharedDirectoryForm = () => {
|
||||
const accessTooltipText = `Manage Control Access for Directories, The three options are for the
|
||||
following purpose. 1. Directory can be searched anonymously, 2. Directory can be accessed
|
||||
anonymously, 3. Directory can be browsed anonymously
|
||||
`;
|
||||
|
||||
const addNewDirInfo = `For Security reasons, Browsers don't allow to read directories so Please
|
||||
copy and paste the absolute path of the directory which you want to share.
|
||||
`;
|
||||
|
||||
let sharedDirArr = [];
|
||||
|
||||
const AddSharedDirForm = () => {
|
||||
let newDirPath = '';
|
||||
|
||||
function handleSubmit(e) {
|
||||
e.preventDefault();
|
||||
// check if newDirPath already exists
|
||||
const sharedDirArrExists = sharedDirArr.find((item) => item.filename === newDirPath);
|
||||
if (sharedDirArrExists) {
|
||||
alert('The path you entered already exists.');
|
||||
return;
|
||||
}
|
||||
rs.rsJsonApiRequest('/rsFiles/addSharedDirectory', {
|
||||
dir: {
|
||||
filename: newDirPath,
|
||||
@ -22,8 +39,22 @@ const SharedDirectoryForm = () => {
|
||||
shareflags: futil.DIR_FLAGS_ANONYMOUS_SEARCH | futil.DIR_FLAGS_ANONYMOUS_DOWNLOAD,
|
||||
parent_groups: [],
|
||||
},
|
||||
}).then((res) => console.log(res));
|
||||
console.log(newDirPath);
|
||||
}).then((res) => {
|
||||
widget.popupMessage(
|
||||
m('.widget', [
|
||||
m('.widget__heading', m('h3', 'Add Shared Directory')),
|
||||
m(
|
||||
'.widget__body',
|
||||
m(
|
||||
'p',
|
||||
res.body.retval
|
||||
? 'Successfully Added Directory to Shared List'
|
||||
: 'Error in Adding Directory to Shared List'
|
||||
)
|
||||
),
|
||||
])
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
@ -31,6 +62,7 @@ const SharedDirectoryForm = () => {
|
||||
m('.widget', [
|
||||
m('.widget__heading', m('h3', 'Add New Directory')),
|
||||
m('form.widget__body.share-manager__form', { onsubmit: handleSubmit }, [
|
||||
m('blockquote.info', addNewDirInfo),
|
||||
m('.share-manager__form_input', [
|
||||
m('label', 'Enter absolute directory path :'),
|
||||
m('input[type=text]', {
|
||||
@ -44,86 +76,91 @@ const SharedDirectoryForm = () => {
|
||||
};
|
||||
};
|
||||
|
||||
const ShareDirTable = () => {
|
||||
return {
|
||||
view: (v) => {
|
||||
const { isEditDisabled } = v.attrs;
|
||||
return m('table.share-manager__table', [
|
||||
m(
|
||||
'thead.share-manager__table_heading',
|
||||
m('tr', [
|
||||
m('td', 'Shared Directories'),
|
||||
m('td', 'Visible Name'),
|
||||
m('td', 'Access', cutil.tooltip(accessTooltipText)),
|
||||
m('td', 'Visibility'),
|
||||
])
|
||||
),
|
||||
m(
|
||||
'tbody.share-manager__table_body',
|
||||
sharedDirArr.length !== 0 &&
|
||||
sharedDirArr.map((sharedDirItem) => {
|
||||
const {
|
||||
filename,
|
||||
virtualname,
|
||||
shareflags,
|
||||
parent_groups: parentGroups,
|
||||
} = sharedDirItem;
|
||||
const sharedFlags = futil.calcShareFlags(shareflags);
|
||||
return m('tr', [
|
||||
m(
|
||||
'td',
|
||||
m('input[type=text]', {
|
||||
value: filename,
|
||||
disabled: isEditDisabled,
|
||||
})
|
||||
),
|
||||
m(
|
||||
'td',
|
||||
m('input[type=text]', {
|
||||
value: virtualname,
|
||||
disabled: isEditDisabled,
|
||||
})
|
||||
),
|
||||
m(
|
||||
'td',
|
||||
Object.keys(sharedFlags).map((flag) => {
|
||||
return m('input[type=checkbox]', {
|
||||
checked: sharedFlags[flag],
|
||||
disabled: isEditDisabled,
|
||||
});
|
||||
})
|
||||
),
|
||||
m(
|
||||
'td',
|
||||
parentGroups.length === 0
|
||||
? m('td', 'All Friend nodes')
|
||||
: m(
|
||||
'td',
|
||||
sharedDirItem.parent_groups.map((group) => `${futil.RsNodeGroupId[group]},`)
|
||||
)
|
||||
),
|
||||
]);
|
||||
})
|
||||
),
|
||||
]);
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
const ShareManager = () => {
|
||||
let sharedDirArr = [];
|
||||
let isEditDisabled = true;
|
||||
return {
|
||||
oninit: () => {
|
||||
rs.rsJsonApiRequest('/rsFiles/getSharedDirectories').then(
|
||||
(res) => (sharedDirArr = res.body.dirs)
|
||||
);
|
||||
rs.rsJsonApiRequest('/rsFiles/getSharedDirectories').then((res) => {
|
||||
if (res.body.retval) sharedDirArr = res.body.dirs;
|
||||
});
|
||||
},
|
||||
view: () => {
|
||||
return m('.widget', [
|
||||
m('.widget__heading', m('h3', 'ShareManager')),
|
||||
m('.widget__body.share-manager', [
|
||||
m('blockquote.info', shareManagerInfo),
|
||||
m('table.share-manager__table', [
|
||||
m(
|
||||
'thead.share-manager__table_heading',
|
||||
m('tr', [
|
||||
m('td', 'Shared Directories'),
|
||||
m('td', 'Visible Name'),
|
||||
m(
|
||||
'td',
|
||||
'Access',
|
||||
cutil.tooltip(`Manage Control Access for Directories, The three options
|
||||
are for the following purpose. 1. Directory can be searched anonymously, 2.
|
||||
Directory can be accessed anonymously, 3. Directory can be browsed anonymously
|
||||
`)
|
||||
),
|
||||
m('td', 'Visibility'),
|
||||
])
|
||||
),
|
||||
m(
|
||||
'tbody.share-manager__table_body',
|
||||
sharedDirArr &&
|
||||
sharedDirArr.map((sharedDirItem) => {
|
||||
const sharedFlags = futil.calcShareFlags(sharedDirItem.shareflags);
|
||||
return m('tr', [
|
||||
m(
|
||||
'td',
|
||||
m('input[type=text]', {
|
||||
value: sharedDirItem.filename,
|
||||
disabled: isEditDisabled,
|
||||
})
|
||||
),
|
||||
m(
|
||||
'td',
|
||||
m('input[type=text]', {
|
||||
value: sharedDirItem.virtualname,
|
||||
disabled: isEditDisabled,
|
||||
})
|
||||
),
|
||||
m(
|
||||
'td',
|
||||
Object.keys(sharedFlags).map((flag) => {
|
||||
return m('input[type=checkbox]', {
|
||||
checked: sharedFlags[flag],
|
||||
disabled: isEditDisabled,
|
||||
});
|
||||
})
|
||||
),
|
||||
m(
|
||||
'td',
|
||||
sharedDirItem.parent_groups.length === 0
|
||||
? m('td', 'All Friend nodes')
|
||||
: m(
|
||||
'td',
|
||||
sharedDirItem.parent_groups.map(
|
||||
(group) => `${futil.RsNodeGroupId[group]},`
|
||||
)
|
||||
)
|
||||
),
|
||||
]);
|
||||
})
|
||||
),
|
||||
]),
|
||||
sharedDirArr.length !== 0 && m(ShareDirTable, { isEditDisabled }),
|
||||
m(
|
||||
'.share-manager__actions',
|
||||
m(
|
||||
'.share-manager__actions-add',
|
||||
m('button', { onclick: () => widget.popupMessage(m(SharedDirectoryForm)) }, 'Add New')
|
||||
m('button', { onclick: () => widget.popupMessage(m(AddSharedDirForm)) }, 'Add New')
|
||||
),
|
||||
m('.share-manager__actions-edit', [
|
||||
isEditDisabled && m('button', { onclick: () => (isEditDisabled = false) }, 'Edit'),
|
||||
|
||||
@ -248,8 +248,11 @@ table.friendsfiles td:nth-child(2) {
|
||||
gap: 0.5rem;
|
||||
&_input {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
input {
|
||||
flex-grow: 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,43 +1,51 @@
|
||||
/* Login */
|
||||
@use '../abstracts' as *;
|
||||
|
||||
.login-page {
|
||||
background-image: linear-gradient(-45deg, #0e76a7, #7bccff);
|
||||
background-image: linear-gradient(
|
||||
-45deg,
|
||||
transparentize($primary-color, 0.25),
|
||||
transparentize($primary-retro-color, 0.25)
|
||||
);
|
||||
height: 100%;
|
||||
animation: fadein 0.5s;
|
||||
}
|
||||
.login-container {
|
||||
background-color: white;
|
||||
box-shadow: 3px 3px 5px #444;
|
||||
margin: auto;
|
||||
position: relative;
|
||||
top: 100px;
|
||||
max-width: 400px;
|
||||
max-height: 500px;
|
||||
border-radius: 5px;
|
||||
.login-container {
|
||||
background-color: white;
|
||||
box-shadow: 3px 3px 5px transparentize($dark-color, 0.6);
|
||||
margin: auto;
|
||||
position: relative;
|
||||
top: 100px;
|
||||
max-width: 400px;
|
||||
max-height: 500px;
|
||||
border-radius: 5px;
|
||||
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
|
||||
.extra > label,
|
||||
.extra > br,
|
||||
.extra > input {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
& input {
|
||||
padding: 0.375rem 0.75rem;
|
||||
border-radius: 0.275rem;
|
||||
}
|
||||
|
||||
.login-container * {
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
.login-container > img {
|
||||
margin-top: 15px;
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
& * {
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
& > img {
|
||||
margin: 1rem 0 2rem;
|
||||
}
|
||||
& extra {
|
||||
margin: 0;
|
||||
}
|
||||
& > a {
|
||||
text-decoration: underline;
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
|
||||
.login-container extra {
|
||||
margin: 0;
|
||||
}
|
||||
.login-container > a {
|
||||
text-decoration: underline;
|
||||
cursor: pointer;
|
||||
.extra > label,
|
||||
.extra > br,
|
||||
.extra > input {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user