Commit db7d888b db7d888b306c4982e4bb309e43f5b4c24e403075 by root

save

1 parent 7d75e9a9
...@@ -41,8 +41,6 @@ public class UtilsController { ...@@ -41,8 +41,6 @@ public class UtilsController {
41 @RequestMapping(value="utils/ping" , method = RequestMethod.POST) 41 @RequestMapping(value="utils/ping" , method = RequestMethod.POST)
42 public @ResponseBody Vector<String> getResultPing(@RequestBody String host) { 42 public @ResponseBody Vector<String> getResultPing(@RequestBody String host) {
43 43
44
45
46 return UtilsService.INSTANCE.Ping(host); 44 return UtilsService.INSTANCE.Ping(host);
47 /* 45 /*
48 Vector<String> results=new Vector<String>(); 46 Vector<String> results=new Vector<String>();
......
...@@ -245,10 +245,6 @@ Ext.application({ ...@@ -245,10 +245,6 @@ Ext.application({
245 ] 245 ]
246 }, 246 },
247 247
248
249
250
251
252 { 248 {
253 title: 'ЖУРНАЛ', 249 title: 'ЖУРНАЛ',
254 items:[ 250 items:[
...@@ -304,6 +300,9 @@ Ext.application({ ...@@ -304,6 +300,9 @@ Ext.application({
304 300
305 }); 301 });
306 302
303
304
305
307 Ext.getBody().unmask(); 306 Ext.getBody().unmask();
308 } 307 }
309 }); 308 });
......
...@@ -11,95 +11,193 @@ Ext.define('App.controller.NetworkSetting', { ...@@ -11,95 +11,193 @@ Ext.define('App.controller.NetworkSetting', {
11 11
12 'toolbar button[action=showformping]' : { 12 'toolbar button[action=showformping]' : {
13 click : this.OpenPingPanel 13 click : this.OpenPingPanel
14 } 14 },
15 15 'toolbar button[action=loadEth]' : {
16 16 click : this.ReloadData
17 17 },
18 'toolbar button[action=rebootEth]' : {
19 click : this.RebootEth
20 }
21
18 }); 22 });
19 23
24
20 25
21 26 Ext.Ajax.request({
22 27 method: "GET",
23 28 url: 'api/eth/byeth/eth0',
29 headers: {
30 'Accept': 'application/json',
31 'Content-Type': 'application/json'
32 },
33
34 success: function(response, opts) {
35
36 var result = Ext.JSON.decode(response.responseText);
37
38 Ext.getCmp('cbxeth').setValue("eth0");
39
40 Ext.getCmp("dhcp").setValue(result.dhcp);
41
42 Ext.getCmp('mac').setValue(result.mac);
43 Ext.getCmp('ip').setValue(result.ip);
44 Ext.getCmp('gateway').setValue(result.gateway);
45 Ext.getCmp('netmask').setValue(result.netmask);
46
47 var str="";
48 for(var i in result.info){
49 str=str+result.info[i]+"\n";
50 }
51 Ext.getCmp('extinfo').setValue(str);
52
53 }, failure: function(response, opts) {
54 Ext.Msg.alert('Ошибка', 'Сервер недоступен');
55 }
56 });
24 }, 57 },
25 58
26 59
27 OpenPingPanel:function() { 60 OpenPingPanel:function() {
28
29
30 var panel = Ext.create("App.view.PingUtil"); 61 var panel = Ext.create("App.view.PingUtil");
31 62 panel.show();
32 panel.show();
33 63
34 }, 64 },
35 65
36 66 RebootEth:function(btn) {
37 67
38 ReloadData: function() { 68
39 69 var networksettingView = btn.up('mvvm-NetworkSettingView');
40 var combo=Ext.getCmp('cbxeth'); 70
41 if (typeof combo.getStore().lastOptions !== "undefined") { 71 //mask
42 72 networksettingView.mask("Перезагрузка сетевого интерфейса...");
43 73
44 var value = combo.getValue(); 74
45 var valueField = combo.valueField; 75 var dhcp=Ext.getCmp("dhcp").getValue();
46 var record; 76 var ip=Ext.getCmp('ip').getValue();
47 combo.getStore().each(function(r){ 77 var gateway=Ext.getCmp('gateway').getValue();
48 if(r.data[valueField] == value){ 78 var netmask=Ext.getCmp('netmask').getValue();
49 record = r; 79 var name=Ext.getCmp('cbxeth').getValue();
50 return false; 80
51 } 81
52 }); 82 var record={
53 var eth=record ? record.get(combo.displayField) : null; 83 id:0,
54 84 name:name,
55 85 info:null,
56 86 mac:"",
87 ip:ip,
88 netmask:netmask,
89 dhcp:dhcp,
90 gateway:gateway,
91 broadcast:""
92 };
93
94 if (record) {
57 95
58 96 var data=Ext.util.JSON.encode(record);
97
59 Ext.Ajax.request({ 98 Ext.Ajax.request({
60 method: "GET", 99 method: "POST",
61 url: 'api/net/byeth/'+eth, 100 url: 'api/eth/reload',
62 headers: { 101 timeout:60000,
63 'Accept': 'application/json', 102 headers: {
64 'Content-Type': 'application/json' 103 'Accept': 'application/json',
65 }, 104 'Content-Type': 'application/json'
66 105 },
67 success: function(response, opts) { 106 params: data,
68 107 success: function(response, opts) {
69 var result = Ext.JSON.decode(response.responseText); 108 networksettingView.unmask();
70 109
71 Ext.getCmp('fromnetwork').viewModel.setData(result); 110 var result = Ext.JSON.decode(response.responseText);
72 111 Ext.Msg.alert(result.type+" "+"Код-"+result.code,result.message);
73
74
75 Ext.getCmp('mac').setDisabled(true);
76
77 }, failure: function(response, opts) {
78 }
79 });
80
81 //unmask
82 112
83 113 }, failure: function(response, opts) {
84 } 114 networksettingView.unmask();
115 Ext.Msg.alert('Ошибка', 'Сервер недоступен');
116 }
117 });
118
119 }
120
121 },
122
123 ReloadData: function(btn) {
124
125 var networksettingView = btn.up('mvvm-NetworkSettingView');
126
127 //mask
128 networksettingView.mask("Загрузка...");
129
130
131
132 Ext.Ajax.request({
133 method: "GET",
134 url: 'api/eth/byeth/eth0',
135 headers: {
136 'Accept': 'application/json',
137 'Content-Type': 'application/json'
138 },
139
140 success: function(response, opts) {
141
142 networksettingView.unmask();
143
144 var result = Ext.JSON.decode(response.responseText);
145
146 Ext.getCmp('cbxeth').setValue("eth0");
147
148 Ext.getCmp("dhcp").setValue(result.dhcp);
149
150 Ext.getCmp('mac').setValue(result.mac);
151 Ext.getCmp('ip').setValue(result.ip);
152 Ext.getCmp('gateway').setValue(result.gateway);
153 Ext.getCmp('netmask').setValue(result.netmask);
154
155 var str="";
156 for(var i in result.info){
157 str=str+result.info[i]+"\n";
158 }
159 Ext.getCmp('extinfo').setValue(str);
160
161 Ext.Msg.alert('Успешно', 'Загрузка данных выполнена');
162
163 }, failure: function(response, opts) {
164 Ext.Msg.alert('Ошибка', 'Сервер недоступен');
165 }
166 });
167
168
85 }, 169 },
86 170
87 onSaveButtonClick : function(btn) { 171 onSaveButtonClick : function(btn) {
88
89
90
91 172
92 var networksettingView = btn.up('mvvm-NetworkSettingView'); 173 var networksettingView = btn.up('mvvm-NetworkSettingView');
93 174
94 //mask 175 //mask
95 networksettingView.mask("Сохранение..."); 176 networksettingView.mask("Сохранение...");
96 177
97 var record = networksettingView.getViewModel().getData(); 178 var dhcp=Ext.getCmp("dhcp").getValue();
179 var ip=Ext.getCmp('ip').getValue();
180 var gateway=Ext.getCmp('gateway').getValue();
181 var netmask=Ext.getCmp('netmask').getValue();
182 var name=Ext.getCmp('cbxeth').getValue();
183
184
185 var record={
186 id:0,
187 name:name,
188 info:null,
189 mac:"",
190 ip:ip,
191 netmask:netmask,
192 dhcp:dhcp,
193 gateway:gateway,
194 broadcast:""
195 };
196
98 if (record) { 197 if (record) {
99 198
100 var data=Ext.util.JSON.encode(record); 199 var data=Ext.util.JSON.encode(record);
101 200
102
103 Ext.Ajax.request({ 201 Ext.Ajax.request({
104 method: "POST", 202 method: "POST",
105 url: 'api/eth/update', 203 url: 'api/eth/update',
...@@ -109,26 +207,18 @@ Ext.define('App.controller.NetworkSetting', { ...@@ -109,26 +207,18 @@ Ext.define('App.controller.NetworkSetting', {
109 }, 207 },
110 params: data, 208 params: data,
111 success: function(response, opts) { 209 success: function(response, opts) {
210 networksettingView.unmask();
112 211
113 var result = Ext.JSON.decode(response.responseText); 212 var result = Ext.JSON.decode(response.responseText);
114 213 Ext.Msg.alert(result.type+" "+"Код-"+result.code,result.message);
115 if(result) {
116
117 }
118 214
119 }, failure: function(response, opts) { 215 }, failure: function(response, opts) {
120 216 networksettingView.unmask();
121 Ext.Msg.alert('Failure', 'Обновление конфигурации не выполнено!'); 217 Ext.Msg.alert('Ошибка', 'Сервер недоступен');
122 } 218 }
123 }); 219 });
124 220
125 221 }
126
127 }
128
129 networksettingView.unmask();
130
131
132 } 222 }
133 }); 223 });
134 224
......
...@@ -80,17 +80,13 @@ Ext.define('App.controller.Proxy', { ...@@ -80,17 +80,13 @@ Ext.define('App.controller.Proxy', {
80 params: data, 80 params: data,
81 success: function(response, opts) { 81 success: function(response, opts) {
82 82
83 var Ok = Ext.JSON.decode(response.responseText); 83 var result = Ext.JSON.decode(response.responseText);
84 if (Ok) { 84 Ext.Msg.alert(result.type+" "+"Код-"+result.code,result.message);
85 Ext.Msg.alert('Success', 'Сохранение выполнено успешно'); 85
86 }else { 86 }, failure: function(response, opts) {
87 Ext.Msg.alert('Failure', 'Ошибка сохранения'); 87 networksettingView.unmask();
88 } 88 Ext.Msg.alert('Ошибка', 'Сервер недоступен');
89 89 }
90 }, failure: function(response, opts) {
91
92 Ext.Msg.alert('Failure', 'Ошибка сохранения');
93 }
94 }); 90 });
95 91
96 92
...@@ -117,7 +113,11 @@ Ext.define('App.controller.Proxy', { ...@@ -117,7 +113,11 @@ Ext.define('App.controller.Proxy', {
117 enabled=fsHttps.checkboxCmp.getValue(); 113 enabled=fsHttps.checkboxCmp.getValue();
118 114
119 host=fsHttps.down('#'+protocol+'Adress').getValue(); 115 host=fsHttps.down('#'+protocol+'Adress').getValue();
120 port=fsHttps.down('#'+protocol+'Port').getValue(); 116 port=parseInt(fsHttps.down('#'+protocol+'Port').getValue());
117
118 if(port==null) {
119 port=0;
120 }
121 121
122 var fsHttpsAuth=fsHttps.down('#fs'+protocol+'Auth'); 122 var fsHttpsAuth=fsHttps.down('#fs'+protocol+'Auth');
123 123
...@@ -133,7 +133,7 @@ Ext.define('App.controller.Proxy', { ...@@ -133,7 +133,7 @@ Ext.define('App.controller.Proxy', {
133 id:id, 133 id:id,
134 protocol:protocol, 134 protocol:protocol,
135 host:host, 135 host:host,
136 port:parseInt(port), 136 port:0,
137 login:login, 137 login:login,
138 pass:pass, 138 pass:pass,
139 enabled:enabled, 139 enabled:enabled,
......
...@@ -49,8 +49,6 @@ Ext.define('App.view.NetworkSetting', { ...@@ -49,8 +49,6 @@ Ext.define('App.view.NetworkSetting', {
49 xtype : 'mvvm-EthView', 49 xtype : 'mvvm-EthView',
50 id:'cbxeth' 50 id:'cbxeth'
51 }, 51 },
52
53
54 { 52 {
55 xtype : 'checkboxfield', 53 xtype : 'checkboxfield',
56 54
...@@ -80,8 +78,6 @@ Ext.define('App.view.NetworkSetting', { ...@@ -80,8 +78,6 @@ Ext.define('App.view.NetworkSetting', {
80 fieldLabel : 'IP', 78 fieldLabel : 'IP',
81 id:'ip', 79 id:'ip',
82 margin:'5 5 10 3' 80 margin:'5 5 10 3'
83
84
85 }, 81 },
86 { 82 {
87 xtype : 'textfield', 83 xtype : 'textfield',
...@@ -89,8 +85,6 @@ Ext.define('App.view.NetworkSetting', { ...@@ -89,8 +85,6 @@ Ext.define('App.view.NetworkSetting', {
89 fieldLabel : 'GATEWAY', 85 fieldLabel : 'GATEWAY',
90 id:'gateway', 86 id:'gateway',
91 margin:'5 5 10 3' 87 margin:'5 5 10 3'
92
93
94 }, 88 },
95 { 89 {
96 xtype : 'textfield', 90 xtype : 'textfield',
...@@ -99,15 +93,13 @@ Ext.define('App.view.NetworkSetting', { ...@@ -99,15 +93,13 @@ Ext.define('App.view.NetworkSetting', {
99 id:'netmask', 93 id:'netmask',
100 margin:'5 5 10 3' 94 margin:'5 5 10 3'
101 }, 95 },
102 96 {
103 { 97 xtype : 'textarea',
104 xtype : 'textarea',
105 bind : '{info}', 98 bind : '{info}',
106 id:'ttt', 99 id:'extinfo',
107 fieldLabel : 'СТАТУС', 100 fieldLabel : 'СТАТУС',
108 margin:'5 5 10 3', 101 margin:'5 5 10 3',
109 allowBlank : false, 102 allowBlank : false,
110
111 width:700, 103 width:700,
112 height:100, 104 height:100,
113 105
......
...@@ -41,9 +41,9 @@ public class EthLinux implements IEth { ...@@ -41,9 +41,9 @@ public class EthLinux implements IEth {
41 41
42 42
43 try { 43 try {
44 Vector<String> buff=cmdexec.Run("ifdown "+name); 44 Vector<String> buff=cmdexec.Run("ifdown"+" "+name);
45 Thread.sleep(5000); 45 Thread.sleep(5000);
46 buff=cmdexec.Run("ifup "+name); 46 buff=cmdexec.Run("ifup"+" "+name);
47 Thread.sleep(5000); 47 Thread.sleep(5000);
48 Msg msg=Msg.RestartEthSucc; 48 Msg msg=Msg.RestartEthSucc;
49 49
...@@ -62,6 +62,7 @@ public class EthLinux implements IEth { ...@@ -62,6 +62,7 @@ public class EthLinux implements IEth {
62 * Список интерфейсов Ethernet на данном устройстве 62 * Список интерфейсов Ethernet на данном устройстве
63 * @see org.emercit.ethmanager.service.IEth#getListEth() 63 * @see org.emercit.ethmanager.service.IEth#getListEth()
64 */ 64 */
65
65 public Vector<String> getListEth() { 66 public Vector<String> getListEth() {
66 67
67 Vector<String> result=new Vector<String>(); 68 Vector<String> result=new Vector<String>();
...@@ -109,11 +110,12 @@ public class EthLinux implements IEth { ...@@ -109,11 +110,12 @@ public class EthLinux implements IEth {
109 110
110 String addr=cmdexec.Run("ifconfig"+" "+eb.getName()+" "+"| grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'").firstElement(); 111 String addr=cmdexec.Run("ifconfig"+" "+eb.getName()+" "+"| grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'").firstElement();
111 String mask=cmdexec.Run("ifconfig"+" "+eb.getName()+" "+"| grep 'inet addr:' | cut -d: -f4 | awk '{ print $1}'").firstElement(); 112 String mask=cmdexec.Run("ifconfig"+" "+eb.getName()+" "+"| grep 'inet addr:' | cut -d: -f4 | awk '{ print $1}'").firstElement();
113
112 //String gateway=cmdexec.Run("/sbin/route -n | grep 'UG' | awk '{print $2}'").firstElement(); 114 //String gateway=cmdexec.Run("/sbin/route -n | grep 'UG' | awk '{print $2}'").firstElement();
113 115
114 eb.setIp(addr); 116 eb.setIp(addr);
115 eb.setNetmask(mask); 117 eb.setNetmask(mask);
116 eb.setGateway(""); 118 eb.setGateway("");
117 } 119 }
118 120
119 return eb; 121 return eb;
...@@ -168,11 +170,9 @@ public class EthLinux implements IEth { ...@@ -168,11 +170,9 @@ public class EthLinux implements IEth {
168 bw.write("\n"); 170 bw.write("\n");
169 bw.write("\n"); 171 bw.write("\n");
170 172
171
172 for (EthBean eb:ebs) { 173 for (EthBean eb:ebs) {
173 174
174 175 if (!eb.getDhcp()) {
175 if (!eb.getDhcp()) {
176 176
177 bw.write("auto "+eb.getName()); 177 bw.write("auto "+eb.getName());
178 bw.write("\n"); 178 bw.write("\n");
...@@ -194,8 +194,6 @@ public class EthLinux implements IEth { ...@@ -194,8 +194,6 @@ public class EthLinux implements IEth {
194 194
195 bw.write("\n"); 195 bw.write("\n");
196 bw.write("\n"); 196 bw.write("\n");
197
198
199 } 197 }
200 198
201 bw.close(); 199 bw.close();
......
...@@ -6,14 +6,17 @@ import junit.framework.Test; ...@@ -6,14 +6,17 @@ import junit.framework.Test;
6 import junit.framework.TestCase; 6 import junit.framework.TestCase;
7 import junit.framework.TestSuite; 7 import junit.framework.TestSuite;
8 import static org.junit.Assert.*; 8 import static org.junit.Assert.*;
9
9 import java.util.Vector; 10 import java.util.Vector;
11
10 import org.emercit.utilstools.config.Msg; 12 import org.emercit.utilstools.config.Msg;
11 import org.junit.Before; 13 import org.junit.Before;
12 import org.junit.After; 14 import org.junit.After;
15 import org.junit.Ignore;
13 import org.emercit.ethmanager.model.EthBean; 16 import org.emercit.ethmanager.model.EthBean;
14 import org.emercit.ethmanager.service.EthLinux; 17 import org.emercit.ethmanager.service.EthLinux;
15 18
16 19 @Ignore
17 public class TestEthLinux extends TestCase { 20 public class TestEthLinux extends TestCase {
18 21
19 22
......
1 package org.emercit.utilstools;
2
3
4 import junit.framework.Test;
5 import junit.framework.TestCase;
6 import junit.framework.TestSuite;
7 import static org.junit.Assert.*;
8 import java.util.Vector;
9 import org.emercit.utilstools.config.Msg;
10 import org.junit.Before;
11 import org.junit.After;
12
13 import org.emercit.proxymanager.model.ProxyBean;
14
15 import org.emercit.proxymanager.service.ProxyLinux;
16
17 import org.emercit.utilstools.config.Msg;
18
19
20 public class TestProxyLinux extends TestCase {
21
22
23 private Vector<ProxyBean> beans;
24 private ProxyLinux proxylinux;
25
26
27
28 public TestProxyLinux( String testName )
29 {
30 super( testName );
31 }
32
33
34 public static Test suite()
35 {
36 return new TestSuite( TestProxyLinux.class );
37 }
38
39 @Before
40 public void upTestProxyLinux()
41 {
42
43 }
44
45 @After
46 public void downTestProxyLinux()
47 {
48
49 }
50
51
52 public void testProxyLinux()
53 {
54
55 proxylinux=new ProxyLinux();
56
57 int value=proxylinux.init();
58
59 Msg msg=Msg.getByCode(value);
60
61 if (msg.getTypeVariable().getCode()==1) {
62 fail("Инициализация настроек прокси не выполнена");
63 }
64
65
66 beans=proxylinux.getProxyBeans();
67
68 assertNotNull(beans);
69
70 for (ProxyBean bean:beans) {
71
72 bean.setHost("127.127.127.127");
73 }
74
75 value=proxylinux.Config(beans);
76 msg=Msg.getByCode(value);
77
78 if (msg.getTypeVariable().getCode()==1) {
79 fail("Изменение параметров прокси не выполнено");
80 }
81
82 assertTrue( true );
83 }
84
85
86 }
87
88 //assertFalse(!stservice.IsRun("start.jar")); // Если true - то тест завален
89 // assertEquals(stservice.IsRun("start.jar")); // Если не равны - тест завален
90 // assertNotNull(stservice.IsRun("start.jar"))); // Если null - тест завален
91 //assertNull(stservice.IsRun("start.jar"))); // Если не null - тест завален
92 //assertNotSame(stservice.IsRun("start.jar")); // Если оба объекта являются одинаковыми(не одно и то же, что равны) - тест завален
93 //assertSame(stservice.IsRun("start.jar")); // Если оба объекта не являются одинаковыми - тест завален