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

AIA.service('ModuleService', function($http, DataService) {       
    return {        
        loadModuleDataBasedOnModuleName: function(moduleName) {           
            var jsonPath;

            modName = moduleName;

            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';
            }

            return $http.get(jsonPath, function (response) {                                                       
                
                moduleData = new jinqJs()
                                  .from(response.data.root.Item)
                                                              .orderBy([{field: '_Title', sort: 'asc' }])
                                                              .select();
                console.log(JSON.stringify(response, null, 4));
                response.data= moduleData;
                return response.data;            
            });
        },

        SaveOpenedModules: function (id,moduleJson) {

            if (modName == ATLAS_ANATOMY)
            {

                alert(moduleJson.data.root.Item.length);

                var selectedTileData = new jinqJs()
                                  .from(moduleJson.data.root.Item)
                                  .where("_Title =="+ id)
                                   .select();

               
                alert(selectedTileData);
                
            }
           

            //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();

        },

    };    
});