@mongoosejs/studio 0.0.6 → 0.0.8
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/frontend/index.js
CHANGED
|
@@ -12,6 +12,12 @@ module.exports = function(apiUrl, isLambda, options) {
|
|
|
12
12
|
})
|
|
13
13
|
]
|
|
14
14
|
}
|
|
15
|
+
if (options?.setAuthorizationHeaderFrom) {
|
|
16
|
+
config.plugins = config.plugins || [];
|
|
17
|
+
config.plugins.push(new webpack.DefinePlugin({
|
|
18
|
+
config__setAuthorizationHeaderFrom: `'${options.setAuthorizationHeaderFrom}'`
|
|
19
|
+
}));
|
|
20
|
+
}
|
|
15
21
|
const compiler = webpack(config);
|
|
16
22
|
|
|
17
23
|
if (options && options.watch) {
|
package/frontend/src/api.js
CHANGED
|
@@ -7,6 +7,16 @@ const client = axios.create({
|
|
|
7
7
|
});
|
|
8
8
|
|
|
9
9
|
window.apiClient = client;
|
|
10
|
+
if (typeof config__setAuthorizationHeaderFrom === 'string' && config__setAuthorizationHeaderFrom) {
|
|
11
|
+
client.interceptors.request.use(req => {
|
|
12
|
+
const accessToken = window.localStorage.getItem(config__setAuthorizationHeaderFrom) || null;
|
|
13
|
+
if (accessToken) {
|
|
14
|
+
req.headers.authorization = accessToken;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return req;
|
|
18
|
+
});
|
|
19
|
+
}
|
|
10
20
|
|
|
11
21
|
if (config__isLambda) {
|
|
12
22
|
exports.Model = {
|
|
@@ -9,6 +9,8 @@ const appendCSS = require('../appendCSS');
|
|
|
9
9
|
|
|
10
10
|
appendCSS(require('./models.css'));
|
|
11
11
|
|
|
12
|
+
const limit = 50;
|
|
13
|
+
|
|
12
14
|
module.exports = app => app.component('models', {
|
|
13
15
|
template: template,
|
|
14
16
|
props: ['model'],
|
|
@@ -18,7 +20,8 @@ module.exports = app => app.component('models', {
|
|
|
18
20
|
documents: [],
|
|
19
21
|
schemaPaths: [],
|
|
20
22
|
numDocuments: 0,
|
|
21
|
-
status: '
|
|
23
|
+
status: 'loading',
|
|
24
|
+
loadedAllDocs: false,
|
|
22
25
|
edittingDoc: null,
|
|
23
26
|
docEdits: null,
|
|
24
27
|
filter: null,
|
|
@@ -28,7 +31,6 @@ module.exports = app => app.component('models', {
|
|
|
28
31
|
sortBy: {},
|
|
29
32
|
query: {},
|
|
30
33
|
scrollHeight: 0,
|
|
31
|
-
limit: 50,
|
|
32
34
|
interval: null
|
|
33
35
|
}),
|
|
34
36
|
created() {
|
|
@@ -64,14 +66,24 @@ module.exports = app => app.component('models', {
|
|
|
64
66
|
},
|
|
65
67
|
methods: {
|
|
66
68
|
async onScroll() {
|
|
67
|
-
if (this.status === 'loading') {
|
|
69
|
+
if (this.status === 'loading' || this.loadedAllDocs) {
|
|
68
70
|
return;
|
|
69
71
|
}
|
|
70
72
|
const container = this.$refs.documentsList;
|
|
71
73
|
if (container.scrollHeight - container.clientHeight - 100 < container.scrollTop) {
|
|
72
74
|
this.status = 'loading';
|
|
73
|
-
|
|
74
|
-
|
|
75
|
+
const { docs } = await api.Model.getDocuments({
|
|
76
|
+
model: this.currentModel,
|
|
77
|
+
filter: this.filter,
|
|
78
|
+
sort: this.sortBy,
|
|
79
|
+
skip: this.documents.length,
|
|
80
|
+
limit
|
|
81
|
+
});
|
|
82
|
+
console.log('FX', docs.length, limit)
|
|
83
|
+
if (docs.length < limit) {
|
|
84
|
+
this.loadedAllDocs = true;
|
|
85
|
+
}
|
|
86
|
+
this.documents.push(...docs);
|
|
75
87
|
this.status = 'loaded';
|
|
76
88
|
}
|
|
77
89
|
},
|
|
@@ -110,9 +122,12 @@ module.exports = app => app.component('models', {
|
|
|
110
122
|
model: this.currentModel,
|
|
111
123
|
filter: this.filter,
|
|
112
124
|
sort: this.sortBy,
|
|
113
|
-
limit
|
|
125
|
+
limit
|
|
114
126
|
});
|
|
115
127
|
this.documents = docs;
|
|
128
|
+
if (docs.length < limit) {
|
|
129
|
+
this.loadedAllDocs = true;
|
|
130
|
+
}
|
|
116
131
|
this.schemaPaths = Object.keys(schemaPaths).sort((k1, k2) => {
|
|
117
132
|
if (k1 === '_id' && k2 !== '_id') {
|
|
118
133
|
return -1;
|