mirror of
https://gitlab.com/ryzen-controller-team/ryzen-controller.git
synced 2024-12-22 10:03:28 +07:00
See #19 Import Export presets v1.
This commit is contained in:
parent
72ee5c1b53
commit
81572aa960
38
index.html
38
index.html
@ -161,7 +161,17 @@
|
||||
</p>
|
||||
</li>
|
||||
|
||||
<li class="uk-margin-top uk-margin-bottom uk-container" id="presetTab"></li>
|
||||
<li class="uk-margin-top uk-margin-bottom uk-container">
|
||||
<div id="presetTab"></div>
|
||||
<p class="uk-margin">
|
||||
<button class="uk-button uk-button-secondary" uk-toggle="target: #modal-export-preset" type="button" onClick="preset_export()">
|
||||
Export
|
||||
</button>
|
||||
<button class="uk-button uk-button-secondary" uk-toggle="target: #modal-import-preset" type="button">
|
||||
Import
|
||||
</button>
|
||||
</p>
|
||||
</li>
|
||||
|
||||
<li class="uk-margin-top uk-margin-bottom uk-container">
|
||||
<!-- <h3>Auto start with system:</h3> -->
|
||||
@ -232,6 +242,32 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Export preset modal -->
|
||||
<div id="modal-export-preset" uk-modal>
|
||||
<div class="uk-modal-dialog uk-modal-body">
|
||||
<h2 class="uk-modal-title">Export presets</h2>
|
||||
<p>This is the data to be used by Ryzen Controller to import presets.</p>
|
||||
<div class="uk-margin">
|
||||
<textarea class="uk-textarea" rows="5" id="modal-export-preset-textarea" readonly></textarea>
|
||||
</div>
|
||||
<button class="uk-button uk-button-secondary uk-modal-close" type="button">Close</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Import preset modal -->
|
||||
<div id="modal-import-preset" uk-modal>
|
||||
<div class="uk-modal-dialog uk-modal-body">
|
||||
<h2 class="uk-modal-title">Import presets</h2>
|
||||
<p>Paste here the presets and valid, your current presets will be merged with this.</p>
|
||||
<div class="uk-margin">
|
||||
<textarea class="uk-textarea" rows="5" id="modal-import-preset-textarea"></textarea>
|
||||
</div>
|
||||
<button class="uk-button uk-button-primary uk-modal-close" type="button" onClick="preset_import()">Import</button>
|
||||
<button class="uk-button uk-button-secondary uk-modal-close" type="button">Close</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript" src="./js/preset.js"></script>
|
||||
<script type="text/javascript" src="./js/methods.js"></script>
|
||||
<script type="text/javascript" src="./js/app.js"></script>
|
||||
</body>
|
||||
|
@ -516,13 +516,13 @@ function updatePresetList() {
|
||||
content += `
|
||||
<li class="uk-margin">
|
||||
<span class="uk-text-lead">${presetName}</span>
|
||||
<i class="uk-text-small">${valueSummary}</i>
|
||||
<button class="uk-button uk-button-danger uk-align-right" type="button" onClick="presetDeletion('${presetName}')">
|
||||
Delete
|
||||
</button>
|
||||
<button class="uk-button uk-button-primary uk-align-right" type="button" onClick="applyPreset('${presetName}')">
|
||||
Apply
|
||||
</button>
|
||||
<i class="uk-text-small">${valueSummary}</i>
|
||||
</li>
|
||||
`;
|
||||
}
|
||||
|
32
js/preset.js
Normal file
32
js/preset.js
Normal file
@ -0,0 +1,32 @@
|
||||
function preset_export() {
|
||||
const modalTextArea = document.getElementById('modal-export-preset-textarea');
|
||||
const settings = require('electron-settings');
|
||||
var presets = settings.get('presets');
|
||||
|
||||
presets = JSON.stringify(presets);
|
||||
modalTextArea.innerHTML = btoa(presets);
|
||||
}
|
||||
|
||||
function preset_import() {
|
||||
const modalTextArea = document.getElementById('modal-import-preset-textarea');
|
||||
const settings = require('electron-settings');
|
||||
var currentPresets = settings.get('presets');
|
||||
var presetsToBeImported = atob(modalTextArea.value);
|
||||
|
||||
try {
|
||||
presetsToBeImported = JSON.parse(presetsToBeImported);
|
||||
} catch (e) {
|
||||
notification('danger', 'Unable to import presets, malformed data.');
|
||||
console.error(e);
|
||||
return;
|
||||
}
|
||||
|
||||
var updatedPresets = Object.assign(
|
||||
{},
|
||||
currentPresets,
|
||||
presetsToBeImported
|
||||
);
|
||||
settings.set('presets', updatedPresets);
|
||||
updatePresetList();
|
||||
modalTextArea.innerText = '';
|
||||
}
|
Loading…
Reference in New Issue
Block a user