Skip to content

Commit

Permalink
Merge pull request #726 from SCADA-LTS/feature_m/#721_State_last_of_r…
Browse files Browse the repository at this point in the history
…efresh_data

#721 Added component isAlive (IsAlive.vue, main.js, package.json, Mis…
  • Loading branch information
grzesiekb authored Oct 18, 2018
2 parents c614a69 + 8ee2882 commit 663a082
Show file tree
Hide file tree
Showing 7 changed files with 3,041 additions and 2,922 deletions.
6 changes: 4 additions & 2 deletions ScadaLTS-UI-1/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@
"dependencies": {
"ajv": "^6.5.2",
"axios": "^0.18.0",
"bootstrap": "^3.3.7",
"material-design-icons-iconfont": "^3.0.3",
"moment": "^2.22.2",
"vue": "^2.5.2",
"uiv": "^0.27.0",
"vue": "2.5.2",
"vue-jsoneditor": "^1.0.13",
"vue-router": "^3.0.1",
"vuetify": "^1.0.19"
Expand Down Expand Up @@ -75,7 +77,7 @@
"vue-jest": "^1.0.2",
"vue-loader": "^13.3.0",
"vue-style-loader": "^3.0.1",
"vue-template-compiler": "^2.5.2",
"vue-template-compiler": "2.5.2",
"webpack": "^3.6.0",
"webpack-bundle-analyzer": "^2.9.0",
"webpack-dev-server": "^2.9.1",
Expand Down
89 changes: 89 additions & 0 deletions ScadaLTS-UI-1/src/components/IsAlive.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<template>
<div>
<alert v-if="bdanger" id="p_is_alive" type="danger"><b>Error</b> - time of the latest server response: {{timeFromServer | moment}} </alert>
<alert v-if="bwarning" id="p_is_alive" type="warning"><b>Warning</b> - time of the latest server response: {{timeFromServer | moment}}</alert>
<alert v-if="bsuccess" id="p_is_alive" type="success">{{label}}</alert>
<popover title="Is Alive" target="#p_is_alive" trigger="hover">
<template slot="popover">
<p class="p_is_now">Time from web browser: <b>{{timeInWeb | moment}}</b></p>
<p class="p_is_last_time_modyfication">Time of the latest server response: <b>{{timeFromServer | moment}}</b></p>
<p>Refresh time: {{timeRefresh}} [ms]</p>
<p>Time before warning: {{timeWarning}} [ms]</p>
<p>Time before error: {{timeError}} [ms]</p>
</template>
</popover>
</div>
</template>

<script>
import moment from "moment";
/**
* @author grzegorz.bylica@gmail.com
*/
export default {
props: ['plabel', 'ptimeWarning', 'ptimeError', 'ptimeRefresh'],
data() {
return {
label: this.plabel, // "Is alive"
timeWarning: this.ptimeWarning, // 5000 [ms]
timeError: this.ptimeError, // 10000 [ms]
timeRefresh: this.ptimeRefresh, // 1000 [ms]
timeInWeb: 0,
timeFromServer: 0,
bdanger: false,
bwarning: false,
bsuccess: true
};
},
methods: {
getTime() {
this.timeInWeb = new Date();
return this.timeInWeb;
},
getTimeFromServer() {
this.timeFromServer = lasTimeUpdate;
return this.timeFromServer;
},
checkTimeWarning() {
let isDanger =
this.getTime() - this.getTimeFromServer() > this.timeError;
if (isDanger) {
this.bwarning = false;
this.bsuccess = false;
this.bdanger = true;
} else {
let isWarning =
this.getTime() - this.getTimeFromServer() > this.timeWarning;
if (isWarning) {
this.bdanger = false;
this.bsuccess = false;
this.bwarning = true;
} else {
this.bdanger = false;
this.bwarning = false;
this.bsuccess = true;
}
}
}
},
created() {
if (this.timeRefresh) {
setInterval(
function() {
this.checkTimeWarning();
}.bind(this),
this.timeRefresh
);
}
},
filters: {
moment: function(date) {
return moment(date).format(" hh:mm:ss");
}
}
};
</script>

<style>
</style>
17 changes: 15 additions & 2 deletions ScadaLTS-UI-1/src/main.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import 'bootstrap/dist/css/bootstrap.min.css'

import Vue from 'vue'
import App from './App'
import Test from './components/Test'
import IsAlive from './components/IsAlive'
import ExportImportPointHierarchy from './components/ExportImportPointHierarchy'
import SimpleComponentSVG from './components/SimpleComponentSVG'
import router from './router'
import VJsoneditor from 'vue-jsoneditor';
import Vuetify from 'vuetify';
import * as uiv from 'uiv'

import 'bootstrap/dist/css/bootstrap.min.css'


Vue.config.productionTip = false
Vue.use(VJsoneditor);
Vue.use(Vuetify);
Vue.use(uiv);

/*eslint-disable no-new */
new Vue({
Expand All @@ -21,25 +29,30 @@ new Vue({
template: '<App/>'
})


new Vue({
el: '#test',
components: { Test },
template: '<Test/>'
})

new Vue({
el: '#app-is-alive',
components: {
"is-alive": IsAlive
},
})

new Vue({
el: '#export-import-ph',
components: { ExportImportPointHierarchy },
template: '<ExportImportPointHierarchy/>'
})


new Vue({
el: '#app',
components: {
"simple-component-svg": SimpleComponentSVG,
"export-import-ph": ExportImportPointHierarchy
}
})

Loading

0 comments on commit 663a082

Please sign in to comment.