Main.js 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480
  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. },
  222. loadSystemNameSetting: function(item){
  223. if (MWF.AC.isAdministrator()) {
  224. if (this.collectData && this.personData && this.tokenData){
  225. this.baseNameSetting = new MWF.xApplication.Setting.BaseNameDocument(this, this.contentAreaNode);
  226. item.store("content", this.baseNameSetting);
  227. }else{
  228. this.loadDataBack = function(){this.loadSystemNameSetting(item)}.bind(this);
  229. }
  230. }
  231. },
  232. loadSystemPersonSetting: function(item){
  233. if (MWF.AC.isAdministrator()) if (this.collectData && this.personData && this.tokenData){
  234. this.basePersonSetting = new MWF.xApplication.Setting.BasePersonDocument(this, this.contentAreaNode);
  235. item.store("content", this.basePersonSetting);
  236. }else{
  237. this.loadDataBack = function(){this.loadSystemPersonSetting(item)}.bind(this);
  238. }
  239. },
  240. loadSystemLoginSetting: function(item){
  241. if (MWF.AC.isAdministrator()) if (this.collectData && this.personData && this.tokenData){
  242. this.baseLoginSetting = new MWF.xApplication.Setting.BaseLoginDocument(this, this.contentAreaNode);
  243. item.store("content", this.baseLoginSetting);
  244. }else{
  245. this.loadDataBack = function(){this.loadSystemLoginSetting(item)}.bind(this);
  246. }
  247. },
  248. loadSystemSSOSetting: function(item){
  249. if (MWF.AC.isAdministrator()) if (this.collectData && this.personData && this.tokenData){
  250. this.baseLoginSetting = new MWF.xApplication.Setting.BaseSSODocument(this, this.contentAreaNode);
  251. item.store("content", this.baseLoginSetting);
  252. }else{
  253. this.loadDataBack = function(){this.loadSystemSSOSetting(item)}.bind(this);
  254. }
  255. }
  256. });
  257. MWF.xApplication.Setting.MobileExplorer = new Class({
  258. Extends: MWF.xApplication.Setting.BaseExplorer,
  259. initialize: function(app, content){
  260. this.app = app;
  261. this.lp = this.app.lp;
  262. this.container = content;
  263. this.actions = this.app.actions;
  264. this.css = this.app.css;
  265. this.naviItems = [];
  266. this.collectData = null;
  267. this.personData = null;
  268. this.tokenData = null;
  269. this.loadDataBack = null;
  270. this.load();
  271. },
  272. getNaviJson: function(){
  273. return [
  274. {
  275. "text": this.app.lp.tab_mobile_connect,
  276. "icon": "connect",
  277. "action": "loadMobileConnectSetting"
  278. },
  279. {
  280. "text": this.app.lp.tab_mobile_module,
  281. "icon": "module",
  282. "action": "loadMobileModuleSetting"
  283. },
  284. {
  285. "text": this.app.lp.tab_mobile_style,
  286. "icon": "style",
  287. "action": "loadMobileStyleSetting"
  288. }
  289. ];
  290. },
  291. getData: function(){
  292. var checkData = function(){
  293. if (this.proxyData && this.nativeData && this.imagesData){
  294. if (this.loadDataBack){
  295. var fun = this.loadDataBack;
  296. this.loadDataBack = null;
  297. fun();
  298. }
  299. }
  300. }.bind(this);
  301. this.actions.getProxy(function(json){
  302. this.proxyData = json.data;
  303. checkData();
  304. }.bind(this));
  305. this.actions.mobile_currentStyle(function(json){
  306. this.nativeData = {"indexType": json.data.indexType, "indexPortal": json.data.indexPortal, "nativeAppList": Array.clone(json.data.nativeAppList)};
  307. this.imagesData = {"images": Array.clone(json.data.images)};
  308. //this.indexData = {"indexType": json.data.indexType, "indexId": json.data.indexId};
  309. this.portalData = {"portalList": Array.clone(json.data.portalList)};
  310. delete json.data;
  311. json = null;
  312. checkData();
  313. }.bind(this));
  314. },
  315. loadMobileConnectSetting: function(item){
  316. if (MWF.AC.isAdministrator()) if (this.proxyData && this.nativeData && this.imagesData){
  317. this.mobileConnectSetting = new MWF.xApplication.Setting.MobileConnectDocument(this, this.contentAreaNode);
  318. item.store("content", this.mobileConnectSetting);
  319. }else{
  320. this.loadDataBack = function(){this.loadMobileConnectSetting(item)}.bind(this);
  321. }
  322. },
  323. loadMobileModuleSetting: function(item){
  324. if (MWF.AC.isAdministrator()) if (this.proxyData && this.nativeData && this.imagesData){
  325. this.mobileModuleSetting = new MWF.xApplication.Setting.MobileModuleDocument(this, this.contentAreaNode);
  326. item.store("content", this.mobileModuleSetting);
  327. }else{
  328. this.loadDataBack = function(){this.loadMobileModuleSetting(item)}.bind(this);
  329. }
  330. },
  331. loadMobileStyleSetting: function(item){
  332. if (MWF.AC.isAdministrator()) if (this.proxyData && this.nativeData && this.imagesData){
  333. this.mobileStyleSetting = new MWF.xApplication.Setting.MobileStyleDocument(this, this.contentAreaNode);
  334. item.store("content", this.mobileStyleSetting);
  335. }else{
  336. this.loadDataBack = function(){this.loadMobileStyleSetting(item)}.bind(this);
  337. }
  338. }
  339. });
  340. MWF.xApplication.Setting.UIExplorer = new Class({
  341. Extends: MWF.xApplication.Setting.BaseExplorer,
  342. initialize: function(app, content){
  343. this.app = app;
  344. this.lp = this.app.lp;
  345. this.container = content;
  346. this.actions = this.app.actions;
  347. this.css = this.app.css;
  348. this.naviItems = [];
  349. this.load();
  350. },
  351. getNaviJson: function(){
  352. return [
  353. {
  354. "text": this.app.lp.tab_ui_index,
  355. "icon": "index",
  356. "action": "loadUIIndexSetting"
  357. },
  358. {
  359. "text": this.app.lp.tab_ui_login,
  360. "icon": "login",
  361. "action": "loadUILoginSetting"
  362. }
  363. ];
  364. },
  365. getData: function(){
  366. },
  367. loadUILoginSetting: function(item){
  368. if (MWF.AC.isAdministrator()){
  369. this.uiLoginSetting = new MWF.xApplication.Setting.UILoginDocument(this, this.contentAreaNode);
  370. item.store("content", this.uiLoginSetting);
  371. }
  372. },
  373. loadUIIndexSetting: function(item){
  374. if (MWF.AC.isAdministrator()) {
  375. this.uiIndexSetting = new MWF.xApplication.Setting.UIIndexDocument(this, this.contentAreaNode);
  376. item.store("content", this.uiIndexSetting);
  377. }
  378. }
  379. });
  380. MWF.xApplication.Setting.DisposeExplorer = new Class({
  381. Extends: MWF.xApplication.Setting.BaseExplorer,
  382. initialize: function(app, content){
  383. this.app = app;
  384. this.lp = this.app.lp;
  385. this.container = content;
  386. this.actions = this.app.actions;
  387. this.css = this.app.css;
  388. this.naviItems = [];
  389. this.load();
  390. },
  391. getNaviJson: function(){
  392. return [
  393. {
  394. "text": this.app.lp.tab_ui_module,
  395. "icon": "module",
  396. "action": "loadUIModuleSetting"
  397. },
  398. {
  399. "text": this.app.lp.tab_ui_resource,
  400. "icon": "resource",
  401. "action": "loadResourceModuleSetting"
  402. },
  403. {
  404. "text": this.app.lp.tab_ui_service,
  405. "icon": "service",
  406. "action": "loadServiceModuleSetting"
  407. }
  408. ];
  409. },
  410. getData: function(){
  411. },
  412. loadUIModuleSetting: function(item){
  413. if (MWF.AC.isAdministrator()) {
  414. this.uiModuleSetting = new MWF.xApplication.Setting.UIModuleDocument(this, this.contentAreaNode);
  415. item.store("content", this.uiModuleSetting);
  416. }
  417. },
  418. loadServiceModuleSetting: function(item){
  419. if (MWF.AC.isAdministrator()) {
  420. this.serviceModuleSetting = new MWF.xApplication.Setting.ServiceModuleDocument(this, this.contentAreaNode);
  421. item.store("content", this.serviceModuleSetting);
  422. }
  423. },
  424. loadResourceModuleSetting: function(item){
  425. if (MWF.AC.isAdministrator()) {
  426. this.resourceModuleSetting = new MWF.xApplication.Setting.ResourceModuleDocument(this, this.contentAreaNode);
  427. item.store("content", this.resourceModuleSetting);
  428. }
  429. }
  430. });