Skip to content

Commit

Permalink
Working backup and restore
Browse files Browse the repository at this point in the history
  • Loading branch information
obra committed Feb 9, 2024
1 parent 4267978 commit b313598
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
4 changes: 2 additions & 2 deletions product-status.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ This is a _test release_ of the next version of Chrysalis, the graphical configu

- Device disconnect detection
- Loading "pre-configured" layouts
- Backup and restore (outside of flashing)

## What should work

Expand All @@ -15,6 +14,7 @@ This is a _test release_ of the next version of Chrysalis, the graphical configu
- Changing device settings
- Loading stock firmware
- Custom firmware updates
- Backup and restore
- Factory reset

## Device support
Expand All @@ -31,4 +31,4 @@ Chrysalis requires a browser with WebSerial support. Right now, this means Chrom

## Last Updated

Feb 5, 2024
Feb 9, 2024
22 changes: 19 additions & 3 deletions src/renderer/screens/Editor/Sidebar/LayoutSharing/ExportToFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,40 @@ import { toast } from "@renderer/components/Toast";
import jsonStringify from "json-stringify-pretty-compact";
import React from "react";
import { useTranslation } from "react-i18next";

import Focus from "@api/focus";
export const ExportToFile = (props) => {
const { t } = useTranslation();

const exportToFile = () => {
const focus = new Focus();

const exportToFile = async () => {
const { keymap, colormap } = props;
const backupData = await focus.readKeyboardConfiguration();
// delete the eeprom contents
delete backupData["eeprom.contents"];
const data = {
keymaps: keymap.custom,
colormaps: colormap.colorMap,
palette: colormap.palette,
deviceConfiguration: backupData,
};
const content = jsonStringify(data);
const blob = new Blob([content], { type: "application/json" });
const url = URL.createObjectURL(blob);

const link = document.createElement("a");
link.href = url;
link.download = "Layout.json";
const currentDate = new Date();
const year = currentDate.getFullYear();
const month = String(currentDate.getMonth() + 1).padStart(2, "0"); // Months are 0-based
const day = String(currentDate.getDate()).padStart(2, "0");
const hours = String(currentDate.getHours()).padStart(2, "0");
const minutes = String(currentDate.getMinutes()).padStart(2, "0");
const seconds = String(currentDate.getSeconds()).padStart(2, "0");

const device_name = focus.focusDeviceDescriptor.info.displayName.replace(/ /g, "-");

link.download = `Chrysalis_${device_name}_layout_${year}-${month}-${day}_${hours}-${minutes}-${seconds}.json`;
link.click();

URL.revokeObjectURL(url);
Expand Down

0 comments on commit b313598

Please sign in to comment.