Skip to content

Commit

Permalink
Merge pull request #484 from RabotaRu/v3.8.1
Browse files Browse the repository at this point in the history
V3.8.1
  • Loading branch information
rpiontik authored Jan 13, 2024
2 parents 1be913e + c13a9d0 commit c3a01ee
Show file tree
Hide file tree
Showing 9 changed files with 208 additions and 105 deletions.
Binary file not shown.
11 changes: 7 additions & 4 deletions src/frontend/components/Docs/DocMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,14 @@ export default {
created: function() {
this.$parent.$on('appendError', (error) => {
let message = (error?.message || error);
if (error.config) {
const link = error.config.url.toString();
if (error.response) {
const description = error.response?.data?.error || JSON.stringify(error.response?.data);
message = (description ? `<pre>${description}</pre>` : '') + `${message}<br><br>URL:<a href="${link}" target="_blank">${link}</a><br><br>`;
}
message = (description ? `<pre>${description}</pre>` : '');
if (error.config) {
const link = error.config.url.toString();
message += `${message}<br><br>URL:<a href="${link}" target="_blank">${link}</a><br><br>`;
}
}
this.errors.push(
{
key: Date.now(),
Expand Down
4 changes: 2 additions & 2 deletions src/frontend/components/JSONata/DevTool.vue
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,10 @@
this.doAutoExecute();
},
refreshOrigins() {
const pipe = query.expression(`(datasets.$spread().{
const pipe = query.expression(`[(datasets.$spread().{
"id": $keys()[0],
"title": *.title
})`, null, null, true, { log: this.log});
})]`, null, null, true, { log: this.log});
pipe.evaluate().then((data) => this.origins = data);
},
doAutoExecute() {
Expand Down
49 changes: 49 additions & 0 deletions src/frontend/components/JSONata/JSONataErrorExplainer.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<template>
<v-alert type="error" icon="error">
<pre class="err-exp-output" v-html="errorExplain" />
</v-alert>
</template>

<script>
export default {
name: 'JSONataErrorExplainer',
props: {
error: {
type: Object,
default: null
},
query: {
type: Object,
default: null
}
},
data() {
return {
};
},
computed: {
errorExplain() {
if (this.error) {
const pos = this.error.position;
let result = (`Error: ${this.error.message}`).replaceAll('\\n', '\n');
if (this.query) result += `\n\n${this.query.slice(0, pos)} <span style="color:red"> ${this.query.slice(pos)} </span>`;
return result;
}
return null;
}
}
};
</script>

<style>
.v-alert__content {
max-width: 100%;
}
.err-exp-output {
width: 100%;
resize: none;
padding: 0px;
overflow-y: auto;
word-wrap: break-word;
}
</style>
146 changes: 75 additions & 71 deletions src/frontend/components/Layouts/Menu.vue
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
<template>
<v-list dense class="grey lighten-4">
<v-list-item>
<v-text-field
dense
clearable
v-on:input="inputFilter">
<v-icon
slot="append">
<errexp v-if="error" v-bind:error="error" v-bind:query="queryCodeForError" />
<v-list-item v-else>
<v-text-field dense clearable v-on:input="inputFilter">
<v-icon slot="append">
mdi-magnify
</v-icon>
</v-text-field>
</v-text-field>
</v-list-item>
<template v-for="(item, i) in menu">
<v-list-item
v-if="(item.route !== '/problems') || (problems.length)"
v-bind:key="i"
v-bind:class="{ 'menu-item' : true, 'menu-item-selected': isMenuItemSelected(item) }"
v-bind:style="{'padding-left': '' + (item.level * 8) + 'px'}">
v-bind:class="{ 'menu-item': true, 'menu-item-selected': isMenuItemSelected(item) }"
v-bind:style="{ 'padding-left': '' + (item.level * 8) + 'px' }">
<v-list-item-action class="menu-item-action">
<v-icon v-if="item.isGroup" v-on:click="onClickMenuExpand(item)">
<template v-if="isExpandItem(item)">expand_more</template>
Expand All @@ -29,10 +26,7 @@
v-on:click="onClickMenuItem(item)">
{{ item.title }} ({{ problemsCount }})
</v-subheader>
<v-subheader
v-else
class="menu-item-header"
v-on:click="onClickMenuItem(item)">
<v-subheader v-else class="menu-item-header" v-on:click="onClickMenuItem(item)">
{{ item.title }}
</v-subheader>
<v-list-item-action v-if="item.icon" class="menu-item-action menu-item-ico">
Expand All @@ -47,13 +41,18 @@
import uri from '@front/helpers/uri';
import query from '@front/manifest/query';
import errexp from '@front/components/JSONata/JSONataErrorExplainer.vue';
export default {
name: 'Menu',
components: {
errexp
},
data() {
return {
// Открытые пункты меню
currentRoute: this.$router.currentRoute,
error: null,
filter: {
text: '',
query: '',
Expand All @@ -69,46 +68,52 @@
asyncComputed: {
async treeMenu() {
const result = { items: {} };
try {
const dataset = (this.menuCache ? this.menuCache : await query.expression(query.menu()).evaluate()) || [];
!this.menuCache && this.$nextTick(() => this.menuCache = dataset);
const dataset = (this.menuCache ? this.menuCache : await query.expression(query.menu()).evaluate()) || [];
!this.menuCache && this.$nextTick(() => this.menuCache = dataset);
dataset.map((item) => {
if (!this.isInFilter(item.location)) return;
const location = item.location.split('/');
let node = result;
let key = null;
for(let i = 0; i < location.length; i++) {
key = location[i];
!node.items[key] && (node.items[key] = { title: key, items: {} });
node = node.items[key];
}
node.title = item.title;
node.route = item.route;
node.icon = item.icon;
if ((node.route === this.currentRoute.fullPath) || (node.route === this.currentRoute.path)) {
this.$nextTick(() => {
let subLocation = null;
location.map((item) => {
subLocation = subLocation ? `${subLocation}/${item}` : item;
if (!this.expands[subLocation])
this.$set(this.expands, subLocation, true);
dataset.map((item) => {
if (!this.isInFilter(item.location)) return;
const location = item.location.split('/');
let node = result;
let key = null;
for (let i = 0; i < location.length; i++) {
key = location[i];
!node.items[key] && (node.items[key] = { title: key, items: {} });
node = node.items[key];
}
node.title = item.title;
node.route = item.route;
node.icon = item.icon;
if ((node.route === this.currentRoute.fullPath) || (node.route === this.currentRoute.path)) {
this.$nextTick(() => {
let subLocation = null;
location.map((item) => {
subLocation = subLocation ? `${subLocation}/${item}` : item;
if (!this.expands[subLocation])
this.$set(this.expands, subLocation, true);
});
});
});
}
});
}
});
this.error = null;
} catch (err) {
this.error = err;
}
return result;
}
},
computed: {
queryCodeForError() {
return query.menu();
},
// Выясняем сколько значимых отклонений зафиксировано
// исключения не учитываем
problemsCount() {
let result = 0;
this.problems.map((validator) => {
(validator.items || []).map((problem) =>
!problem.exception && result ++
!problem.exception && result++
);
});
return result;
Expand Down Expand Up @@ -140,9 +145,9 @@
}
}
};
this.treeMenu && expand(this.treeMenu);
return result;
}
},
Expand Down Expand Up @@ -180,7 +185,7 @@
if (struct[i] && (request.indexOf(struct[i]) < 0)) return false;
}
return true;
},
},
isMenuItemSelected(item) {
return (item.route === this.currentRoute.fullPath) || (item.route === this.currentRoute.path);
},
Expand All @@ -192,7 +197,7 @@
if (uri.isExternalURI(item.route)) {
window.open(item.route, '_blank');
} else {
this.$router.push({ path: item.route }).catch(()=> null);
this.$router.push({ path: item.route }).catch(() => null);
}
else
this.onClickMenuExpand(item);
Expand All @@ -205,34 +210,33 @@
</script>

<style scoped>
.menu-item {
min-height: 20px !important;
margin-top: 2px;
margin-bottom: 2px;
}
.menu-item-action {
padding: 0;
margin: 2px !important;
}
.menu-item {
min-height: 20px !important;
margin-top: 2px;
margin-bottom: 2px;
}
.menu-item-ico {
position: absolute;
right: 4px;
}
.menu-item-action {
padding: 0;
margin: 2px !important;
}
.menu-item-header {
line-height: 14px;
height: 32px !important;
cursor: pointer;
}
.menu-item-ico {
position: absolute;
right: 4px;
}
.menu-item-selected {
background: rgb(52, 149, 219);
}
.menu-item-header {
line-height: 14px;
height: 32px !important;
cursor: pointer;
}
.menu-item-selected * {
color: #fff !important;
}
.menu-item-selected {
background: rgb(52, 149, 219);
}
.menu-item-selected * {
color: #fff !important;
}
</style>
7 changes: 3 additions & 4 deletions src/frontend/manifest/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,9 @@ const queryDriver = {
if (env.isBackendMode() && e?.request?.response) {
const content = typeof e?.request?.response === 'object' ? e?.request?.response : JSON.parse(e?.request?.response);
message = content.message;
} else message = e.toString();
// eslint-disable-next-line no-console
console.error(message);
throw new Error(message);
console.error(message);
throw new Error(message);
} else throw e;
}
return result || def;
}
Expand Down
4 changes: 2 additions & 2 deletions src/frontend/storage/gitlab.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,6 @@ export default {
location: url
});
}
} else if (data.uri === consts.plugin.ROOT_MANIFEST || action === 'file-system') {
context.commit('setNoInited', true);
} else if (action === 'package') {
if (errors.package?.items.find(({ description }) => description === `${error.toString()}\n`)) return;
if (!errors.package) {
Expand All @@ -215,6 +213,8 @@ export default {

item.description = `${error.toString()}\n`;
errors.package.items.push(item);
} else if (data.uri === consts.plugin.ROOT_MANIFEST || action === 'file-system') {
context.commit('setNoInited', true);
} else {
const item = {
uid,
Expand Down
Loading

0 comments on commit c3a01ee

Please sign in to comment.