@tekkare/auriga 0.2.156 → 0.2.160
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/dist/module.json
CHANGED
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div v-if="!isLoadingQuery && sourceResults" class="oip_body oip_list gap-12">
|
|
3
|
+
<ArgSourceCollapse
|
|
4
|
+
v-for="(uuid, index) in uuids"
|
|
5
|
+
:key="index"
|
|
6
|
+
:source-country="
|
|
7
|
+
sourceResults?.find(
|
|
8
|
+
(x) =>
|
|
9
|
+
x.provider_uuid == uuid ||
|
|
10
|
+
x?.sources?.some((y) => y?.source_id === uuid)
|
|
11
|
+
)?.country_label
|
|
12
|
+
"
|
|
13
|
+
:source-id="uuid"
|
|
14
|
+
:source-title="constructTitle(uuid)"
|
|
15
|
+
>
|
|
16
|
+
<div class="oip_list gap-24">
|
|
17
|
+
<div class="oip_row v-center gap-24">
|
|
18
|
+
<div>
|
|
19
|
+
<p class="oip_filter_label">Last Update :</p>
|
|
20
|
+
{{ getLastUpdate(uuid)?.update }}
|
|
21
|
+
</div>
|
|
22
|
+
|
|
23
|
+
<div>
|
|
24
|
+
<p class="oip_filter_label">Update Frequency :</p>
|
|
25
|
+
{{ getLastUpdate(uuid)?.frequency }}
|
|
26
|
+
</div>
|
|
27
|
+
</div>
|
|
28
|
+
<div class="oip_list gap-8">
|
|
29
|
+
<p class="small_heading">About the provider</p>
|
|
30
|
+
<p v-html="getDescriptions(uuid).provider" />
|
|
31
|
+
</div>
|
|
32
|
+
<div class="oip_list gap-8">
|
|
33
|
+
<p class="small_heading">About the source</p>
|
|
34
|
+
<p v-html="getDescriptions(uuid).source" />
|
|
35
|
+
</div>
|
|
36
|
+
</div>
|
|
37
|
+
</ArgSourceCollapse>
|
|
38
|
+
</div>
|
|
39
|
+
<div v-else class="oip_body oip_list gap-12">
|
|
40
|
+
<div v-for="i in 3" :key="i" class="oneLoader" />
|
|
41
|
+
</div>
|
|
42
|
+
</template>
|
|
43
|
+
|
|
44
|
+
<script>
|
|
45
|
+
import { onMounted, ref, watch, defineComponent } from "vue";
|
|
46
|
+
import ArgSourceCollapse from "./argSourceCollapse.vue";
|
|
47
|
+
export default defineComponent({
|
|
48
|
+
name: "argSourcesElastic",
|
|
49
|
+
components: { ArgSourceCollapse },
|
|
50
|
+
props: {
|
|
51
|
+
fields: { type: Array },
|
|
52
|
+
uuids: { type: Array },
|
|
53
|
+
index: { type: String },
|
|
54
|
+
authKey: { type: String },
|
|
55
|
+
cluster: { type: String, default: "new" }
|
|
56
|
+
},
|
|
57
|
+
emits: ["updateSources"],
|
|
58
|
+
setup(props, { emit }) {
|
|
59
|
+
const sourceResults = ref(null);
|
|
60
|
+
const isLoadingQuery = ref(false);
|
|
61
|
+
function constructTitle(uuid) {
|
|
62
|
+
const provider = sourceResults.value.find(
|
|
63
|
+
(x) => x.provider_uuid === uuid || x?.sources?.some((y) => y?.source_id === uuid)
|
|
64
|
+
);
|
|
65
|
+
const source = provider?.sources?.find((x) => x.source_id === uuid);
|
|
66
|
+
return `${provider?.provider_title} - ${source?.source_nickname}`;
|
|
67
|
+
}
|
|
68
|
+
function getDescriptions(uuid) {
|
|
69
|
+
const provider = sourceResults.value.find(
|
|
70
|
+
(x) => x.provider_uuid === uuid || x?.sources?.some((y) => y?.source_id === uuid)
|
|
71
|
+
);
|
|
72
|
+
const source = provider?.sources?.find((x) => x.source_id === uuid);
|
|
73
|
+
return {
|
|
74
|
+
provider: provider?.provider_description,
|
|
75
|
+
source: source?.source_description
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
function getLastUpdate(uuid) {
|
|
79
|
+
const provider = sourceResults.value.find(
|
|
80
|
+
(x) => x.provider_uuid === uuid || x?.sources?.some((y) => y?.source_id === uuid)
|
|
81
|
+
);
|
|
82
|
+
const source = provider?.sources?.find((x) => x.source_id === uuid);
|
|
83
|
+
return {
|
|
84
|
+
update: source?.last_update ? new Date(source?.last_update)?.toLocaleDateString({
|
|
85
|
+
day: "numeric",
|
|
86
|
+
month: "long",
|
|
87
|
+
year: "numeric"
|
|
88
|
+
}) : "-",
|
|
89
|
+
visit: source?.last_visit ? new Date(source?.last_visit)?.toLocaleDateString({
|
|
90
|
+
day: "numeric",
|
|
91
|
+
month: "long",
|
|
92
|
+
year: "numeric"
|
|
93
|
+
}) : "-",
|
|
94
|
+
frequency: source?.update_frequency ?? "-"
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
async function queryElastic({
|
|
98
|
+
index,
|
|
99
|
+
customQuery,
|
|
100
|
+
cluster
|
|
101
|
+
}) {
|
|
102
|
+
const esResults = {
|
|
103
|
+
results: [],
|
|
104
|
+
total: 0
|
|
105
|
+
};
|
|
106
|
+
const queryMustValues = customQuery.map((obj) => obj.values).filter((item) => item !== void 0);
|
|
107
|
+
const query = {
|
|
108
|
+
from: 0,
|
|
109
|
+
_source: [],
|
|
110
|
+
query: {
|
|
111
|
+
bool: {
|
|
112
|
+
must: queryMustValues
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
size: 100,
|
|
116
|
+
sort: [],
|
|
117
|
+
track_total_hits: true
|
|
118
|
+
};
|
|
119
|
+
await fetch(setFetchUrl(cluster, index), {
|
|
120
|
+
method: "POST",
|
|
121
|
+
headers: {
|
|
122
|
+
...setFetchHeaders(cluster),
|
|
123
|
+
"Content-Type": "application/json"
|
|
124
|
+
},
|
|
125
|
+
body: JSON.stringify(query)
|
|
126
|
+
}).then((res) => res?.json()).then((res) => {
|
|
127
|
+
if (res) {
|
|
128
|
+
sourceResults.value = res?.hits?.hits?.map((x) => x?._source);
|
|
129
|
+
emit("updateSources", sourceResults.value);
|
|
130
|
+
}
|
|
131
|
+
}).catch((err) => {
|
|
132
|
+
console.log("Error", err);
|
|
133
|
+
});
|
|
134
|
+
return esResults;
|
|
135
|
+
}
|
|
136
|
+
const setFetchUrl = (cluster = "default", index) => {
|
|
137
|
+
switch (cluster) {
|
|
138
|
+
case "old":
|
|
139
|
+
return `https://4c565382f4b24aa0ac703379841bd608.eu-central-1.aws.cloud.es.io:443/${index}/_search`;
|
|
140
|
+
case "new":
|
|
141
|
+
case "default":
|
|
142
|
+
return `https://search.openinnovationprogram.com/${index}/_search`;
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
const setFetchHeaders = (cluster = "default") => {
|
|
146
|
+
switch (cluster) {
|
|
147
|
+
case "old":
|
|
148
|
+
return {
|
|
149
|
+
authorization: `Basic ${props.authKey}`
|
|
150
|
+
};
|
|
151
|
+
case "new":
|
|
152
|
+
case "default":
|
|
153
|
+
default:
|
|
154
|
+
return {
|
|
155
|
+
authorization: `ApiKey ${props.authKey}`
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
function buildFilters(fields, uuids) {
|
|
160
|
+
const filters = [];
|
|
161
|
+
if (fields && fields.length > 0) {
|
|
162
|
+
for (const field of fields) {
|
|
163
|
+
const term = {
|
|
164
|
+
[`${field}.keyword`]: uuids
|
|
165
|
+
};
|
|
166
|
+
if (field.startsWith("sources.")) {
|
|
167
|
+
filters.push({
|
|
168
|
+
nested: {
|
|
169
|
+
path: "sources",
|
|
170
|
+
query: {
|
|
171
|
+
terms: term
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
} else {
|
|
176
|
+
filters.push({
|
|
177
|
+
terms: term
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
} else {
|
|
182
|
+
filters.push({
|
|
183
|
+
terms: {
|
|
184
|
+
"provider_uuid.keyword": uuids
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
filters.push({
|
|
188
|
+
nested: {
|
|
189
|
+
path: "sources",
|
|
190
|
+
query: {
|
|
191
|
+
terms: {
|
|
192
|
+
"sources.source_id.keyword": uuids
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
return filters;
|
|
199
|
+
}
|
|
200
|
+
async function runQuery() {
|
|
201
|
+
if (!props.authKey) {
|
|
202
|
+
throw new Error("You have to provide your App's Auth key.");
|
|
203
|
+
}
|
|
204
|
+
isLoadingQuery.value = true;
|
|
205
|
+
const filters = buildFilters(props.fields, props.uuids);
|
|
206
|
+
const matchTable = [
|
|
207
|
+
{
|
|
208
|
+
filter: "uuid",
|
|
209
|
+
values: {
|
|
210
|
+
bool: {
|
|
211
|
+
should: filters,
|
|
212
|
+
minimum_should_match: 1
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
];
|
|
217
|
+
await queryElastic({
|
|
218
|
+
index: props.index,
|
|
219
|
+
take: { values: 500 },
|
|
220
|
+
customQuery: matchTable
|
|
221
|
+
});
|
|
222
|
+
isLoadingQuery.value = false;
|
|
223
|
+
}
|
|
224
|
+
onMounted(runQuery);
|
|
225
|
+
watch(
|
|
226
|
+
() => props.uuids,
|
|
227
|
+
async () => {
|
|
228
|
+
await runQuery();
|
|
229
|
+
}
|
|
230
|
+
);
|
|
231
|
+
return {
|
|
232
|
+
sourceResults,
|
|
233
|
+
constructTitle,
|
|
234
|
+
getDescriptions,
|
|
235
|
+
getLastUpdate,
|
|
236
|
+
isLoadingQuery
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
</script>
|
|
241
|
+
|
|
242
|
+
<style scoped>
|
|
243
|
+
.small_heading{font-size:14px;font-weight:800;text-decoration:underline}.oneLoader{background:var(--white);border:1px solid var(--light);border-radius:8px;overflow:hidden;position:relative}.oneLoader,.oneLoader:after{height:70px;width:calc(100% - 2px)}.oneLoader:after{animation:shimmer 1.5s infinite;background:linear-gradient(90deg,rgba(219,222,240,0),rgba(219,222,240,.6) 50%,rgba(219,222,240,0));content:"";left:-2px;position:absolute;top:0}@keyframes shimmer{0%{left:-100%}to{left:100%}}
|
|
244
|
+
</style>
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
2
|
+
fields: {
|
|
3
|
+
type: ArrayConstructor;
|
|
4
|
+
};
|
|
5
|
+
uuids: {
|
|
6
|
+
type: ArrayConstructor;
|
|
7
|
+
};
|
|
8
|
+
index: {
|
|
9
|
+
type: StringConstructor;
|
|
10
|
+
};
|
|
11
|
+
authKey: {
|
|
12
|
+
type: StringConstructor;
|
|
13
|
+
};
|
|
14
|
+
cluster: {
|
|
15
|
+
type: StringConstructor;
|
|
16
|
+
default: string;
|
|
17
|
+
};
|
|
18
|
+
}>, {
|
|
19
|
+
sourceResults: import("vue").Ref<null, null>;
|
|
20
|
+
constructTitle: (uuid: string) => string;
|
|
21
|
+
getDescriptions: (uuid: any) => {
|
|
22
|
+
provider: any;
|
|
23
|
+
source: any;
|
|
24
|
+
};
|
|
25
|
+
getLastUpdate: (uuid: any) => {
|
|
26
|
+
update: string;
|
|
27
|
+
visit: string;
|
|
28
|
+
frequency: any;
|
|
29
|
+
};
|
|
30
|
+
isLoadingQuery: import("vue").Ref<boolean, boolean>;
|
|
31
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "updateSources"[], "updateSources", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
32
|
+
fields: {
|
|
33
|
+
type: ArrayConstructor;
|
|
34
|
+
};
|
|
35
|
+
uuids: {
|
|
36
|
+
type: ArrayConstructor;
|
|
37
|
+
};
|
|
38
|
+
index: {
|
|
39
|
+
type: StringConstructor;
|
|
40
|
+
};
|
|
41
|
+
authKey: {
|
|
42
|
+
type: StringConstructor;
|
|
43
|
+
};
|
|
44
|
+
cluster: {
|
|
45
|
+
type: StringConstructor;
|
|
46
|
+
default: string;
|
|
47
|
+
};
|
|
48
|
+
}>> & Readonly<{
|
|
49
|
+
onUpdateSources?: ((...args: any[]) => any) | undefined;
|
|
50
|
+
}>, {
|
|
51
|
+
cluster: string;
|
|
52
|
+
}, {}, {
|
|
53
|
+
ArgSourceCollapse: any;
|
|
54
|
+
}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
55
|
+
export default _default;
|