fixed service page

pull/655/head
hunterlong 2020-06-10 17:19:16 -07:00
parent dde3951264
commit a86b8de718
15 changed files with 100 additions and 188 deletions

View File

@ -1,5 +1,6 @@
# 0.90.47 (06-10-2020) # 0.90.47 (06-10-2020)
- Modified HTTP server, now in it's own go routine/channel - Modified HTTP server, now in it's own go routine/channel
- Fixed Service form for editing
- Added pprof golang debugging http server if `GO_ENV` == "test" - Added pprof golang debugging http server if `GO_ENV` == "test"
- Added `HOST` env variable (hostname for http server) - Added `HOST` env variable (hostname for http server)
- Added `DISABLE_HTTP` env variable (defaults to false, disables the http server) - Added `DISABLE_HTTP` env variable (defaults to false, disables the http server)

View File

@ -23,7 +23,7 @@
</template> </template>
<script> <script>
import ServiceInfo from "../Service/ServiceInfo"; const ServiceInfo = () => import('@/components/Service/ServiceInfo')
export default { export default {
name: 'DashboardIndex', name: 'DashboardIndex',

View File

@ -59,11 +59,11 @@
</template> </template>
<script> <script>
import FormGroup from "../../forms/Group"; const FormGroup = () => import('@/forms/Group')
const ToggleSwitch = () => import('@/forms/ToggleSwitch')
const ServicesList = () => import('@/components/Dashboard/ServicesList')
import Api from "../../API"; import Api from "../../API";
import ToggleSwitch from "../../forms/ToggleSwitch";
import draggable from 'vuedraggable' import draggable from 'vuedraggable'
import ServicesList from './ServicesList';
export default { export default {
name: 'DashboardServices', name: 'DashboardServices',

View File

@ -45,7 +45,7 @@
<script> <script>
import Api from "../../API" import Api from "../../API"
import FormUser from "../../forms/User"; const FormUser = () => import('@/forms/User')
export default { export default {
name: 'DashboardUsers', name: 'DashboardUsers',

View File

@ -1,150 +1,55 @@
<template> <template>
<div class="col-12">
<div v-if='ready'> <div v-if="!ready" class="row mt-5">
<div class="col-12 text-center">
<div v-if='errorCode==404' class="col-12"> <font-awesome-icon icon="circle-notch" size="3x" spin/>
<div class="alert alert-warning" role="alert"> </div>
Service {{ this.$route.params.id }} not found! <div class="col-12 text-center mt-3 mb-3">
<router-link v-if="$store.state.admin" to="/dashboard/create_service" class="btn btn-sm btn-outline-success float-right"> <span class="text-muted">Loading Service</span>
<font-awesome-icon icon="plus"/> Create One?
</router-link>
</div> </div>
</div> </div>
<FormService v-if="ready" :in_service="service"/>
<div v-else-if='errorCode==401' class="col-12">
<div class="alert alert-danger" role="alert">
Unauthorized! Perhaps your session has expired?
</div>
</div>
<div v-else class="col-12">
<FormService :in_service="service"/>
</div>
</div> </div>
<div v-else>
<div class="text-center">
<div class="spinner-border text-primary" role="status">
<span class="sr-only">Loading...</span>
</div>
</div>
</div>
</template> </template>
<script> <script>
import Api from "@/API"; import FormGroup from "../../forms/Group";
import FormService from "@/forms/Service"; import Api from "../../API";
import ToggleSwitch from "../../forms/ToggleSwitch";
import draggable from 'vuedraggable'
import FormService from "../../forms/Service";
export default { export default {
name: 'EditService', name: 'EditService',
components: { components: {
FormService, FormService,
}, ToggleSwitch,
props: { FormGroup,
draggable
}, },
data () { created() {
return { this.fetchData()
ready: false, },
errorCode: 'none', watch: {
service: { '$route': 'fetchData'
name: "", },
type: "http", data () {
domain: "", return {
group_id: 0, service: null,
method: "GET", ready: false
post_data: "", }
headers: "", },
expected: "", methods: {
expected_status: 200, async fetchData () {
port: 80, if (!this.$route.params.id) {
check_interval: 60, this.ready = true
timeout: 15, return
permalink: "", }
order: 1, this.service = await Api.service(this.$route.params.id)
verify_ssl: true, this.ready = true
redirect: true, }
allow_notifications: true,
notify_all_changes: true,
notify_after: 2,
public: true,
tls_cert: "",
tls_cert_key: "",
tls_cert_root: "",
},
} }
},
// because route changes within the same component are re-used
watch: {
$route(to, from) {
this.errorCode = 'none';
this.ready = true;
}
},
// beforeCreated() causes sync issues with mounted() as they are executed
// one after the other regardless of async/await methods inside.
mounted() {
const id = this.$route.params.id
if (id) {
this.loadService(id);
} else {
this.errorCode = 'none';
this.ready = true;
};
},
methods: {
async loadService(id){
this.ready = false;
// api still responds if session is invalid
// specifically, if statping is restarted and an existing session exists
// theres a further check to not display the data in the form component it seems ??
await Api.service(id).then(
response => {
this.service = response;
this.errorCode = 'none';
this.ready = true;
},
error => {
const respStatus = error.response.status;
if ( respStatus == '404' ) {
this.errorCode = 404;
} else if ( respStatus == '401' ) {
this.errorCode = 401 ;
} else {
this.errorCode = 'none';
};
this.ready = true;
}
);
}
} }
}
</script> </script>
<!-- Add "scoped" attribute to limit CSS to this component only --> <!-- Add "scoped" attribute to limit CSS to this component only -->

View File

@ -45,13 +45,13 @@
</form> </form>
</div> </div>
</div> </div>
</div> </div>
</template> </template>
<script> <script>
import Api from "../../API"; import Api from "../../API";
import FormIncidentUpdates from "@/forms/IncidentUpdates"; const FormIncidentUpdates = () => import('@/forms/IncidentUpdates')
export default { export default {
name: 'Incidents', name: 'Incidents',

View File

@ -56,7 +56,9 @@
</div> </div>
</div> </div>
<button @click.prevent="saveSettings" id="save_core" type="submit" class="btn btn-primary btn-block mt-3">Save Settings</button> <button @click.prevent="saveSettings" id="save_core" type="submit" class="btn btn-primary btn-block mt-3" v-bind:disabled="loading">
<font-awesome-icon v-if="loading" icon="circle-notch" class="mr-2" spin/>Save Settings
</button>
</form> </form>
</template> </template>
@ -66,6 +68,11 @@
export default { export default {
name: 'CoreSettings', name: 'CoreSettings',
data () {
return {
loading: false
}
},
computed: { computed: {
core() { core() {
return this.$store.getters.core return this.$store.getters.core
@ -73,10 +80,12 @@
}, },
methods: { methods: {
async saveSettings() { async saveSettings() {
this.loading = true
const c = this.core const c = this.core
await Api.core_save(c) await Api.core_save(c)
const core = await Api.core() const core = await Api.core()
this.$store.commit('setCore', core) this.$store.commit('setCore', core)
setInterval(() => { this.loading = false }, 1500)
}, },
selectAll() { selectAll() {
this.$refs.input.select(); this.$refs.input.select();

View File

@ -292,7 +292,7 @@
} }
}, },
watch: { watch: {
in_service: function(svr) { in_service(svr, old) {
this.service = svr this.service = svr
this.use_tls = svr.tls_cert this.use_tls = svr.tls_cert
} }
@ -312,7 +312,7 @@
if (this.in_service) { if (this.in_service) {
this.service = this.in_service this.service = this.in_service
} }
this.use_tls = this.service.tls_cert this.use_tls = this.service.tls_cert !== ""
}, },
updatePermalink() { updatePermalink() {
const a = 'àáâäæãåāăąçćčđďèéêëēėęěğǵḧîïíīįìłḿñńǹňôöòóœøōõőṕŕřßśšşșťțûüùúūǘůűųẃẍÿýžźż·/_,:;' const a = 'àáâäæãåāăąçćčđďèéêëēėęěğǵḧîïíīįìłḿñńǹňôöòóœøōõőṕŕřßśšşșťțûüùúūǘůűųẃẍÿýžźż·/_,:;'

View File

@ -8,7 +8,7 @@ import VueI18n from 'vue-i18n'
import router from './routes' import router from './routes'
import "./mixin" import "./mixin"
import "./icons" import "./icons"
import App from '@/App.vue' const App = () => import('@/App.vue')
import store from './store' import store from './store'
import language from './languages' import language from './languages'

View File

@ -6,8 +6,7 @@
</template> </template>
<script> <script>
import Api from "../API" const TopNav = () => import('@/components/Dashboard/TopNav')
import TopNav from "../components/Dashboard/TopNav";
export default { export default {
name: 'Dashboard', name: 'Dashboard',

View File

@ -34,14 +34,12 @@
</template> </template>
<script> <script>
import Api from '../API'; const Group = () => import('@/components/Index/Group')
import Group from '../components/Index/Group'; const Header = () => import('@/components/Index/Header')
import Header from '../components/Index/Header'; const MessageBlock = () => import('@/components/Index/MessageBlock')
import MessageBlock from '../components/Index/MessageBlock'; const ServiceBlock = () => import('@/components/Service/ServiceBlock')
import ServiceBlock from '../components/Service/ServiceBlock'; const GroupServiceFailures = () => import('@/components/Index/GroupServiceFailures')
import GroupServiceFailures from "../components/Index/GroupServiceFailures"; const IncidentsBlock = () => import('@/components/Index/IncidentsBlock')
import IncidentsBlock from "../components/Index/IncidentsBlock";
export default { export default {
name: 'Index', name: 'Index',

View File

@ -10,8 +10,7 @@
</template> </template>
<script> <script>
import Api from "../API"; const FormLogin = () => import('@/forms/Login')
import FormLogin from '../forms/Login';
export default { export default {
name: 'Login', name: 'Login',

View File

@ -64,15 +64,15 @@
<script> <script>
import Api from "../API" import Api from "../API"
import MessageBlock from '../components/Index/MessageBlock'; const MessageBlock = () => import('@/components/Index/MessageBlock')
import ServiceFailures from '../components/Service/ServiceFailures'; const ServiceFailures = () => import('@/components/Service/ServiceFailures')
import Checkin from "../forms/Checkin"; const Checkin = () => import('@/forms/Checkin')
import ServiceHeatmap from "@/components/Service/ServiceHeatmap"; const ServiceHeatmap = () => import('@/components/Service/ServiceHeatmap')
import ServiceTopStats from "@/components/Service/ServiceTopStats"; const ServiceTopStats = () => import('@/components/Service/ServiceTopStats')
import store from '../store' const AdvancedChart = () => import('@/components/Service/AdvancedChart')
import flatPickr from 'vue-flatpickr-component'; import flatPickr from 'vue-flatpickr-component';
import 'flatpickr/dist/flatpickr.css'; import 'flatpickr/dist/flatpickr.css';
import AdvancedChart from "@/components/Service/AdvancedChart";
const timeoptions = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric', hour: 'numeric', minute: 'numeric' }; const timeoptions = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric', hour: 'numeric', minute: 'numeric' };
const axisOptions = { const axisOptions = {

View File

@ -261,14 +261,15 @@
<script> <script>
import Api from '../API'; import Api from '../API';
import CoreSettings from '../forms/CoreSettings';
import FormIntegration from '../forms/Integration';
import Notifier from "../forms/Notifier";
import ThemeEditor from "../components/Dashboard/ThemeEditor";
import Cache from "@/components/Dashboard/Cache";
import OAuth from "../forms/OAuth";
import GithubButton from 'vue-github-button' import GithubButton from 'vue-github-button'
const CoreSettings = () => import('@/forms/CoreSettings')
const FormIntegration = () => import('@/forms/Integration')
const Notifier = () => import('@/forms/Notifier')
const OAuth = () => import('@/forms/OAuth')
const ThemeEditor = () => import('@/components/Dashboard/ThemeEditor')
const Cache = () => import('@/components/Dashboard/Cache')
export default { export default {
name: 'Settings', name: 'Settings',
components: { components: {

View File

@ -1,21 +1,21 @@
import Index from "./pages/Index"; const Index = () => import('@/pages/Index')
import Dashboard from "./pages/Dashboard"; const Dashboard = () => import('@/pages/Dashboard')
import DashboardIndex from "./components/Dashboard/DashboardIndex"; const DashboardIndex = () => import('@/components/Dashboard/DashboardIndex')
import DashboardUsers from "./components/Dashboard/DashboardUsers"; const DashboardUsers = () => import('@/components/Dashboard/DashboardUsers')
import DashboardServices from "./components/Dashboard/DashboardServices"; const DashboardServices = () => import('@/components/Dashboard/DashboardServices')
import EditService from "./components/Dashboard/EditService"; const DashboardMessages = () => import('@/components/Dashboard/DashboardMessages')
import DashboardMessages from "./components/Dashboard/DashboardMessages"; const EditService = () => import('@/components/Dashboard/EditService')
import Logs from './pages/Logs'; const Logs = () => import('@/pages/Logs')
import Settings from "./pages/Settings"; const Settings = () => import('@/pages/Settings')
import Login from "./pages/Login"; const Login = () => import('@/pages/Login')
import Service from "./pages/Service"; const Service = () => import('@/pages/Service')
import VueRouter from "vue-router"; const Setup = () => import('@/forms/Setup')
import Setup from "./forms/Setup"; const Incidents = () => import('@/components/Dashboard/Incidents')
const Checkins = () => import('@/components/Dashboard/Checkins')
const Failures = () => import('@/components/Dashboard/Failures')
import VueRouter from "vue-router";
import Api from "./API"; import Api from "./API";
import Incidents from "@/components/Dashboard/Incidents";
import Checkins from "@/components/Dashboard/Checkins";
import Failures from "@/components/Dashboard/Failures";
const routes = [ const routes = [
{ {