@steedos/service-pages 2.1.27 → 2.1.32

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.
Files changed (2) hide show
  1. package/package.json +2 -2
  2. package/package.service.js +51 -13
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@steedos/service-pages",
3
- "version": "2.1.27",
3
+ "version": "2.1.32",
4
4
  "main": "package.service.js",
5
5
  "scripts": {},
6
6
  "license": "MIT",
@@ -8,5 +8,5 @@
8
8
  "publishConfig": {
9
9
  "access": "public"
10
10
  },
11
- "gitHead": "f71887eddb2f94a28c812e990bd83c56fb601ee4"
11
+ "gitHead": "9824a14875521dca45ebba66792001d93b608e10"
12
12
  }
@@ -76,29 +76,67 @@ module.exports = {
76
76
  page.widgets = await objectql.getObject('widgets').find({ filters: [['page', '=', apiName]] });
77
77
  }
78
78
  page.options = {};
79
+ const widgets = [];
79
80
  for (const widget of page.widgets) {
80
81
  if(widget.type === 'charts'){
81
82
  if(widget.visualization){
82
83
  const chart = await getCharts(widget.visualization)
83
- const query = await getQueries(chart.query)
84
- if(!query.options){
85
- query.options = {}
86
- }
87
- widget.visualization = {
88
- _id: chart._id,
89
- description: chart.description,
90
- query: query,
91
- type: chart.type,
92
- options: chart.options,
93
- name: chart.name,
94
- label: chart.label,
84
+ if(chart){
85
+ const query = await getQueries(chart.query)
86
+ if(query){
87
+ if(!query.options){
88
+ query.options = {}
89
+ }
90
+ widget.visualization = {
91
+ _id: chart._id,
92
+ description: chart.description,
93
+ query: query,
94
+ type: chart.type,
95
+ options: chart.options,
96
+ name: chart.name,
97
+ label: chart.label,
98
+ }
99
+ widgets.push(widget)
100
+ }
95
101
  }
102
+ }else{
103
+ widgets.push(widget)
96
104
  }
105
+ }else{
106
+ widgets.push(widget)
97
107
  }
98
108
  }
99
-
109
+ page.widgets = widgets;
100
110
  return page;
101
111
  }
112
+ },
113
+ searchPage:{
114
+ rest: {
115
+ method: "GET",
116
+ path: "/search/page"
117
+ },
118
+ async handler(ctx){
119
+ try {
120
+ const { q } = ctx.params;
121
+ let pages = await objectql.getObject('pages').find({filters: [['label', 'contains', q],'or',['name', 'contains', q]]});
122
+ _.each(pages, function(page){
123
+ page.id = page.name
124
+ })
125
+ return {
126
+ count: pages.length,
127
+ page: 1,
128
+ page_size: pages.length + 1000,
129
+ results: pages
130
+ }
131
+ } catch (error) {
132
+ return {
133
+ count: 0,
134
+ page: 1,
135
+ page_size: 1000,
136
+ results: []
137
+ }
138
+ }
139
+ }
102
140
  }
103
141
  },
104
142