Closed minthemiddle closed 3 months ago
Copying to the clipboard works. But downloading does not. It works with the following patch when running outside of Tauri:
diff --git forkSrcPrefix/src-tauri/tauri.conf.json forkDstPrefix/src-tauri/tauri.conf.json
index 85315b752f1779bd27d6a76fc463f19187abf595..29ec53d3f1a26c1675682809e1a27c23e39f630d 100644
--- forkSrcPrefix/src-tauri/tauri.conf.json
+++ forkDstPrefix/src-tauri/tauri.conf.json
@@ -10,6 +10,9 @@
},
"tauri": {
"allowlist": {
+ "dialog": {
+ "all": true
+ },
"all": false,
"shell": {
"all": false,
diff --git forkSrcPrefix/src/index.html forkDstPrefix/src/index.html
index c8105c2984ce1047d931dbb355705933ebc07b6d..868c33599e09dc28224b1c7b747430da9687bb53 100644
--- forkSrcPrefix/src/index.html
+++ forkDstPrefix/src/index.html
@@ -105,6 +105,7 @@
+10
</button>
</div>
+ <div id="download-link-container" class="mt-4"></div>
</div>
<script>
@@ -265,14 +266,13 @@
}); // HH:mm
updateSessionWithActualEndTime(timestamp, actualEndTime);
- // Generate the iCal event and copy it to the clipboard
+ // Generate the iCal event and offer it as a download link
const iCalEvent = generateICalEvent(
this.startTime,
actualEndTime,
this.intention
);
- navigator.clipboard.writeText(iCalEvent);
- console.log("iCal event copied to clipboard:", iCalEvent);
+ createDownloadLink(iCalEvent);
this.intention = "";
},
@@ -372,6 +372,19 @@
oscillator.start(audioContext.currentTime);
oscillator.stop(audioContext.currentTime + 0.1);
}
+
+ function createDownloadLink(iCalEvent) {
+ const blob = new Blob([iCalEvent], { type: 'text/calendar' });
+ const url = URL.createObjectURL(blob);
+ const linkContainer = document.getElementById('download-link-container');
+ linkContainer.innerHTML = ''; // Clear any existing link
+ const a = document.createElement('a');
+ a.href = url;
+ a.download = 'event.ics';
+ a.textContent = 'Download iCal Event';
+ a.className = 'text-blue-500 underline';
+ linkContainer.appendChild(a);
+ }
</script>
</body>
</html>
Released with copy to clipboard only in v1.3 (this means: no download).
To enable downloading a *.ics file when you hit stop. This has start, stop date and intention. You can add to your calendar to track how you actually spent your time.