the-djmaze / snappymail

Simple, modern & fast web-based email client
https://snappymail.eu
GNU Affero General Public License v3.0
1.01k stars 121 forks source link

Show calendar content if .ics file is within attachments #592

Closed Bolli84 closed 1 year ago

Bolli84 commented 1 year ago

The putICS is already a good solution, but the information for the calendar content is missing. It would be good to create a little box in the mail content, which is showing the calendar content (Title, Timezone, Date Time) to see this content.

The box and how to render it within nextcloud is already included in: https://github.com/pierre-alain-b/rainloop-nextcloud/issues/152#issue-613532704

cal

the-djmaze commented 1 year ago

The code in that post is hardly readable. Can you use 3 backticks to properly code it?

Like:

var windowHtml = `<title>Add to Calendar</title>
<script>
var allOptions = "";
var optionString = 'option';
`;
the-djmaze commented 1 year ago

You may also modify the code, test it and then create a pull request.

See the code at https://github.com/the-djmaze/snappymail/blob/master/plugins/nextcloud/ And especially https://github.com/the-djmaze/snappymail/blob/master/plugins/nextcloud/js/message.js

Bolli84 commented 1 year ago
/*Holt sich die Dateinamen und Links aller Anhänge*/
function getFileInfo(){
    var rainloopFrame = document.getElementById("rliframe");
    var items = rainloopFrame.contentDocument.getElementsByClassName("attachmentItem");
    var names = [];
    var links = [];
    for(let i=0; i<items.length; i++){
        if (items[i].title.endsWith(".ics")){
            names.push(items[i].title);
            links.push(items[i].getElementsByTagName("a")[0].href);
          break
        }
    }
    return [names, links];
}
function getNamesString(names){
    var full="";
    for(let i=0; i<names.length; i++){
        full += names[i];
    }
    return full;
}
//duplicate to make freebusy working
function getFileInfo2() {
    var rainloopFrame = document.getElementById("rliframe");
    var items = rainloopFrame.contentDocument.getElementsByClassName("attachmentItem");
    var links = [];
    for (let i = 0; i < items.length; i++) {
        if (items[i].title.endsWith(".ics")) {
            links.push(items[i].getElementsByTagName("a")[0].href);
        }
    }
    return links;
}

//xmlhttpget but synchrone not async

// REMOVED BY DJMaze as nothing was related or working
the-djmaze commented 1 year ago

Your code is incomplete and has loads of not related code. Could you properly upload the related code as attachment?

Bolli84 commented 1 year ago

I uploaded the full file, since it was hard to remove some of the unneeded lines. But i suppose they might be needed.

The attached file contains everything now. rainloop (18).docx

the-djmaze commented 1 year ago

Thanks. I've looked at it and it can't be used. That doesn't mean that it worthless because there are some good ideas in there to write and extend/improve the current Nextcloud integration.

Bolli84 commented 1 year ago

All right. I created and used it in Rainloop and it was pretty useful there.

the-djmaze commented 1 year ago

Oh yes, it works in RainLoop.

However it relies on jQuery and SnappyMail doesn't. Also Nextcloud is slowly abandoning jQuery.

Secondly your code requires iframe mode but SnappyMail can be run without iframe to be better integrated.

So i will use your usefull code as reference to built similar features.