mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-06 16:07:03 +03:00
Resolve #825
This commit is contained in:
parent
02a553c79f
commit
e95b919c1e
5 changed files with 59 additions and 39 deletions
|
|
@ -4,8 +4,8 @@ class NextcloudPlugin extends \RainLoop\Plugins\AbstractPlugin
|
||||||
{
|
{
|
||||||
const
|
const
|
||||||
NAME = 'Nextcloud',
|
NAME = 'Nextcloud',
|
||||||
VERSION = '2.13',
|
VERSION = '2.14',
|
||||||
RELEASE = '2022-12-16',
|
RELEASE = '2023-01-04',
|
||||||
CATEGORY = 'Integrations',
|
CATEGORY = 'Integrations',
|
||||||
DESCRIPTION = 'Integrate with Nextcloud v20+',
|
DESCRIPTION = 'Integrate with Nextcloud v20+',
|
||||||
REQUIRED = '2.23.0';
|
REQUIRED = '2.23.0';
|
||||||
|
|
|
||||||
|
|
@ -120,6 +120,7 @@
|
||||||
view.message.subscribe(msg => {
|
view.message.subscribe(msg => {
|
||||||
view.nextcloudICS(null);
|
view.nextcloudICS(null);
|
||||||
if (msg && cfg.CalDAV) {
|
if (msg && cfg.CalDAV) {
|
||||||
|
// let ics = msg.attachments.find(attachment => 'application/ics' == attachment.mimeType);
|
||||||
let ics = msg.attachments.find(attachment => 'text/calendar' == attachment.mimeType);
|
let ics = msg.attachments.find(attachment => 'text/calendar' == attachment.mimeType);
|
||||||
if (ics && ics.download) {
|
if (ics && ics.download) {
|
||||||
// fetch it and parse the VEVENT
|
// fetch it and parse the VEVENT
|
||||||
|
|
|
||||||
|
|
@ -149,31 +149,14 @@ const
|
||||||
items.forEach(item => {
|
items.forEach(item => {
|
||||||
if (item.isFile) {
|
if (item.isFile) {
|
||||||
let li = document.createElement('li'),
|
let li = document.createElement('li'),
|
||||||
btn = document.createElement('button');
|
cb = document.createElement('input');
|
||||||
|
|
||||||
li.item = item;
|
li.item = item;
|
||||||
li.textContent = item.name.replace(/^.*\/([^/]+)$/, '$1');
|
li.textContent = item.name.replace(/^.*\/([^/]+)$/, '$1');
|
||||||
li.dataset.icon = '🗎';
|
li.dataset.icon = '🗎';
|
||||||
|
|
||||||
btn.name = 'select';
|
cb.type = 'checkbox';
|
||||||
btn.dataset.icon = '📎';
|
li.append(cb);
|
||||||
btn.textContent = 'attach';
|
|
||||||
btn.className = 'button-vue';
|
|
||||||
li.append(btn);
|
|
||||||
|
|
||||||
btn = document.createElement('button');
|
|
||||||
btn.name = 'share-internal';
|
|
||||||
btn.dataset.icon = '🔗';
|
|
||||||
btn.textContent = 'internal';
|
|
||||||
btn.className = 'button-vue';
|
|
||||||
li.append(btn);
|
|
||||||
|
|
||||||
btn = document.createElement('button');
|
|
||||||
btn.name = 'share-public';
|
|
||||||
btn.dataset.icon = '🔗';
|
|
||||||
btn.textContent = 'public';
|
|
||||||
btn.className = 'button-vue';
|
|
||||||
li.append(btn);
|
|
||||||
|
|
||||||
parent.append(li);
|
parent.append(li);
|
||||||
}
|
}
|
||||||
|
|
@ -203,28 +186,42 @@ class NextcloudFilesPopupView extends rl.pluginPopupView {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
onBuild(dom) {
|
attach() {
|
||||||
this.tree = dom.querySelector('#sm-nc-files-tree');
|
this.select = [];
|
||||||
this.tree.addEventListener('click', event => {
|
this.tree.querySelectorAll('input').forEach(input =>
|
||||||
let el = event.target;
|
input.checked && this.select.push(input.parentNode.item)
|
||||||
if (el.matches('button')) {
|
);
|
||||||
let parent = el.parentNode,
|
this.close();
|
||||||
item = parent.item;
|
}
|
||||||
if ('select' == el.name) {
|
|
||||||
this.select = this.files() ? [item] : parent.item_name;
|
shareInternal() {
|
||||||
|
this.select = [];
|
||||||
|
this.tree.querySelectorAll('input').forEach(input =>
|
||||||
|
input.checked && this.select.push({url:generateRemoteUrl(`/f/${input.parentNode.item.id}`)})
|
||||||
|
);
|
||||||
|
this.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
sharePublic() {
|
||||||
|
const inputs = [...this.tree.querySelectorAll('input')],
|
||||||
|
loop = () => {
|
||||||
|
if (!inputs.length) {
|
||||||
this.close();
|
this.close();
|
||||||
} else if ('share-internal' == el.name) {
|
return;
|
||||||
this.select = [{url:generateRemoteUrl(`/f/${item.id}`)}];
|
}
|
||||||
this.close();
|
const input = inputs.pop();
|
||||||
} else if ('share-public' == el.name) {
|
if (!input.checked) {
|
||||||
|
loop();
|
||||||
|
} else {
|
||||||
|
const item = input.parentNode.item;
|
||||||
if (item.shared) {
|
if (item.shared) {
|
||||||
ncFetch(
|
ncFetch(
|
||||||
shareUrl() + `?format=json&path=${encodeURIComponent(item.name)}&reshares=true`
|
shareUrl() + `?format=json&path=${encodeURIComponent(item.name)}&reshares=true`
|
||||||
)
|
)
|
||||||
.then(response => (response.status < 400) ? response.json() : Promise.reject(new Error({ response })))
|
.then(response => (response.status < 400) ? response.json() : Promise.reject(new Error({ response })))
|
||||||
.then(json => {
|
.then(json => {
|
||||||
this.select = [{url:json.ocs.data[0].url}];
|
this.select.push({url:json.ocs.data[0].url});
|
||||||
this.close();
|
loop();
|
||||||
// json.data[0].password
|
// json.data[0].password
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -246,10 +243,26 @@ class NextcloudFilesPopupView extends rl.pluginPopupView {
|
||||||
.then(response => (response.status < 400) ? response.json() : Promise.reject(new Error({ response })))
|
.then(response => (response.status < 400) ? response.json() : Promise.reject(new Error({ response })))
|
||||||
.then(json => {
|
.then(json => {
|
||||||
// PUT /ocs/v2.php/apps/files_sharing/api/v1/shares/2 {"password":"ABC09"}
|
// PUT /ocs/v2.php/apps/files_sharing/api/v1/shares/2 {"password":"ABC09"}
|
||||||
this.select = [{url:json.ocs.data.url}];
|
this.select.push({url:json.ocs.data.url});
|
||||||
this.close();
|
loop();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
this.select = [];
|
||||||
|
loop();
|
||||||
|
}
|
||||||
|
|
||||||
|
onBuild(dom) {
|
||||||
|
this.tree = dom.querySelector('#sm-nc-files-tree');
|
||||||
|
this.tree.addEventListener('click', event => {
|
||||||
|
let el = event.target;
|
||||||
|
if (el.matches('button')) {
|
||||||
|
let parent = el.parentNode;
|
||||||
|
if ('select' == el.name) {
|
||||||
|
this.select = parent.item_name;
|
||||||
|
this.close();
|
||||||
} else if ('create' == el.name) {
|
} else if ('create' == el.name) {
|
||||||
let name = el.input.value.replace(/[|\\?*<":>+[]\/&\s]/g, '');
|
let name = el.input.value.replace(/[|\\?*<":>+[]\/&\s]/g, '');
|
||||||
if (name.length) {
|
if (name.length) {
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@
|
||||||
clear: right;
|
clear: right;
|
||||||
line-height: 2.5em;
|
line-height: 2.5em;
|
||||||
}
|
}
|
||||||
|
#V-PopupsNextcloudFiles li input,
|
||||||
#V-PopupsNextcloudFiles li button {
|
#V-PopupsNextcloudFiles li button {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
float: right;
|
float: right;
|
||||||
|
|
|
||||||
|
|
@ -11,3 +11,8 @@
|
||||||
-->
|
-->
|
||||||
<ul id="sm-nc-files-tree"></ul>
|
<ul id="sm-nc-files-tree"></ul>
|
||||||
</div>
|
</div>
|
||||||
|
<footer data-bind="visible:files">
|
||||||
|
<button data-bind="click:attach" name="select" data-icon="📎" class="button-vue">attach</button>
|
||||||
|
<button data-bind="click:shareInternal" name="share-internal" data-icon="🔗" class="button-vue">internal</button>
|
||||||
|
<button data-bind="click:sharePublic" name="share-public" data-icon="🔗" class="button-vue">public</button>
|
||||||
|
</footer>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue