7 '../model/JobPagingModel',
9 '../widget/ImageEmptyItem',
10 '../widget/ImageItem',
24 var logger = Logger('image.js');
29 // the list for the image
30 var ModelImageList = [];
32 // the paging model for the table of job
35 function _update(pageNum) {
39 function _updateView(arrImages) {
40 return new Promise(function (resolve, reject) {
41 logger.info('_updateView');
42 var targetBody = $('#tic-image-list');
45 if (arrImages.length <= 0) {
46 targetBody.append(new ImageEmptyItem().getTemplate());
49 _.forEach(arrImages, function (value, index) {
50 targetBody.append(new ImageItem(value, index).getTemplate());
54 $('#tic-image-list a.btnbiglog').on('click', function (e) {
56 Util.showBigLogView(this);
62 function _updateDataModel(result) {
63 return new Promise(function (resolve, reject) {
64 logger.info('_updateDataModel');
67 _.forEach(result, function (imageItem) {
68 var item = new ImageModel(imageItem);
69 ModelImageList.push(item);
72 resolve(ModelImageList);
76 function _getAllListItem() {
77 logger.info('_getAllListItem');
81 return Util.POST(AppConfig.EVENT.IMAGE.IMAGE_GET_ALL_LISTITEM, msgData);
84 function _updatePagingView(dataObj) {
85 return new Promise(function (resolve, reject) {
86 logger.info('_updatePagingView');
88 var targetPaging = $('#tic-image-list-pagination');
92 targetPaging.append(new JobPaging(dataObj).getTemplate());
95 $('#tic-image-section .pagination > li > a').on('click', function(e) {
100 pagenum = $(this).data('pagenum');
103 gotoPageNum(pagenum);
112 function _updatePagingModel(result) {
113 return new Promise(function (resolve, reject) {
114 logger.info('_updatePagingModel');
116 var totalCount, pagingCount;
120 $('#tic-image-list-pagination').empty();
123 totalCount = Number(result[0].total_count);
125 if (_.isEmpty(ModelImagePaging)) {
126 ModelImagePaging = new JobPagingModel({
127 totalCount: totalCount,
128 currentPageNum: pageNum
132 resolve(ModelImagePaging);
136 function _getTotalCount() {
137 logger.info('_getTotalCount');
138 return Util.POST(AppConfig.EVENT.IMAGE.IMAGE_GET_ALL_COUNT);
141 return _getTotalCount()
142 .then(_updatePagingModel)
143 .then(_updatePagingView)
144 .then(_getAllListItem)
145 .then(_updateDataModel)
149 function gotoPageNum(pageNum) {
150 logger.info('gotoPageNum : ' + pageNum);
154 function updateList(selectedPageNum) {
155 logger.info('updateList');
158 // the default value of pageNum is 1.
159 var pageNum = selectedPageNum || 1;
160 gotoPageNum(pageNum);
166 Util.getAppConfig().then(function (data) {
176 * Update list in image page
179 updateList: updateList