Skip to content

Commit 14a6423

Browse files
author
Leonid Vakulenko
committed
Merge branch 'dev'
2 parents 35a7098 + c0bf06a commit 14a6423

File tree

107 files changed

+2139
-396
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+2139
-396
lines changed

wa-apps/apiexplorer/client/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@
55
npm install
66
```
77

8+
### Environment variables
9+
Create `.env.development.local` (see `.env.development.local.example`)
10+
Where
11+
- `VUE_APP_WA_DEV`: URL to the Webasyst framework root
12+
- `VUE_APP_BASE_URL`: Path to API Explorer backend from domain root
13+
814
### Compiles and hot-reloads for development
915
```
1016
npm run serve

wa-apps/apiexplorer/client/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
"swagger-client": "^3.18.1",
2222
"v-calendar": "^3.0.0-alpha.6",
2323
"vue": "^3.2.27",
24-
"vue-i18n": "^9.2.0-beta.28",
25-
"vue-router": "^4.0.12",
24+
"vue-i18n": "^9.2.2",
25+
"vue-router": "^4.1.5",
2626
"vuex": "^4.0.2"
2727
},
2828
"devDependencies": {

wa-apps/apiexplorer/client/public/index.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
"rootUrl": "/",
2020
"user_id": "1",
2121
"development_mode": "1",
22-
"locale": "<%= VUE_APP_I18N_LOCALE %>"
22+
"locale": "<%= VUE_APP_I18N_LOCALE %>",
23+
"centralUrl": "<%= VUE_APP_WA_CENTRAL %>"
2324
};
2425
</script>
2526
<% } %>
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<template>
2+
<div :class="[ error && 'orange', 'highlighted', 'dark-mode-inverted', 'flexbox', 'full-width']">
3+
<pre class="small custom-p-8 custom-m-0 wide" v-html="value_to_show"></pre>
4+
<div v-if="just_copied" class="custom-my-4 custom-mx-8 large" style="color: var(--green);"><i class="fas fa-check" title="copied"></i></div>
5+
<a v-else style="color: var(--gray);" title="Copy to clipboard" class="custom-my-4 custom-mx-8 large" href="javascript:void(0);" @click="copy()"><i class="far fa-copy"></i></a>
6+
</div>
7+
</template>
8+
9+
<script>
10+
import { prettyPrintJson } from 'pretty-print-json';
11+
export default {
12+
name: "CodeBlock",
13+
props: {
14+
value: [Object, String],
15+
error: {
16+
type: Boolean,
17+
default: () => false
18+
}
19+
},
20+
data() {
21+
return {
22+
just_copied: false
23+
};
24+
},
25+
computed: {
26+
value_to_show() {
27+
if (typeof this.value === 'object') {
28+
return prettyPrintJson.toHtml(this.value);
29+
}
30+
return this.value;
31+
},
32+
value_to_copy() {
33+
if (typeof this.value === 'object') {
34+
return JSON.stringify(this.value, null, '\t');
35+
}
36+
return this.value;
37+
}
38+
},
39+
methods: {
40+
copy() {
41+
navigator.clipboard.writeText(this.value_to_copy).then(() => {
42+
this.just_copied = true;
43+
setTimeout(() => {
44+
this.just_copied = false;
45+
}, 3000);
46+
});
47+
}
48+
}
49+
}
50+
</script>

wa-apps/apiexplorer/client/src/components/SchemaInput.vue

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,16 @@
2020
</span>
2121
<input v-else-if="schema.format === 'email'" :value="modelValue" @input="updateValue($event.target.value)" :id="name" type="email" />
2222
<input v-else-if="schema.format === 'password'" :value="modelValue" @input="updateValue($event.target.value)" :id="name" type="password" />
23+
<div v-else-if="schema.format === 'binary'">
24+
<div class="upload">
25+
<label class="link">
26+
<i class="fas fa-file-upload"></i>
27+
<span v-if="filename" class="custom-mx-8">{{ filename }}</span>
28+
<span v-else class="custom-mx-8">{{ $t("Select file") }}</span>
29+
<input type="file" autocomplete="off" @change="readFile" :id="name" />
30+
</label>
31+
</div>
32+
</div>
2333
<input v-else :value="modelValue" @input="updateValue($event.target.value)" :id="name" type="text" class="long" />
2434
</span>
2535
<input v-else-if="schema.type === 'integer'" :value="modelValue" @input="updateValue($event.target.value)" :id="name" type="number" />
@@ -132,7 +142,8 @@ export default {
132142
},
133143
data() {
134144
return {
135-
l_value: {}
145+
l_value: {},
146+
filename: null
136147
};
137148
},
138149
created() {
@@ -167,6 +178,19 @@ export default {
167178
this.$emit('update:modelValue', val);
168179
this.$emit('updated');
169180
},
181+
readFile: function (event) {
182+
if (event.target.files.length == 0) {
183+
return;
184+
}
185+
const file = event.target.files[0];
186+
if (Object.prototype.toString.call(file) !== '[object File]') {
187+
return;
188+
}
189+
const reader = new FileReader();
190+
reader.onload = e => this.updateValue(e.target.result);
191+
reader.readAsBinaryString(file);
192+
this.filename = file.name;
193+
},
170194
updateArrValue: function (val, index) {
171195
this.l_value[index] = val;
172196
this.$emit('update:modelValue', Object.values(this.l_value));

wa-apps/apiexplorer/client/src/i18n.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//import Vue from "vue";
2-
import { createI18n } from "vue-i18n";
2+
import { createI18n } from "vue-i18n/index";
33

44
//Vue.use(VueI18n);
55

wa-apps/apiexplorer/client/src/locales/en.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"no-api-hint": "If you are a developer of this app, please refer to this guide on how to create <a href='https://developers.webasyst.com/features/apis/' target='_blank'>an API-enabled Webasyst app</a>.",
55
"empty": "empty",
66
"Request": "Request",
7+
"Response": "Response",
78
"Schema": "Schema",
89
"Headers": "Headers",
910
"Data": "Data",
@@ -38,5 +39,11 @@
3839
"Date & time": "Date & time",
3940
"Run API": "Run API",
4041
"Body": "Body",
41-
"OpenAPI Document": "OpenAPI Document"
42+
"OpenAPI Document": "OpenAPI Document",
43+
"Query string parameters": "Query string parameters",
44+
"Request body parameters": "Request body parameters",
45+
"Select file": "Select file",
46+
"Response data format": "Response data format",
47+
"show": "show",
48+
"hide": "hide"
4249
}

wa-apps/apiexplorer/client/src/locales/ru.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"Headers": "Заголовки",
2929
"Schema": "Схема",
3030
"Request": "Запрос",
31+
"Response": "Ответ",
3132
"no-api-message": "Приложение «{0}» не предоставляет публичного API",
3233
"No API": "Нет API",
3334
"no-api-hint": "Если вы являетесь разработчиком данного приложения, ознакомьтесь с инструкцией по созданию <a href='https://developers.webasyst.ru/docs/features/apis/' target='_blank'>публичного API в приложениях Webasyst</a>.",
@@ -38,5 +39,11 @@
3839
"URL parameters": "Параметры строки запроса",
3940
"Run API": "Запустить API",
4041
"Body": "Содержимое",
41-
"OpenAPI Document": "Описание OpenAPI"
42+
"OpenAPI Document": "Описание OpenAPI",
43+
"Query string parameters": "Параметры строки запроса",
44+
"Request body parameters": "Параметры тела запроса",
45+
"Select file": "Выберите файл",
46+
"Response data format": "Формат ответа",
47+
"show": "показать",
48+
"hide": "скрыть"
4249
}

wa-apps/apiexplorer/client/src/views/About.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export default {
2727
const resp = await this.axios.get('?module=pages&action=about');
2828
this.page = resp.data;
2929
this.state.loading = false;
30+
document.title = 'About — API Explorer';
3031
}
3132
}
3233
</script>

wa-apps/apiexplorer/client/src/views/Application.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export default {
3737
mounted() {
3838
this.app_id = this.$route.params.name;
3939
this.app = this.$store.getters.getApp(this.app_id);
40+
document.title = this.app.name + ' — API Explorer';
4041
}
4142
}
4243
</script>

0 commit comments

Comments
 (0)