Commit 0dbe71f2 0dbe71f2defc6e4db04398fffe5d0596dd2613be by root

Добавление функционала: перезагрузка, выключение, установка параметров

NTP 
1 parent 3a8d7501
Showing 31 changed files with 572 additions and 218 deletions
eclipse.preferences.version=1
encoding//src/main/webapp/WEB-INF/views/login.jsp=UTF-8
......@@ -128,19 +128,7 @@
<version>1.2</version>
</dependency>
<!-- Test -->
<dependency>
......@@ -193,7 +181,11 @@
<version>1.0</version>
</dependency>
<dependency>
<groupId>org.emercit</groupId>
<artifactId>dtmanager</artifactId>
<version>1.2</version>
</dependency>
......@@ -201,6 +193,23 @@
</dependencies>
<repositories>
<!-- For testing against latest Spring snapshots -->
<repository>
......@@ -226,7 +235,17 @@
<repository>
<repository>
<id>project.local</id>
<name>project</name>
<url>file:/root/git/hardwareconfig/DevTools/repo</url>
</repository>
<repository>
<id>org.repo.jfrog.artifactory.libs-releases</id>
<name>Repository1</name>
<url>http://repo.jfrog.org/artifactory/libs-releases</url>
......
9b270266d406498c4c46a39cf6a66def
\ No newline at end of file
06a207b558d6eaed84033124b59981ecb7d71466
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>org.emercit</groupId>
<artifactId>dtmanager</artifactId>
<version>1.1</version>
</project>
a4aa91f89ab51f76f964dea56f98dd86
\ No newline at end of file
8f121b8c03501fd42750867dfc24c41526faf68e
\ No newline at end of file
d866175ba3e831cb50eff67dccf1c5e3
\ No newline at end of file
0a9b721ea35bbe6d87e490184ca427a9a1326b04
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>org.emercit</groupId>
<artifactId>dtmanager</artifactId>
<version>1.2</version>
</project>
0f3dd1c62f9bcdb88159382dd9ab1fc3
\ No newline at end of file
da6b0490fdc274c0533e0ce714355a10d620e177
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<metadata>
<groupId>org.emercit</groupId>
<artifactId>dtmanager</artifactId>
<versioning>
<release>1.2</release>
<versions>
<version>1.1</version>
<version>1.2</version>
</versions>
<lastUpdated>20150723083113</lastUpdated>
</versioning>
</metadata>
7b199d75cde3425e268a167addd233a7
\ No newline at end of file
42b5711bbb0d86f2ddb7e7352797848c0e39afeb
\ No newline at end of file
package org.emercit.devtools.app;
import java.util.Locale;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.beans.factory.annotation.Autowired;
import javax.servlet.http.*;
import javax.servlet.ServletContext;
import java.io.*;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.Vector;
import org.emercit.ethmanager.model.EthBean;
import org.emercit.proxymanager.model.ProxyBean;
import org.emercit.devinfo.model.DevInfoBean;
import org.emercit.devtools.service.DevInfoService;
import org.emercit.devtools.service.DnsService;
import org.emercit.devtools.service.EthService;
import org.emercit.dnsmanager.model.DnsBean;
import java.util.ArrayList;
import java.util.List;
import org.emercit.devtools.service.DevControlService;
import org.emercit.dtmanager.model.DateInfo;
@Controller
@RequestMapping("api")
public class DevControlController {
@RequestMapping(value="devcontrol/ntp" , method = RequestMethod.POST)
public @ResponseBody boolean changeNtp(@RequestBody DateInfo m) {
return DevControlService.INSTANCE.ChangeNtp(m.ntp);
}
@RequestMapping(value = "devcontrol/dateinfo", method = RequestMethod.GET)
public @ResponseBody DateInfo getDi() {
return DevControlService.INSTANCE.getDateInfo();
}
@RequestMapping(value = "devcontrol/reboot", method = RequestMethod.GET)
public @ResponseBody boolean DevReboot() {
DevControlService.INSTANCE.Reboot();
return true;
}
@RequestMapping(value = "devcontrol/calibration", method = RequestMethod.GET)
public @ResponseBody boolean DvCalibration() {
DevControlService.INSTANCE.Calibration();
return true;
}
}
/*
url: 'api/devcontrol/ntp',
url: 'api/devcontrol/reboot',
url: 'api/devcontrol/off',
url: 'api/devcontrol/dateinfo',
*/
\ No newline at end of file
package org.emercit.devtools.service;
import org.emercit.devinfo.model.DevInfoBean;
import org.emercit.dtmanager.model.DateInfo;
import org.emercit.dtmanager.service.NtpLinux;
import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone;
import java.text.SimpleDateFormat;
import org.emercit.pckutils.cmd.CmdExec;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
public enum DevControlService {
INSTANCE;
private NtpLinux ntplinux= new NtpLinux();
private CmdExec cmdexec=new CmdExec();
public DateInfo getDateInfo() {
DateInfo dateinfo=new DateInfo();
dateinfo.ntp=ntplinux.getUseNtpServer();
Calendar calendar = Calendar.getInstance();
TimeZone.setDefault(TimeZone.getTimeZone("Europe/Moscow"));
TimeZone timeZone = calendar.getTimeZone();
Date date=calendar.getTime();
dateinfo.dt = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss").format(new Date());
return dateinfo;
}
public boolean ChangeNtp(String value) {
boolean result=ntplinux.setUsNtpServer(value);
if (result) {
try { cmdexec.Run("/etc/init.d/ntp restart"); } catch (Exception e) {};
}
return result;
}
public void Reboot() {
try { cmdexec.Run("reboot"); } catch (Exception e) {};
}
public void Off() {
try { cmdexec.Run("shutdown -h now"); } catch (Exception e) {};
}
public void Calibration() {
try { cmdexec.Run("/opt/devtools/calibrator.sh"); } catch (Exception e) {};
}
}
\ No newline at end of file
......@@ -4,8 +4,5 @@
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<!-- Файл с настройками безопасности -->
<import resource="security.xml" />
</beans>
\ No newline at end of file
......
<beans:beans xmlns="http://www.springframework.org/schema/security"
xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.0.xsd">
<http access-denied-page="/error403.jsp">
<intercept-url pattern="/" access="ROLE_USER,ROLE_ANONYMOUS" />
<intercept-url pattern="/add*" access="ROLE_USER" />
<intercept-url pattern="/delete/*" access="ROLE_ADMIN" />
<form-login login-page="/login.jsp" default-target-url="/index"
authentication-failure-url="/login.jsp?error=true" />
<logout logout-url="/logout" logout-success-url="/index" />
<anonymous username="guest" granted-authority="ROLE_ANONYMOUS" />
<remember-me />
</http>
<authentication-manager>
<authentication-provider>
<user-service>
<user name="admin" password="pass" authorities="ROLE_ADMIN,ROLE_USER" />
<user name="user1" password="1111" authorities="ROLE_USER" />
<user name="user2" password="2222" disabled="true" authorities="ROLE_USER" />
</user-service>
</authentication-provider>
</authentication-manager>
</beans:beans>
\ No newline at end of file
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<html>
<head></head>
<body>
<h1>Anonymous page</h1>
<a href="<c:url value="/login.html" />">To Login</a>
</body>
</html>
\ No newline at end of file
......@@ -48,6 +48,25 @@
}
.displayconfig {
background-image:url(resources/img/displayconfig.png) !important;
}
.datetime {
background-image:url(resources/img/datetime.png) !important;
}
.fieladtime {
background-image:none;
background-color:#FFFFCC;
color:red;
}
</style>
......@@ -55,20 +74,7 @@
<body>
<h1>This is the body of the sample view</h1>
<security:authorize access="hasRole('ROLE_USER')">
This text is only visible to a user
<br/>
</security:authorize>
<security:authorize access="hasRole('ROLE_ADMIN')">
This text is only visible to an admin
<br/>
</security:authorize>
<a href="<c:url value="/perform_logout" />">Logout</a>
</body>
......
<%@ page language="java" contentType="text/html; charset=utf8"
pageEncoding="utf8"%>
<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf8">
<title><spring:message code="label.title" /></title>
</head>
<body>
<a href="<c:url value="/index" />">
<spring:message code="label.contacts" />
</a><br/>
<c:if test="${not empty param.error}">
<font color="red"> <spring:message code="label.loginerror" />
: ${sessionScope["SPRING_SECURITY_LAST_EXCEPTION"].message} </font>
</c:if>
<form method="POST" action="<c:url value="/j_spring_security_check" />">
<table>
<tr>
<td align="right"><spring:message code="label.login" /></td>
<td><input type="text" name="j_username" /></td>
</tr>
<tr>
<td align="right"><spring:message code="label.password" /></td>
<td><input type="password" name="j_password" /></td>
</tr>
<tr>
<td align="right"><spring:message code="label.remember" /></td>
<td><input type="checkbox" name="_spring_security_remember_me" /></td>
</tr>
<tr>
<td colspan="2" align="right"><input type="submit" value="Login" />
<input type="reset" value="Reset" /></td>
</tr>
</table>
</form>
</body>
</html>
\ No newline at end of file
......@@ -207,6 +207,21 @@ Ext.application({
{
title: 'СЕРВИСЫ',
items:[
{
region: 'center',
xtype: 'tabpanel',
items: [
]
}
]
},
/*
{
title: 'ПЕРЕМЕННЫЕ',
......@@ -235,49 +250,8 @@ Ext.application({
]
},
*/
/*
{
title: 'СЕРВИСЫ',
items:[
{
region: 'center',
xtype: 'tabpanel',
items: [
{
title: 'SNMP Клиент',
items:[]
},
{
title: 'SNMP Агент',
items:[]
}
]
}
]
}
*/
{
title: 'СОХРАНЕНИЕ',
items:[
{
region: 'center',
xtype: 'tabpanel',
items: [
]
}
]
},
} */
]
}
]
......
......@@ -10,35 +10,99 @@ Ext.define('App.controller.DeviceControl', {
'toolbar button[action=DcReboot]' : {
click : this.DcRebootClick
},
'#btnToolsTime': {
click: this.DcToolsTime
},
'#btnCalibration': {
click: this.Calibration
}
});
Ext.Ajax.request({
method: "GET",
url: 'api/devcontrol/dateinfo',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
success: function(response, opts) {
var result = Ext.JSON.decode(response.responseText);
Ext.getCmp('dtCurrent').setValue(result.dt);
Ext.getCmp('ntpServer').setValue(result.ntp);
}, failure: function(response, opts) {
}
});
this.LoadDTParams();
Ext.TaskManager.start({
run: this.LoadDTParams,
interval: 15000 ,
scope: this
});
},
// timeout: 60000
LoadDTParams:function() {
// Ext.getCmp('fsdateinfo').mask('Обновление ...');
Ext.Ajax.request({
method: "GET",
url: 'api/devcontrol/dateinfo',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
success: function(response, opts) {
var result = Ext.JSON.decode(response.responseText);
Ext.getCmp('dtCurrent').setValue(result.dt);
// Ext.getCmp('ntpServer').setValue(result.ntp);
}, failure: function(response, opts) {
}
});
},
DcOffClick:function() {
Ext.getBody().mask('Выключение устройства ...');
/*
Ext.Ajax.request({
method: "GET",
url: 'api/devinfo/',
url: 'api/devcontrol/off',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
success: function(response, opts) {
var result = Ext.JSON.decode(response.responseText);
Ext.getCmp('guid').setValue(result.guid);
Ext.getCmp('title').setValue(result.description);
}, failure: function(response, opts) {
}
});
*/
},
......@@ -48,30 +112,101 @@ Ext.define('App.controller.DeviceControl', {
Ext.getBody().mask('Перезагрузка устройства ...');
/*
Ext.Ajax.request({
method: "GET",
url: 'api/devinfo/',
url: 'api/devcontrol/reboot',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
success: function(response, opts) {
//var result = Ext.JSON.decode(response.responseText);
Ext.getBody('Перезагрузка устройства ...');
// Ext.getCmp('guid').setValue(result.guid);
// Ext.getCmp('title').setValue(result.description);
}, failure: function(response, opts) {
}
});
*/
}
},
Calibration : function() {
Ext.getCmp('fsdisplay').mask('Калибровка экрана...');
Ext.Ajax.request({
method: "GET",
url: 'api/devcontrol/calibration',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
success: function(response, opts) {
Ext.getCmp('fsdisplay').unmask();
}
});
},
DcToolsTime:function () {
Ext.getCmp('fsdateinfo').mask('Сохранение и перезапуск NTP ...');
var value=Ext.getCmp('ntpServer').getValue();
var m={
dt: '',
ntp: value
}
var data=Ext.util.JSON.encode(m);
Ext.Ajax.request({
method: "POST",
url: 'api/devcontrol/ntp',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
params: data,
success: function(response, opts) {
var result = Ext.JSON.decode(response.responseText);
Ext.getCmp('fsdateinfo').unmask();
/*
if(result) {
Ext.Msg.alert('Успешно', 'Обновление конфигурации выполнено!');
}
else
{
Ext.Msg.alert('Ошибка', 'Обновление конфигурации не выполнено!');
}
*/
}
});
}
});
......@@ -97,4 +232,3 @@ Ext.define('App.controller.DeviceControl', {
......
......@@ -21,6 +21,7 @@ Ext.define('App.controller.MainConfig', {
onLoadButtonClick:function() {
Ext.Ajax.request({
method: "GET",
url: 'api/devinfo/',
......@@ -39,11 +40,15 @@ Ext.define('App.controller.MainConfig', {
}, failure: function(response, opts) {
}
});
},
onSaveButtonClick : function(btn) {
Ext.getCmp('formmainconfig').mask('Загрузка...');
var mainconfigView = btn.up('mvvm-MainConfigView');
......@@ -83,9 +88,9 @@ Ext.define('App.controller.MainConfig', {
});
}
else {
// Ext.Msg.alert('Failure', 'Обновление конфигурации не выполнено!');
}
Ext.getCmp('formmainconfig').unmask();
}
});
......
......@@ -20,13 +20,7 @@ Ext.define('App.controller.NetworkSetting', {
/*
Ext.TaskManager.start({
run: this.ReloadData,
interval: 10000 ,
scope: this
});
*/
},
......
......@@ -11,23 +11,116 @@ Ext.define('App.view.DeviceControl', {
},
bbar: {items: [{
xtype: 'button',
iconCls:'off',
itemId: 'btnOffDc',
text: 'Выключить',
action: 'DcOff',
disabled:false
},
{
xtype: 'button',
iconCls:'restart',
itemId: 'btnRebootDc',
text: 'Перезагрузить',
action: 'DcReboot',
disabled:false
}]
tbar: {items: [
{
xtype: 'button',
iconCls:'off',
itemId: 'btnOffDc',
text: 'Выключить',
action: 'DcOff',
disabled:false
},
{
xtype: 'button',
iconCls:'restart',
itemId: 'btnRebootDc',
text: 'Перезагрузить',
action: 'DcReboot',
disabled:false
}
]
},
items : []
items : [{
xtype:'fieldset',
title: 'Экран',
id:"fsdisplay",
collapsed: false,
width:150,
padding:'5 5 5 5',
// layout: 'anchor',
defaults: {
// anchor: '100%'
},
items :[{
xtype: 'button',
iconCls:'displayconfig',
id: 'btnCalibration',
text: 'Калибровка',
width:120,
disabled:false
}]
},
{
xtype:'fieldset',
// title: 'Дата/время',
width:350,
id:'fsdateinfo',
collapsed: false,
padding:'5 5 5 5',
// layout: 'anchor',
defaults: {
// anchor: '100%'
},
items :[
{
xtype: 'textfield',
id: 'dtCurrent',
fieldLabel: "Дата/время",
value: '',
margin:'5 0 5 5',
fieldStyle : "color:red",
allowBlank: false
},
{
xtype: 'textfield',
id: 'ntpServer',
fieldLabel: "NTP сервер",
value: '',
margin:'5 0 5 5',
allowBlank: false
},
// {
// xtype: 'fieldcontainer',
// layout: 'hbox',
// padding:'5 5 5 5',
// items: [
{
xtype: 'button',
iconCls:'save',
id: 'btnToolsTime',
text: 'Применить',
margin:'5 0 5 5',
width:120,
disabled:false
}
]
}
// ]
// }
]
});
\ No newline at end of file
......