Revision 56844
Added by Andreas Mantas almost 5 years ago
modules/uoa-repository-dashboard-gui/branches/metrics/src/app/pages/adminPg/adminPg-metrics.component.ts | ||
---|---|---|
15 | 15 |
import {ActivatedRoute, Router} from '@angular/router'; |
16 | 16 |
import {PiwikInfoPage} from '../../domain/page-content'; |
17 | 17 |
import {environment} from '../../../environments/environment'; |
18 |
import {st} from '@angular/core/src/render3'; |
|
18 | 19 |
|
19 | 20 |
@Component ({ |
20 | 21 |
selector: 'app-admin-metrics', |
... | ... | |
162 | 163 |
} |
163 | 164 |
|
164 | 165 |
getPages() { |
166 |
let addToEndCounter = 0; |
|
167 |
let addToStartCounter = 0; |
|
165 | 168 |
this.pages = []; |
166 | 169 |
this.pageTotal = Math.ceil(this.piwiks.total / (this.dataForm.get('quantity').value)); |
167 | 170 |
for ( let i = (+this.dataForm.get('page').value - this.offset); i < (+this.dataForm.get('page').value + 1 + this.offset); ++i ) { |
168 |
if ((i >= 0) && (i < this.pageTotal)) { |
|
169 |
this.pages.push(i); |
|
171 |
if ( i < 0 ) { addToEndCounter++; } |
|
172 |
if ( i >= this.pageTotal ) { addToStartCounter++; } |
|
173 |
if ((i >= 0) && (i < this.pageTotal)) { |
|
174 |
this.pages.push(i); |
|
170 | 175 |
} |
171 | 176 |
} |
177 |
for ( let i = 0; i < addToEndCounter; ++i ) { |
|
178 |
if (this.pages.length < this.pageTotal) { |
|
179 |
this.pages.push(this.pages.length); |
|
180 |
} |
|
181 |
} |
|
182 |
for ( let i = 0; i < addToStartCounter; ++i ) { |
|
183 |
if (this.pages[0] > 0) { |
|
184 |
this.pages.unshift(this.pages[0] - 1 ); |
|
185 |
} |
|
186 |
} |
|
172 | 187 |
} |
173 | 188 |
|
174 | 189 |
selectPage(page) { |
Also available in: Unified diff
adminPg-metrics: pagination update: display 5 pages when possible