Skip to content

Commit 9818116

Browse files
open graphql ide button
1 parent 274cef0 commit 9818116

8 files changed

Lines changed: 5979 additions & 1843 deletions

File tree

dist/assets/css/widgets.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/widgets.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 1245 additions & 1829 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "widgets",
3-
"version": "1.3.9",
3+
"version": "1.3.10",
44
"description": "",
55
"main": "dist/widgets.js",
66
"directories": {
@@ -25,7 +25,6 @@
2525
"css-loader": "^3.2.0",
2626
"file-loader": "^4.2.0",
2727
"mini-css-extract-plugin": "^0.9.0",
28-
"node-sass": "^4.14.1",
2928
"optimize-css-assets-webpack-plugin": "^5.0.3",
3029
"sass-loader": "^8.0.0",
3130
"style-loader": "^1.0.0",
@@ -47,6 +46,7 @@
4746
"numeral": "^2.0.6",
4847
"react": "^16.11.0",
4948
"react-dom": "^16.11.0",
49+
"sass": "^1.42.1",
5050
"vue": "^2.6.10",
5151
"vue-google-charts": "^0.3.2",
5252
"vue-i18n": "^8.15.0"

src/components/base.vue

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@
77
<nodata v-else-if="is_no_data" :options="options"></nodata>
88
<component :is="componentName" :data="data" :variables="variables" :options="options" :theme="theme" :context="context" :componentName="componentName" v-else></component>
99
</div>
10-
<links :obj="componentName" :func="func" :exclude="exclude" :title="title"></links>
10+
<!-- <links :obj="componentName" :func="func" :exclude="exclude" :title="title"></links>-->
11+
<div style="margin-top: 5px;float: right; cursor: pointer;">
12+
<a v-on:click="handleOpenIde" class="badge badge-secondary open-btn">Open GraphQL IDE</a>
13+
</div>
14+
1115
</div>
1216
</template>
1317
<script>
@@ -24,7 +28,7 @@
2428
context: context,
2529
theme: context.themes[context.theme],
2630
variables: context.query.variables,
27-
data: this.$parent._data
31+
data: this.$parent._data,
2832
}
2933
},
3034
computed: {
@@ -34,6 +38,29 @@
3438
is_no_data: function(){
3539
return Array.isArray(this.data.result) && this.data.result.length < 1;
3640
}
41+
},
42+
methods: {
43+
handleOpenIde: function() {
44+
fetch(this.data.ideUrl, {
45+
method: 'POST',
46+
headers: {
47+
'Content-Type': 'application/json',
48+
Accept: 'application/json',
49+
},
50+
body: JSON.stringify({
51+
query: this.context.query.query,
52+
variables: JSON.stringify(this.context.query.variables),
53+
}),
54+
})
55+
.then((res) => {
56+
if (res.status === 200 || res.status === 302) {
57+
window.open(res.url, '_blank').focus()
58+
// res.redirect(302, res.url)
59+
} else {
60+
console.log(res.message)
61+
}
62+
})
63+
}
3764
}
3865
}
3966
</script>

src/widgets.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,9 @@ let props = {
145145
}
146146
};
147147

148-
export function init(url, apikey, options = {}){
149-
options['url'] = url;
150-
options['apikey'] = apikey;
148+
export function init(graphqlUrl, ideUrl, options = {}){
149+
options['graphqlUrl'] = graphqlUrl;
150+
options['ideUrl'] = ideUrl;
151151
props = _.merge(props, options);
152152
// apollo = new ApolloClient({uri: options['url']});
153153
return props
@@ -172,10 +172,7 @@ export function query(query, schema = undefined){
172172
// apollo = new ApolloClient({uri: props['url'], cache});
173173
} else {
174174
apollo = new ApolloClient({
175-
uri: props['url'],
176-
headers: {
177-
'X-API-KEY': props['apikey']
178-
},
175+
uri: props['graphqlUrl'],
179176
});
180177
}
181178

@@ -284,7 +281,8 @@ export function component(name, funcName, selector, query, path, options={},init
284281
locale: it.vmi18n.locale,
285282
path: it.path,
286283
result: result_data,
287-
errors: _.get(query.errors, '', query.errors)
284+
errors: _.get(query.errors, '', query.errors),
285+
ideUrl: props['ideUrl']
288286
},
289287
render: h => h(Components['base'])
290288
});

webpack.config.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ const VueLoaderPlugin = require('vue-loader/lib/plugin');
33
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
44
const TerserPlugin = require('terser-webpack-plugin');
55
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
6+
const path = require('path')
67

78
module.exports = function(paths){
89
return {
@@ -13,6 +14,7 @@ module.exports = function(paths){
1314
},
1415
output: {
1516
filename: '[name].js',
17+
// path: path.resolve(__dirname, '../explorer/app/javascript/packs'),
1618
// globalObject: 'this',
1719
libraryTarget: 'window',
1820
library: '[name]'

0 commit comments

Comments
 (0)