Main.js 17 KB

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