confirm download,fixed bug

This commit is contained in:
Sukhamjot Singh 2022-09-13 23:23:00 +05:30
parent 0b54e44da3
commit 33fe35f963
7 changed files with 137 additions and 57 deletions

View File

@ -97,7 +97,15 @@ table.comments td:nth-child(2) {
table.comments tr {
height: 40px;
}
table.files th:nth-child(1) {
width: 40%;
}
table.files th:nth-child(3) {
width: 50%;
}
table.files td {
word-wrap: break-word;
}
/* #options{
width: 100px;
text-align: center;
@ -105,10 +113,10 @@ table.comments tr {
margin-left: 20px;
height: 40px;
} */
#mtags{
#mtags {
width: 160px;
text-align: center;
font-size: medium;
margin-left: 10px;
height: 40px;
}
}

View File

@ -687,6 +687,7 @@ const PostView = () => {
}
voteIdentity = ownId[0];
});
fileDown.Downloads.loadStatus(); // for retrieving downloading files.
},
view: (v) =>
m('.widget', { key: v.attrs.msgId }, [
@ -717,20 +718,54 @@ const PostView = () => {
'button',
{
style: { fontSize: '0.9em' },
onclick: async () => {
filesInfo[file.mHash]
? filesInfo[file.mHash].retval
? ''
: (await rs.rsJsonApiRequest('/rsFiles/FileRequest', {
fileName: file.mName,
hash: file.mHash,
flags: util.RS_FILE_REQ_ANONYMOUS_ROUTING,
size: {
xstr64: file.mSize.xstr64,
},
})) && m.redraw()
: '';
},
onclick: async () =>
widget.popupMessage([
m('p', 'Start Download?'),
m(
'button',
{
onclick: async () => {
if (filesInfo[file.mHash] && !filesInfo[file.mHash].retval) {
const res = await rs.rsJsonApiRequest('/rsFiles/FileRequest', {
fileName: file.mName,
hash: file.mHash,
flags: util.RS_FILE_REQ_ANONYMOUS_ROUTING,
size: {
xstr64: file.mSize.xstr64,
},
});
res.body.retval === false
? widget.popupMessage([
m('h3', 'Error'),
m('hr'),
m('p', res.body.errorMessage),
])
: widget.popupMessage([
m('h3', 'Success'),
m('hr'),
m('p', 'Download Started'),
]);
m.redraw();
}
},
},
'Start Download'
),
]),
// {
// filesInfo[file.mHash]
// ? filesInfo[file.mHash].retval
// ? ''
// : (await rs.rsJsonApiRequest('/rsFiles/FileRequest', {
// fileName: file.mName,
// hash: file.mHash,
// flags: util.RS_FILE_REQ_ANONYMOUS_ROUTING,
// size: {
// xstr64: file.mSize.xstr64,
// },
// })) && m.redraw()
// : '';
// },
},
filesInfo[file.mHash]
? filesInfo[file.mHash].retval

View File

@ -6,28 +6,16 @@ const util = require('config/config_util'); // for future use
/* eslint-disable no-unused-vars */
const SetNwMode = () => {
let mode = undefined;
let sslId = undefined;
const setMode = () => rs.rsJsonApiRequest('/');
let sslId;
return {
oninit: util.getSslId().then((val) => {
sslId = val;
rs.rsJsonApiRequest('/');
}),
oninit: async () => {
// const res = await rs.rsJsonApiRequest('/rsPeers/getOwnId');
console.log(util.getSslId());
},
view: () => [
m('p', 'Network mode:'),
m(
'select',
{
oninput: (e) => (mode = e.target.value),
value: mode,
onchange: setMode,
},
['Discovery on(recommended)', 'Discovery off'].map((val, i) =>
m('option[value=' + (i + 1) + ']', val)
)
),
],
};
};
@ -130,7 +118,7 @@ const Component = () => {
m('.grid-2col', [
m(SetLimits),
m(SetOpMode),
// m(SetNwMode),
m(SetNwMode),
]),
]),
};

View File

@ -62,4 +62,19 @@ table.myfiles th:nth-child(2) {
}
table.myfiles td:nth-child(2) {
text-align: start;
}
}
table.friendsfiles td {
word-wrap: break-word;
}
table.friendsfiles th:nth-child(1) {
width: 2%;
}
table.friendsfiles th:nth-child(2) {
width: 50%;
}
table.friendsfiles th:nth-child(4) {
width: 40%;
}
table.friendsfiles td:nth-child(2) {
text-align: start;
}

View File

@ -169,5 +169,6 @@ const Component = () => {
module.exports = {
Component,
Downloads,
list: Downloads.statusMap,
};

View File

@ -295,7 +295,7 @@ const MyFilesTable = () => {
const FriendsFilesTable = () => {
return {
view: (v) =>
m('table.myfiles', [
m('table.friendsfiles', [
m('tr', [
m('th', ''),
m('th', 'Friends Directories'),

View File

@ -1,6 +1,8 @@
const m = require('mithril');
const rs = require('rswebui');
const util = require('files/files_util');
const widget = require('widgets');
const fileDown = require('files/files_downloads');
function displayfiles() {
const childrenList = []; // stores children details
@ -75,26 +77,57 @@ function displayfiles() {
isFile &&
m(
'td',
m(
'button',
{
style: { fontSize: '0.9em' },
onclick: async () => {
haveFile
? ''
: await rs.rsJsonApiRequest('/rsFiles/FileRequest', {
fileName: parStruct.details.name,
hash: parStruct.details.hash,
flags: util.RS_FILE_REQ_ANONYMOUS_ROUTING,
size: {
xstr64: parStruct.details.size.xstr64,
},
});
},
},
// using the file from files_util to display download.
fileDown.list[parStruct.details.hash]
? m(util.File, {
info: fileDown.list[parStruct.details.hash],
direction: 'down',
transferred: fileDown.list[parStruct.details.hash].transfered.xint64,
parts: [],
})
: m(
'button',
{
style: { fontSize: '0.9em' },
onclick: async () => {
widget.popupMessage([
m('p', 'Start Download?'),
m(
'button',
{
onclick: async () => {
if (!haveFile) {
const res = await rs.rsJsonApiRequest('/rsFiles/FileRequest', {
fileName: parStruct.details.name,
hash: parStruct.details.hash,
flags: util.RS_FILE_REQ_ANONYMOUS_ROUTING,
size: {
xstr64: parStruct.details.size.xstr64,
},
});
res.body.retval === false
? widget.popupMessage([
m('h3', 'Error'),
m('hr'),
m('p', res.body.errorMessage),
])
: widget.popupMessage([
m('h3', 'Success'),
m('hr'),
m('p', 'Download Started'),
]);
m.redraw();
}
},
},
'Start Download'
),
]);
},
},
haveFile ? 'Open File' : ['Download', m('i.fas.fa-download')]
)
haveFile ? 'Open File' : ['Download', m('i.fas.fa-download')]
)
),
]),
parStruct.showChild && // recursive call to show children