@mongoosejs/studio 0.0.5 → 0.0.7

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) {
@@ -6,6 +6,18 @@ const client = axios.create({
6
6
  baseURL: config__baseURL
7
7
  });
8
8
 
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
+ }
20
+
9
21
  if (config__isLambda) {
10
22
  exports.Model = {
11
23
  deleteDocument(params) {
@@ -108,7 +108,16 @@
108
108
  width: calc(100% - 1em);
109
109
  }
110
110
 
111
- .sort-arrow {
111
+ .models .sort-arrow {
112
112
  padding-left: 10px;
113
113
  padding-right: 10px;
114
+ }
115
+
116
+ .models .loader {
117
+ width: 100%;
118
+ text-align: center;
119
+ }
120
+
121
+ .models .loader img {
122
+ height: 4em;
114
123
  }
@@ -7,7 +7,7 @@
7
7
  </router-link>
8
8
  </div>
9
9
  </div>
10
- <div class="documents">
10
+ <div class="documents" ref="documentsList">
11
11
  <div>
12
12
  <div class="documents-menu">
13
13
  <div class="search-input">
@@ -46,6 +46,9 @@
46
46
  </tr>
47
47
  </tbody>
48
48
  </table>
49
+ <div v-if="true" class="loader">
50
+ <img src="images/loader.gif">
51
+ </div>
49
52
  </div>
50
53
  <modal v-if="shouldShowExportModal">
51
54
  <template v-slot:body>
@@ -26,12 +26,19 @@ module.exports = app => app.component('models', {
26
26
  shouldShowExportModal: false,
27
27
  shouldExport: {},
28
28
  sortBy: {},
29
- query: {}
29
+ query: {},
30
+ scrollHeight: 0,
31
+ limit: 50,
32
+ interval: null
30
33
  }),
31
34
  created() {
32
35
  this.currentModel = this.model;
33
36
  },
37
+ beforeDestroy() {
38
+ document.removeEventListener('scroll', () => this.onScroll(), true);
39
+ },
34
40
  async mounted() {
41
+ document.addEventListener('scroll', () => this.onScroll(), true);
35
42
  this.models = await api.Model.listModels().then(res => res.models);
36
43
  if (this.currentModel == null && this.models.length > 0) {
37
44
  this.currentModel = this.models[0];
@@ -56,6 +63,18 @@ module.exports = app => app.component('models', {
56
63
  this.status = 'loaded';
57
64
  },
58
65
  methods: {
66
+ async onScroll() {
67
+ if (this.status === 'loading') {
68
+ return;
69
+ }
70
+ const container = this.$refs.documentsList;
71
+ if (container.scrollHeight - container.clientHeight - 100 < container.scrollTop) {
72
+ this.status = 'loading';
73
+ this.limit += 50;
74
+ await this.getDocuments();
75
+ this.status = 'loaded';
76
+ }
77
+ },
59
78
  async sortDocs(num, path) {
60
79
  let sorted = false;
61
80
  if (this.sortBy[path] == num) {
@@ -90,7 +109,8 @@ module.exports = app => app.component('models', {
90
109
  const { docs, schemaPaths, numDocs } = await api.Model.getDocuments({
91
110
  model: this.currentModel,
92
111
  filter: this.filter,
93
- sort: this.sortBy
112
+ sort: this.sortBy,
113
+ limit: this.limit
94
114
  });
95
115
  this.documents = docs;
96
116
  this.schemaPaths = Object.keys(schemaPaths).sort((k1, k2) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mongoosejs/studio",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
4
4
  "dependencies": {
5
5
  "archetype": "0.13.0",
6
6
  "csv-stringify": "6.3.0",