dochub-sdk 0.1.159 → 0.1.161
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/classes/vue2/Documents.ts +19 -15
- package/package.json +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/* eslint-disable no-unused-vars */
|
|
2
2
|
import { Vue, Prop, Watch, Component } from 'vue-property-decorator';
|
|
3
|
-
import { DocHub
|
|
3
|
+
import { DocHub } from '../..';
|
|
4
|
+
import type { IDocHubEditableComponent, IDocHubPresentationProfile, IDocHubPresentationsParams } from '../..';
|
|
4
5
|
|
|
5
6
|
import ajv from 'ajv';
|
|
6
7
|
import ajv_localize from 'ajv-i18n/localize/ru';
|
|
@@ -9,7 +10,8 @@ import ajv_localize from 'ajv-i18n/localize/ru';
|
|
|
9
10
|
export class DocHubDocumentProto extends Vue implements IDocHubEditableComponent {
|
|
10
11
|
onRefresher: any = null; // Таймер отложенного выполнения обновления
|
|
11
12
|
followURI: string | null = null; // URI файла за которым установлено слежение
|
|
12
|
-
error: string | null = null; // Ошибка
|
|
13
|
+
error: string | null = null; // Ошибка
|
|
14
|
+
isPending = true; // Признак внутренней работы. Например загрузка данных.
|
|
13
15
|
|
|
14
16
|
/**
|
|
15
17
|
* Профиль документа
|
|
@@ -84,27 +86,29 @@ export class DocHubDocumentProto extends Vue implements IDocHubEditableComponent
|
|
|
84
86
|
*/
|
|
85
87
|
async doRefresh(): Promise<void> {
|
|
86
88
|
try {
|
|
89
|
+
this.isPending = true;
|
|
87
90
|
await this.refreshFileFollow();
|
|
88
91
|
if (this.profile?.source) {
|
|
89
|
-
DocHub.dataLake.pullData(this.profile.source, this.params)
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
});
|
|
92
|
+
const result = await DocHub.dataLake.pullData(this.profile.source, this.params);
|
|
93
|
+
// Валидируем данные по структуре
|
|
94
|
+
const rules = new ajv({ allErrors: true });
|
|
95
|
+
const validator = rules.compile(this.getSchemaData());
|
|
96
|
+
if (!validator(result)) {
|
|
97
|
+
ajv_localize(validator.errors);
|
|
98
|
+
this.error = JSON.stringify(validator.errors, null, 4);
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
// Если все в порядке, вызываем процессинг данных
|
|
102
|
+
this.processingData(result);
|
|
103
|
+
this.error = null;
|
|
102
104
|
} else this.processingData(undefined);
|
|
103
105
|
} catch (error) {
|
|
104
106
|
// eslint-disable-next-line no-console
|
|
105
107
|
console.error(error);
|
|
106
108
|
this.error = error;
|
|
107
109
|
this.processingData(undefined);
|
|
110
|
+
} finally {
|
|
111
|
+
this.isPending = false;
|
|
108
112
|
}
|
|
109
113
|
}
|
|
110
114
|
|