mirror of
https://github.com/Lissy93/dashy.git
synced 2024-12-01 04:33:02 +03:00
⚡ Adds info log for interactive-editor to store
This commit is contained in:
parent
dcdd1018d2
commit
08072f1fb6
@ -34,9 +34,9 @@ import JsYaml from 'js-yaml';
|
||||
import Button from '@/components/FormElements/Button';
|
||||
import StoreKeys from '@/utils/StoreMutations';
|
||||
import { modalNames } from '@/utils/defaults';
|
||||
|
||||
import DownloadConfigIcon from '@/assets/interface-icons/config-download-file.svg';
|
||||
import CopyConfigIcon from '@/assets/interface-icons/interactive-editor-copy-clipboard.svg';
|
||||
import { InfoHandler } from '@/utils/ErrorHandler';
|
||||
|
||||
export default {
|
||||
name: 'ExportConfigMenu',
|
||||
@ -70,11 +70,13 @@ export default {
|
||||
document.body.appendChild(element);
|
||||
element.click();
|
||||
document.body.removeChild(element);
|
||||
InfoHandler('Config downloaded as YAML file', 'Interactive Editor');
|
||||
},
|
||||
copyConfigToClipboard() {
|
||||
const config = this.convertJsonToYaml();
|
||||
navigator.clipboard.writeText(config);
|
||||
this.$toasted.show(this.$t('config.data-copied-msg'));
|
||||
InfoHandler('Config copied to clipboard', 'Interactive Editor');
|
||||
},
|
||||
modalClosed() {
|
||||
this.$store.commit(StoreKeys.SET_MODAL_OPEN, false);
|
||||
|
18
src/store.js
18
src/store.js
@ -6,6 +6,7 @@ import ConfigAccumulator from '@/utils/ConfigAccumalator';
|
||||
import { componentVisibility } from '@/utils/ConfigHelpers';
|
||||
import { applyItemId } from '@/utils/MiscHelpers';
|
||||
import filterUserSections from '@/utils/CheckSectionVisibility';
|
||||
import { InfoHandler, InfoKeys } from '@/utils/ErrorHandler';
|
||||
|
||||
Vue.use(Vuex);
|
||||
|
||||
@ -27,6 +28,10 @@ const {
|
||||
INSERT_ITEM,
|
||||
} = Keys;
|
||||
|
||||
const editorLog = (logMessage) => {
|
||||
InfoHandler(logMessage, InfoKeys.EDITOR);
|
||||
};
|
||||
|
||||
const store = new Vuex.Store({
|
||||
state: {
|
||||
config: {},
|
||||
@ -87,7 +92,10 @@ const store = new Vuex.Store({
|
||||
state.modalOpen = modalOpen;
|
||||
},
|
||||
[SET_EDIT_MODE](state, editMode) {
|
||||
state.editMode = editMode;
|
||||
if (editMode !== state.editMode) {
|
||||
editorLog(editMode ? 'Edit session started' : 'Edit session ended');
|
||||
state.editMode = editMode;
|
||||
}
|
||||
},
|
||||
[UPDATE_ITEM](state, payload) {
|
||||
const { itemId, newItem } = payload;
|
||||
@ -96,6 +104,7 @@ const store = new Vuex.Store({
|
||||
section.items.forEach((item, itemIndex) => {
|
||||
if (item.id === itemId) {
|
||||
newConfig.sections[secIndex].items[itemIndex] = newItem;
|
||||
editorLog('Item updated');
|
||||
}
|
||||
});
|
||||
});
|
||||
@ -105,23 +114,27 @@ const store = new Vuex.Store({
|
||||
const newConfig = state.config;
|
||||
newConfig.pageInfo = newPageInfo;
|
||||
state.config = newConfig;
|
||||
editorLog('Page info updated');
|
||||
},
|
||||
[UPDATE_APP_CONFIG](state, newAppConfig) {
|
||||
const newConfig = state.config;
|
||||
newConfig.appConfig = newAppConfig;
|
||||
state.config = newConfig;
|
||||
editorLog('App config updated');
|
||||
},
|
||||
[UPDATE_SECTION](state, payload) {
|
||||
const { sectionIndex, sectionData } = payload;
|
||||
const newConfig = { ...state.config };
|
||||
newConfig.sections[sectionIndex] = sectionData;
|
||||
state.config = newConfig;
|
||||
editorLog('Section updated');
|
||||
},
|
||||
[REMOVE_SECTION](state, payload) {
|
||||
const { sectionIndex, sectionName } = payload;
|
||||
const newConfig = { ...state.config };
|
||||
if (newConfig.sections[sectionIndex].name === sectionName) {
|
||||
newConfig.sections.splice(sectionIndex, 1);
|
||||
editorLog('Section removed');
|
||||
}
|
||||
state.config = newConfig;
|
||||
},
|
||||
@ -131,6 +144,7 @@ const store = new Vuex.Store({
|
||||
config.sections.forEach((section) => {
|
||||
if (section.name === targetSection) {
|
||||
section.items.push(newItem);
|
||||
editorLog('New item added');
|
||||
}
|
||||
});
|
||||
config.sections = applyItemId(config.sections);
|
||||
@ -147,6 +161,7 @@ const store = new Vuex.Store({
|
||||
} else {
|
||||
section.items.push(newItem);
|
||||
}
|
||||
editorLog('Item copied');
|
||||
}
|
||||
});
|
||||
config.sections = applyItemId(config.sections);
|
||||
@ -160,6 +175,7 @@ const store = new Vuex.Store({
|
||||
section.items.forEach((item, index) => {
|
||||
if (item.id === itemId) {
|
||||
section.items.splice(index, 1);
|
||||
editorLog('Item removed');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -38,4 +38,9 @@ export const WarningInfoHandler = (msg, title, log) => {
|
||||
statusErrorMsg(title || 'Warning', msg, log);
|
||||
};
|
||||
|
||||
/* Titles for info logging */
|
||||
export const InfoKeys = {
|
||||
EDITOR: 'Interactive Editor',
|
||||
};
|
||||
|
||||
export default ErrorHandler;
|
||||
|
Loading…
Reference in New Issue
Block a user