main.js 49 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225
  1. var app = angular.module('itsmApp', ['itsm-dep']);
  2. // // 华科ip
  3. // //var serverIp = "http://testncc.hust.edu.cn/service";
  4. // var serverIp = "http://itservice.hust.edu.cn/service";
  5. // var serviceip = "http://pass.hust.edu.cn/cas/logout.jsp?redirectUrl=http://itservice.hust.edu.cn";
  6. // //var servicewechatip = "http://115.156.150.70:8080/requester/#/tab/dashboard";
  7. // var servicewechatip = "http://itservice.hust.edu.cn/requester/#/tab/dashboard";
  8. // //var reportIp = "http://115.156.150.117";
  9. // //var reportIp = "http://172.16.4.91";
  10. // var reportIp = "http://172.16.4.91:8080/service";
  11. // var inspectIp = "http://192.168.77.57";
  12. // var callIp = "http://192.168.77.57:8088";
  13. // 本地调试ip
  14. //var serverIp = "http://testncc.hust.edu.cn/service";
  15. var serverIp = "http://localhost/service";
  16. var serviceip = "http://pass.hust.edu.cn/cas/logout.jsp?redirectUrl=http://itservice.hust.edu.cn";
  17. //var servicewechatip = "http://115.156.150.70:8080/requester/#/tab/dashboard";
  18. var servicewechatip = "http://itservice.hust.edu.cn/requester/#/tab/dashboard";
  19. //var reportIp = "http://115.156.150.117";
  20. // var reportIp = "http://172.16.4.91";
  21. // var reportIp = "http://192.168.3.95:8080/service";
  22. var reportIp = location.origin +"/service";
  23. // var reportIp = "http://192.168.3.95:8080/service";
  24. var inspectIp = "http://localhost";
  25. var callIp = "http://localhost";
  26. app.run(['$rootScope', '$state', '$stateParams', '$auth', '$http', '$cookieStore', 'Restangular',
  27. function($rootScope, $state, $stateParams, $auth, $http, $cookieStore, Restangular) {
  28. // Attach Fastclick for eliminating the 300ms delay between a physical tap and the firing of a click event on mobile browsers
  29. FastClick.attach(document.body);
  30. // Set some reference to access them from any scope
  31. $rootScope.$state = $state;
  32. $rootScope.$stateParams = $stateParams;
  33. // GLOBAL APP SCOPE
  34. // set below basic information
  35. // $rootScope.audioiIp="http://218.197.181.213:8080"
  36. $rootScope.app = {
  37. name: '智慧华中大 | 网络与信息化运维管理系统', // name of your project
  38. author: '网络与信息化运维管理系统', // author's name or company name
  39. description: '智慧华中大 | 网络与信息化运维管理系统 V2.0', // brief description
  40. version: 'V2.0', // current version
  41. year: ((new Date()).getFullYear()), // automatic current year (for copyright information)
  42. isMobile: (function() { // true if the browser is a mobile device
  43. var check = false;
  44. if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
  45. check = true;
  46. };
  47. return check;
  48. })(),
  49. isChrome: false,
  50. isLoginFixed: false,
  51. layout: {
  52. // isLoginFixed: true,
  53. isNavbarFixed: true, //true if you want to initialize the template with fixed header
  54. isSidebarFixed: true, // true if you want to initialize the template with fixed sidebar
  55. isSidebarClosed: false, // true if you want to initialize the template with closed sidebar
  56. isFooterFixed: false, // true if you want to initialize the template with fixed footer
  57. theme: 'theme-8', // indicate the theme chosen for your project
  58. logo: 'assets/images/logo.png' // relative path of the project logo
  59. }
  60. };
  61. // $http.defaults.headers.common["X-Auth-Token"] = $cookieStore.get('Auth-Token') || null;
  62. // $http.defaults.headers.common["X-Auth-Token"] = $cookieStore.get('Auth-Token') || null;
  63. Restangular.setErrorInterceptor(function(element, operation, what, url, headers, queryParams) {
  64. if (!url) {
  65. // console.log($http);
  66. // console.log($auth);
  67. if (element.config.url ==
  68. "http://testncc.hust.edu.cn/service/api/bpm/data/getCount"
  69. ) {
  70. window.location.href = serviceip;
  71. document.getElementById("casUserId").value = null;
  72. }
  73. }
  74. // console.log(element);
  75. })
  76. Restangular.setFullRequestInterceptor(function(element, operation, what, url, headers, queryParams) {
  77. var token = $cookieStore.get('Auth-Token') || null;
  78. var isReportUri = url.indexOf('saiku') > 0;
  79. if (token && isReportUri) {
  80. return {
  81. element: element,
  82. params: queryParams,
  83. headers: _.extend({}, headers, { 'X-Auth-Token': $cookieStore.get('Auth-Token') || null })
  84. };
  85. } else {
  86. return {
  87. element: element,
  88. params: queryParams,
  89. headers: headers
  90. };
  91. }
  92. });
  93. Restangular.addResponseInterceptor(function(data, operation, what, url, response, deferred) {
  94. var ua = window.navigator.userAgent.toLowerCase();
  95. ua.match(/chrome/i)
  96. if (data) {
  97. if (data.state == "433") {
  98. $rootScope.logout();
  99. var Notification = window.Notification;
  100. Notification.requestPermission();
  101. sessionStorage.clear();
  102. data = {};
  103. var n = new Notification("登录退出", {
  104. body: "您的账号在其他地方登录,请确认后重新登录",
  105. icon: './bower_components/HTML5-Desktop-Notifications/alert.ico',
  106. onclick: function onNotificationClicked() {
  107. console.log('Notification clicked.');
  108. }
  109. });
  110. } else if (data.state == "403") {
  111. $state.go("app.dashboard");
  112. var Notification = window.Notification;
  113. Notification.requestPermission();
  114. var n = new Notification("无权限访问", {
  115. body: "此页面无权限访问",
  116. icon: './bower_components/HTML5-Desktop-Notifications/alert.ico',
  117. onclick: function onNotificationClicked() {
  118. console.log('Notification clicked.');
  119. }
  120. });
  121. } else {
  122. deferred.resolve(data)
  123. }
  124. }
  125. });
  126. // $rootScope.nickname ='lijin';
  127. // $rootScope.user = {
  128. // name: 'Peter',
  129. // job: 'ng-Dev',
  130. // picture: 'app/img/user/02.jpg'
  131. // };
  132. }
  133. ]);
  134. // translate config
  135. app.config(['$translateProvider',
  136. function($translateProvider) {
  137. // prefix and suffix information is required to specify a pattern
  138. // You can simply use the static-files loader with this pattern:
  139. $translateProvider.useStaticFilesLoader({
  140. prefix: 'assets/i18n/',
  141. suffix: '.json'
  142. });
  143. // Since you've now registered more then one translation table, angular-translate has to know which one to use.
  144. // This is where preferredLanguage(langKey) comes in.
  145. $translateProvider.preferredLanguage('zh');
  146. // Store the language in the local storage
  147. $translateProvider.useLocalStorage();
  148. }
  149. ]);
  150. // Angular-Loading-Bar
  151. // configuration
  152. app.config(['cfpLoadingBarProvider',
  153. function(cfpLoadingBarProvider) {
  154. cfpLoadingBarProvider.includeBar = true;
  155. cfpLoadingBarProvider.includeSpinner = false;
  156. }
  157. ]);
  158. /**
  159. * // http: //115.156.150.70:9680/api/webservice/data/fetchDataList/queryUser
  160. */
  161. app.config(['RestangularProvider', function(RestangularProvider) {
  162. RestangularProvider.setBaseUrl('');
  163. }]);
  164. app.factory('serviceip', function(Restangular) {
  165. return Restangular.withConfig(function(RestangularConfigurer) {
  166. RestangularConfigurer.setBaseUrl(serviceip);
  167. });
  168. });
  169. app.factory('WechatRestangular', function(Restangular) {
  170. return Restangular.withConfig(function(RestangularConfigurer) {
  171. RestangularConfigurer.setBaseUrl(serverIp + '/api/common/');
  172. });
  173. });
  174. app.factory('api_wechatfile', ['WechatRestangular', function(WechatRestangular) {
  175. var dataService = WechatRestangular.all("common");
  176. return {
  177. listAttachments: function(type, model) {
  178. return dataService.customGET('listAttachment/' + type + "/" + model, {});
  179. // return dataService.one('listAttachment/' + type + "/" + model);
  180. },
  181. downloadAttachment: function(model) {
  182. return dataService.one('downloadAttachment/' + model, {});
  183. },
  184. attachmentsPreviewUrl: function(attachmentId) {
  185. return dataService.customGET('attachmentsPreviewUrl/' + attachmentId);
  186. },
  187. download: function(attachmentId) {
  188. return dataService.one('getAttachmentContent/' + attachmentId);
  189. },
  190. getDictionary: function(data) {
  191. return dataService.customPOST(data, 'getDictionary', {});
  192. }
  193. };
  194. }]);
  195. /**
  196. * // http: //115.156.150.70:9680/webservice/data/fetchDataList/queryUser
  197. */
  198. //信息中心 --wt
  199. app.factory('msgRestangular', function(Restangular) {
  200. return Restangular.withConfig(function(RestangularConfigurer) {
  201. RestangularConfigurer.setBaseUrl(serverIp + '/messageStation');
  202. });
  203. });
  204. app.factory('api_msg', ['msgRestangular', function(msgRestangular) {
  205. var msgService = msgRestangular.all("data");
  206. return {
  207. msgDataList: function(data) {
  208. return msgService.customPOST(data, 'fetchDataList/messageStation', {});
  209. },
  210. updateDataList: function(data) {
  211. return msgService.customPOST(data, 'updateModel/messageStation', {});
  212. },
  213. };
  214. }]);
  215. // 微信配置查询接口
  216. app.factory('wechatConfig', function (Restangular) {
  217. return Restangular.withConfig(function (RestangularConfigurer) {
  218. RestangularConfigurer.setBaseUrl(reportIp + '/wechat');
  219. });
  220. });
  221. app.factory('api_wechat_operate', ['wechatConfig', function (wechatConfig) {
  222. var dataService = wechatConfig.all("");
  223. return {
  224. //获取微信配置信息
  225. mapToken: function (data, model) {
  226. return dataService.customPOST(data, model);
  227. },
  228. //修改微信配置
  229. // postWxList: function (data) {
  230. // return dataService.customPOST(data, 'addData/wechatConfig');
  231. // }
  232. };
  233. }]);
  234. //报表
  235. app.factory('hkreportRestangular', function(Restangular) {
  236. return Restangular.withConfig(function(RestangularConfigurer) {
  237. RestangularConfigurer.setBaseUrl(reportIp + '/statistics');
  238. });
  239. });
  240. app.factory('api_hkreport', ['hkreportRestangular', function(hkreportRestangular) {
  241. var msgService = hkreportRestangular.all("data");
  242. return {
  243. incidentreport: function(data, key) {
  244. return msgService.customPOST(data, key, {});
  245. }
  246. };
  247. }]);
  248. //
  249. app.factory('webserviceRestangular', function(Restangular) {
  250. return Restangular.withConfig(function(RestangularConfigurer) {
  251. RestangularConfigurer.setBaseUrl(serverIp + '/api/webservice/');
  252. });
  253. });
  254. app.factory('api_webservice', ['webserviceRestangular', function(webserviceRestangular) {
  255. var dataService = webserviceRestangular.all("data");
  256. return {
  257. fetchDataList: function(model, data) {
  258. return dataService.customPOST(data, 'fetchDataList/' + model, {});
  259. }
  260. };
  261. }]);
  262. app.factory('playRestangular', function(Restangular) {
  263. return Restangular.withConfig(function(RestangularConfigurer) {
  264. RestangularConfigurer.setBaseUrl(callIp);
  265. });
  266. });
  267. app.factory('api_playservice', ['playRestangular', function(playRestangular) {
  268. var dataService = playRestangular.all("recording");
  269. return {
  270. playData: function(attachmentId) {
  271. return dataService.customGET('recording?callID=' + attachmentId);
  272. },
  273. };
  274. }]);
  275. app.factory('ConversationRestangular', function(Restangular) {
  276. return Restangular.withConfig(function(RestangularConfigurer) {
  277. RestangularConfigurer.setBaseUrl(serverIp + '/api/conversation/');
  278. });
  279. });
  280. app.factory('api_conversation', ['ConversationRestangular', function(ConversationRestangular) {
  281. var dataService = ConversationRestangular.all("conversation");
  282. return {
  283. roleMenu: function(model) {
  284. return dataService.customGET('roleMenu/' + model, {});
  285. },
  286. pageMenuByCode: function(model) {
  287. return dataService.customGET('pageMenuByCode/' + model, {});
  288. },
  289. pageEvent: function(data, model) {
  290. return dataService.customPOST(data, 'pageEvent', {});
  291. }
  292. };
  293. }]);
  294. app.factory('textRestangular', function(Restangular) {
  295. return Restangular.withConfig(function(RestangularConfigurer) {
  296. // RestangularConfigurer.setBaseUrl(inspectIp + ':8080/IXServer/');
  297. RestangularConfigurer.setBaseUrl(inspectIp + ':8088/IXServer/');
  298. });
  299. });
  300. app.factory('api_text', ['textRestangular', function(textRestangular) {
  301. var loginService = textRestangular.all("comm");
  302. var loginsins = textRestangular.all("tele/agent");
  303. return {
  304. start: function(phone, id) {
  305. var rdata = "dom=0&epwd=&aid=" + id + "&apwd=e10adc3949ba59abbe56e057f20f883e&adn=" + phone;
  306. return loginService.customPOST(rdata, 'start', {}, { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8' });
  307. },
  308. exit: function(token) {
  309. var rdata = "dom=0&token=" + token;
  310. return loginService.customPOST(rdata, 'exit', {}, { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8' });
  311. },
  312. login: function(group, token, id) {
  313. var rdata = "dom=0&token=" + token + "&aid=" + id + "&acd=" + group + "&skill=-1&mon=false&silent=false";
  314. return loginsins.customPOST(rdata, 'login', {}, { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8' });
  315. },
  316. logout: function(token, id) {
  317. var rdata = "dom=0&token=" + token + "&aid=" + id + "";
  318. return loginsins.customPOST(rdata, 'logout', {}, { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8' });
  319. },
  320. dialout: function(token, gid, teleno) {
  321. var rdata = "dom=0&token=" + token + "&teleno=" + teleno + "&gid=" + gid + "&uud=&async=true";
  322. return loginsins.customPOST(rdata, 'dialout', {}, { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8' });
  323. },
  324. callout: function(token, teleno) {
  325. var rdata = "dom=0&token=" + token + "&teleno=" + teleno + "&uud=&async=true";
  326. return loginsins.customPOST(rdata, 'dialout', {}, { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8' });
  327. },
  328. setbusy: function(token) {
  329. var rdata = "dom=0&token=" + token;
  330. return loginsins.customPOST(rdata, 'setbusy', {}, { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8' });
  331. },
  332. setidle: function(token) {
  333. var rdata = "dom=0&token=" + token;
  334. return loginsins.customPOST(rdata, 'setidle', {}, { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8' });
  335. },
  336. inittrans: function(telephone, token) {
  337. var rdata = "dom=0&token=" + token + "&teleno=" + telephone + "&uud=&async=true";
  338. return loginsins.customPOST(rdata, 'inittrans', {}, { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8' });
  339. },
  340. comptrans: function(telephone, token) {
  341. var rdata = "dom=0&token=" + token;
  342. return loginsins.customPOST(rdata, 'comptrans', {}, { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8' });
  343. },
  344. record: function(token) {
  345. var rdata = "dom=0&token=" + token + "&filename=/tmp/agent.wav&async=true&maxtime=10&termchar=&append=true";
  346. return loginsins.customPOST(rdata, 'record', {}, { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8' });
  347. },
  348. offhook: function(token) {
  349. var rdata = "dom=0&token=" + token;
  350. return loginsins.customPOST(rdata, 'offhook', {}, { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8' });
  351. },
  352. onhook: function(token) {
  353. var rdata = "dom=0&token=" + token;
  354. return loginsins.customPOST(rdata, 'onhook', {}, { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8' });
  355. },
  356. getcdrid: function(token) {
  357. var rdata = "dom=0&token=" + token;
  358. return loginsins.customPOST(rdata, 'getcdrid', {}, { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8' });
  359. }
  360. }
  361. }])
  362. app.factory('UserRestangular', function(Restangular) {
  363. return Restangular.withConfig(function(RestangularConfigurer) {
  364. RestangularConfigurer.setBaseUrl(serverIp + '/api/user/');
  365. });
  366. });
  367. app.factory('api_user', ['UserRestangular', function(UserRestangular) {
  368. var basePath = "user/";
  369. return {
  370. };
  371. }]);
  372. app.factory('api_login', ['UserRestangular', function(UserRestangular) {
  373. var loginService = UserRestangular.all("auth");
  374. return {
  375. login: function(username, password) {
  376. return loginService.customPOST({ 'username': username, 'password': password }, 'login', {});
  377. },
  378. // logout: function(sessionid,userid){
  379. // return loginService.customPOST(sessionid + '/' + userid);
  380. // },
  381. sso: function(nickname) {
  382. return loginService.customGET('sso/' + nickname);
  383. },
  384. resetpwd: function(userid) {
  385. return loginService.customGET('resetpwd/' + userid);
  386. },
  387. uppwd: function(data) {
  388. return loginService.customPOST(data, 'uppwd', {});
  389. }
  390. }
  391. }])
  392. app.factory('applyRestangular', function(Restangular) {
  393. return Restangular.withConfig(function(RestangularConfigurer) {
  394. RestangularConfigurer.setBaseUrl(serverIp + '/api/apply/');
  395. });
  396. });
  397. app.factory('api_apply', ['applyRestangular', function(applyRestangular) {
  398. var applyService = applyRestangular.all("bpm");
  399. return {
  400. wxIncidentReject: function(id, data) {
  401. return applyService.customPOST(data, 'wxIncidentReject/' + id, {});
  402. }
  403. }
  404. }])
  405. app.factory('api_user_data', ['UserRestangular', function(UserRestangular) {
  406. var dataService = UserRestangular.all("data");
  407. var userService = UserRestangular.all("auth");
  408. return {
  409. validate: function(data) {
  410. return dataService.customPOST(data, 'validate/role', {});
  411. },
  412. importData: function() {
  413. return dataService.one('/importData');
  414. },
  415. fetchDataList: function(model, data) {
  416. return dataService.customPOST(data, 'fetchDataList/' + model, {});
  417. },
  418. fetchData: function(model, data) {
  419. return dataService.customPOST(data, 'fetchData/' + model, {});
  420. },
  421. addData: function(model, data) {
  422. return dataService.customPOST(data, 'addData/' + model, {});
  423. },
  424. updData: function(model, data) {
  425. return dataService.customPOST(data, 'updData/' + model, {});
  426. },
  427. rmvData: function(model, data) {
  428. return dataService.customPOST(data, 'rmvData/' + model, {});
  429. },
  430. register: function(data) {
  431. return dataService.customPOST(data, 'register', {});
  432. },
  433. downDataModel: function(type, month) {
  434. return dataService.one('downDataModel/' + type + '/' + month);
  435. },
  436. fetchgetData: function(model, data) {
  437. return dataService.customGET('fetchData/' + model + '/' + data, {});
  438. },
  439. roleMenu: function(model) {
  440. return userService.customGET('roleMenu/' + model, {});
  441. },
  442. pageMenuByCode: function(model) {
  443. return userService.customGET('pageMenuByCode/' + model, {});
  444. },
  445. pageEvent: function(data, model) {
  446. return userService.customPOST(data, 'pageEvent', {});
  447. },
  448. pageMenu: function(data, model) {
  449. return userService.customPOST(data, 'pageMenu', {});
  450. // return userService.one('/pageMenu' + data);
  451. },
  452. getMenu: function(data, model) {
  453. return userService.customPOST(data, 'getMenu', {});
  454. }
  455. };
  456. }]);
  457. // app.factory('DpmRestangular', function(Restangular) {
  458. // return Restangular.withConfig(function(RestangularConfigurer) {
  459. // RestangularConfigurer.setBaseUrl(serverIp+':9008/data/');
  460. // });
  461. // });
  462. // app.factory('api_bpm_dbca', ['DpmRestangular', function(DpmRestangular){
  463. // var bpm = DpmRestangular.all("bpm");
  464. // return {
  465. // impFileData: function(pdKey){
  466. // return bpm.customPOST( 'impFileData/' + pdKey);
  467. // },
  468. // };
  469. // }]);
  470. app.factory('BpmRestangular', function(Restangular) {
  471. return Restangular.withConfig(function(RestangularConfigurer) {
  472. // RestangularConfigurer.setBaseUrl("http://168.166.3.41"+':9008/api/');
  473. RestangularConfigurer.setBaseUrl(serverIp + '/api/bpm');
  474. });
  475. });
  476. app.factory('api_statistic', ['BpmRestangular', function(BpmRestangular) {
  477. var statistic = BpmRestangular.all("statistic");
  478. return {
  479. query: function(data, rptId) {
  480. return statistic.customPOST(data, 'unidimensional/' + rptId, {});
  481. },
  482. // exportData: function(reportView, uuid, reportfileName){
  483. // return reportService.one('query/rest/export/xls/?exportname='+reportfileName+'xls');
  484. // }
  485. unidimensionalExport: function(rptId) {
  486. return statistic.one('unidimensionalExport/' + rptId);
  487. }
  488. }
  489. }]);
  490. app.factory('api_bpm', ['BpmRestangular', function(BpmRestangular) {
  491. var process = BpmRestangular.all("process");
  492. return {
  493. deploy: function(data) {
  494. return process.customPOST(data, 're/model/deploy', {});
  495. },
  496. list: function() {
  497. return process.customGET('re/model/list');
  498. },
  499. modelsource: function(pdId) {
  500. return process.customGET('re/model/' + pdId + '/source');
  501. },
  502. // savemodel: function(pdId, data) {
  503. // return process.customPOST(data, 're/model/' + pdId + '/save', {});
  504. // },
  505. savemodel: function(pdId, data) {
  506. return process.customPOST(data, 'saveModel/' + pdId, {});
  507. },
  508. removemodel: function(modelId) {
  509. return process.customGET('re/model/' + modelId + '/remove');
  510. }
  511. };
  512. }]);
  513. app.factory('CommonRestangular', function(Restangular) {
  514. return Restangular.withConfig(function(RestangularConfigurer) {
  515. RestangularConfigurer.setBaseUrl(serverIp + '/api/common');
  516. });
  517. });
  518. app.factory('api_bpm_domain', ['BpmRestangular', 'CommonRestangular', function(BpmRestangular, CommonRestangular) {
  519. var bpmService = BpmRestangular.all("bpm");
  520. var commonService = CommonRestangular.all("common");
  521. return {
  522. fetchtask: function(pdKey, data) {
  523. return bpmService.customPOST(data, 'fetchTask/' + pdKey, {});
  524. },
  525. start: function(pdKey, data) {
  526. return bpmService.customPOST(data, 'start/' + pdKey, {});
  527. },
  528. flowTracing: function(processInstanceId, data) {
  529. return bpmService.customPOST(data, 'flowTracing/' + processInstanceId, {});
  530. },
  531. complete: function(taskId, userId, data) {
  532. return bpmService.customPOST(data, 'completeTask/' + taskId + '/' + userId, {});
  533. },
  534. completeUpgrade: function(data) {
  535. return bpmService.customPOST(data, 'upgradeIncident', {});
  536. },
  537. save: function(taskId, data) {
  538. return bpmService.customPOST(data, 'saveTaskVar/' + taskId, {});
  539. },
  540. claimtask: function(taskId, data) {
  541. return bpmService.customPOST(data, 'claimTask/' + taskId, {});
  542. },
  543. claimAndCompletedTask: function(taskId, data) {
  544. return bpmService.customPOST(data, 'claimAndCompletedTask/' + taskId, {});
  545. },
  546. delegateTask: function(taskId, data) {
  547. return bpmService.customPOST(data, 'delegateTask/' + taskId, {});
  548. },
  549. expectedTime: function(taskId) {
  550. return bpmService.customGET('expectedTime/' + taskId);
  551. },
  552. history: function(processId) {
  553. return bpmService.customGET('history/' + processId);
  554. },
  555. upgrade: function(processInstanceId, taskId, data) {
  556. return bpmService.customPOST(data, 'upgradeIncident/' + processInstanceId + '/' + taskId, {});
  557. },
  558. listAttachments: function(processId, data) {
  559. return bpmService.customPOST(data, 'getAttachmentList/' + processId, {});
  560. },
  561. saveAttachments: function(processId, taskId, userId, data) {
  562. return bpmService.one('saveAttachments/' + processId + '/' + taskId + '/' + userId);
  563. },
  564. uploadAttachment: function(processId, taskId, userId, data) {
  565. return commonService.one('uploadAttachment/' + 'inspection/' + processId);
  566. },
  567. download: function(attachmentId) {
  568. return bpmService.one('getAttachmentContent/' + attachmentId);
  569. },
  570. // download: function(attachmentId){
  571. // return bpmService.customGET('getAttachmentContent/' + attachmentId,{},{'responseType':'arraybuffer'});
  572. // },
  573. attachmentsPreviewUrl: function(attachmentId) {
  574. return bpmService.customGET('attachmentsPreviewUrl/' + attachmentId);
  575. },
  576. startformkey: function(pdKey) {
  577. return bpmService.customGET('startformkey/' + pdKey);
  578. },
  579. taskformkey: function(taskId) {
  580. return bpmService.customGET('taskformkey/' + taskId);
  581. },
  582. workernumber: function(type) {
  583. return bpmService.customGET('restful/' + type);
  584. },
  585. getWatchAreaPosition: function(data) {
  586. return bpmService.customGET('getWatchAreaPosition');
  587. },
  588. getWatchAreaData: function(id) {
  589. return bpmService.customGET('getWatchAreaData/' + id);
  590. }
  591. };
  592. }]);
  593. app.factory('api_bpm_data', ['BpmRestangular', function(BpmRestangular) {
  594. var dataService = BpmRestangular.all("data");
  595. var serviceCatalogue = BpmRestangular.all("ServiceCatalogue");
  596. var inspectionProcessActual = BpmRestangular.all("InspectionProcessActual");
  597. return {
  598. impFileData: function() {
  599. return dataService.one('/impFileData/bpm_scheduleorder');
  600. },
  601. importData: function() {
  602. return dataService.one('/impFileData');
  603. },
  604. fetchDataList: function(model, data) {
  605. return dataService.customPOST(data, 'fetchDataList/' + model, {});
  606. },
  607. fetchData: function(model, dataId) {
  608. return dataService.customGET('fetchData/' + model + '/' + dataId);
  609. },
  610. fetchServiceTasks: function(model, data) {
  611. if (!model) {
  612. model = "ALL"
  613. }
  614. return serviceCatalogue.customPOST(data, 'fetchServiceTasks/' + model, {});
  615. },
  616. fetchInspectServiceTasks: function(model, data) {
  617. if (!model) {
  618. model = "ALL"
  619. }
  620. return inspectionProcessActual.customPOST(data, 'fetchServiceTasks/' + model, {});
  621. },
  622. addData: function(model, data) {
  623. return dataService.customPOST(data, 'addData/' + model, {});
  624. },
  625. updData: function(model, data) {
  626. return dataService.customPOST(data, 'updData/' + model, {});
  627. },
  628. rmvData: function(model, data) {
  629. return dataService.customPOST(data, 'rmvData/' + model, {});
  630. },
  631. getCount: function(data) {
  632. return dataService.customPOST(data, 'getCount', {});
  633. },
  634. downDataModel: function(type, month) {
  635. return dataService.one('downDataModel/' + type + '/' + month);
  636. },
  637. fetchDataByGroupId: function(data) {
  638. return dataService.customPOST(data, 'fetchDataByGroupId', {});
  639. },
  640. // downDataModel: function(type, month, data) {
  641. // return dataService.customPOST(data, 'downDataModel/' + type + '/' + month, {}, { 'Accept': 'application/json, text/javascript, */*' });
  642. // }
  643. };
  644. }]);
  645. app.factory('api_bpm_schedule', ['BpmRestangular', function(BpmRestangular) {
  646. var dataService = BpmRestangular.all("data");
  647. return {
  648. getScheduleClass: function() {
  649. var data = {
  650. "idx": "0",
  651. "sum": "10"
  652. };
  653. return dataService.customPOST(data, 'fetchDataList/scheduleclass', {});
  654. },
  655. fetchList: function(startTime, endTime, userId, queryKey) {
  656. var scheduleOrder = {
  657. "scheduleorder": {
  658. "startTime": startTime,
  659. "endTime": endTime
  660. },
  661. "idx": "0",
  662. "sum": "1000"
  663. };
  664. if (userId) {
  665. scheduleOrder['scheduleorder']['user'] = userId;
  666. }
  667. if (queryKey) {
  668. scheduleOrder['scheduleorder']['description'] = queryKey;
  669. }
  670. return dataService.customPOST(scheduleOrder, 'fetchDataList/scheduleorder', {});
  671. },
  672. fetchData: function(dataId) {
  673. return dataService.customGET('fetchData/scheduleorder/' + dataId);
  674. },
  675. update: function(data) {
  676. return dataService.customPOST(data, 'updData/scheduleorder', {});
  677. },
  678. add: function(data) {
  679. return dataService.customPOST(data, 'addData/scheduleorder', {});
  680. },
  681. remove: function(data) {
  682. return dataService.customPOST(data, 'rmvData/scheduleorder', {});
  683. },
  684. fetchSchedule: function(userId, startTime, endTime) {
  685. var scheduleData = {
  686. "schedulewatch": {
  687. "type": "1",
  688. "user": {
  689. "id": userId
  690. },
  691. "startTime": startTime,
  692. "endTime": endTime
  693. },
  694. "idx": "0",
  695. "sum": "100"
  696. };
  697. return dataService.customPOST(scheduleData, 'fetchDataList/schedulewatch', {});
  698. },
  699. queryRecieveSwitch: function(userId) {
  700. var handleSwitch = {
  701. "schedulewatch": {
  702. "type": "3",
  703. "user": {
  704. "id": userId
  705. }
  706. },
  707. "idx": "0",
  708. "sum": "10"
  709. };
  710. return dataService.customPOST(handleSwitch, 'fetchDataList/schedulewatch', {});
  711. },
  712. queryHandleoutSwitch: function(userId) {
  713. var handleSwitch = {
  714. "schedulewatch": {
  715. "type": "2",
  716. "user": {
  717. "id": userId
  718. }
  719. },
  720. "idx": "0",
  721. "sum": "10"
  722. };
  723. return dataService.customPOST(handleSwitch, 'fetchDataList/schedulewatch', {});
  724. },
  725. handleSchedule: function(data) {
  726. return dataService.customPOST(data, 'updData/schedulewatch', {});
  727. },
  728. querySwitch: function(filterData) {
  729. var switchData = {
  730. "scheduleorder": {
  731. "type": "4"
  732. },
  733. "idx": filterData.idx,
  734. "sum": filterData.sum
  735. };
  736. return dataService.customPOST(switchData, 'fetchDataList/scheduleorder', {});
  737. },
  738. query: function(filterData) {
  739. var switchData = {
  740. "scheduleorder": filterData.scheduleorder,
  741. "idx": filterData.idx,
  742. "sum": filterData.sum
  743. };
  744. return dataService.customPOST(switchData, 'fetchDataList/scheduleorder', {});
  745. }
  746. };
  747. }]);
  748. app.factory('SysinfoRestangular', function(Restangular) {
  749. return Restangular.withConfig(function(RestangularConfigurer) {
  750. RestangularConfigurer.setBaseUrl(serverIp + '/api/sysinfo/');
  751. });
  752. });
  753. app.factory('api_sysinfo', ['SysinfoRestangular', function(SysinfoRestangular) {
  754. var dataService = SysinfoRestangular.all("data");
  755. return {
  756. fetchDataList: function(model, data) {
  757. return dataService.customPOST(data, 'fetchDataList/' + model, {});
  758. },
  759. addData: function(model, data) {
  760. return dataService.customPOST(data, 'addData/' + model, {});
  761. },
  762. getSerialnumber: function(type, model) {
  763. return dataService.customGET('getSerialnumber/' + type + '/' + model);
  764. }
  765. };
  766. }]);
  767. app.factory('ConfigureRestangular', function(Restangular) {
  768. return Restangular.withConfig(function(RestangularConfigurer) {
  769. RestangularConfigurer.setBaseUrl(serverIp + '/api/config/');
  770. });
  771. });
  772. app.factory('api_configure_form', ['ConfigureRestangular', function(ConfigureRestangular) {
  773. var formService = ConfigureRestangular.all("form");
  774. return {
  775. renderForm: function(formKey, userId, processInstanceId) {
  776. if (processInstanceId) {
  777. return formService.customGET('renderForm/' + formKey + "/" + processInstanceId + "/" + userId);
  778. } else {
  779. return formService.customGET('renderForm/' + formKey + "/000000/" + userId);
  780. }
  781. },
  782. renderList: function(formKey) {
  783. return formService.customGET('renderList/' + formKey);
  784. },
  785. renderTabForm: function(classify) {
  786. return formService.customGET('renderTabForm/' + classify);
  787. }
  788. };
  789. }]);
  790. app.factory('api_configure_data', ['ConfigureRestangular', function(ConfigureRestangular) {
  791. var dataService = ConfigureRestangular.all("data");
  792. return {
  793. fetchDataList: function(model, data) {
  794. return dataService.customPOST(data, 'fetchDataList/' + model, {});
  795. },
  796. linkConfigure: function(model, data) {
  797. return dataService.customPOST(data, 'linkConfigure/' + model, {});
  798. },
  799. fetchDataById: function(model, id) {
  800. return dataService.customGET('fetchData/' + id + '/' + model);
  801. },
  802. fetchData: function(model, data) {
  803. return dataService.customPOST(data, 'fetchData/' + model, {});
  804. },
  805. addData: function(model, data) {
  806. return dataService.customPOST(data, 'addData/' + model, {});
  807. },
  808. rmvData: function(model, data) {
  809. return dataService.customPOST(data, 'rmvData/' + model, {});
  810. },
  811. updData: function(model, data) {
  812. return dataService.customPOST(data, 'updData/' + model, {});
  813. },
  814. downModels: function(type, id, name) {
  815. return dataService.one('export/' + type + '/' + id + '/' + name);
  816. }
  817. };
  818. }]);
  819. app.factory('SolutionRestangular', function(Restangular) {
  820. return Restangular.withConfig(function(RestangularConfigurer) {
  821. //RestangularConfigurer.setBaseUrl('http://168.166.203.41:9000/services');
  822. RestangularConfigurer.setBaseUrl(serverIp + '/api/solution');
  823. });
  824. });
  825. app.factory('api_solution', ['SolutionRestangular', function(SolutionRestangular) {
  826. var solutionService = SolutionRestangular.all("solution");
  827. var data = SolutionRestangular.all("solutionData");
  828. var history = SolutionRestangular.all("solutionHistory");
  829. var review = SolutionRestangular.all("solution_review");
  830. var typeservice = SolutionRestangular.all("solutionType");
  831. var groupservice = SolutionRestangular.all("solutionGroup");
  832. return {
  833. findSolutionByKeys: function(data) {
  834. var key = data.key,
  835. status = data.status || 0,
  836. pageIndex = data.pageIndex || 0,
  837. pageSum = data.pageSum,
  838. treeIds = data.treeIds,
  839. userId = data.userId;
  840. if (angular.isUndefined(treeIds)) {
  841. return solutionService.customGET('findSolutionByKeys/' + key + '/' + status + '/' + pageIndex + '/' + pageSum + '/' + userId);
  842. } else {
  843. return solutionService.customGET('findSolutionByKeys/' + key + '/' + status + '/' + pageIndex + '/' + pageSum + '/' + treeIds + '/' + userId);
  844. }
  845. },
  846. // searcher: function(data){
  847. // var queryBuilder=data.key, indexname=data.treeIds, type=data.userId;
  848. // return searchservice.customGET('searcher/' + queryBuilder + '/' + indexname + '/' + type );
  849. // },
  850. addSolution: function() {
  851. return solutionService.one('add');
  852. },
  853. addFile: function(data) {
  854. return solutionService.customPOST(data, 'addSolution', {});
  855. },
  856. addModel: function(type, data) {
  857. return solutionService.customPOST(data, 'addModel/' + type, {});
  858. },
  859. updModel: function(type, data) {
  860. return solutionService.customPOST(data, 'updModel/' + type, {});
  861. },
  862. rmModels: function(id, data) {
  863. return solutionService.customPOST(data, 'rmModels/' + id, {});
  864. },
  865. update: function() {
  866. return solutionService.one('update');
  867. },
  868. upload: function() {
  869. return solutionService.one('upload');
  870. },
  871. uploadResponseUri: function() {
  872. return solutionService.one('/');
  873. },
  874. addNotFile: function(data) {
  875. return solutionService.customPOST(data, 'addNotFile', {});
  876. },
  877. // export: function(data) {
  878. // return solutionService.customGET(data, 'export', {});
  879. // },
  880. export: function(data) {
  881. return solutionService.one('export');
  882. },
  883. updateNotFile: function(data) {
  884. return solutionService.customPOST(data, 'updateNotFile', {});
  885. },
  886. updateSolution: function(data) {
  887. return solutionService.customPOST(data, 'updateSolution', {});
  888. },
  889. searchSolutionByKey: function(key, id) {
  890. return solutionService.customGET('searchSolutionByKey/' + key + '/' + id);
  891. },
  892. findSolutionById: function(id) {
  893. return solutionService.customGET('check/' + id);
  894. },
  895. findSolutions: function(id) {
  896. return solutionService.customGET('check2/' + id);
  897. },
  898. fetchDataList: function(model, data) {
  899. return solutionService.customPOST(data, 'fetchDataList/' + model, {});
  900. },
  901. findSolutionDataByDateById: function(ndate, sid) {
  902. return data.customGET('findSolutionDataByDateById/' + ndate + '/' + sid);
  903. },
  904. findSolutionTypeActions: function(userId) {
  905. return typeservice.customGET('findSolutionTypeActions/' + userId);
  906. },
  907. findSolutionTypesUser: function(data) {
  908. return typeservice.customPOST(data, 'findSolutionTypesUser', {});
  909. },
  910. addTypeUserAll: function(data) {
  911. return typeservice.customPOST(data, 'addTypeUserAll', {});
  912. },
  913. hotRanking: function(num) {
  914. return solutionService.customGET('hotRanking/' + num);
  915. },
  916. scoreRanking: function(num) {
  917. return solutionService.customGET('scoreRanking/' + num);
  918. },
  919. fetchBBSSolutions: function(pageIndex, pageSum, sequence, userId) {
  920. return solutionService.customGET('communicationSolutions/' + pageIndex + '/' + pageSum + '/' + sequence + '/' + userId);
  921. },
  922. queryBBSSolutions: function(pageIndex, pageSum, sequence, userId, key) {
  923. return solutionService.customGET('communicationSolutions/' + pageIndex + '/' + pageSum + '/' + sequence + '/' + userId + '/' + key);
  924. },
  925. updateSolutionStatus: function(data) {
  926. return solutionService.customPOST(data, 'updateSolutionStatus', {});
  927. },
  928. getSolutionNumber: function() {
  929. return solutionService.customGET('getSolutionNumber');
  930. },
  931. addSolutionType: function(data) {
  932. return typeservice.customPOST(data, 'add', {});
  933. },
  934. updateSolutionType: function(data) {
  935. return typeservice.customPOST(data, 'update', {});
  936. },
  937. removeSolutionType: function(id) {
  938. return typeservice.customGET('delete/' + id);
  939. },
  940. getSolutionType: function(id) {
  941. return typeservice.customGET('' + id);
  942. },
  943. getTree: function(typeId, groupId, flag) {
  944. return typeservice.customGET('getTree/' + typeId + '/' + groupId + '/' + flag);
  945. },
  946. checkCommentScoreByUserIds: function(userId, id) {
  947. return review.customGET('findCommentScore/' + userId + '/' + id);
  948. },
  949. addSolutionReview: function(data) {
  950. return solutionService.customPOST(data, 'addScore', {});
  951. },
  952. findSolutionReviewById: function(userid, id, pageIndex, pageSum) {
  953. return solutionService.customGET('findSolutionReviewByType/' + userid + '/' + id + '/' + pageIndex + '/' + pageSum);
  954. },
  955. saveAllUserAuth: function(solutionId, flag) {
  956. return solutionService.customGET('saveAllUserTrees/' + solutionId + '/' + flag);
  957. },
  958. updatermvSolutionType: function(typeId, groupId, userIds, flag) {
  959. return typeservice.customGET('delOrUpdateTrees/' + typeId + '/' + groupId + '/' + userIds + '/' + flag);
  960. },
  961. findSolutionGroup: function(id) {
  962. return groupservice.customGET('findSolutionGroup/' + id);
  963. },
  964. saveSolutionGroup: function(id, data) {
  965. return groupservice.customPOST(data, 'saveSolutionGroup/' + id);
  966. },
  967. // getSolutionDowpath: function(id){
  968. // return solutionService.one('download/'+id);
  969. // }
  970. getSolutionDowpath: function(attachmentId) {
  971. return solutionService.one('download/' + attachmentId + '/file');
  972. }
  973. // getSolutionDowpath: function(attachmentId){
  974. // return solutionService.customGET('download/' + attachmentId);
  975. // }
  976. };
  977. }]);
  978. app.factory('CMDBRestangular', function(Restangular) {
  979. return Restangular.withConfig(function(RestangularConfigurer) {
  980. RestangularConfigurer.setBaseUrl(serverIp + '/api/cmdb/cmdb/');
  981. });
  982. });
  983. app.factory('api_cmdb', ['CMDBRestangular', function(CMDBRestangular) {
  984. var ciService = CMDBRestangular.all("ci");
  985. var uuidService = CMDBRestangular.all("uuid");
  986. var edgeService = CMDBRestangular.all("edge");
  987. var traversal = CMDBRestangular.all("traversal");
  988. var downloadService = CMDBRestangular.all("download");
  989. var exportService = CMDBRestangular.all("export");
  990. var importService = CMDBRestangular.all("import");
  991. var exportModelService = CMDBRestangular.all("exportModel");
  992. var importDataService = CMDBRestangular.all("importData");
  993. var exportDataService = CMDBRestangular.all("exportData");
  994. var searchService = CMDBRestangular.all("search");
  995. function serializeData(data) {
  996. // If this is not an object, defer to native stringification.
  997. if (!angular.isObject(data)) {
  998. return ((data == null) ? "" : data.toString());
  999. }
  1000. var buffer = [];
  1001. // Serialize each key in the object.
  1002. for (var name in data) {
  1003. if (!data.hasOwnProperty(name)) {
  1004. continue;
  1005. }
  1006. var value = data[name];
  1007. buffer.push(
  1008. encodeURIComponent(name) + "=" + encodeURIComponent((value == null) ? "" : value)
  1009. );
  1010. }
  1011. // Serialize the buffer and clean it up for transportation.
  1012. var source = buffer.join("&").replace(/%20/g, "+");
  1013. return (source);
  1014. }
  1015. return {
  1016. create: function(data) {
  1017. return ciService.customPOST(data, '', {});
  1018. },
  1019. importData: function() {
  1020. return importDataService.one('/nodes');
  1021. },
  1022. put: function(data, id) {
  1023. return ciService.customPUT(data, id, {});
  1024. },
  1025. remove: function(id) {
  1026. return ciService.customDELETE(id);
  1027. },
  1028. removeByUUId: function(uuid) {
  1029. return ciService.customDELETE('uuid/' + id, {}, { 'Content-Type': 'application/json' });
  1030. },
  1031. removeRefById: function(id) {
  1032. return ciService.customDELETE(id + '/ref');
  1033. },
  1034. find: function(id) {
  1035. return ciService.customGET(id);
  1036. },
  1037. searchkey: function(type, key, idx, sum) {
  1038. return searchService.customGET(type + '/' + key + '/' + idx + '/' + sum);
  1039. },
  1040. findByUUId: function(uuid) {
  1041. return ciService.customGET('?uuid=' + uuid);
  1042. },
  1043. query: function(data) {
  1044. return ciService.customGET('query', data);
  1045. },
  1046. findRefById: function(id) {
  1047. return ciService.customGET(id + '/refs');
  1048. },
  1049. finduuid: function(type, model) {
  1050. return uuidService.customGET(type + '/' + model);
  1051. },
  1052. types: function() {
  1053. return CMDBRestangular.customGET('types');
  1054. },
  1055. createRef: function(data) {
  1056. return edgeService.customPOST(data, '', {});
  1057. },
  1058. putRef: function(data, id) {
  1059. return edgeService.customPUT(data, '' + id, {});
  1060. },
  1061. removeRef: function(id) {
  1062. return edgeService.customDELETE(id, {}, { 'Content-Type': 'application/json' });
  1063. },
  1064. traversal: function(uuid) {
  1065. return traversal.customGET(uuid);
  1066. },
  1067. traversalRel: function(uuid, relation) {
  1068. return traversal.customGET(uuid + '/' + relation + '/' + 'none');
  1069. },
  1070. export: function(label) {
  1071. return exportService.customGET('nodes/' + label);
  1072. },
  1073. import: function() {
  1074. return importService.one('/nodes');
  1075. },
  1076. download: function(label) {
  1077. return downloadService.one('/label');
  1078. },
  1079. exportData: function(type, model) {
  1080. return exportDataService.one(model + '/' + type);
  1081. },
  1082. downModels: function(type, model) {
  1083. return exportModelService.one(model + '/' + type);
  1084. }
  1085. };
  1086. }]);
  1087. app.factory('MonitorRestangular', function(Restangular) {
  1088. return Restangular.withConfig(function(RestangularConfigurer) {
  1089. RestangularConfigurer.setBaseUrl(serverIp + ':9004/services');
  1090. });
  1091. });
  1092. app.factory('api_monitor', ['MonitorRestangular', function(MonitorRestangular) {
  1093. //http://127.0.0.1:9004/services/ftpFile/monitor/bankTip/
  1094. var process = MonitorRestangular.all("ftpFile/monitor");
  1095. return {
  1096. bankTip: function(id) {
  1097. return process.customGET('bankTip/' + id);
  1098. },
  1099. list: function() {
  1100. return process.customGET('list/1000');
  1101. },
  1102. devList: function(id) {
  1103. return process.customGET('devList/' + id);
  1104. },
  1105. cpuList: function() {
  1106. return process.customGET('cpuList/10');
  1107. },
  1108. memList: function() {
  1109. return process.customGET('memList/10');
  1110. },
  1111. storageList: function() {
  1112. return process.customGET('storageList/10');
  1113. },
  1114. transData: function() {
  1115. return process.customGET('transData/5');
  1116. },
  1117. banklist: function() {
  1118. return process.customGET('banklist');
  1119. },
  1120. app: function(id) {
  1121. return process.customGET('app/' + id);
  1122. },
  1123. beita: function(id) {
  1124. return process.customGET('beita/' + id);
  1125. },
  1126. gongji: function(id) {
  1127. return process.customGET('gongji/' + id);
  1128. }
  1129. };
  1130. }]);
  1131. app.factory('ReportRestangular', function(Restangular) {
  1132. return Restangular.withConfig(function(RestangularConfigurer) {
  1133. //RestangularConfigurer.setBaseUrl('http://127.0.0.1:9005/api/cmdb/');
  1134. RestangularConfigurer.setBaseUrl(reportIp + '/saiku/rest');
  1135. // RestangularConfigurer.setBaseUrl(serverIp + ':8888/saiku/rest');
  1136. //saiku/rest/saiku/api/query/execute/
  1137. });
  1138. });
  1139. app.factory('api_report', ['ReportRestangular', 'Restangular', function(MonitorRestangular, Restangular) {
  1140. var reportService = MonitorRestangular.all("saiku/api");
  1141. var authService = MonitorRestangular.one("saiku/session");
  1142. return {
  1143. getLicenseKey: function() {
  1144. return Restangular.one('assets/').customGET('api/reportToken.js');
  1145. },
  1146. // auth: function(){
  1147. // return authService.customPOST('username=admin&password=admin&language=zh'
  1148. // ,'', {}, {'Content-Type': 'application/x-www-form-urlencoded'});
  1149. // },
  1150. // session: function(){
  1151. // return authService.customGET('');
  1152. // },
  1153. list: function() {
  1154. return reportService.customGET('repository?type=saiku');
  1155. /**
  1156. /saiku/api/repository
  1157. path: /homes/home:admin/itsm_reports
  1158. */
  1159. },
  1160. getMdx: function(path, uuid) {
  1161. var rdata = 'file=' + path + '&formatter=flattened&language=zh';
  1162. return reportService.customPOST(rdata, 'query/' + uuid, {}, { 'Content-Type': 'application/x-www-form-urlencoded' });
  1163. },
  1164. execute: function(data) {
  1165. return reportService.customPOST(data, 'query/execute', {}, { 'Accept': 'application/json, text/javascript, */*' });
  1166. },
  1167. exportData: function(reportView, uuid, reportfileName) {
  1168. return reportService.one('query/rest/export/xls/?exportname=' + reportfileName + 'xls');
  1169. }
  1170. };
  1171. }]);