Skip to content

Commit

Permalink
fix quotes during import and moved the upload template button to drop…
Browse files Browse the repository at this point in the history
…down
  • Loading branch information
sadnub committed Oct 2, 2023
1 parent 817a37c commit 00b4896
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 58 deletions.
5 changes: 2 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@
"eslint.validate": ["javascript", "javascriptreact", "typescript", "vue"],
"typescript.tsdk": "node_modules/typescript/lib",
"files.watcherExclude": {
"files.watcherExclude": {
"**/.git/objects/**": true,
"**/.git/subtree-cache/**": true,
"**/node_modules/": true,
"/node_modules/**": true,
"**/env/": true,
"/env/**": true
}
}
},
"prettier.prettierPath": "./node_modules/prettier"
}
37 changes: 5 additions & 32 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 10 additions & 10 deletions src/ee/reporting/components/ReportTemplateForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ watch(
() => {
edited.value = true;
},
{ deep: true }
{ deep: true },
);

function openClosePrompt() {
Expand Down Expand Up @@ -385,15 +385,15 @@ watch(
const removed = oldArray.filter((item) => newArray.indexOf(item) == -1);
removed.forEach((item) => delete dependencies.value[item]);
}
}
},
);

// initial set of depends on options
const dependsOnOptions = ["client", "site", "agent"];

// will add any custom added depend_on options to the list
state.depends_on?.forEach((item) =>
!dependsOnOptions.includes(item) ? dependsOnOptions.push(item) : null
!dependsOnOptions.includes(item) ? dependsOnOptions.push(item) : null,
);

// the filtered list that the select uses
Expand All @@ -402,7 +402,7 @@ const dependsOnFilterOptions = ref(dependsOnOptions);
function createValue(
val: string,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
done: (val: any, mode: "add-unique" | "add" | "toggle" | undefined) => void
done: (val: any, mode: "add-unique" | "add" | "toggle" | undefined) => void,
) {
if (val.length > 0) {
if (!dependsOnOptions.includes(val)) {
Expand All @@ -419,7 +419,7 @@ function filterFn(val: string, update: (callback: () => void) => void) {
} else {
const needle = val.toLowerCase();
dependsOnFilterOptions.value = dependsOnOptions.filter(
(v) => v.toLowerCase().indexOf(needle) > -1
(v) => v.toLowerCase().indexOf(needle) > -1,
);
}
});
Expand Down Expand Up @@ -457,7 +457,7 @@ const HTMLTemplateOptions = computed<QSelectOption<number>[]>(() =>
reportHTMLTemplates.value.map((template) => ({
label: template.name,
value: template.id,
}))
})),
);

const debug = ref(false);
Expand Down Expand Up @@ -559,7 +559,7 @@ function initializeEditor() {
templateModel = monaco.editor.createModel(
state.template_md,
props.templateType,
templateUri
templateUri,
);
cssModel = monaco.editor.createModel(state.template_css, "css", cssUri);

Expand Down Expand Up @@ -590,7 +590,7 @@ function initializeEditor() {
variablesModel = monaco.editor.createModel(
state.template_variables,
"yaml",
variablesUri
variablesUri,
);
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
variablesEditor.value = monaco.editor.create(variablesDiv.value!, {
Expand All @@ -612,8 +612,8 @@ function initializeEditor() {

// make sure to put quotes around any variable values that have { or }
function wrapDoubleQuotes() {
const matchJsonCharacters = /(\b.*: *?[^\n\r])([^"].*[{}]+.*[^"])\r?$/gm;
const putDoubleQuotes = '$1"$2"';
const matchJsonCharacters = /(\b.*: *?[^\n\r])([^'].*[{}]+.*[^'])\r?$/gm;
const putDoubleQuotes = "$1'$2'";

if (matchJsonCharacters.test(state.template_variables)) {
const newText = variablesEditor.value
Expand Down
4 changes: 3 additions & 1 deletion src/ee/reporting/components/ReportTemplateImport.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ For details, see: https://license.tacticalrmm.com/ee
dense
filled
label="Import File"
style="width: 250px"
style="width: 400px"
accept=".json"
hint="Only accepts exported report template json files"
/>
</q-card-section>

Expand Down
18 changes: 6 additions & 12 deletions src/ee/reporting/components/ReportsManager.vue
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ For details, see: https://license.tacticalrmm.com/ee
<q-item-label>Html Template</q-item-label>
</q-item-section>
</q-item>

<q-item clickable v-close-popup @click="importReportTemplate">
<q-item-section>
<q-item-label>Import Report Template</q-item-label>
</q-item-section>
</q-item>
</q-list>
</q-btn-dropdown>
<q-btn
Expand Down Expand Up @@ -108,18 +114,6 @@ For details, see: https://license.tacticalrmm.com/ee
<q-icon name="search" color="primary" />
</template>
</q-input>

<q-btn icon="menu" dropdown-icon="none" dense>
<q-menu>
<q-list dense>
<q-item clickable v-close-popup @click="importReportTemplate">
<q-item-section>
<q-item-label>Import Report Template</q-item-label>
</q-item-section>
</q-item>
</q-list>
</q-menu>
</q-btn>
</template>

<template #body="props">
Expand Down

0 comments on commit 00b4896

Please sign in to comment.