//debugger;
'use strict';

angular.module('nurseApp', [
	'ui.router',
	'ngTable',
	'ngSanitize',
	'ngCsv',
	'ngAnimate',
	'mgcrea.ngStrap',
	'isteven-multi-select',
	'nurseApp.filters',
	'nurseApp.services',
	'nurseApp.directives',
	'nurseApp.controllers',
	'oc.lazyLoad'
]).run(['$rootScope', '$state', '$stateParams', 'userService',
	function ($rootScope, $state, $stateParams, userService) {

		$rootScope.$state = $state;
		$rootScope.$stateParams = $stateParams;

		$rootScope.$on('$stateChangeStart', function (event, toState, toStateParams) {
			//If in cameraview page,stop playing video.
			$(".fullscreen").hide();
			switch (toState.name) {
				case "cameraview":
				case "camerarecord":
					for (var i = 0; i < 16; i++) {
						var videostate = WebVideoCtrl.I_GetWindowStatus(i);
						if (videostate == 0) continue;
						WebVideoCtrl.I_Stop(i);
					}
					break;
				case "device.diagram":
				case "adevice.diagram":
					$(".fullscreen").show();
					break;
			}
			var token = localStorage.getItem("token");
			userService.isLogin(token).then(function (data) {
				if (data != "TRUE") {
					event.preventDefault();
					$(window.location).attr("href", "login.html");
				}
			});
		});
	}
]
)
	.config(
		['$stateProvider', '$urlRouterProvider',
			function ($stateProvider, $urlRouterProvider, plUploadServiceProvider) {
				$urlRouterProvider.otherwise('/');
				// Use $stateProvider to configure your states.
				$stateProvider
					.state("home", {
						url: "/",
						views: {
							'container': {
								templateUrl: 'partials/alarm.html'
							}
						}
					})
					.state('alarm', {
						url: '/alarm/{alarmLevel:int}',
						views: {
							'container': {
								templateUrl: 'partials/alarm.html'
							}
						},
						resolve:{
							loadMyCtrl:['$ocLazyLoad',function($ocLazyLoad){
								return $ocLazyLoad.load({
									name:'nurseApp',
									files:['js/script/alarmExpertConfigCtrl.js']
								})
							}]
						}
					})
					.state('device.diagram', {
						url: '/diagram',
						parent: 'device',
						params: {
							'diagram': null
						},
						views: {
							'diagram': {
								templateUrl: 'partials/diagram.html'
							}
						}
					})
					.state('mdcpower', {
						url: '/mdcpower',
						views: {
							'container': {
								templateUrl: 'partials/mdcpower.html'/*双排:partials/mdcpower.html 单排:partials/mdcpowerone.html*/
							}
						}
					})
					.state('mdctemp', {
						url: '/mdctemp',
						views: {
							'container': {
								templateUrl: 'partials/mdctemp.html'
							}
						}
					})
					.state('mdcalarm', {
						url: '/mdcalarm',
						views: {
							'container': {
								templateUrl: 'partials/mdcalarm.html'/*双排:partials/mdcalarm.html 单排:partials/mdcalarmone.html*/
							}
						}
					})
					.state('configMDC', {
						url: '/configMDC',
						views: {
							'container': {
								templateUrl: 'partials/configMDC.html'/*双排:partials/configMDC.html 单排:partials/configMDCone.html*/
							}
						}
					})
					.state('device', {
						url: '/device/:deviceBaseTypeId',
						params: {
							'diagramview': 'device.diagram'
						},
						views: {
							'container': {
								templateUrl: 'partials/deviceDiagramView.html'
							}
						}
					})
					.state('adevice', {
						url: '/adevice/:deviceBaseTypeId',
						params: {
							'diagramview': 'adevice.diagram'
						},
						views: {
							'container': {
								templateUrl: 'partials/adeviceDiagramView.html'
							}
						}
					})
					.state('adevice.diagram', {
						url: '/adiagram',
						parent: 'adevice',
						params: {
							'diagram': null
						},
						views: {
							'diagram': {
								templateUrl: 'partials/diagram.html'
							}
						}
					})
					.state('config', {
						url: '/config',
						views: {
							'container': {
								templateUrl: 'fsu_model/partials/config.html'
							}
						}
					})
					.state('config3d', {
						url: '/config3d',
						views: {
							'container': {
								templateUrl: 'partials/editor.html'
							}
						}
					})
					.state('viewer3d', {
						url: '/viewer3d',
						views: {
							'container': {
								templateUrl: 'partials/viewer.html'
							}
						}
					})
					.state('debug', {
						url: '/debug',
						views: {
							'container': {
								templateUrl: 'partials/debug.html'
							}
						}
					})
					.state('employee', {
						url: '/employee',
						views: {
							'container': {
								templateUrl: 'partials/employee.html'
							}
						}
					})
					.state('lampTape', {
						url: '/lampTape',
						views: {
							'container': {
								templateUrl: 'partials/lampTape.html'
							}
						}
					})
					.state('protocol', {
						url: '/protocol',
						views: {
							'container': {
								templateUrl: 'partials/protocol.html'
							}
						}
					})
					.state('alarmrecord', {
						url: '/alarmrecord',
						views: {
							'container': {
								templateUrl: 'partials/alarmrecord.html'
							}
						}
					})
					.state('signalrecord', {
						url: '/signalrecord',
						views: {
							'container': {
								templateUrl: 'partials/signalrecord.html'
							}
						}
					})
					.state('cardsrecord', {
						url: '/cardsrecord',
						views: {
							'container': {
								templateUrl: 'partials/cardsrecord.html'
							}
						}
					})
					.state('deviceInfo', {
						url: '/deviceInfo/{deviceId:int}',
						views: {
							'container': {
								templateUrl: 'fsu_model/partials/deviceInfo.html'
							}
						}
					})
					.state('cameraview', {
						url: '/cameraview',
						views: {
							'container': {
								templateUrl: 'partials/cameraview.html'
							}
						}
					})
					.state('dhCameraview', {
						url: '/dhCameraview',
						views: {
							'container': {
								templateUrl: 'partials/dhCameraview.html'
							}
						}
					})
					.state('camerarecord', {
						url: '/camerarecord',
						views: {
							'container': {
								templateUrl: 'partials/camera.html'
							}
						}
					})
					.state('notify', {
						url: '/notify',
						views: {
							'container': {
								templateUrl: 'partials/notify.html'
							}
						}
					})
					.state('netnotify', {
						url: '/netnotify',
						views: {
							'container': {
								templateUrl: 'partials/netnotify.html'
							}
						}
					})
					.state('kpi', {
						url: '/kpi/{id:int}',
						views: {
							'container': {
								templateUrl: 'partials/kpi.html'
							}
						},
						controller:'kpiCtrl',
						resolve:{
							loadMyCtrl:['$ocLazyLoad',function($ocLazyLoad){
								return $ocLazyLoad.load({
									name:'nurseApp',
									files:['js/script/historyChartConfigCtrl.js']
								})
							}]
						}
					})
					.state('timeSetting', {
						url: '/timeSetting',
						views: {
							'container': {
								templateUrl: 'partials/timeSetting.html'
							}
						}
					})
					.state('about', {
						url: '/about',
						views: {
							'container': {
								templateUrl: 'partials/about.html'
							}
						}
					})
					.state('videoCamera', {
						url: '/videoCamera',
						views: {
							'container': {
								templateUrl: 'partials/VideoCamera.html'
							}
						}
					})
					.state('temperature', {
						url: '/temperature',
						views: {
							'container': {
								templateUrl: 'partials/temperature.html'
							}
						}
					})
					.state('doorControl', {
						url: '/doorControl',
						params: {
							'tab': 1,
							'tabs': 0
						},
						views: {
							'container': {
								templateUrl: 'partials/doorControl.html'
							}
						}
					})
					.state('zkDoorControl',{
						url: '/zkDoorControl',
						params: {
							'tab': 1,
							'tabs': 0
						},
						views: {
							'container': {
								templateUrl: 'partials/zkDoorControl.html'
							}
						}
					})
					.state('doorControlGovern', {
						url: '/doorControlGovern',
						views: {
							'container': {
								templateUrl: 'partials/doorControlGovern.html'
							}
						}
					})
					.state('alarmLinkage', {
						url: '/alarmLinkage',
						views: {
							'container': {
								templateUrl: 'partials/alarmLinkage.html'
							}
						}
					})
					.state('assetsManager', {
						url: '/assetsManager',
						views: {
							'container': {
								templateUrl: 'partials/assetsManager.html'
							}
						}
					})
					.state('assetRackManager', {
						url: '/assetRackManager',
						views: {
							'container': {
								templateUrl: 'partials/assetRackManager.html'
							}
						}
					})
					.state('userOperationRecord', {
						url: '/userOperationRecord',
						views: {
							'container': {
								templateUrl: 'partials/userOperationRecord.html'
							}
						}
					})
					.state('assetRackHistory',{
						url: '/assetRackHistory',
						views: {
							'container': {
								templateUrl: 'partials/assetRackHistory.html'
							}
						}
					})
					.state('otherModule', {
						url: '/otherModule',
						views: {
							'container': {
								templateUrl: 'fsu_model/partials/otherModule.html'
							}
						}
					})
					.state('mdcSignalRecord', {
						url: '/mdcSignalRecord',
						views: {
							'container': {
								templateUrl: 'partials/mdcSignalRecord.html'
							}
						}
					})
					.state('nodeTemp', {
						url: '/nodeTemp',
						views: {
							'container': {
								templateUrl: 'partials/nodeTemperature.html'
							}
						}
					})
					.state('structure', {
						url: '/structure/{deviceBaseTypeId:int}',
						params: {
							'diagramview': 'structure'
						},
						views: {
							'container': {
								templateUrl: 'partials/structure.html'
							}
						}
					})
					.state('cameraViewVlc', {
						url: '/cameraViewVlc',
						views: {
							'container': {
								templateUrl: 'partials/cameraViewVlc.html'
							}
						}
					})
					.state('mdcAssetsManager', {
						url: '/mdcAssetsManager',
						views: {
							'container': {
								templateUrl: 'partials/mdcAssetsManager.html'
							}
						}
					})
					.state('mdcAssetsDisplay', {
						url: '/mdcAssetsDisplay',
						views: {
							'container': {
								templateUrl: 'partials/mdcAssetsDisplay.html'
							}
						}
					})
					.state('mdcAssetsDisplay2', {
						url: '/mdcAssetsDisplay2',
						views: {
							'container': {
								templateUrl: 'partials/mdcAssetsDisplay2.html'
							}
						}
					})
					.state('authority', {
						url: '/authority',
						views: {
							'container': {
								templateUrl: 'partials/authority.html'
							}
						}
					})
					.state('authoritySetting', {
						url: '/authoritySetting',
						views: {
							'container': {
								templateUrl: 'partials/authoritySetting.html'
							}
						}
					})
					.state('mdcdiagram', {
						url: '/mdcdiagram/{fileid:int}',
						views: {
							'container': {
								templateUrl: 'partials/mdcDiagram.html'
							}
						}
					})
					.state('appLicense', {
						url: '/appLicense',
						views: {
							'container': {
								templateUrl: 'partials/appLicense.html'
							}
						}
					})
					.state('alarmLevelConfig', {
						url: '/alarmLevelConfig',
						views: {
							'container': {
								templateUrl: 'partials/alarmLevelConfig.html'
							}
						}
					})
					.state('analogDeviceConfig', {
						url: '/analogDeviceConfig',
						views: {
							'container': {
								templateUrl: 'partials/analogDeviceConfig.html'
							}
						}
					})
					.state('patrolConfig', {
						url: '/patrolConfig',
						views: {
							'container': {
								templateUrl: 'partials/patrolConfig.html'
							}
						}
					})
					.state('interfaceConfig', {
						url: '/interfaceConfig',
						views: {
							'container': {
								templateUrl: 'partials/interfaceConfig.html'
							}
						},
						controller:'interfaceConfigCtrl',
						resolve:{
							loadMyCtrl:['$ocLazyLoad',function($ocLazyLoad){
								return $ocLazyLoad.load({
									name:'nurseApp',
									files:['js/script/interfaceConfigCtrl.js']
								})
							}]
						}
					})
					.state('mosaicVideo', {
						url: '/mosaicVideo',
						views: {
							'container': {
								templateUrl: 'partials/mosaicVideo.html'
							}
						}
					})
					.state('newNetNotify', {
						url: '/newNetNotify',
						views: {
							'container': {
								templateUrl: 'partials/newNetNotify.html'
							}
						}
					})
					.state('settingNova', {
						url: '/settingNova',
						views: {
							'container': {
								templateUrl: 'partials/settingNova.html'
							}
						}
					})
					.state('ipSetting', {
						url: '/ipSetting',
						views: {
							'container': {
								templateUrl: 'partials/include/ipSetting.html'
							}
						}
					})
					.state('alarmExpertConfig', {
						url: '/alarmExpertConfig',
						views: {
							'container': {
								templateUrl: 'partials/alarmExpert/alarmExpertConfig.html'
							}
						},
						controller:'alarmExpertConfigCtrl',
						resolve:{
							loadMyCtrl:['$ocLazyLoad',function($ocLazyLoad){
								return $ocLazyLoad.load({
									name:'nurseApp',
									files:['js/script/alarmExpertConfigCtrl.js']
								})
							}]
						}
					})
					.state('shoot', {
						url: '/shoot',
						views: {
							'container': {
								templateUrl: 'partials/shoot.html'
							}
						}
					})
					.state('alarmCapture', {
						url: '/alarmCapture',
						views: {
							'container': {
								templateUrl: 'partials/alarmCapture.html'
							}
						}
					})
					.state('rtspCameraView', {
						url: '/rtspCameraView',
						views: {
							'container': {
								templateUrl: 'partials/rtspCameraView.html'
							}
						},
						controller:'rtspCameraViewCtrl',
						resolve:{
							loadMyCtrl:['$ocLazyLoad',function($ocLazyLoad){
								return $ocLazyLoad.load({
									name:'nurseApp',
									files:['js/script/rtspCameraViewCtrl.js']
								})
							}]
						}
					})
					.state('inspection',{
						url: '/inspection',
						views: {
							'container': {
								templateUrl: 'partials/equipmentInspection.html'
							}
						},
						controller:'inspectionCtrl',
						resolve:{
							loadMyCtrl:['$ocLazyLoad',function($ocLazyLoad){
								return $ocLazyLoad.load({
									name:'nurseApp',
									files:['js/script/inspectionCtrl.js']
								})
							}]
						}
					})
					.state('historyChartConfig',{
						url: '/historyChartConfig',
						views: {
							'container': {
								templateUrl: 'partials/historyChartConfig.html'
							}
						},
						controller:'historyChartConfigCtrl',
						resolve:{
							loadMyCtrl:['$ocLazyLoad',function($ocLazyLoad){
								return $ocLazyLoad.load({
									name:'nurseApp',
									files:['js/script/historyChartConfigCtrl.js']
								})
							}]
						}
					})
					.state('intervalClearData',{
						url: '/intervalClearData',
						views: {
							'container': {
								templateUrl: 'partials/intervalClearData.html'
							}
						},
						controller:'intervalClearDataCtrl',
						resolve:{
							loadMyCtrl:['$ocLazyLoad',function($ocLazyLoad){
								return $ocLazyLoad.load({
									name:'nurseApp',
									files:['js/script/intervalClearDataCtrl.js']
								})
							}]
						}
					});
			}
		]);

angular.module('loginApp', [
	'mgcrea.ngStrap',
	'nurseApp.filters',
	'nurseApp.services',
	'nurseApp.directives',
	'nurseApp.controllers'
]);