Skip to content

Commit

Permalink
#721 Added component isAlive (IsAlive.vue, main.js, package.json, Mis…
Browse files Browse the repository at this point in the history
…cDwr.java, common.js, views.jsp) and some correct messages_fi.properties
  • Loading branch information
grzesiekb committed Oct 17, 2018
1 parent c444c79 commit 3a66599
Show file tree
Hide file tree
Showing 7 changed files with 128 additions and 9 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
}
})

1 change: 1 addition & 0 deletions WebContent/WEB-INF/classes/messages_fi.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2903,4 +2903,5 @@ menu.point_hierarchy.add.tooltip=Add folder
menu.point_hierarchy.delete.tooltip=Delete folder / Move point to root
menu.point_hierarchy.refresh.tooltip=Refresh
menu.point_hierarchy.info.tooltip=Info
dsList.statusDescribe=Status description

10 changes: 8 additions & 2 deletions WebContent/WEB-INF/jsp/views.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,18 @@
<script type="text/javascript" src="resources/wz_jsgraphics.js"></script>
<script type="text/javascript" src="resources/shortcut.js"></script>
<script type="text/javascript" src="resources/customClientScripts/customView.js"></script>
<link href="resources/new-ui/css/app.css" rel="stylesheet" type="text/css">
<link
href="resources/app/bower_components/sweetalert2/dist/sweetalert2.min.css"
rel="stylesheet" type="text/css">

<style>
table {
border-collapse: separate !important;
border-spacing: 2px !important;
}
</style>
<script type="text/javascript" src="resources/app/bower_components/sweetalert2/dist/sweetalert2.min.js"></script>

<script type="text/javascript">
jQuery.noConflict();
Expand Down
8 changes: 7 additions & 1 deletion WebContent/resources/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@

var mango = {};

// last time update

var lasTimeUpdate;

//
// String prototypes
//
Expand Down Expand Up @@ -103,7 +107,9 @@ mango.longPoll.pollCB = function(response) {
mango.soundPlayer.stop();
}
}

if (response.runtime) {
lasTimeUpdate = response.runtime;
}
if (response.watchListStates)
mango.view.watchList.setData(response.watchListStates);

Expand Down
6 changes: 4 additions & 2 deletions src/com/serotonin/mango/web/dwr/MiscDwr.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import org.apache.commons.logging.LogFactory;
import org.directwebremoting.WebContext;
import org.directwebremoting.WebContextFactory;
import org.scada_lts.dao.SystemSettingsDAO;
import org.springframework.beans.propertyeditors.LocaleEditor;
import org.springframework.web.servlet.LocaleResolver;
import org.springframework.web.servlet.i18n.SessionLocaleResolver;
Expand All @@ -46,7 +47,6 @@
import com.serotonin.mango.Common;
import com.serotonin.mango.db.dao.EventDao;
import com.serotonin.mango.db.dao.MailingListDao;
import org.scada_lts.dao.SystemSettingsDAO;
import com.serotonin.mango.db.dao.UserDao;
import com.serotonin.mango.rt.EventManager;
import com.serotonin.mango.rt.event.EventInstance;
Expand Down Expand Up @@ -305,7 +305,9 @@ public Map<String, Object> doLongPoll(int pollSessionId) {

LongPollRequest pollRequest = data.getRequest();

long expireTime = System.currentTimeMillis() + 60000; // One minute
long runTime = System.currentTimeMillis();
response.put("runtime",runTime);
long expireTime = runTime + 60000; // One minute
LongPollState state = data.getState();
int waitTime = SystemSettingsDAO
.getIntValue(SystemSettingsDAO.UI_PERFORMANCE);
Expand Down

0 comments on commit 3a66599

Please sign in to comment.