config file + tooltips

This commit is contained in:
Dmitry Belyaev 2021-06-04 14:13:40 +03:00
parent 833995e739
commit d3bb7df356
Signed by: b4tman
GPG Key ID: 41A00BF15EA7E5F3
8 changed files with 81 additions and 52 deletions

View File

@ -77,7 +77,6 @@ export default {
InfobaseListItem, InfobaseListItem,
}, },
data: () => ({ data: () => ({
url_base: "http://localhost:11111",
is_loading: true, is_loading: true,
loading_error: false, loading_error: false,
infobases: [], infobases: [],

View File

@ -15,9 +15,9 @@
<a <a
class="text-break" class="text-break"
v-if="!url_edit" v-if="!url_edit"
v-bind:href="url_base + url" v-bind:href="url_full"
target="blank" target="blank"
>{{ infobase.url }}</a >{{ url }}</a
> >
</template> </template>
</td> </td>
@ -29,6 +29,7 @@
class="btn btn-warning" class="btn btn-warning"
@click="start_edit_url" @click="start_edit_url"
title="Изменить URL" title="Изменить URL"
v-tooltip:left
> >
Изменить Изменить
</button> </button>
@ -38,6 +39,7 @@
class="btn btn-danger" class="btn btn-danger"
@click="remove_publication" @click="remove_publication"
title="Снять с публикации" title="Снять с публикации"
v-tooltip:top
> >
Отменить Отменить
</button> </button>
@ -47,6 +49,7 @@
class="btn btn-primary" class="btn btn-primary"
@click="add_publication" @click="add_publication"
title="Опубликовать базу" title="Опубликовать базу"
v-tooltip:left
> >
Публиковать Публиковать
</button> </button>
@ -57,11 +60,15 @@
</template> </template>
<script> <script>
import { mapGetters, mapMutations, mapActions } from "vuex"; import { mapGetters, mapActions } from "vuex";
import InfobaseURLEditor from "@/components/InfobaseURLEditor.vue"; import InfobaseURLEditor from "@/components/InfobaseURLEditor.vue";
import ItemLoading from "@/components/ItemLoading.vue"; import ItemLoading from "@/components/ItemLoading.vue";
import config from "@/config.js";
const url_base = config.publication.url_base;
export default { export default {
name: "InfobaseListItem", name: "InfobaseListItem",
components: { components: {
@ -69,7 +76,6 @@ export default {
ItemLoading, ItemLoading,
}, },
data: () => ({ data: () => ({
url_base: "http://localhost:11111",
url_edit: false, url_edit: false,
}), }),
props: { props: {
@ -93,15 +99,14 @@ export default {
url() { url() {
return this.infobase.url; return this.infobase.url;
}, },
url_full() {
return `${url_base}${this.infobase.url}`;
},
is_locked() { is_locked() {
return this.$store.getters.isInfobaseLocked(this.infobase.name); return this.$store.getters.isInfobaseLocked(this.infobase.name);
}, },
}, },
methods: { methods: {
...mapMutations({
//set_url: "setInfobaseURL",
//set_publication: "setInfobasePublication",
}),
...mapActions({ ...mapActions({
set_url: "updateInfobaseURL", set_url: "updateInfobaseURL",
}), }),

View File

@ -6,6 +6,7 @@
type="submit" type="submit"
class="btn btn-sm btn-outline-primary" class="btn btn-sm btn-outline-primary"
title="Принять" title="Принять"
v-tooltip:top
> >
<svg width="16" height="16"> <svg width="16" height="16">
<use xlink:href="#check-lg--sprite"></use> <use xlink:href="#check-lg--sprite"></use>
@ -16,6 +17,7 @@
class="btn btn-sm btn-outline-secondary" class="btn btn-sm btn-outline-secondary"
@click="cancel" @click="cancel"
title="Отменить" title="Отменить"
v-tooltip:top
> >
<svg width="16" height="16"><use xlink:href="#x-lg--sprite"></use></svg> <svg width="16" height="16"><use xlink:href="#x-lg--sprite"></use></svg>
</button> </button>

View File

@ -7,38 +7,7 @@
</div> </div>
</template> </template>
<style scoped> <style lang="less" scoped>
.lds-ellipsis {
display: inline-block;
position: relative;
width: 80px;
height: 30px;
}
.lds-ellipsis div {
position: absolute;
top: 10px;
width: 13px;
height: 13px;
border-radius: 50%;
background: rgb(37, 192, 23);
animation-timing-function: cubic-bezier(0, 1, 1, 0);
}
.lds-ellipsis div:nth-child(1) {
left: 8px;
animation: lds-ellipsis1 0.6s infinite;
}
.lds-ellipsis div:nth-child(2) {
left: 8px;
animation: lds-ellipsis2 0.6s infinite;
}
.lds-ellipsis div:nth-child(3) {
left: 32px;
animation: lds-ellipsis2 0.6s infinite;
}
.lds-ellipsis div:nth-child(4) {
left: 56px;
animation: lds-ellipsis3 0.6s infinite;
}
@keyframes lds-ellipsis1 { @keyframes lds-ellipsis1 {
0% { 0% {
transform: scale(0); transform: scale(0);
@ -63,4 +32,35 @@
transform: translate(24px, 0); transform: translate(24px, 0);
} }
} }
.lds-ellipsis {
display: inline-block;
position: relative;
width: 80px;
height: 30px;
div {
position: absolute;
top: 10px;
width: 13px;
height: 13px;
border-radius: 50%;
background: rgb(37, 192, 23);
animation-timing-function: cubic-bezier(0, 1, 1, 0);
&:nth-child(1) {
left: 8px;
animation: lds-ellipsis1 0.6s infinite;
}
&:nth-child(2) {
left: 8px;
animation: lds-ellipsis2 0.6s infinite;
}
&:nth-child(3) {
left: 32px;
animation: lds-ellipsis2 0.6s infinite;
}
&:nth-child(4) {
left: 56px;
animation: lds-ellipsis3 0.6s infinite;
}
}
}
</style> </style>

5
src/config.js Normal file
View File

@ -0,0 +1,5 @@
import config from "@/config.json";
export default {
...config,
};

6
src/config.json Normal file
View File

@ -0,0 +1,6 @@
{
"api": "http://localhost:17653",
"publication": {
"url_base": "http://localhost:11111"
}
}

View File

@ -5,8 +5,25 @@ import store from "./store";
import "jquery/src/jquery.js"; import "jquery/src/jquery.js";
import "bootstrap/dist/css/bootstrap.min.css"; import "bootstrap/dist/css/bootstrap.min.css";
import "bootstrap/dist/js/bootstrap.min.js"; import "bootstrap/dist/js/bootstrap.bundle.min.js";
window.jQuery = window.$ = require("jquery"); window.jQuery = window.$ = require("jquery");
createApp(App).use(store).use(router).mount("#app"); const app = createApp(App).use(store).use(router);
app.directive("tooltip", {
mounted(el, binding) {
window.$(el).tooltip({
placement: binding.arg,
trigger: "hover",
});
},
updated(el) {
window.$(el).tooltip("update");
},
unmounted(el) {
window.$(el).tooltip("dispose");
},
});
app.mount("#app");

View File

@ -1,7 +1,8 @@
import axios from "axios"; import axios from "axios";
//const api_base = "http://localhost:5000/api/v1"; // test1 import config from "@/config.js";
const api_base = "http://localhost:17653"; // test2 - mock
const api_base = config.api;
const LoadingStatus = Object.freeze({ const LoadingStatus = Object.freeze({
Loaded: { loading: false, error: false }, Loaded: { loading: false, error: false },
@ -9,12 +10,6 @@ const LoadingStatus = Object.freeze({
Error: { loading: false, error: true }, Error: { loading: false, error: true },
}); });
// const new_infobase = (name) => ({
// name,
// url: "",
// publicated: false,
// });
const infobaseByName = (state) => (name) => const infobaseByName = (state) => (name) =>
state.infobases.find((infobase) => name === infobase.name); state.infobases.find((infobase) => name === infobase.name);