Main.js 19 KB

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