Добавление функционала: перезагрузка, выключение, установка параметров
NTP
Showing
31 changed files
with
532 additions
and
178 deletions
| ... | @@ -130,18 +130,6 @@ | ... | @@ -130,18 +130,6 @@ |
| 130 | 130 | ||
| 131 | 131 | ||
| 132 | 132 | ||
| 133 | |||
| 134 | |||
| 135 | |||
| 136 | |||
| 137 | |||
| 138 | |||
| 139 | |||
| 140 | |||
| 141 | |||
| 142 | |||
| 143 | |||
| 144 | |||
| 145 | <!-- Test --> | 133 | <!-- Test --> |
| 146 | <dependency> | 134 | <dependency> |
| 147 | <groupId>junit</groupId> | 135 | <groupId>junit</groupId> |
| ... | @@ -193,7 +181,11 @@ | ... | @@ -193,7 +181,11 @@ |
| 193 | <version>1.0</version> | 181 | <version>1.0</version> |
| 194 | </dependency> | 182 | </dependency> |
| 195 | 183 | ||
| 196 | 184 | <dependency> | |
| 185 | <groupId>org.emercit</groupId> | ||
| 186 | <artifactId>dtmanager</artifactId> | ||
| 187 | <version>1.2</version> | ||
| 188 | </dependency> | ||
| 197 | 189 | ||
| 198 | 190 | ||
| 199 | 191 | ||
| ... | @@ -201,6 +193,23 @@ | ... | @@ -201,6 +193,23 @@ |
| 201 | </dependencies> | 193 | </dependencies> |
| 202 | 194 | ||
| 203 | 195 | ||
| 196 | |||
| 197 | |||
| 198 | |||
| 199 | |||
| 200 | |||
| 201 | |||
| 202 | |||
| 203 | |||
| 204 | |||
| 205 | |||
| 206 | |||
| 207 | |||
| 208 | |||
| 209 | |||
| 210 | |||
| 211 | |||
| 212 | |||
| 204 | <repositories> | 213 | <repositories> |
| 205 | <!-- For testing against latest Spring snapshots --> | 214 | <!-- For testing against latest Spring snapshots --> |
| 206 | <repository> | 215 | <repository> |
| ... | @@ -226,6 +235,16 @@ | ... | @@ -226,6 +235,16 @@ |
| 226 | 235 | ||
| 227 | 236 | ||
| 228 | 237 | ||
| 238 | |||
| 239 | |||
| 240 | |||
| 241 | <repository> | ||
| 242 | <id>project.local</id> | ||
| 243 | <name>project</name> | ||
| 244 | <url>file:/root/git/hardwareconfig/DevTools/repo</url> | ||
| 245 | </repository> | ||
| 246 | |||
| 247 | |||
| 229 | <repository> | 248 | <repository> |
| 230 | <id>org.repo.jfrog.artifactory.libs-releases</id> | 249 | <id>org.repo.jfrog.artifactory.libs-releases</id> |
| 231 | <name>Repository1</name> | 250 | <name>Repository1</name> | ... | ... |
No preview for this file type
| 1 | 9b270266d406498c4c46a39cf6a66def | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | 06a207b558d6eaed84033124b59981ecb7d71466 | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | <?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | <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" | ||
| 3 | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
| 4 | <modelVersion>4.0.0</modelVersion> | ||
| 5 | <groupId>org.emercit</groupId> | ||
| 6 | <artifactId>dtmanager</artifactId> | ||
| 7 | <version>1.1</version> | ||
| 8 | </project> |
| 1 | a4aa91f89ab51f76f964dea56f98dd86 | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | 8f121b8c03501fd42750867dfc24c41526faf68e | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
No preview for this file type
| 1 | d866175ba3e831cb50eff67dccf1c5e3 | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | 0a9b721ea35bbe6d87e490184ca427a9a1326b04 | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | <?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | <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" | ||
| 3 | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
| 4 | <modelVersion>4.0.0</modelVersion> | ||
| 5 | <groupId>org.emercit</groupId> | ||
| 6 | <artifactId>dtmanager</artifactId> | ||
| 7 | <version>1.2</version> | ||
| 8 | </project> |
| 1 | 0f3dd1c62f9bcdb88159382dd9ab1fc3 | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | da6b0490fdc274c0533e0ce714355a10d620e177 | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | <?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | <metadata> | ||
| 3 | <groupId>org.emercit</groupId> | ||
| 4 | <artifactId>dtmanager</artifactId> | ||
| 5 | <versioning> | ||
| 6 | <release>1.2</release> | ||
| 7 | <versions> | ||
| 8 | <version>1.1</version> | ||
| 9 | <version>1.2</version> | ||
| 10 | </versions> | ||
| 11 | <lastUpdated>20150723083113</lastUpdated> | ||
| 12 | </versioning> | ||
| 13 | </metadata> |
| 1 | 7b199d75cde3425e268a167addd233a7 | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | 42b5711bbb0d86f2ddb7e7352797848c0e39afeb | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | package org.emercit.devtools.app; | ||
| 2 | |||
| 3 | import java.util.Locale; | ||
| 4 | |||
| 5 | import org.slf4j.Logger; | ||
| 6 | import org.slf4j.LoggerFactory; | ||
| 7 | import org.springframework.web.bind.annotation.RequestMapping; | ||
| 8 | import org.springframework.web.bind.annotation.RequestMethod; | ||
| 9 | import org.springframework.beans.factory.annotation.Autowired; | ||
| 10 | |||
| 11 | import javax.servlet.http.*; | ||
| 12 | import javax.servlet.ServletContext; | ||
| 13 | |||
| 14 | import java.io.*; | ||
| 15 | |||
| 16 | import org.springframework.stereotype.Controller; | ||
| 17 | import org.springframework.validation.BindingResult; | ||
| 18 | import org.springframework.web.bind.annotation.ModelAttribute; | ||
| 19 | import org.springframework.web.bind.annotation.PathVariable; | ||
| 20 | import org.springframework.web.bind.annotation.ResponseBody; | ||
| 21 | import org.springframework.web.bind.annotation.RequestBody; | ||
| 22 | |||
| 23 | import java.util.Vector; | ||
| 24 | |||
| 25 | import org.emercit.ethmanager.model.EthBean; | ||
| 26 | import org.emercit.proxymanager.model.ProxyBean; | ||
| 27 | import org.emercit.devinfo.model.DevInfoBean; | ||
| 28 | import org.emercit.devtools.service.DevInfoService; | ||
| 29 | import org.emercit.devtools.service.DnsService; | ||
| 30 | import org.emercit.devtools.service.EthService; | ||
| 31 | import org.emercit.dnsmanager.model.DnsBean; | ||
| 32 | |||
| 33 | import java.util.ArrayList; | ||
| 34 | import java.util.List; | ||
| 35 | |||
| 36 | import org.emercit.devtools.service.DevControlService; | ||
| 37 | import org.emercit.dtmanager.model.DateInfo; | ||
| 38 | |||
| 39 | @Controller | ||
| 40 | @RequestMapping("api") | ||
| 41 | public class DevControlController { | ||
| 42 | |||
| 43 | @RequestMapping(value="devcontrol/ntp" , method = RequestMethod.POST) | ||
| 44 | public @ResponseBody boolean changeNtp(@RequestBody DateInfo m) { | ||
| 45 | |||
| 46 | return DevControlService.INSTANCE.ChangeNtp(m.ntp); | ||
| 47 | |||
| 48 | |||
| 49 | |||
| 50 | } | ||
| 51 | |||
| 52 | |||
| 53 | @RequestMapping(value = "devcontrol/dateinfo", method = RequestMethod.GET) | ||
| 54 | public @ResponseBody DateInfo getDi() { | ||
| 55 | |||
| 56 | |||
| 57 | return DevControlService.INSTANCE.getDateInfo(); | ||
| 58 | |||
| 59 | } | ||
| 60 | |||
| 61 | |||
| 62 | |||
| 63 | |||
| 64 | |||
| 65 | @RequestMapping(value = "devcontrol/reboot", method = RequestMethod.GET) | ||
| 66 | public @ResponseBody boolean DevReboot() { | ||
| 67 | |||
| 68 | |||
| 69 | DevControlService.INSTANCE.Reboot(); | ||
| 70 | |||
| 71 | return true; | ||
| 72 | |||
| 73 | } | ||
| 74 | |||
| 75 | |||
| 76 | |||
| 77 | @RequestMapping(value = "devcontrol/calibration", method = RequestMethod.GET) | ||
| 78 | public @ResponseBody boolean DvCalibration() { | ||
| 79 | |||
| 80 | |||
| 81 | DevControlService.INSTANCE.Calibration(); | ||
| 82 | |||
| 83 | return true; | ||
| 84 | |||
| 85 | } | ||
| 86 | |||
| 87 | |||
| 88 | |||
| 89 | |||
| 90 | |||
| 91 | } | ||
| 92 | |||
| 93 | |||
| 94 | /* | ||
| 95 | url: 'api/devcontrol/ntp', | ||
| 96 | url: 'api/devcontrol/reboot', | ||
| 97 | url: 'api/devcontrol/off', | ||
| 98 | url: 'api/devcontrol/dateinfo', | ||
| 99 | */ | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | package org.emercit.devtools.service; | ||
| 2 | |||
| 3 | import org.emercit.devinfo.model.DevInfoBean; | ||
| 4 | import org.emercit.dtmanager.model.DateInfo; | ||
| 5 | import org.emercit.dtmanager.service.NtpLinux; | ||
| 6 | |||
| 7 | import java.util.Calendar; | ||
| 8 | import java.util.Date; | ||
| 9 | import java.util.TimeZone; | ||
| 10 | import java.text.SimpleDateFormat; | ||
| 11 | |||
| 12 | import org.emercit.pckutils.cmd.CmdExec; | ||
| 13 | import org.springframework.web.bind.annotation.RequestMapping; | ||
| 14 | import org.springframework.web.bind.annotation.RequestMethod; | ||
| 15 | import org.springframework.web.bind.annotation.ResponseBody; | ||
| 16 | |||
| 17 | public enum DevControlService { | ||
| 18 | |||
| 19 | INSTANCE; | ||
| 20 | |||
| 21 | private NtpLinux ntplinux= new NtpLinux(); | ||
| 22 | |||
| 23 | private CmdExec cmdexec=new CmdExec(); | ||
| 24 | |||
| 25 | |||
| 26 | public DateInfo getDateInfo() { | ||
| 27 | DateInfo dateinfo=new DateInfo(); | ||
| 28 | |||
| 29 | |||
| 30 | dateinfo.ntp=ntplinux.getUseNtpServer(); | ||
| 31 | |||
| 32 | Calendar calendar = Calendar.getInstance(); | ||
| 33 | |||
| 34 | TimeZone.setDefault(TimeZone.getTimeZone("Europe/Moscow")); | ||
| 35 | |||
| 36 | TimeZone timeZone = calendar.getTimeZone(); | ||
| 37 | |||
| 38 | |||
| 39 | Date date=calendar.getTime(); | ||
| 40 | dateinfo.dt = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss").format(new Date()); | ||
| 41 | |||
| 42 | return dateinfo; | ||
| 43 | } | ||
| 44 | |||
| 45 | |||
| 46 | public boolean ChangeNtp(String value) { | ||
| 47 | |||
| 48 | |||
| 49 | boolean result=ntplinux.setUsNtpServer(value); | ||
| 50 | |||
| 51 | if (result) { | ||
| 52 | |||
| 53 | try { cmdexec.Run("/etc/init.d/ntp restart"); } catch (Exception e) {}; | ||
| 54 | } | ||
| 55 | |||
| 56 | return result; | ||
| 57 | } | ||
| 58 | |||
| 59 | |||
| 60 | |||
| 61 | public void Reboot() { | ||
| 62 | try { cmdexec.Run("reboot"); } catch (Exception e) {}; | ||
| 63 | |||
| 64 | } | ||
| 65 | |||
| 66 | |||
| 67 | |||
| 68 | public void Off() { | ||
| 69 | try { cmdexec.Run("shutdown -h now"); } catch (Exception e) {}; | ||
| 70 | |||
| 71 | } | ||
| 72 | |||
| 73 | public void Calibration() { | ||
| 74 | |||
| 75 | try { cmdexec.Run("/opt/devtools/calibrator.sh"); } catch (Exception e) {}; | ||
| 76 | |||
| 77 | } | ||
| 78 | |||
| 79 | |||
| 80 | |||
| 81 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | <beans:beans xmlns="http://www.springframework.org/schema/security" | ||
| 2 | xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| 3 | xsi:schemaLocation="http://www.springframework.org/schema/beans | ||
| 4 | http://www.springframework.org/schema/beans/spring-beans-3.0.xsd | ||
| 5 | http://www.springframework.org/schema/security | ||
| 6 | http://www.springframework.org/schema/security/spring-security-3.0.xsd"> | ||
| 7 | |||
| 8 | |||
| 9 | <http access-denied-page="/error403.jsp"> | ||
| 10 | <intercept-url pattern="/" access="ROLE_USER,ROLE_ANONYMOUS" /> | ||
| 11 | <intercept-url pattern="/add*" access="ROLE_USER" /> | ||
| 12 | <intercept-url pattern="/delete/*" access="ROLE_ADMIN" /> | ||
| 13 | <form-login login-page="/login.jsp" default-target-url="/index" | ||
| 14 | authentication-failure-url="/login.jsp?error=true" /> | ||
| 15 | <logout logout-url="/logout" logout-success-url="/index" /> | ||
| 16 | |||
| 17 | <anonymous username="guest" granted-authority="ROLE_ANONYMOUS" /> | ||
| 18 | <remember-me /> | ||
| 19 | </http> | ||
| 20 | |||
| 21 | <authentication-manager> | ||
| 22 | <authentication-provider> | ||
| 23 | <user-service> | ||
| 24 | <user name="admin" password="pass" authorities="ROLE_ADMIN,ROLE_USER" /> | ||
| 25 | <user name="user1" password="1111" authorities="ROLE_USER" /> | ||
| 26 | <user name="user2" password="2222" disabled="true" authorities="ROLE_USER" /> | ||
| 27 | </user-service> | ||
| 28 | </authentication-provider> | ||
| 29 | </authentication-manager> | ||
| 30 | |||
| 31 | |||
| 32 | |||
| 33 | </beans:beans> | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| ... | @@ -48,26 +48,32 @@ | ... | @@ -48,26 +48,32 @@ |
| 48 | } | 48 | } |
| 49 | 49 | ||
| 50 | 50 | ||
| 51 | </style> | 51 | .displayconfig { |
| 52 | background-image:url(resources/img/displayconfig.png) !important; | ||
| 53 | } | ||
| 54 | |||
| 55 | |||
| 56 | .datetime { | ||
| 57 | background-image:url(resources/img/datetime.png) !important; | ||
| 58 | } | ||
| 52 | 59 | ||
| 53 | 60 | ||
| 54 | </head> | ||
| 55 | <body> | ||
| 56 | 61 | ||
| 62 | .fieladtime { | ||
| 63 | background-image:none; | ||
| 64 | background-color:#FFFFCC; | ||
| 65 | color:red; | ||
| 57 | 66 | ||
| 58 | <h1>This is the body of the sample view</h1> | 67 | } |
| 59 | 68 | ||
| 60 | <security:authorize access="hasRole('ROLE_USER')"> | ||
| 61 | This text is only visible to a user | ||
| 62 | <br/> | ||
| 63 | </security:authorize> | ||
| 64 | 69 | ||
| 65 | <security:authorize access="hasRole('ROLE_ADMIN')"> | 70 | </style> |
| 66 | This text is only visible to an admin | 71 | |
| 67 | <br/> | 72 | |
| 68 | </security:authorize> | 73 | </head> |
| 74 | <body> | ||
| 75 | |||
| 69 | 76 | ||
| 70 | <a href="<c:url value="/perform_logout" />">Logout</a> | ||
| 71 | 77 | ||
| 72 | 78 | ||
| 73 | 79 | ... | ... |
| 1 | <%@ page language="java" contentType="text/html; charset=utf8" | ||
| 2 | pageEncoding="utf8"%> | ||
| 3 | <%@taglib uri="http://www.springframework.org/tags" prefix="spring"%> | ||
| 4 | <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> | ||
| 5 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> | ||
| 6 | <html> | ||
| 7 | <head> | ||
| 8 | <meta http-equiv="Content-Type" content="text/html; charset=utf8"> | ||
| 9 | <title><spring:message code="label.title" /></title> | ||
| 10 | </head> | ||
| 11 | <body> | ||
| 12 | |||
| 13 | <a href="<c:url value="/index" />"> | ||
| 14 | <spring:message code="label.contacts" /> | ||
| 15 | </a><br/> | ||
| 16 | |||
| 17 | <c:if test="${not empty param.error}"> | ||
| 18 | <font color="red"> <spring:message code="label.loginerror" /> | ||
| 19 | : ${sessionScope["SPRING_SECURITY_LAST_EXCEPTION"].message} </font> | ||
| 20 | </c:if> | ||
| 21 | <form method="POST" action="<c:url value="/j_spring_security_check" />"> | ||
| 22 | <table> | ||
| 23 | <tr> | ||
| 24 | <td align="right"><spring:message code="label.login" /></td> | ||
| 25 | <td><input type="text" name="j_username" /></td> | ||
| 26 | </tr> | ||
| 27 | <tr> | ||
| 28 | <td align="right"><spring:message code="label.password" /></td> | ||
| 29 | <td><input type="password" name="j_password" /></td> | ||
| 30 | </tr> | ||
| 31 | <tr> | ||
| 32 | <td align="right"><spring:message code="label.remember" /></td> | ||
| 33 | <td><input type="checkbox" name="_spring_security_remember_me" /></td> | ||
| 34 | </tr> | ||
| 35 | <tr> | ||
| 36 | <td colspan="2" align="right"><input type="submit" value="Login" /> | ||
| 37 | <input type="reset" value="Reset" /></td> | ||
| 38 | </tr> | ||
| 39 | </table> | ||
| 40 | </form> | ||
| 41 | </body> | ||
| 42 | </html> | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
1.21 KB
805 Bytes
| ... | @@ -207,76 +207,50 @@ Ext.application({ | ... | @@ -207,76 +207,50 @@ Ext.application({ |
| 207 | 207 | ||
| 208 | 208 | ||
| 209 | 209 | ||
| 210 | /* | 210 | |
| 211 | { | 211 | { |
| 212 | title: 'ПЕРЕМЕННЫЕ', | 212 | title: 'СЕРВИСЫ', |
| 213 | items:[ | 213 | items:[ |
| 214 | |||
| 215 | { | 214 | { |
| 216 | region: 'center', | 215 | region: 'center', |
| 217 | xtype: 'tabpanel', | 216 | xtype: 'tabpanel', |
| 218 | items: [ | 217 | items: [ |
| 219 | { | ||
| 220 | title: 'Аналоговые', | ||
| 221 | items:[] | ||
| 222 | }, | ||
| 223 | { | ||
| 224 | title: 'Дискретные', | ||
| 225 | items:[] | ||
| 226 | } | ||
| 227 | 218 | ||
| 228 | ] | 219 | ] |
| 229 | 220 | ||
| 230 | } | 221 | } |
| 231 | |||
| 232 | |||
| 233 | |||
| 234 | |||
| 235 | |||
| 236 | |||
| 237 | ] | 222 | ] |
| 238 | }, | 223 | }, |
| 239 | */ | ||
| 240 | 224 | ||
| 241 | /* | 225 | /* |
| 242 | { | 226 | { |
| 243 | title: 'СЕРВИСЫ', | 227 | title: 'ПЕРЕМЕННЫЕ', |
| 244 | items:[ | 228 | items:[ |
| 229 | |||
| 245 | { | 230 | { |
| 246 | region: 'center', | 231 | region: 'center', |
| 247 | xtype: 'tabpanel', | 232 | xtype: 'tabpanel', |
| 248 | items: [ | 233 | items: [ |
| 249 | { | 234 | { |
| 250 | title: 'SNMP Клиент', | 235 | title: 'Аналоговые', |
| 251 | items:[] | 236 | items:[] |
| 252 | }, | 237 | }, |
| 253 | { | 238 | { |
| 254 | title: 'SNMP Агент', | 239 | title: 'Дискретные', |
| 255 | items:[] | 240 | items:[] |
| 256 | } | 241 | } |
| 257 | ] | ||
| 258 | 242 | ||
| 259 | } | ||
| 260 | ] | 243 | ] |
| 244 | |||
| 261 | } | 245 | } |
| 262 | */ | ||
| 263 | 246 | ||
| 264 | 247 | ||
| 265 | 248 | ||
| 266 | { | ||
| 267 | title: 'СОХРАНЕНИЕ', | ||
| 268 | items:[ | ||
| 269 | { | ||
| 270 | region: 'center', | ||
| 271 | xtype: 'tabpanel', | ||
| 272 | items: [ | ||
| 273 | 249 | ||
| 274 | ] | ||
| 275 | 250 | ||
| 276 | } | ||
| 277 | ] | ||
| 278 | }, | ||
| 279 | 251 | ||
| 252 | ] | ||
| 253 | } */ | ||
| 280 | 254 | ||
| 281 | ] | 255 | ] |
| 282 | } | 256 | } | ... | ... |
| ... | @@ -10,19 +10,61 @@ Ext.define('App.controller.DeviceControl', { | ... | @@ -10,19 +10,61 @@ Ext.define('App.controller.DeviceControl', { |
| 10 | 10 | ||
| 11 | 'toolbar button[action=DcReboot]' : { | 11 | 'toolbar button[action=DcReboot]' : { |
| 12 | click : this.DcRebootClick | 12 | click : this.DcRebootClick |
| 13 | }, | ||
| 14 | |||
| 15 | '#btnToolsTime': { | ||
| 16 | click: this.DcToolsTime | ||
| 17 | }, | ||
| 18 | '#btnCalibration': { | ||
| 19 | click: this.Calibration | ||
| 13 | } | 20 | } |
| 14 | }); | 21 | }); |
| 15 | 22 | ||
| 23 | |||
| 24 | |||
| 25 | Ext.Ajax.request({ | ||
| 26 | method: "GET", | ||
| 27 | url: 'api/devcontrol/dateinfo', | ||
| 28 | headers: { | ||
| 29 | 'Accept': 'application/json', | ||
| 30 | 'Content-Type': 'application/json' | ||
| 16 | }, | 31 | }, |
| 17 | 32 | ||
| 18 | DcOffClick:function() { | 33 | success: function(response, opts) { |
| 19 | 34 | ||
| 20 | Ext.getBody().mask('Выключение устройства ...'); | 35 | var result = Ext.JSON.decode(response.responseText); |
| 21 | 36 | ||
| 22 | /* | 37 | |
| 38 | Ext.getCmp('dtCurrent').setValue(result.dt); | ||
| 39 | Ext.getCmp('ntpServer').setValue(result.ntp); | ||
| 40 | |||
| 41 | }, failure: function(response, opts) { | ||
| 42 | } | ||
| 43 | }); | ||
| 44 | |||
| 45 | |||
| 46 | this.LoadDTParams(); | ||
| 47 | |||
| 48 | Ext.TaskManager.start({ | ||
| 49 | run: this.LoadDTParams, | ||
| 50 | interval: 15000 , | ||
| 51 | scope: this | ||
| 52 | }); | ||
| 53 | |||
| 54 | }, | ||
| 55 | |||
| 56 | |||
| 57 | |||
| 58 | |||
| 59 | // timeout: 60000 | ||
| 60 | LoadDTParams:function() { | ||
| 61 | |||
| 62 | |||
| 63 | |||
| 64 | // Ext.getCmp('fsdateinfo').mask('Обновление ...'); | ||
| 23 | Ext.Ajax.request({ | 65 | Ext.Ajax.request({ |
| 24 | method: "GET", | 66 | method: "GET", |
| 25 | url: 'api/devinfo/', | 67 | url: 'api/devcontrol/dateinfo', |
| 26 | headers: { | 68 | headers: { |
| 27 | 'Accept': 'application/json', | 69 | 'Accept': 'application/json', |
| 28 | 'Content-Type': 'application/json' | 70 | 'Content-Type': 'application/json' |
| ... | @@ -32,13 +74,35 @@ Ext.define('App.controller.DeviceControl', { | ... | @@ -32,13 +74,35 @@ Ext.define('App.controller.DeviceControl', { |
| 32 | 74 | ||
| 33 | var result = Ext.JSON.decode(response.responseText); | 75 | var result = Ext.JSON.decode(response.responseText); |
| 34 | 76 | ||
| 35 | Ext.getCmp('guid').setValue(result.guid); | 77 | |
| 36 | Ext.getCmp('title').setValue(result.description); | 78 | Ext.getCmp('dtCurrent').setValue(result.dt); |
| 79 | // Ext.getCmp('ntpServer').setValue(result.ntp); | ||
| 37 | 80 | ||
| 38 | }, failure: function(response, opts) { | 81 | }, failure: function(response, opts) { |
| 39 | } | 82 | } |
| 40 | }); | 83 | }); |
| 41 | */ | 84 | |
| 85 | |||
| 86 | |||
| 87 | }, | ||
| 88 | |||
| 89 | |||
| 90 | |||
| 91 | |||
| 92 | DcOffClick:function() { | ||
| 93 | |||
| 94 | Ext.getBody().mask('Выключение устройства ...'); | ||
| 95 | |||
| 96 | |||
| 97 | Ext.Ajax.request({ | ||
| 98 | method: "GET", | ||
| 99 | url: 'api/devcontrol/off', | ||
| 100 | headers: { | ||
| 101 | 'Accept': 'application/json', | ||
| 102 | 'Content-Type': 'application/json' | ||
| 103 | } | ||
| 104 | }); | ||
| 105 | |||
| 42 | 106 | ||
| 43 | }, | 107 | }, |
| 44 | 108 | ||
| ... | @@ -48,34 +112,104 @@ Ext.define('App.controller.DeviceControl', { | ... | @@ -48,34 +112,104 @@ Ext.define('App.controller.DeviceControl', { |
| 48 | 112 | ||
| 49 | Ext.getBody().mask('Перезагрузка устройства ...'); | 113 | Ext.getBody().mask('Перезагрузка устройства ...'); |
| 50 | 114 | ||
| 51 | /* | 115 | |
| 52 | Ext.Ajax.request({ | 116 | Ext.Ajax.request({ |
| 53 | method: "GET", | 117 | method: "GET", |
| 54 | url: 'api/devinfo/', | 118 | url: 'api/devcontrol/reboot', |
| 55 | headers: { | 119 | headers: { |
| 56 | 'Accept': 'application/json', | 120 | 'Accept': 'application/json', |
| 57 | 'Content-Type': 'application/json' | 121 | 'Content-Type': 'application/json' |
| 122 | } | ||
| 123 | }); | ||
| 124 | |||
| 125 | |||
| 126 | |||
| 58 | }, | 127 | }, |
| 59 | 128 | ||
| 60 | success: function(response, opts) { | ||
| 61 | 129 | ||
| 62 | //var result = Ext.JSON.decode(response.responseText); | ||
| 63 | Ext.getBody('Перезагрузка устройства ...'); | ||
| 64 | 130 | ||
| 65 | // Ext.getCmp('guid').setValue(result.guid); | 131 | Calibration : function() { |
| 66 | // Ext.getCmp('title').setValue(result.description); | ||
| 67 | 132 | ||
| 68 | }, failure: function(response, opts) { | 133 | |
| 134 | Ext.getCmp('fsdisplay').mask('Калибровка экрана...'); | ||
| 135 | |||
| 136 | |||
| 137 | Ext.Ajax.request({ | ||
| 138 | method: "GET", | ||
| 139 | url: 'api/devcontrol/calibration', | ||
| 140 | headers: { | ||
| 141 | 'Accept': 'application/json', | ||
| 142 | 'Content-Type': 'application/json' | ||
| 143 | }, | ||
| 144 | success: function(response, opts) { | ||
| 145 | |||
| 146 | Ext.getCmp('fsdisplay').unmask(); | ||
| 69 | } | 147 | } |
| 70 | }); | 148 | }); |
| 149 | |||
| 150 | |||
| 151 | |||
| 152 | }, | ||
| 153 | |||
| 154 | |||
| 155 | |||
| 156 | |||
| 157 | |||
| 158 | DcToolsTime:function () { | ||
| 159 | |||
| 160 | |||
| 161 | |||
| 162 | Ext.getCmp('fsdateinfo').mask('Сохранение и перезапуск NTP ...'); | ||
| 163 | var value=Ext.getCmp('ntpServer').getValue(); | ||
| 164 | |||
| 165 | var m={ | ||
| 166 | dt: '', | ||
| 167 | ntp: value | ||
| 168 | } | ||
| 169 | |||
| 170 | |||
| 171 | |||
| 172 | var data=Ext.util.JSON.encode(m); | ||
| 173 | |||
| 174 | Ext.Ajax.request({ | ||
| 175 | method: "POST", | ||
| 176 | url: 'api/devcontrol/ntp', | ||
| 177 | headers: { | ||
| 178 | 'Accept': 'application/json', | ||
| 179 | 'Content-Type': 'application/json' | ||
| 180 | }, | ||
| 181 | params: data, | ||
| 182 | success: function(response, opts) { | ||
| 183 | |||
| 184 | var result = Ext.JSON.decode(response.responseText); | ||
| 185 | |||
| 186 | Ext.getCmp('fsdateinfo').unmask(); | ||
| 187 | /* | ||
| 188 | if(result) { | ||
| 189 | Ext.Msg.alert('Успешно', 'Обновление конфигурации выполнено!'); | ||
| 190 | |||
| 191 | } | ||
| 192 | else | ||
| 193 | { | ||
| 194 | Ext.Msg.alert('Ошибка', 'Обновление конфигурации не выполнено!'); | ||
| 195 | } | ||
| 196 | |||
| 71 | */ | 197 | */ |
| 72 | 198 | ||
| 73 | 199 | ||
| 200 | |||
| 74 | } | 201 | } |
| 75 | }); | 202 | }); |
| 76 | 203 | ||
| 77 | 204 | ||
| 78 | 205 | ||
| 206 | } | ||
| 207 | |||
| 208 | |||
| 209 | |||
| 210 | }); | ||
| 211 | |||
| 212 | |||
| 79 | 213 | ||
| 80 | 214 | ||
| 81 | 215 | ... | ... |
| ... | @@ -21,6 +21,7 @@ Ext.define('App.controller.MainConfig', { | ... | @@ -21,6 +21,7 @@ Ext.define('App.controller.MainConfig', { |
| 21 | 21 | ||
| 22 | onLoadButtonClick:function() { | 22 | onLoadButtonClick:function() { |
| 23 | 23 | ||
| 24 | |||
| 24 | Ext.Ajax.request({ | 25 | Ext.Ajax.request({ |
| 25 | method: "GET", | 26 | method: "GET", |
| 26 | url: 'api/devinfo/', | 27 | url: 'api/devinfo/', |
| ... | @@ -40,11 +41,15 @@ Ext.define('App.controller.MainConfig', { | ... | @@ -40,11 +41,15 @@ Ext.define('App.controller.MainConfig', { |
| 40 | } | 41 | } |
| 41 | }); | 42 | }); |
| 42 | 43 | ||
| 44 | |||
| 45 | |||
| 43 | }, | 46 | }, |
| 44 | 47 | ||
| 45 | 48 | ||
| 46 | onSaveButtonClick : function(btn) { | 49 | onSaveButtonClick : function(btn) { |
| 47 | 50 | ||
| 51 | Ext.getCmp('formmainconfig').mask('Загрузка...'); | ||
| 52 | |||
| 48 | var mainconfigView = btn.up('mvvm-MainConfigView'); | 53 | var mainconfigView = btn.up('mvvm-MainConfigView'); |
| 49 | 54 | ||
| 50 | var record = mainconfigView.getViewModel().getData(); | 55 | var record = mainconfigView.getViewModel().getData(); |
| ... | @@ -83,9 +88,9 @@ Ext.define('App.controller.MainConfig', { | ... | @@ -83,9 +88,9 @@ Ext.define('App.controller.MainConfig', { |
| 83 | }); | 88 | }); |
| 84 | 89 | ||
| 85 | } | 90 | } |
| 86 | else { | 91 | |
| 87 | // Ext.Msg.alert('Failure', 'Обновление конфигурации не выполнено!'); | 92 | Ext.getCmp('formmainconfig').unmask(); |
| 88 | } | 93 | |
| 89 | } | 94 | } |
| 90 | }); | 95 | }); |
| 91 | 96 | ... | ... |
| ... | @@ -11,7 +11,8 @@ Ext.define('App.view.DeviceControl', { | ... | @@ -11,7 +11,8 @@ Ext.define('App.view.DeviceControl', { |
| 11 | }, | 11 | }, |
| 12 | 12 | ||
| 13 | 13 | ||
| 14 | bbar: {items: [{ | 14 | tbar: {items: [ |
| 15 | { | ||
| 15 | xtype: 'button', | 16 | xtype: 'button', |
| 16 | iconCls:'off', | 17 | iconCls:'off', |
| 17 | itemId: 'btnOffDc', | 18 | itemId: 'btnOffDc', |
| ... | @@ -26,8 +27,100 @@ Ext.define('App.view.DeviceControl', { | ... | @@ -26,8 +27,100 @@ Ext.define('App.view.DeviceControl', { |
| 26 | text: 'Перезагрузить', | 27 | text: 'Перезагрузить', |
| 27 | action: 'DcReboot', | 28 | action: 'DcReboot', |
| 28 | disabled:false | 29 | disabled:false |
| 30 | } | ||
| 31 | ] | ||
| 32 | }, | ||
| 33 | |||
| 34 | items : [{ | ||
| 35 | xtype:'fieldset', | ||
| 36 | title: 'Экран', | ||
| 37 | id:"fsdisplay", | ||
| 38 | collapsed: false, | ||
| 39 | width:150, | ||
| 40 | padding:'5 5 5 5', | ||
| 41 | // layout: 'anchor', | ||
| 42 | defaults: { | ||
| 43 | // anchor: '100%' | ||
| 44 | }, | ||
| 45 | items :[{ | ||
| 46 | xtype: 'button', | ||
| 47 | iconCls:'displayconfig', | ||
| 48 | id: 'btnCalibration', | ||
| 49 | text: 'Калибровка', | ||
| 50 | width:120, | ||
| 51 | disabled:false | ||
| 29 | }] | 52 | }] |
| 30 | }, | 53 | }, |
| 31 | 54 | ||
| 32 | items : [] | 55 | |
| 56 | |||
| 57 | { | ||
| 58 | xtype:'fieldset', | ||
| 59 | // title: 'Дата/время', | ||
| 60 | width:350, | ||
| 61 | id:'fsdateinfo', | ||
| 62 | collapsed: false, | ||
| 63 | padding:'5 5 5 5', | ||
| 64 | // layout: 'anchor', | ||
| 65 | defaults: { | ||
| 66 | // anchor: '100%' | ||
| 67 | }, | ||
| 68 | items :[ | ||
| 69 | |||
| 70 | { | ||
| 71 | xtype: 'textfield', | ||
| 72 | id: 'dtCurrent', | ||
| 73 | fieldLabel: "Дата/время", | ||
| 74 | value: '', | ||
| 75 | margin:'5 0 5 5', | ||
| 76 | fieldStyle : "color:red", | ||
| 77 | allowBlank: false | ||
| 78 | }, | ||
| 79 | |||
| 80 | |||
| 81 | { | ||
| 82 | xtype: 'textfield', | ||
| 83 | id: 'ntpServer', | ||
| 84 | fieldLabel: "NTP сервер", | ||
| 85 | value: '', | ||
| 86 | margin:'5 0 5 5', | ||
| 87 | |||
| 88 | allowBlank: false | ||
| 89 | }, | ||
| 90 | |||
| 91 | |||
| 92 | // { | ||
| 93 | // xtype: 'fieldcontainer', | ||
| 94 | // layout: 'hbox', | ||
| 95 | // padding:'5 5 5 5', | ||
| 96 | // items: [ | ||
| 97 | |||
| 98 | { | ||
| 99 | xtype: 'button', | ||
| 100 | iconCls:'save', | ||
| 101 | id: 'btnToolsTime', | ||
| 102 | text: 'Применить', | ||
| 103 | margin:'5 0 5 5', | ||
| 104 | width:120, | ||
| 105 | |||
| 106 | disabled:false | ||
| 107 | } | ||
| 108 | |||
| 109 | |||
| 110 | ] | ||
| 111 | } | ||
| 112 | |||
| 113 | |||
| 114 | |||
| 115 | // ] | ||
| 116 | // } | ||
| 117 | |||
| 118 | |||
| 119 | |||
| 120 | |||
| 121 | |||
| 122 | |||
| 123 | |||
| 124 | |||
| 125 | ] | ||
| 33 | }); | 126 | }); |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
-
Please register or sign in to post a comment