Skip to content

Commit

Permalink
Merge pull request #90 from RabotaRu/ex-render
Browse files Browse the repository at this point in the history
Стабилизация функционала
  • Loading branch information
rpiontik authored Sep 6, 2022
2 parents a29d2de + 09f49ec commit f3af6fb
Show file tree
Hide file tree
Showing 13 changed files with 176 additions and 58 deletions.
13 changes: 11 additions & 2 deletions src/components/Controls/Empty.vue
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
<template>
<div
style="width: 160px; height: 32px; left: 50%; top: 50%; position: absolute; margin-left: -80px; margin-top: -16px; text-align:center;">
Упс... здесь пусто :(
<template v-if="isLoading">
Вжуууух...
</template>
<template v-else>
Упс... здесь пусто :(
</template>
</div>
</template>

<script>
export default {
name: 'Empty',
data() {
return {};
},
computed: {
isLoading() {
return this.$store.state.isReloading;
}
}
};
</script>
Expand Down
3 changes: 2 additions & 1 deletion src/components/Controls/Tree.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<tree-item v-bind:items="items" />
<tree-item v-bind:expands="expands" v-bind:items="items" />
</template>

<script>
Expand All @@ -16,6 +16,7 @@
},
data() {
return {
expands: {}
};
},
computed: {
Expand Down
14 changes: 7 additions & 7 deletions src/components/Controls/TreeItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
{{ getTitleOfItem(item) }}
</template>
<template v-if="item.items && expands[item.key]">
<tree-item v-bind:items="item.items" />
<tree-item v-bind:expands="expands" v-bind:items="item.items" />
</template>
</li>
</ul>
Expand Down Expand Up @@ -46,20 +46,20 @@
}
}
},
computed: {
},
watch: {
state() {
this.$emit('input', this.state);
},
items(items) {
this.refreshExpand(items);
}
},
props: {
items: Array
items: Array,
expands: Object
},
data() {
return {
expands: {}
};
return {};
}
};
Expand Down
31 changes: 28 additions & 3 deletions src/components/Docs/DocMixin.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import datasets from '../../helpers/datasets';
import docs from '@/helpers/docs';
import gateway from '@/idea/gateway';

const SOURCE_PENGING = 'pending';
const SOURCE_READY = 'ready';
const SOURCE_ERROR = 'error';

export default {
methods: {
doRefresh() {
if (this.source.refreshTimer) clearTimeout(this.source.refreshTimer);
this.source.refreshTimer = setTimeout(() => this.refresh(), 100);
},
sourceRefresh() {
this.source.status = SOURCE_PENGING;
this.source.dataset = null;
Expand All @@ -21,6 +26,15 @@ export default {
this.source.status = SOURCE_ERROR;
});
} else this.source.dataset = {};
},
onChangeSource(data) {
if (data) {
for (const source in data) {
if (source === this.url.split('?')[0]) {
this.doRefresh();
}
}
}
}
},
computed: {
Expand Down Expand Up @@ -54,14 +68,25 @@ export default {
provider,
status: SOURCE_READY,
error: null,
dataset: null
dataset: null,
refreshTimer: null
}
};
},
watch: {
url() { this.refresh(); }
url() { this.doRefresh(); },
manifest() {
this.isTemplate && this.doRefresh();
}
},
created() {
// Следим за обновлением документа
gateway.appendListener('source/changed', this.onChangeSource);
},
destroyed() {
gateway.removeListener('source/changed', this.onChangeSource);
},
mounted() {
this.refresh();
this.doRefresh();
}
};
23 changes: 12 additions & 11 deletions src/components/Docs/DocTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,7 @@
document: { type: String, default: '' }
},
data() {
const provider = datasets();
provider.dsResolver = (id) => {
return {
subject: Object.assign({$id: id}, (this.manifest.datasets || {})[id]),
baseURI: (this.$store.state.sources.find((item) => item.path === `/datasets/${id}`) || {}).location
};
};
return {
provider,
error: null,
dataset: null,
search: ''
Expand All @@ -89,16 +81,25 @@
}
},
watch: {
document() { this.refresh(); }
document() { this.refresh(); },
manifest() { this.refresh(); }
},
mounted(){
mounted() {
this.refresh();
},
methods: {
refresh() {
this.provider.getData(this.manifest, this.docParams)
const provider = datasets();
provider.dsResolver = (id) => {
return {
subject: Object.assign({$id: id}, (this.manifest.datasets || {})[id]),
baseURI: (this.$store.state.sources.find((item) => item.path === `/datasets/${id}`) || {}).location
};
};
provider.getData(this.manifest, this.docParams)
.then((dataset) => {
this.dataset = dataset;
this.error = null;
})
.catch((e) => this.error = e);
},
Expand Down
44 changes: 33 additions & 11 deletions src/components/Root.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
id="keep"
v-bind:class="{'no-select-text': isDrawerResize}">
<v-app-bar
v-show="!isLoading"
app
clipped-left
color="#3495db"
Expand Down Expand Up @@ -42,7 +41,6 @@
-->
</v-app-bar>
<v-navigation-drawer
v-show="!isLoading"
ref="drawer"
v-model="drawer"
v-bind:width="width"
Expand All @@ -52,18 +50,20 @@
<menu-component />
</v-navigation-drawer>
<plugin-init v-if="isNotInited" />
<v-content v-else v-show="!isLoading" style="min-height:100%" class="router-view">
<v-content v-else style="min-height:100%" class="router-view">
<problems v-if="isCriticalError" />
<router-view v-else />
</v-content>
<v-progress-circular
v-show="isLoading"
v-bind:size="64"
v-bind:width="7"
style="left: 50%; top: 50%; position: absolute; margin-left: -32px; margin-top: -32px;"
v-bind:value="60"
color="primary"
indeterminate />
<template v-if="isLoading">
<div class="loading-splash" />
<v-progress-circular
class="whell"
v-bind:size="64"
v-bind:width="7"
v-bind:value="60"
color="primary"
indeterminate />
</template>
</v-app>
</template>

Expand Down Expand Up @@ -191,4 +191,26 @@
-ms-user-select: none;
}
.loading-splash {
background: #FFF;
opacity: 0.7;
z-index: 10;
position: absolute;
left: 0;
top: 0;
bottom: 0;
right: 0;
filter: blur(8px);
-webkit-filter: blur(8px);
}
.whell {
z-index: 100;
left: 50%;
top: 50vh;
position: absolute !important;
margin-left: -32px;
margin-top: -32px;
}
</style>
3 changes: 3 additions & 0 deletions src/components/Schema/Schema.vue
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@
return structure;
},
uml() {
if (!this.schema.components) return '';
let uml = '@startuml\n';
// Определяем в какой нотации будем выводить схему
Expand Down
11 changes: 7 additions & 4 deletions src/helpers/datasets.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ export default function() {
} else if (typeof data === 'string') {
// Inline запрос JSONata
if (/(\s+|)\(((.*|\d|\D)+?)(\)(\s+|))$/.test(data)) {
resolve(query.expression(data, subject).evaluate(context));
const exp = query.expression(data, subject);
exp.onError = reject;
resolve(exp.evaluate(context));
// Ссылка на файл с данными
} else if (data.slice(-5) === '.yaml' || data.slice(-5) === '.json' || (data.search(':') > 0)) {
requests.request(data)
Expand All @@ -33,10 +35,11 @@ export default function() {
} else if (data.slice(-8) === '.jsonata') {
const url = docs.urlFromProfile({source: data});
requests.request(url).then((response) => {
resolve(query.expression(typeof response.data === 'string'
const exp = query.expression(typeof response.data === 'string'
? response.data
: JSON.stringify(response.data)).evaluate(context)
, subject);
: JSON.stringify(response.data));
exp.onError = reject;
resolve(exp.evaluate(context), subject);
}).catch((e) => reject(e));
// Идентификатор источника данных
} else {
Expand Down
14 changes: 14 additions & 0 deletions src/helpers/requests.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ import axios from 'axios';
import gitlab from './gitlab';
import config from '../../config';
import YAML from 'yaml';
import crc16 from './crc16';

// CRC16 URL задействованных файлов
const tracers = {};

// Add a request interceptor

Expand Down Expand Up @@ -179,6 +182,16 @@ export default {
return result;
},

// Фиксируются все обращения для построения карты задействованных русурсов
trace(url) {
tracers[crc16(url)] = Date.now();
},

// Возвращает время последнего обращения к ресурсу
isUsedURL(url) {
return tracers[crc16(url)];
},

// axios_params - параметры передавамые в axios
// responseHook - содержит функцию обработыки ответа перед работой interceptors
// raw - если true возвращает ответ без обработки
Expand All @@ -187,6 +200,7 @@ export default {
params.source = this.makeURL(uri, baseURI);
params.url = params.source.url.toString();
if (window.$IDE_PLUGIN && params.url.split(':')[0] === 'plugin') {
this.trace(params.url);
return window.$PAPI.request(params);
} else {
return axios(params);
Expand Down
15 changes: 12 additions & 3 deletions src/helpers/rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ export default function(manifest, success, reject) {
const provider = datasets();
provider.dsResolver = (id) => {
return {
subject: (this.manifest.rules.validators || {})[id],
subject: Object.assign({_id: id}, this.manifest.rules.validators?.[id]),
baseURI: (this.$store.state.sources.find((item) => item.path === `/rules/validators/${id}`) || {}).location
};
};

provider.getData(manifest, validators[id])
provider.getData(manifest, Object.assign({_id: id}, validators[id]))
.then((items) => {
success({
id,
Expand All @@ -24,7 +24,16 @@ export default function(manifest, success, reject) {
reject(
{
id,
error
title: validators[id].title || id,
error,
items: [
{
uid: id,
title: 'Критическая ошибка валидатора!',
correction: 'Исправьте ошибку в запросе валидатора',
description: error.message
}
]
}
);
});
Expand Down
5 changes: 5 additions & 0 deletions src/idea/gateway.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,10 @@ export default {
appendListener(action, listener) {
const arr = listeners[action] = (listeners[action] || []);
arr.push(listener);
},
removeListener(action, listener) {
const arr = listeners[action] = (listeners[action] || []);
const index = arr.indexOf(listener);
if (index >=0 ) arr.splice(index, 1);
}
};
Loading

0 comments on commit f3af6fb

Please sign in to comment.