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