ModuleService.js 4.07 KB
var ATLAS_ANATOMY = 'Atlas Anatomy';
var CLINICAL_ILLUSTRATION = 'Clinical Illustrations';
var CLINICAL_ANIMATION = 'Clinical Animations';
var OpenedModuleItemList = [];
var ModDetail = [];

AIA.factory('ModuleService', function (DataService)
{   
    return {
        SaveOpenedModules: function (moduleDetails)
        {
            ModDetail = moduleDetails;

            OpenedModuleItemList.push("imageId: "+ moduleDetails[0]);
            OpenedModuleItemList.push("moduleId:" + moduleDetails[1]);
            OpenedModuleItemList.push("moduleName: " + moduleDetails[2]);
            

            //var moduleId = moduleDetails.moduleId;
            //OpenedModuleList.push(moduleId);
            //OpenedModuleList.tileViewId = moduleDetails.TileViewId;
            //OpenedModuleList.tileImageName = moduleDetails.imageName;
            //OpenedModuleList.tileImageSRC = moduleDetails.imagePath;

            //moduleData.push($scope.moduleId);
            //moduleData.push(value._Id);
            //moduleData.push(value._ImageId);
            //moduleData.push(value._Title);
            //moduleData.push(value._ImageName);
            //moduleData.push(value._BodySystem);
            //moduleData.push(value._BodyRegion);
            //moduleData.push(value._ViewOrientation);
            //moduleData.push(value._ImageType);
            //moduleData.push(value._TileImageName);    
            
           
            console.log('called service');

         
            this.renderModuleItemById();          
            
        },

        renderModuleItemById : function () {
        
            var jsonFileForOpenModule;

            if (ModDetail[2] == ATLAS_ANATOMY)
            {
               this.loadPinData();
            
            }
            else if (ModDetail[2] == CLINICAL_ANIMATION) {

            }
            else if (ModDetail[3] == CLINICAL_ILLUSTRATION) {

            }

        },
        loadPinData: function () {
            var pinJsonFile = "/content/data/json/aa/aa_pin_data/aa_dat_pindata_" + ModDetail[0] + ".json";
            alert('pinJsonFile: ' + pinJsonFile);
            var promise = DataService.getJson(pinJsonFile);
            promise.then(
                    function (result) {
                        var AtlasAnatomyPinData = result;

                        var data = new jinqJs()
                             .from(AtlasAnatomyPinData.root.Item)
                                                         //.orderBy([{ field: '_Title', sort: 'asc' }])
                                                         .select();

                    })
        },
        
            loadModuleDataBasedOnModuleName: function (moduleName) {

                alert('loadModuleDataBasedOnModuleName is called');

                var jsonPath;
                if (moduleName == ATLAS_ANATOMY) {
                    jsonPath = '~/../content/data/json/aa/aa_dat_contentlist.json';
                }
                else if (moduleName == CLINICAL_ANIMATION) {
                    //to do, in next phase of project
                    jsonPath = '~/../content/data/json/ca/ca_dat_contentlist.json';
                }
                else if (moduleName == CLINICAL_ILLUSTRATION) {
                    //to do, in next phase of project
                    jsonPath = '~/../content/data/json/ci/ci_dat_contentlist.json';
                }

                var promise = DataService.getJson(jsonPath)
                promise.then(
                          function (result) {
                              var AtlasAnatomyData = result;

                              var data = new jinqJs()
                                  .from($scope.AtlasAnatomyData.root.Item)
                                                              .orderBy([{ field: '_Title', sort: 'asc' }])
                                                              .select();

                              // to do we can now load pin data here

                          })
            }
        }
      

 
   
});