Commit eaf211800f8464c0ad5fabfc0e426473183af0f2

Authored by Nikita Kulshreshtha
1 parent 4ec78545

same s QA

400-SOURCECODE/AIAHTML5.Web/app/controllers/AIController.js
1 -AIA.controller("AIController", ["$scope", "$window", "$rootScope", "$compile", "$http", "$log", "$location", "$timeout", "pages", "DataService","AIAConstants", 1 +AIA.controller("AIController", ["$scope", "$window", "$rootScope", "$compile", "$http", "$log", "$location", "$timeout", "pages", "DataService", "AIAConstants",
2 function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout, pages, DataService, AIAConstants) { 2 function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout, pages, DataService, AIAConstants) {
3 // $rootScope.currentActiveModuleTitle = pages[3].name; 3 // $rootScope.currentActiveModuleTitle = pages[3].name;
4 $scope.showTabButton = true; 4 $scope.showTabButton = true;
@@ -77,8 +77,7 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout @@ -77,8 +77,7 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout
77 if (typeof (searchByText) !== "undefined" && searchByText !== null && searchByText !== '') { 77 if (typeof (searchByText) !== "undefined" && searchByText !== null && searchByText !== '') {
78 $scope.query.SearchText = searchByText; 78 $scope.query.SearchText = searchByText;
79 } 79 }
80 - else if (typeof (searchTextByAlphabet) !== "undefined" && searchTextByAlphabet !== null && searchTextByAlphabet !== '')  
81 - { 80 + else if (typeof (searchTextByAlphabet) !== "undefined" && searchTextByAlphabet !== null && searchTextByAlphabet !== '') {
82 $scope.query.SearchTextByAlphabet = searchTextByAlphabet; 81 $scope.query.SearchTextByAlphabet = searchTextByAlphabet;
83 } 82 }
84 else { 83 else {
@@ -86,11 +85,10 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout @@ -86,11 +85,10 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout
86 } 85 }
87 86
88 if ($scope.query.SearchText == "" && $scope.query.SearchTextByAlphabet == "") { 87 if ($scope.query.SearchText == "" && $scope.query.SearchTextByAlphabet == "") {
89 - 88 +
90 $scope.loadAllAI(); 89 $scope.loadAllAI();
91 } 90 }
92 - else if ($scope.query.SearchTextByAlphabet != "" || $scope.query.SearchText == "")  
93 - { 91 + else if ($scope.query.SearchTextByAlphabet != "" || $scope.query.SearchText == "") {
94 $scope.ApplySearchByAlphabet($scope.query.SearchTextByAlphabet); 92 $scope.ApplySearchByAlphabet($scope.query.SearchTextByAlphabet);
95 } 93 }
96 else { 94 else {
@@ -157,7 +155,7 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout @@ -157,7 +155,7 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout
157 155
158 $rootScope.isLoading = false; 156 $rootScope.isLoading = false;
159 $('#aiSpinner').css('visibility', 'hidden'); 157 $('#aiSpinner').css('visibility', 'hidden');
160 - 158 +
161 }, 159 },
162 function (error) { 160 function (error) {
163 // handle errors here 161 // handle errors here
@@ -239,15 +237,13 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout @@ -239,15 +237,13 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout
239 $('ul li a').removeAttr("style"); 237 $('ul li a').removeAttr("style");
240 var currentSearchtext = $rootScope.getLocalStorageValue("SearchText"); 238 var currentSearchtext = $rootScope.getLocalStorageValue("SearchText");
241 localStorage.setItem("SearchText", ''); 239 localStorage.setItem("SearchText", '');
242 - if (currentSearchtext == "undefined" || (currentSearchtext == null || currentSearchtext == ""))  
243 - {  
244 - if (query.SearchText == "undefined" || (query.SearchText == null || query.SearchText == ""))  
245 - {  
246 - $rootScope.errorMessage = AIAConstants.PLEASE_ENTER_SEARCH_TEXT;  
247 - $("#messageModal").modal('show');  
248 - // alert("Please enter the text !")  
249 - return false;  
250 - } 240 + if (currentSearchtext == "undefined" || (currentSearchtext == null || currentSearchtext == "")) {
  241 + if (query.SearchText == "undefined" || (query.SearchText == null || query.SearchText == "")) {
  242 + $rootScope.errorMessage = AIAConstants.PLEASE_ENTER_SEARCH_TEXT;
  243 + $("#messageModal").modal('show');
  244 + // alert("Please enter the text !")
  245 + return false;
  246 + }
251 } 247 }
252 248
253 $rootScope.isLoading = true; 249 $rootScope.isLoading = true;
@@ -316,7 +312,7 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout @@ -316,7 +312,7 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout
316 + '<div class="caption"><p>' + value._Title + '</p></div></a></div></div>').appendTo('#grid-view'); 312 + '<div class="caption"><p>' + value._Title + '</p></div></a></div></div>').appendTo('#grid-view');
317 313
318 $compile($el)($scope); 314 $compile($el)($scope);
319 - 315 +
320 316
321 $(".sidebar").mCustomScrollbar({ 317 $(".sidebar").mCustomScrollbar({
322 autoHideScrollbar: true, 318 autoHideScrollbar: true,
@@ -358,208 +354,208 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout @@ -358,208 +354,208 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout
358 354
359 355
360 356
361 - $scope.ApplySearchByAlphabet = function (SearchText) { 357 + $scope.ApplySearchByAlphabet = function (SearchText) {
362 358
363 - $rootScope.isLoading = true;  
364 - $('#spinner').css('visibility', 'visible');  
365 -  
366 - $scope.filterstring = true; 359 + $rootScope.isLoading = true;
  360 + $('#spinner').css('visibility', 'visible');
367 361
368 - while ($scope.searchAIListViewData.length) {  
369 - $scope.searchAIListViewData.pop();  
370 - } 362 + $scope.filterstring = true;
371 363
  364 + while ($scope.searchAIListViewData.length) {
  365 + $scope.searchAIListViewData.pop();
  366 + }
372 367
373 368
374 369
375 - if (typeof (SearchText) !== "undefined" && (SearchText !== null && SearchText !== "")) {  
376 370
377 - localStorage.setItem("AIImageId", SearchText); 371 + if (typeof (SearchText) !== "undefined" && (SearchText !== null && SearchText !== "")) {
378 372
379 - }  
380 - else {  
381 - localStorage.setItem("AIImageId", ''); 373 + localStorage.setItem("AIImageId", SearchText);
382 374
383 - } 375 + }
  376 + else {
  377 + localStorage.setItem("AIImageId", '');
384 378
385 - var promise = DataService.getJson('~/../content/data/json/ai/ai_dat_contentlist.json')  
386 - promise.then(  
387 - function (result) {  
388 - $scope.IllustrationData = result; 379 + }
389 380
390 - $scope.selectedAIListViewData = new jinqJs()  
391 - .from($scope.IllustrationData.root.AIData)  
392 - .orderBy([{ field: '_Title', sort: 'asc' }])  
393 - .select(); 381 + var promise = DataService.getJson('~/../content/data/json/ai/ai_dat_contentlist.json')
  382 + promise.then(
  383 + function (result) {
  384 + $scope.IllustrationData = result;
394 385
395 - $('#grid-view').empty(); 386 + $scope.selectedAIListViewData = new jinqJs()
  387 + .from($scope.IllustrationData.root.AIData)
  388 + .orderBy([{ field: '_Title', sort: 'asc' }])
  389 + .select();
396 390
397 - angular.forEach($scope.selectedAIListViewData, function (value, key) { 391 + $('#grid-view').empty();
398 392
399 - var selectimg = true;  
400 - //var count = 0;  
401 - if (typeof (SearchText) !== "undefined" && (SearchText !== null && SearchText !== "")) { 393 + angular.forEach($scope.selectedAIListViewData, function (value, key) {
402 394
403 - var firstChar = value._Title[0]; 395 + var selectimg = true;
  396 + //var count = 0;
  397 + if (typeof (SearchText) !== "undefined" && (SearchText !== null && SearchText !== "")) {
404 398
405 - if (firstChar == SearchText) {  
406 - selectimg = true;  
407 - //count = count + 1; 399 + var firstChar = value._Title[0];
408 400
409 - }  
410 - else {  
411 - selectimg = false;  
412 - //count = count - 1;  
413 - } 401 + if (firstChar == SearchText) {
  402 + selectimg = true;
  403 + //count = count + 1;
414 404
415 } 405 }
  406 + else {
  407 + selectimg = false;
  408 + //count = count - 1;
  409 + }
416 410
417 - if (selectimg === true) {  
418 - $scope.imagePath = "~/../content/images/ai/thumbnails/" + value._ThumbnailImage; 411 + }
419 412
420 - var $el = $('<div id="' + value._id + '" class="col-sm-3 col-md-2" title = "' + value._Title + '" data-ng-click="AdamDetail($event)">'  
421 - + '<div style="width:auto;height:auto;" class="thumbnail" >'  
422 - + '<img style="height:150px" id="' + value._Title + '"ng-src="' + $scope.imagePath + '" alt="" title="" >'  
423 - + '<div class="caption"><p>' + value._Title + '</p></div></a></div></div>').appendTo('#grid-view'); 413 + if (selectimg === true) {
  414 + $scope.imagePath = "~/../content/images/ai/thumbnails/" + value._ThumbnailImage;
424 415
425 - $compile($el)($scope);  
426 - 416 + var $el = $('<div id="' + value._id + '" class="col-sm-3 col-md-2" title = "' + value._Title + '" data-ng-click="AdamDetail($event)">'
  417 + + '<div style="width:auto;height:auto;" class="thumbnail" >'
  418 + + '<img style="height:150px" id="' + value._Title + '"ng-src="' + $scope.imagePath + '" alt="" title="" >'
  419 + + '<div class="caption"><p>' + value._Title + '</p></div></a></div></div>').appendTo('#grid-view');
427 420
428 - $(".sidebar").mCustomScrollbar({  
429 - autoHideScrollbar: true,  
430 - //theme:"rounded"  
431 - }); 421 + $compile($el)($scope);
432 422
433 423
434 - $scope.searchAIListViewData.push(  
435 - {  
436 - "_id": value._id,  
437 - //"_ImageId": value._ImageId,  
438 - "_Title": value._Title,  
439 - "_contentImage": value._contentImage,  
440 - "_ThumbnailImage": value._ThumbnailImage, 424 + $(".sidebar").mCustomScrollbar({
  425 + autoHideScrollbar: true,
  426 + //theme:"rounded"
  427 + });
441 428
442 429
443 - });  
444 - }  
445 - });  
446 - $('table > #ListViewDiv > #searchItem').remove();  
447 - //Show Error Message in case of gridview if no data is found  
448 - if ($scope.searchAIListViewData.length == 0) {  
449 - var $el = $('<div class="col-sm-12" style="padding-left:25px;padding-top:10px;"><strong style="color:white">No illustration found for the selected search criteria!</strong></div>').appendTo('#grid-view');  
450 - $compile($el)($scope);  
451 - $('table > #ListViewDiv > #searchItem').remove(); 430 + $scope.searchAIListViewData.push(
  431 + {
  432 + "_id": value._id,
  433 + //"_ImageId": value._ImageId,
  434 + "_Title": value._Title,
  435 + "_contentImage": value._contentImage,
  436 + "_ThumbnailImage": value._ThumbnailImage,
  437 +
452 438
453 - $('#ListViewDiv').append('<tr id="searchItem"><td colspan="6"><strong style="color:black;">No illustration found for the selected search criteria!</strong></td></tr>'); 439 + });
454 } 440 }
  441 + });
  442 + $('table > #ListViewDiv > #searchItem').remove();
  443 + //Show Error Message in case of gridview if no data is found
  444 + if ($scope.searchAIListViewData.length == 0) {
  445 + var $el = $('<div class="col-sm-12" style="padding-left:25px;padding-top:10px;"><strong style="color:white">No illustration found for the selected search criteria!</strong></div>').appendTo('#grid-view');
  446 + $compile($el)($scope);
  447 + $('table > #ListViewDiv > #searchItem').remove();
  448 +
  449 + $('#ListViewDiv').append('<tr id="searchItem"><td colspan="6"><strong style="color:black;">No illustration found for the selected search criteria!</strong></td></tr>');
  450 + }
455 $rootScope.isLoading = false; 451 $rootScope.isLoading = false;
456 $('#spinner').css('visibility', 'hidden'); 452 $('#spinner').css('visibility', 'hidden');
457 453
458 }, 454 },
459 - function (error) {  
460 - // handle errors here  
461 - console.log(' $scope.IllustrationData = ' + error.statusText);  
462 - }  
463 - ); 455 + function (error) {
  456 + // handle errors here
  457 + console.log(' $scope.IllustrationData = ' + error.statusText);
  458 + }
  459 + );
464 } 460 }
465 461
466 462
467 463
468 $scope.ApplySearchByAlphabet = function (SearchTextByAlphabet) { 464 $scope.ApplySearchByAlphabet = function (SearchTextByAlphabet) {
469 465
470 - $rootScope.SearchTextByAlphabet = SearchTextByAlphabet  
471 - $rootScope.isLoading = true;  
472 - $('ul li a').removeAttr("style");  
473 - $('#spinner').css('visibility', 'visible');  
474 - $('#' + $rootScope.SearchTextByAlphabet ).css({ "color": "white", "background-color": "#1B92D0" }); 466 + $rootScope.SearchTextByAlphabet = SearchTextByAlphabet
  467 + $rootScope.isLoading = true;
  468 + $('ul li a').removeAttr("style");
  469 + $('#spinner').css('visibility', 'visible');
  470 + $('#' + $rootScope.SearchTextByAlphabet).css({ "color": "white", "background-color": "#1B92D0" });
475 471
476 //color: #0095da; 472 //color: #0095da;
477 //background-color: #ffffff; 473 //background-color: #ffffff;
478 474
479 - $scope.filterstring = true; 475 + $scope.filterstring = true;
480 476
481 - while ($scope.searchAIListViewData.length) {  
482 - $scope.searchAIListViewData.pop();  
483 - }  
484 - if (typeof (SearchTextByAlphabet) !== "undefined" && (SearchTextByAlphabet !== null && SearchTextByAlphabet !== "")) {  
485 - localStorage.setItem("SearchByAlphabet", SearchTextByAlphabet);  
486 - }  
487 - else {  
488 - localStorage.setItem("SearchByAlphabet", '');  
489 - } 477 + while ($scope.searchAIListViewData.length) {
  478 + $scope.searchAIListViewData.pop();
  479 + }
  480 + if (typeof (SearchTextByAlphabet) !== "undefined" && (SearchTextByAlphabet !== null && SearchTextByAlphabet !== "")) {
  481 + localStorage.setItem("SearchByAlphabet", SearchTextByAlphabet);
  482 + }
  483 + else {
  484 + localStorage.setItem("SearchByAlphabet", '');
  485 + }
490 486
491 - var promise = DataService.getJson('~/../content/data/json/ai/ai_dat_contentlist.json')  
492 - promise.then(  
493 - function (result) {  
494 - $scope.IllustrationData = result;  
495 -  
496 - $scope.selectedAIListViewData = new jinqJs()  
497 - .from($scope.IllustrationData.root.AIData)  
498 - .orderBy([{ field: '_Title', sort: 'asc' }])  
499 - .select();  
500 -  
501 - $('#grid-view').empty();  
502 -  
503 - angular.forEach($scope.selectedAIListViewData, function (value, key) {  
504 -  
505 - var selectimg = true;  
506 - //var count = 0;  
507 - if (typeof (SearchTextByAlphabet) !== "undefined" && (SearchTextByAlphabet !== null && SearchTextByAlphabet !== "")) {  
508 - var firstChar = value._Title[0];  
509 - if (firstChar == SearchTextByAlphabet) {  
510 - selectimg = true;  
511 - }  
512 - else {  
513 - selectimg = false;  
514 - }  
515 - }  
516 - if (selectimg === true) {  
517 - $scope.imagePath = "~/../content/images/ai/thumbnails/" + value._ThumbnailImage; 487 + var promise = DataService.getJson('~/../content/data/json/ai/ai_dat_contentlist.json')
  488 + promise.then(
  489 + function (result) {
  490 + $scope.IllustrationData = result;
518 491
519 - var $el = $('<div id="' + value._id + '" class="col-sm-3 col-md-2" title = "' + value._Title + '" data-ng-click="OpenAdamImage($event)">'  
520 - + '<div style="width:auto;height:auto;" class="thumbnail" >'  
521 - + '<img style="height:150px" id="' + value._Title + '"ng-src="' + $scope.imagePath + '" alt="" title="" >'  
522 - + '<div class="caption"><p>' + value._Title + '</p></div></a></div></div>').appendTo('#grid-view'); 492 + $scope.selectedAIListViewData = new jinqJs()
  493 + .from($scope.IllustrationData.root.AIData)
  494 + .orderBy([{ field: '_Title', sort: 'asc' }])
  495 + .select();
523 496
524 - $compile($el)($scope); 497 + $('#grid-view').empty();
525 498
  499 + angular.forEach($scope.selectedAIListViewData, function (value, key) {
526 500
527 - $(".sidebar").mCustomScrollbar({  
528 - autoHideScrollbar: true,  
529 - //theme:"rounded"  
530 - }); 501 + var selectimg = true;
  502 + //var count = 0;
  503 + if (typeof (SearchTextByAlphabet) !== "undefined" && (SearchTextByAlphabet !== null && SearchTextByAlphabet !== "")) {
  504 + var firstChar = value._Title[0];
  505 + if (firstChar == SearchTextByAlphabet) {
  506 + selectimg = true;
  507 + }
  508 + else {
  509 + selectimg = false;
  510 + }
  511 + }
  512 + if (selectimg === true) {
  513 + $scope.imagePath = "~/../content/images/ai/thumbnails/" + value._ThumbnailImage;
531 514
  515 + var $el = $('<div id="' + value._id + '" class="col-sm-3 col-md-2" title = "' + value._Title + '" data-ng-click="OpenAdamImage($event)">'
  516 + + '<div style="width:auto;height:auto;" class="thumbnail" >'
  517 + + '<img style="height:150px" id="' + value._Title + '"ng-src="' + $scope.imagePath + '" alt="" title="" >'
  518 + + '<div class="caption"><p>' + value._Title + '</p></div></a></div></div>').appendTo('#grid-view');
532 519
533 - $scope.searchAIListViewData.push(  
534 - {  
535 - "_id": value._id,  
536 - //"_ImageId": value._ImageId,  
537 - "_Title": value._Title,  
538 - "_contentImage": value._contentImage,  
539 - "_ThumbnailImage": value._ThumbnailImage, 520 + $compile($el)($scope);
540 521
541 522
542 - });  
543 - }  
544 - });  
545 - $('table > #ListViewDiv > #searchItem').remove();  
546 - //Show Error Message in case of gridview if no data is found  
547 - if ($scope.searchAIListViewData.length == 0) {  
548 - var $el = $('<div class="col-sm-12" style="padding-left:25px;padding-top:10px;"><strong style="color:white">No illustration found for the selected search criteria!</strong></div>').appendTo('#grid-view');  
549 - $compile($el)($scope);  
550 - $('table > #ListViewDiv > #searchItem').remove(); 523 + $(".sidebar").mCustomScrollbar({
  524 + autoHideScrollbar: true,
  525 + //theme:"rounded"
  526 + });
551 527
552 - $('#ListViewDiv').append('<tr id="searchItem"><td colspan="6"><strong style="color:black;">No illustration found for the selected search criteria!</strong></td></tr>'); 528 +
  529 + $scope.searchAIListViewData.push(
  530 + {
  531 + "_id": value._id,
  532 + //"_ImageId": value._ImageId,
  533 + "_Title": value._Title,
  534 + "_contentImage": value._contentImage,
  535 + "_ThumbnailImage": value._ThumbnailImage,
  536 +
  537 +
  538 + });
553 } 539 }
554 - $rootScope.isLoading = false;  
555 - $('#spinner').css('visibility', 'hidden'); 540 + });
  541 + $('table > #ListViewDiv > #searchItem').remove();
  542 + //Show Error Message in case of gridview if no data is found
  543 + if ($scope.searchAIListViewData.length == 0) {
  544 + var $el = $('<div class="col-sm-12" style="padding-left:25px;padding-top:10px;"><strong style="color:white">No illustration found for the selected search criteria!</strong></div>').appendTo('#grid-view');
  545 + $compile($el)($scope);
  546 + $('table > #ListViewDiv > #searchItem').remove();
556 547
557 - },  
558 - function (error) {  
559 - console.log(' $scope.IllustrationData = ' + error.statusText); 548 + $('#ListViewDiv').append('<tr id="searchItem"><td colspan="6"><strong style="color:black;">No illustration found for the selected search criteria!</strong></td></tr>');
560 } 549 }
561 - );  
562 - } 550 + $rootScope.isLoading = false;
  551 + $('#spinner').css('visibility', 'hidden');
  552 +
  553 + },
  554 + function (error) {
  555 + console.log(' $scope.IllustrationData = ' + error.statusText);
  556 + }
  557 + );
  558 + }
563 559
564 560
565 $scope.scroll = function () { 561 $scope.scroll = function () {
@@ -596,7 +592,7 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout @@ -596,7 +592,7 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout
596 $location.url('/adam-images-detail'); 592 $location.url('/adam-images-detail');
597 } 593 }
598 594
599 - $scope.OpenAdamImageView= function () { 595 + $scope.OpenAdamImageView = function () {
600 596
601 if ($rootScope.refreshcheck == null) { 597 if ($rootScope.refreshcheck == null) {
602 $location.path('/'); 598 $location.path('/');
@@ -758,4 +754,3 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout @@ -758,4 +754,3 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout
758 754
759 755
760 756
761 -