Main.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560
  1. MWF.xDesktop.requireApp("Setting", "Document", null, false);
  2. MWF.xDesktop.requireApp("Setting", "SettingBase", null, false);
  3. MWF.xDesktop.requireApp("Setting", "SettingMobile", null, false);
  4. MWF.xDesktop.requireApp("Setting", "SettingCloud", null, false);
  5. MWF.xDesktop.requireApp("Setting", "SettingLoginUI", null, false);
  6. MWF.xDesktop.requireApp("Setting", "SettingIndexUI", null, false);
  7. MWF.xDesktop.requireApp("Setting", "SettingModuleUI", null, false);
  8. MWF.xDesktop.requireApp("Setting", "SettingModuleService", null, false);
  9. MWF.xDesktop.requireApp("Setting", "SettingModuleResource", null, false);
  10. MWF.xApplication.Setting.Main = new Class({
  11. Extends: MWF.xApplication.Common.Main,
  12. Implements: [Options, Events],
  13. options: {
  14. "style": "default",
  15. "name": "Setting",
  16. "icon": "icon.png",
  17. "width": "1020",
  18. "height": "660",
  19. "title": MWF.xApplication.Setting.LP.title
  20. },
  21. onQueryLoad: function(){
  22. this.lp = MWF.xApplication.Setting.LP;
  23. this.actions = MWF.Actions.get("x_program_center");
  24. //this.actions = new MWF.xApplication.Setting.Actions.RestActions();
  25. },
  26. loadApplication: function(callback){
  27. this.baseAreaNode = new Element("div", {"styles": this.css.tabAreaNode}).inject(this.content);
  28. this.uiAreaNode = new Element("div", {"styles": this.css.tabAreaNode}).inject(this.content);
  29. this.mobileAreaNode = new Element("div", {"styles": this.css.tabAreaNode}).inject(this.content);
  30. this.cloudAreaNode = new Element("div", {"styles": this.css.tabAreaNode}).inject(this.content);
  31. this.disposeAreaNode = new Element("div", {"styles": this.css.tabAreaNode}).inject(this.content);
  32. // this.serverAreaNode = new Element("div", {"styles": this.css.tabAreaNode}).inject(this.content);
  33. // this.applicationAreaNode = new Element("div", {"styles": this.css.tabAreaNode}).inject(this.content);
  34. // this.resourceAreaNode = new Element("div", {"styles": this.css.tabAreaNode}).inject(this.content);
  35. // this.mobileAreaNode = new Element("div", {"styles": this.css.tabAreaNode}).inject(this.content);
  36. MWF.require("MWF.widget.Tab", function(){
  37. this.tab = new MWF.widget.Tab(this.content, {"style": "administrator"});
  38. this.tab.load();
  39. this.basePage = this.tab.addTab(this.baseAreaNode, this.lp.tab_base, false);
  40. this.uiPage = this.tab.addTab(this.uiAreaNode, this.lp.tab_ui, false);
  41. this.cloudPage = this.tab.addTab(this.cloudAreaNode, this.lp.tab_cloud, false);
  42. this.mobilePage = this.tab.addTab(this.mobileAreaNode, this.lp.tab_mobile, false);
  43. this.disposePage = this.tab.addTab(this.disposeAreaNode, this.lp.tab_dispose, false);
  44. this.basePage.addEvent("postShow", function(){
  45. if (!this.baseExplorer) this.baseExplorer = new MWF.xApplication.Setting.BaseExplorer(this, this.baseAreaNode);
  46. }.bind(this));
  47. this.uiPage.addEvent("postShow", function(){
  48. if (!this.uiExplorer) this.uiExplorer = new MWF.xApplication.Setting.UIExplorer(this, this.uiAreaNode);
  49. }.bind(this));
  50. this.mobilePage.addEvent("postShow", function(){
  51. if (!this.mobileExplorer) this.mobileExplorer = new MWF.xApplication.Setting.MobileExplorer(this, this.mobileAreaNode);
  52. }.bind(this));
  53. this.cloudPage.addEvent("postShow", function(){
  54. if (!this.cloudExplorer) this.cloudExplorer = new MWF.xApplication.Setting.CloudExplorer(this, this.cloudAreaNode);
  55. }.bind(this));
  56. this.disposePage.addEvent("postShow", function(){
  57. if (!this.disposeExplorer) this.disposeExplorer = new MWF.xApplication.Setting.DisposeExplorer(this, this.disposeAreaNode);
  58. }.bind(this));
  59. // this.serverPage = this.tab.addTab(this.serverAreaNode, this.lp.tab_Server, false);
  60. // this.applicationPage = this.tab.addTab(this.applicationAreaNode, this.lp.tab_Application, false);
  61. // this.resourcePage = this.tab.addTab(this.resourceAreaNode, this.lp.tab_Resource, false);
  62. // this.mobilePage = this.tab.addTab(this.mobileAreaNode, this.lp.tab_Mobile, false);
  63. // this.serverPage.addEvent("postShow", function(){
  64. // if (!this.serversExplorer) this.serversExplorer = new MWF.xApplication.Setting.ServersExplorer(this);
  65. // }.bind(this));
  66. //
  67. // this.applicationPage.addEvent("postShow", function(){
  68. // if (!this.applicationExplorer) this.applicationExplorer = new MWF.xApplication.Setting.ApplicationsExplorer(this);
  69. // }.bind(this));
  70. //
  71. // this.resourcePage.addEvent("postShow", function(){
  72. // if (!this.resourceExplorer) this.resourceExplorer = new MWF.xApplication.Setting.ResourceExplorer(this);
  73. // }.bind(this));
  74. //
  75. // this.mobilePage.addEvent("postShow", function(){
  76. // if (!this.mobileExplorer) this.mobileExplorer = new MWF.xApplication.Setting.MobileExplorer(this);
  77. // }.bind(this));
  78. this.basePage.showIm();
  79. //this.loadServers();
  80. this.setContentHeight();
  81. this.addEvent("resize", function(){this.setContentHeight();}.bind(this));
  82. }.bind(this));
  83. //MWF.xDesktop.requireApp("Setting", "ApplicationServers", function(){
  84. // this.applicationServerList = new MWF.xApplication.Setting.ApplicationServers(this);
  85. //}.bind(this));
  86. //this.loadApplicationServers();
  87. },
  88. loadTitle: function(){
  89. this.titleBar = new Element("div", {"styles": this.css.titleBar}).inject(this.content);
  90. this.taskTitleTextNode = new Element("div", {"styles": this.css.titleTextNode,"text": this.lp.title}).inject(this.titleBar);
  91. },
  92. setContentHeight: function(node){
  93. var size = this.content.getSize();
  94. //var titleSize = this.titleBar.getSize();
  95. var tabSize = this.tab.tabNodeContainer.getSize();
  96. //var height = size.y-tabSize.y-titleSize.y;
  97. var height = size.y-tabSize.y;
  98. this.tab.pages.each(function(page){
  99. page.contentNodeArea.setStyles({"height": ""+height+"px", "overflow": "auto"})
  100. });
  101. //this.appDeploymentContent.setStyle("height", height);
  102. }
  103. });
  104. MWF.xApplication.Setting.BaseExplorer = new Class({
  105. Implements: [Events],
  106. initialize: function(app, content){
  107. this.app = app;
  108. this.lp = this.app.lp;
  109. this.container = content;
  110. this.actions = this.app.actions;
  111. this.css = this.app.css;
  112. this.naviItems = [];
  113. this.collectData = null;
  114. this.personData = null;
  115. this.tokenData = null;
  116. this.portalData = null;
  117. this.loadDataBack = null;
  118. this.publicData = null;
  119. this.load();
  120. },
  121. getData: function(){
  122. var checkData = function(){
  123. if (this.collectData && this.personData && this.tokenData && this.portalData && this.publicData){
  124. if (this.loadDataBack){
  125. var fun = this.loadDataBack;
  126. this.loadDataBack = null;
  127. fun();
  128. }
  129. }
  130. }.bind(this);
  131. this.actions.getCollect(function(json){
  132. this.collectData = json.data;
  133. checkData();
  134. }.bind(this));
  135. this.actions.getPerson(function(json){
  136. this.personData = json.data;
  137. checkData();
  138. }.bind(this));
  139. this.actions.getToken(function(json){
  140. this.tokenData = json.data;
  141. checkData();
  142. }.bind(this));
  143. this.actions.getPortal(function(json){
  144. this.portalData = json.data;
  145. checkData();
  146. }.bind(this));
  147. //o2.UD.deletePublicData("faceKeys");
  148. o2.UD.getPublicData("faceKeys", function(json){
  149. if (json){
  150. if (json["api-key"]){
  151. json.api_key = json["api-key"];
  152. delete json["api-key"]
  153. }
  154. if (json["api_secret"]){
  155. json.api_secret = json["api_secret"];
  156. delete json["api_secret"]
  157. }
  158. }
  159. this.publicData = json || {"api": {"api_key":"", "api_secret":""}};
  160. checkData();
  161. }.bind(this));
  162. },
  163. load: function(){
  164. if (MWF.AC.isAdministrator()) this.getData();
  165. this.naviAreaNode = new Element("div", {"styles": this.css.explorerNaviAreaNode}).inject(this.container);
  166. this.naviNode = new Element("div", {"styles": this.css.explorerNaviNode}).inject(this.naviAreaNode);
  167. this.contentAreaNode = new Element("div", {"styles": this.css.explorerContentAreaNode}).inject(this.container);
  168. this.loadNavi();
  169. },
  170. loadNavi: function(){
  171. var json = this.getNaviJson();
  172. json.each(function(navi){
  173. this.naviItems.push(this.createNaviItem(navi));
  174. }.bind(this));
  175. this.naviItems[0].click();
  176. },
  177. createNaviItem: function(navi){
  178. var naviItemNode = new Element("div", {"styles": this.css.naviItemNode}).inject(this.naviNode);
  179. //var naviItemIconNode = new Element("div", {"styles": this.css.naviItemIconNode}).inject(naviItemNode);
  180. naviItemNode.setStyle("background-image", "url(../x_component_Setting/$Main/default/icon/"+navi.icon+".png)");
  181. //var naviItemTextNode = new Element("div", {"styles": this.css.naviItemTextNode}).inject(naviItemNode);
  182. naviItemNode.set("text", navi.text);
  183. naviItemNode.store("navi", navi);
  184. var _self = this;
  185. naviItemNode.addEvent("click", function(){
  186. _self.setNavi(this);
  187. });
  188. return naviItemNode;
  189. },
  190. setNavi: function(item){
  191. var navi = item.retrieve("navi");
  192. this.naviItems.each(function(node){
  193. var itemNavi = node.retrieve("navi");
  194. var content = node.retrieve("content", null);
  195. if (content) content.destroy();
  196. node.eliminate("content");
  197. node.setStyles(this.css.naviItemNode);
  198. node.setStyle("background-image", "url(../x_component_Setting/$Main/default/icon/"+itemNavi.icon+".png)");
  199. }.bind(this));
  200. item.setStyles(this.css.naviItemNode_current);
  201. item.setStyle("background-image", "url(../x_component_Setting/$Main/default/icon/"+navi.icon+"_current.png)");
  202. if (this[navi.action]) this[navi.action](item);
  203. },
  204. getNaviJson: function(){
  205. return [
  206. {
  207. "text": this.app.lp.tab_name,
  208. "icon": "name",
  209. "action": "loadSystemNameSetting"
  210. },
  211. {
  212. "text": this.app.lp.tab_user,
  213. "icon": "user",
  214. "action": "loadSystemPersonSetting"
  215. },
  216. {
  217. "text": this.app.lp.tab_login,
  218. "icon": "login",
  219. "action": "loadSystemLoginSetting"
  220. },
  221. {
  222. "text": this.app.lp.tab_sso,
  223. "icon": "sso",
  224. "action": "loadSystemSSOSetting"
  225. },
  226. {
  227. "text": this.app.lp.tab_config,
  228. "icon": "config",
  229. "action": "loadSystemConfigSetting"
  230. }
  231. ];
  232. },
  233. loadSystemConfigSetting:function(item){
  234. if (MWF.AC.isAdministrator()) {
  235. var appId = "ConfigDesigner";
  236. if (layout.desktop.apps["ConfigDesigner"]){
  237. layout.desktop.apps[appId].setCurrent();
  238. return;
  239. }
  240. layout.openApplication(null, "ConfigDesigner",{
  241. "appId": appId
  242. });
  243. }
  244. },
  245. loadSystemNameSetting: function(item){
  246. if (MWF.AC.isAdministrator()) {
  247. if (this.collectData && this.personData && this.tokenData){
  248. this.baseNameSetting = new MWF.xApplication.Setting.BaseNameDocument(this, this.contentAreaNode);
  249. item.store("content", this.baseNameSetting);
  250. }else{
  251. this.loadDataBack = function(){this.loadSystemNameSetting(item)}.bind(this);
  252. }
  253. }
  254. },
  255. loadSystemPersonSetting: function(item){
  256. if (MWF.AC.isAdministrator()) if (this.collectData && this.personData && this.tokenData){
  257. this.basePersonSetting = new MWF.xApplication.Setting.BasePersonDocument(this, this.contentAreaNode);
  258. item.store("content", this.basePersonSetting);
  259. }else{
  260. this.loadDataBack = function(){this.loadSystemPersonSetting(item)}.bind(this);
  261. }
  262. },
  263. loadSystemLoginSetting: function(item){
  264. if (MWF.AC.isAdministrator()) if (this.collectData && this.personData && this.tokenData){
  265. this.baseLoginSetting = new MWF.xApplication.Setting.BaseLoginDocument(this, this.contentAreaNode);
  266. item.store("content", this.baseLoginSetting);
  267. }else{
  268. this.loadDataBack = function(){this.loadSystemLoginSetting(item)}.bind(this);
  269. }
  270. },
  271. loadSystemSSOSetting: function(item){
  272. if (MWF.AC.isAdministrator()) if (this.collectData && this.personData && this.tokenData){
  273. this.baseLoginSetting = new MWF.xApplication.Setting.BaseSSODocument(this, this.contentAreaNode);
  274. item.store("content", this.baseLoginSetting);
  275. }else{
  276. this.loadDataBack = function(){this.loadSystemSSOSetting(item)}.bind(this);
  277. }
  278. }
  279. });
  280. MWF.xApplication.Setting.MobileExplorer = new Class({
  281. Extends: MWF.xApplication.Setting.BaseExplorer,
  282. initialize: function(app, content){
  283. this.app = app;
  284. this.lp = this.app.lp;
  285. this.container = content;
  286. this.actions = this.app.actions;
  287. this.css = this.app.css;
  288. this.naviItems = [];
  289. this.collectData = null;
  290. this.personData = null;
  291. this.tokenData = null;
  292. this.loadDataBack = null;
  293. this.load();
  294. },
  295. getNaviJson: function(){
  296. return [
  297. {
  298. "text": this.app.lp.tab_mobile_module,
  299. "icon": "module",
  300. "action": "loadMobileModuleSetting"
  301. },
  302. {
  303. "text": this.app.lp.tab_mobile_style,
  304. "icon": "style",
  305. "action": "loadMobileStyleSetting"
  306. }
  307. ];
  308. },
  309. getData: function(){
  310. var checkData = function(){
  311. if (this.proxyData && this.nativeData && this.imagesData){
  312. if (this.loadDataBack){
  313. var fun = this.loadDataBack;
  314. this.loadDataBack = null;
  315. fun();
  316. }
  317. }
  318. }.bind(this);
  319. this.actions.getProxy(function(json){
  320. this.proxyData = json.data;
  321. checkData();
  322. }.bind(this));
  323. this.actions.mobile_currentStyle(function(json){
  324. this.nativeData = {"indexType": json.data.indexType, "indexPortal": json.data.indexPortal, "simpleMode": json.data.simpleMode, "nativeAppList": Array.clone(json.data.nativeAppList)};
  325. this.imagesData = {"images": Array.clone(json.data.images)};
  326. //this.indexData = {"indexType": json.data.indexType, "indexId": json.data.indexId};
  327. this.portalData = {"portalList": Array.clone(json.data.portalList)};
  328. delete json.data;
  329. json = null;
  330. checkData();
  331. }.bind(this));
  332. },
  333. // loadMobileConnectSetting: function(item){
  334. // if (MWF.AC.isAdministrator()) if (this.proxyData && this.nativeData && this.imagesData){
  335. // this.mobileConnectSetting = new MWF.xApplication.Setting.MobileConnectDocument(this, this.contentAreaNode);
  336. // item.store("content", this.mobileConnectSetting);
  337. // }else{
  338. // this.loadDataBack = function(){this.loadMobileConnectSetting(item)}.bind(this);
  339. // }
  340. // },
  341. loadMobileModuleSetting: function(item){
  342. if (MWF.AC.isAdministrator()) if (this.proxyData && this.nativeData && this.imagesData){
  343. this.mobileModuleSetting = new MWF.xApplication.Setting.MobileModuleDocument(this, this.contentAreaNode);
  344. item.store("content", this.mobileModuleSetting);
  345. }else{
  346. this.loadDataBack = function(){this.loadMobileModuleSetting(item)}.bind(this);
  347. }
  348. },
  349. loadMobileStyleSetting: function(item){
  350. if (MWF.AC.isAdministrator()) if (this.proxyData && this.nativeData && this.imagesData){
  351. this.mobileStyleSetting = new MWF.xApplication.Setting.MobileStyleDocument(this, this.contentAreaNode);
  352. item.store("content", this.mobileStyleSetting);
  353. }else{
  354. this.loadDataBack = function(){this.loadMobileStyleSetting(item)}.bind(this);
  355. }
  356. }
  357. });
  358. MWF.xApplication.Setting.CloudExplorer = new Class({
  359. Extends: MWF.xApplication.Setting.BaseExplorer,
  360. initialize: function(app, content){
  361. this.app = app;
  362. this.lp = this.app.lp;
  363. this.container = content;
  364. this.actions = this.app.actions;
  365. this.css = this.app.css;
  366. this.naviItems = [];
  367. this.collectData = null;
  368. this.personData = null;
  369. this.tokenData = null;
  370. this.loadDataBack = null;
  371. this.load();
  372. },
  373. getNaviJson: function(){
  374. return [
  375. {
  376. "text": this.app.lp.tab_cloud_connect,
  377. "icon": "connect",
  378. "action": "loadCloudConnectSetting"
  379. }
  380. ];
  381. },
  382. getData: function(){
  383. var checkData = function(){
  384. if (this.proxyData && this.nativeData && this.imagesData){
  385. if (this.loadDataBack){
  386. var fun = this.loadDataBack;
  387. this.loadDataBack = null;
  388. fun();
  389. }
  390. }
  391. }.bind(this);
  392. this.actions.getProxy(function(json){
  393. this.proxyData = json.data;
  394. checkData();
  395. }.bind(this));
  396. this.actions.mobile_currentStyle(function(json){
  397. this.nativeData = {"indexType": json.data.indexType, "indexPortal": json.data.indexPortal, "nativeAppList": Array.clone(json.data.nativeAppList)};
  398. this.imagesData = {"images": Array.clone(json.data.images)};
  399. //this.indexData = {"indexType": json.data.indexType, "indexId": json.data.indexId};
  400. this.portalData = {"portalList": Array.clone(json.data.portalList)};
  401. delete json.data;
  402. json = null;
  403. checkData();
  404. }.bind(this));
  405. },
  406. loadCloudConnectSetting: function(item){
  407. if (MWF.AC.isAdministrator()) if (this.proxyData && this.nativeData && this.imagesData){
  408. this.mobileConnectSetting = new MWF.xApplication.Setting.CloudConnectDocument(this, this.contentAreaNode);
  409. item.store("content", this.mobileConnectSetting);
  410. }else{
  411. this.loadDataBack = function(){this.loadCloudConnectSetting(item)}.bind(this);
  412. }
  413. },
  414. });
  415. MWF.xApplication.Setting.UIExplorer = new Class({
  416. Extends: MWF.xApplication.Setting.BaseExplorer,
  417. initialize: function(app, content){
  418. this.app = app;
  419. this.lp = this.app.lp;
  420. this.container = content;
  421. this.actions = this.app.actions;
  422. this.css = this.app.css;
  423. this.naviItems = [];
  424. this.load();
  425. },
  426. getNaviJson: function(){
  427. return [
  428. {
  429. "text": this.app.lp.tab_ui_index,
  430. "icon": "index",
  431. "action": "loadUIIndexSetting"
  432. },
  433. {
  434. "text": this.app.lp.tab_ui_login,
  435. "icon": "login",
  436. "action": "loadUILoginSetting"
  437. }
  438. ];
  439. },
  440. getData: function(){
  441. },
  442. loadUILoginSetting: function(item){
  443. if (MWF.AC.isAdministrator()){
  444. this.uiLoginSetting = new MWF.xApplication.Setting.UILoginDocument(this, this.contentAreaNode);
  445. item.store("content", this.uiLoginSetting);
  446. }
  447. },
  448. loadUIIndexSetting: function(item){
  449. if (MWF.AC.isAdministrator()) {
  450. this.uiIndexSetting = new MWF.xApplication.Setting.UIIndexDocument(this, this.contentAreaNode);
  451. item.store("content", this.uiIndexSetting);
  452. }
  453. }
  454. });
  455. MWF.xApplication.Setting.DisposeExplorer = new Class({
  456. Extends: MWF.xApplication.Setting.BaseExplorer,
  457. initialize: function(app, content){
  458. this.app = app;
  459. this.lp = this.app.lp;
  460. this.container = content;
  461. this.actions = this.app.actions;
  462. this.css = this.app.css;
  463. this.naviItems = [];
  464. this.load();
  465. },
  466. getNaviJson: function(){
  467. return [
  468. {
  469. "text": this.app.lp.tab_ui_module,
  470. "icon": "module",
  471. "action": "loadUIModuleSetting"
  472. },
  473. {
  474. "text": this.app.lp.tab_ui_resource,
  475. "icon": "resource",
  476. "action": "loadResourceModuleSetting"
  477. },
  478. {
  479. "text": this.app.lp.tab_ui_service,
  480. "icon": "service",
  481. "action": "loadServiceModuleSetting"
  482. }
  483. ];
  484. },
  485. getData: function(){
  486. },
  487. loadUIModuleSetting: function(item){
  488. if (MWF.AC.isAdministrator()) {
  489. this.uiModuleSetting = new MWF.xApplication.Setting.UIModuleDocument(this, this.contentAreaNode);
  490. item.store("content", this.uiModuleSetting);
  491. }
  492. },
  493. loadServiceModuleSetting: function(item){
  494. if (MWF.AC.isAdministrator()) {
  495. this.serviceModuleSetting = new MWF.xApplication.Setting.ServiceModuleDocument(this, this.contentAreaNode);
  496. item.store("content", this.serviceModuleSetting);
  497. }
  498. },
  499. loadResourceModuleSetting: function(item){
  500. if (MWF.AC.isAdministrator()) {
  501. this.resourceModuleSetting = new MWF.xApplication.Setting.ResourceModuleDocument(this, this.contentAreaNode);
  502. item.store("content", this.resourceModuleSetting);
  503. }
  504. }
  505. });