Flatten nested repos
This commit is contained in:
39
test/vuex/one-ui-replication-status/api/replication.js
Normal file
39
test/vuex/one-ui-replication-status/api/replication.js
Normal file
@@ -0,0 +1,39 @@
|
||||
const URL = "/one-api/tools/replikasi/replikasi/";
|
||||
|
||||
export async function status(prm) {
|
||||
try {
|
||||
var resp = await axios.post(URL + 'status', prm);
|
||||
if (resp.status != 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: resp.statusText
|
||||
};
|
||||
}
|
||||
let data = resp.data;
|
||||
return data;
|
||||
} catch (e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export async function start_slave(prm) {
|
||||
try {
|
||||
var resp = await axios.post(URL + 'start_slave', prm);
|
||||
if (resp.status != 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: resp.statusText
|
||||
};
|
||||
}
|
||||
let data = resp.data;
|
||||
return data;
|
||||
} catch (e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,274 @@
|
||||
<template>
|
||||
<v-layout>
|
||||
|
||||
<v-flex xs12>
|
||||
<v-card>
|
||||
|
||||
<!-- Toolbar -->
|
||||
<v-toolbar color="blue darken-1" dark scroll-off-screen scroll-target="#scrolling-techniques">
|
||||
|
||||
<v-toolbar-title class="headline font-weight-bold">Replication Status</v-toolbar-title>
|
||||
<v-spacer></v-spacer>
|
||||
<v-chip v-if="is_error" label color="error" dark>ERROR</v-chip>
|
||||
<v-btn color="success" small @click="startSlave()" dark>
|
||||
Start Slave
|
||||
</v-btn>
|
||||
</v-toolbar>
|
||||
<!-- End Toolbar -->
|
||||
|
||||
<div id="scrolling-techniques" class="scroll-y" :style="{ 'height': windowHeight }">
|
||||
|
||||
<!-- data tabel -->
|
||||
<v-data-table :items="vreplication" :loading="isLoading" hide-actions>
|
||||
<v-progress-linear v-slot:progress color="blue" indeterminate></v-progress-linear>
|
||||
<template v-slot:no-data>
|
||||
<v-alert :value="true" color="error" icon="warning">
|
||||
Belum ditemukan data
|
||||
</v-alert>
|
||||
</template>
|
||||
<template v-slot:items="props">
|
||||
<tr>
|
||||
<td>Master Host</td>
|
||||
<td>: </td>
|
||||
<td class="text-xs-left pa-2" @click="selectMe(props.item)">{{ props.item.Master_Host}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Master Log File</td>
|
||||
<td>: </td>
|
||||
<td class="text-xs-left pa-2" @click="selectMe(props.item)">{{ props.item.Master_Log_File }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Relay Log File</td>
|
||||
<td>: </td>
|
||||
<td class="text-xs-left pa-2" @click="selectMe(props.item)">{{ props.item.Relay_Log_File }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Slave IO Running</td>
|
||||
<td>: </td>
|
||||
<td class="text-xs-left pa-2" @click="selectMe(props.item)">{{ props.item.Slave_IO_Running }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Slave SQL Running</td>
|
||||
<td>: </td>
|
||||
<td class="text-xs-left pa-2" @click="selectMe(props.item)">{{ props.item.Slave_SQL_Running }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Exec Master Log Pos</td>
|
||||
<td>: </td>
|
||||
<td class="text-xs-left pa-2" @click="selectMe(props.item)">{{ props.item.Exec_Master_Log_Pos }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Seconds Behind Master</td>
|
||||
<td>: </td>
|
||||
<td class="text-xs-left pa-2" @click="selectMe(props.item)">{{ props.item.Seconds_Behind_Master }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Last IO Errno</td>
|
||||
<td>: </td>
|
||||
<td class="text-xs-left pa-2" @click="selectMe(props.item)">{{ props.item.Last_IO_Errno }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Last IO Error</td>
|
||||
<td>: </td>
|
||||
<td class="text-xs-left pa-2" @click="selectMe(props.item)">{{ props.item.Last_IO_Error }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Last SQL Errno</td>
|
||||
<td>: </td>
|
||||
<td class="text-xs-left pa-2" @click="selectMe(props.item)">{{ props.item.Last_SQL_Errno }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Last SQL Error</td>
|
||||
<td>: </td>
|
||||
<td class="text-xs-left pa-2" @click="selectMe(props.item)">{{ props.item.Last_SQL_Error }}</td>
|
||||
</tr>
|
||||
</template>
|
||||
</v-data-table>
|
||||
<!-- end data tabel -->
|
||||
|
||||
</div>
|
||||
<v-divider></v-divider>
|
||||
<!-- pagination -->
|
||||
<v-flex xs12 class="text-xs-left pt-3 pb-5">
|
||||
|
||||
</v-flex>
|
||||
<!-- end pagination -->
|
||||
</v-card>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.searchbox .v-input.v-text-field .v-input__slot {
|
||||
min-height: 60px;
|
||||
}
|
||||
|
||||
.searchbox .v-btn {
|
||||
min-height: 60px;
|
||||
}
|
||||
|
||||
table.v-table tbody td,
|
||||
table.v-table tbody th {
|
||||
height: 40px;
|
||||
}
|
||||
|
||||
table.v-table thead tr {
|
||||
height: 40px;
|
||||
}
|
||||
|
||||
.textinput {
|
||||
-webkit-transition: width 0.4s ease-in-out;
|
||||
transition: width 0.4s ease-in-out;
|
||||
background-color: white;
|
||||
background-position: 10px 10px;
|
||||
background-repeat: no-repeat;
|
||||
padding-left: 40px;
|
||||
width: 100%;
|
||||
padding: 8px 10px;
|
||||
margin-bottom: 5px;
|
||||
box-sizing: border-box;
|
||||
border: 1px solid #607d8b;
|
||||
|
||||
}
|
||||
|
||||
.textinput:focus {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.textinput:focus::-webkit-input-placeholder {
|
||||
color: transparent;
|
||||
}
|
||||
|
||||
.textinput:focus::-moz-placeholder {
|
||||
color: transparent;
|
||||
}
|
||||
|
||||
.textinput:-moz-placeholder {
|
||||
color: transparent;
|
||||
}
|
||||
|
||||
.boxoutline {
|
||||
color: red;
|
||||
border: 1px solid red;
|
||||
justify-content: center;
|
||||
height: 45px;
|
||||
line-height: 45px;
|
||||
padding-left: 10px;
|
||||
background: #ffffff;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
border-radius: 1px
|
||||
}
|
||||
|
||||
.boxoutline:hover {
|
||||
background: rgba(0, 0, 0, 0.07) !important;
|
||||
font-size: 15px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.boxsolid {
|
||||
color: #ffffff;
|
||||
border: 1px solid #ffffff;
|
||||
justify-content: center;
|
||||
height: 45px;
|
||||
line-height: 45px;
|
||||
padding-left: 10px;
|
||||
background: #f44336;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
border-radius: 1px
|
||||
}
|
||||
|
||||
.boxsolid:hover {
|
||||
background: #f44336de;
|
||||
font-size: 15px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.scroll-container {
|
||||
scroll-padding: 50px 0 0 50px;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar {
|
||||
width: 7px;
|
||||
}
|
||||
|
||||
/* this targets the default scrollbar (compulsory) */
|
||||
|
||||
::-webkit-scrollbar-track {
|
||||
background-color: #73baf3;
|
||||
}
|
||||
|
||||
/* the new scrollbar will have a flat appearance with the set background color */
|
||||
|
||||
::-webkit-scrollbar-thumb {
|
||||
background-color: #2196f3;
|
||||
}
|
||||
|
||||
/* this will style the thumb, ignoring the track */
|
||||
|
||||
::-webkit-scrollbar-button {
|
||||
background-color: #0079da;
|
||||
}
|
||||
|
||||
/* optionally, you can style the top and the bottom buttons (left and right for horizontal bars) */
|
||||
|
||||
::-webkit-scrollbar-corner {
|
||||
background-color: black;
|
||||
}
|
||||
|
||||
/* if both the vertical and the horizontal bars appear, then perhaps the right bottom corner also needs to be styled */
|
||||
</style>
|
||||
|
||||
<script>
|
||||
module.exports = {
|
||||
data() {
|
||||
return {
|
||||
windowHeight: window.innerHeight - ((38/100)*window.outerHeight) + 'px'
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
this.$store.dispatch("replication/status")
|
||||
},
|
||||
computed: {
|
||||
vreplication() {
|
||||
return this.$store.state.replication.replication
|
||||
},
|
||||
isLoading() {
|
||||
return this.$store.state.replication.search_status
|
||||
},
|
||||
is_error: {
|
||||
get() {
|
||||
select = this.$store.state.replication.selected_replication
|
||||
if (select.Slave_IO_Running === "No") {
|
||||
return true
|
||||
}
|
||||
if (select.Slave_SQL_Running === "No") {
|
||||
return true
|
||||
}
|
||||
if (select.Last_IO_Errno != "0") {
|
||||
return true
|
||||
}
|
||||
if (select.Last_SQL_Errno != "0") {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// isSelected(p) {
|
||||
// return p.Slave_IO_State == this.$store.state.replication.selected_replication.Slave_IO_State
|
||||
// },
|
||||
selectMe(selected) {
|
||||
this.$store.commit("replication/update_selected_replication", selected)
|
||||
},
|
||||
startSlave() {
|
||||
this.$store.dispatch("replication/start_slave")
|
||||
this.$store.dispatch("replication/status")
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
70
test/vuex/one-ui-replication-status/index.php
Normal file
70
test/vuex/one-ui-replication-status/index.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title>One</title>
|
||||
<link rel="stylesheet" href="../../../libs/vendor/css/google-fonts.css">
|
||||
<link rel="stylesheet" href="../../../libs/vendor/css/vuetify.min.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div v-cloak id="app">
|
||||
<v-app id="smartApp" >
|
||||
<one-navbar></one-navbar>
|
||||
<v-content class="blue lighten-5" >
|
||||
<v-container fluid fill-height class="pl-1 pr-1 pt-2 pb-2">
|
||||
<v-layout row wrap >
|
||||
<v-flex xs12 class="left" fill-height pa-1>
|
||||
<one-list-replication-status></one-list-replication-status>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
</v-container>
|
||||
</v-content>
|
||||
<one-footer> </one-footer>
|
||||
</v-app>
|
||||
</div>
|
||||
|
||||
<!-- Vendor -->
|
||||
<script src="../../../libs/vendor/moment.min.js"></script>
|
||||
<script src="../../../libs/vendor/numeral.min.js"></script>
|
||||
<script src="../../../libs/vendor/moment-locale-id.js"></script>
|
||||
<script src="../../../libs/vendor/lodash.js"></script>
|
||||
<script src="../../../libs/vendor/axios.min.js"></script>
|
||||
<script src="../../../libs/vendor/vue.js"></script>
|
||||
<script src="../../../libs/vendor/vuex.js"></script>
|
||||
<script src="../../../libs/vendor/vuetify.js"></script>
|
||||
<script src="../../../libs/vendor/httpVueLoader.js"></script>
|
||||
<script src="../../../libs/one_global.js"></script>
|
||||
<!-- App Script -->
|
||||
<?php
|
||||
$ts = "?ts=" . Date("ymdhis");
|
||||
?>
|
||||
<script type="module">
|
||||
import { store } from './store.js<?php echo $ts ?>';
|
||||
//for testing
|
||||
window.store = store;
|
||||
new Vue({
|
||||
store,
|
||||
el: '#app',
|
||||
components: {
|
||||
'one-navbar': httpVueLoader('../../../apps/components/oneNavbarComponent.vue'),
|
||||
'one-footer': httpVueLoader('../../../apps/components/oneFooter.vue'),
|
||||
'one-list-replication-status': httpVueLoader('./components/oneReplicationStatus.vue')
|
||||
}
|
||||
})
|
||||
</script>
|
||||
<style>
|
||||
[v-cloak] {
|
||||
display: none
|
||||
}
|
||||
.left {
|
||||
}
|
||||
.right {
|
||||
}
|
||||
</style>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
87
test/vuex/one-ui-replication-status/modules/replication.js
Normal file
87
test/vuex/one-ui-replication-status/modules/replication.js
Normal file
@@ -0,0 +1,87 @@
|
||||
// 1 => LOADING
|
||||
// 2 => DONE
|
||||
// 3 => ERROR
|
||||
import * as api from "../api/replication.js"
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
replication: [],
|
||||
search_status: false,
|
||||
last_id: -1,
|
||||
selected_replication: {},
|
||||
startslave: []
|
||||
},
|
||||
mutations: {
|
||||
update_replication(state, val) {
|
||||
state.replication = val
|
||||
},
|
||||
update_search_status(state, val) {
|
||||
state.search_status = val
|
||||
},
|
||||
update_last_id(state, val) {
|
||||
state.last_id = val
|
||||
},
|
||||
update_selected_replication(state, val) {
|
||||
state.selected_replication = val
|
||||
},
|
||||
update_startslave(state, val) {
|
||||
state.startslave = val
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
async status(context) {
|
||||
context.commit("update_search_status", true)
|
||||
try {
|
||||
var prm = {
|
||||
token: one_token()
|
||||
}
|
||||
let resp = await api.status(prm)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_search_status", false)
|
||||
console.log(resp.message)
|
||||
} else {
|
||||
context.commit("update_search_status", false)
|
||||
let data = {
|
||||
records: resp.data.records
|
||||
}
|
||||
context.commit("update_replication", data.records)
|
||||
if (context.state.last_id == -1) {
|
||||
if (resp.data && resp.data.records.length > 0) {
|
||||
context.commit("update_selected_replication", resp.data.records[0])
|
||||
}
|
||||
} else {
|
||||
let idx = _.findIndex(resp.data.records, function (o) {
|
||||
});
|
||||
console.log(idx)
|
||||
if (idx >= 0) {
|
||||
context.commit("update_selected_replication", resp.data.records[idx]);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_search_status", false)
|
||||
console.log(e)
|
||||
}
|
||||
},
|
||||
|
||||
async start_slave(context) {
|
||||
try {
|
||||
var prm = {
|
||||
token: one_token()
|
||||
}
|
||||
let resp = await api.start_slave(prm)
|
||||
if (resp.status != "OK") {
|
||||
console.log(resp.message)
|
||||
} else {
|
||||
let data = {
|
||||
data: resp.data
|
||||
}
|
||||
context.commit("update_startslave", data.data)
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
23
test/vuex/one-ui-replication-status/store.js
Normal file
23
test/vuex/one-ui-replication-status/store.js
Normal file
@@ -0,0 +1,23 @@
|
||||
// State
|
||||
// data ...
|
||||
// Mutations
|
||||
//
|
||||
//
|
||||
// Actions
|
||||
import replication from "./modules/replication.js";
|
||||
import system from "../../../apps/modules/system/system.js";
|
||||
export const store = new Vuex.Store({
|
||||
modules: {
|
||||
replication: replication,
|
||||
system:system
|
||||
},
|
||||
state: {
|
||||
|
||||
},
|
||||
mutations: {
|
||||
|
||||
},
|
||||
actions: {
|
||||
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user