Skip to content

Commit

Permalink
fix and close #70
Browse files Browse the repository at this point in the history
  • Loading branch information
iradraconis committed Nov 11, 2024
1 parent 7813a35 commit c6c6180
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 7 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": "j-lawyer.org-Thunderbird-Extension",
"version": "1.1.2",
"version": "1.1.3",
"description": "Sendet E-Mails an einen j-lawyer.org Server",
"author": "Maximilian Steinert",
"icons": {
Expand Down
7 changes: 2 additions & 5 deletions popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,17 +215,14 @@ document.addEventListener("DOMContentLoaded", async function() {
console.log(eventCalendars);
browser.storage.local.set({ eventCalendars });
console.log("Kalender heruntergeladen: " + calendarsRaw);
});
getEmailTemplates(result.username, result.password, result.serverAddress).then(data => {
const emailTemplates = data.map((item, index) => ({ id: index + 1, name: item.name })).sort((a, b) => a.name.localeCompare(b.name));
browser.storage.local.set({ emailTemplatesNames: emailTemplates });
emailTemplates.forEach(template => console.log(`ID: ${template.id}, Name: ${template.name}`));
//save emailTemplates to storage with id and name
browser.storage.local.set({ emailTemplates });
});



});
});
getUsers(result.username, result.password, result.serverAddress).then(data => {
const users = data.map(item => item.displayName);

Expand Down
29 changes: 28 additions & 1 deletion popup_compose.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>. */}
let currentSelectedCase = null; // Speichert den aktuell ausgewählten Case
let caseFolders = {}; // Speichert die Ordner des aktuell ausgewählten Cases
let selectedCaseFolderID = null; // Speichert den aktuell ausgewählten Ordner des aktuell ausgewählten Cases

let emailTemplatesNames = {}; // Speichert die Email-Templates

document.addEventListener("DOMContentLoaded", async function() {
browser.runtime.sendMessage({
Expand Down Expand Up @@ -126,6 +126,14 @@ document.addEventListener("DOMContentLoaded", async function() {
console.log("Kalender heruntergeladen: " + calendarsRaw);

});
getEmailTemplates(result.username, result.password, result.serverAddress).then(data => {
const emailTemplates = data.map((item, index) => ({ id: index + 1, name: item.name })).sort((a, b) => a.name.localeCompare(b.name));
browser.storage.local.set({ emailTemplatesNames: emailTemplates });
emailTemplates.forEach(template => console.log(`ID: ${template.id}, Name: ${template.name}`));
//save emailTemplates to storage with id and name
browser.storage.local.set({ emailTemplates });
});

getUsers(result.username, result.password, result.serverAddress).then(data => {
const users = data.map(item => item.displayName);

Expand Down Expand Up @@ -594,4 +602,23 @@ async function getUsers(username, password, serverAddress) {
} catch (error) {
console.error('Fehler beim Abrufen der User:', error);
}
}

function getEmailTemplates(username, password, serverAddress) {
const url = serverAddress + '/j-lawyer-io/rest/v6/templates/email';

const headers = new Headers();
const loginBase64Encoded = btoa(unescape(encodeURIComponent(username + ':' + password)));
headers.append('Authorization', 'Basic ' + loginBase64Encoded);
headers.append('Content-Type', 'application/json');

return fetch(url, {
method: 'GET',
headers: headers
}).then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json();
});
}

0 comments on commit c6c6180

Please sign in to comment.