Merge pull request #4768 from ninjadq/fix_bug_search_result

Fix bug on search result ui
This commit is contained in:
Qian Deng 2018-04-25 15:55:48 +08:00 committed by GitHub
commit ac8e5d6e25
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -11,8 +11,8 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
import { Component, Input, Output, EventEmitter, ChangeDetectionStrategy, ChangeDetectorRef } from '@angular/core';
import { Router, NavigationExtras } from '@angular/router';
import { Component, Input, Output, EventEmitter, ChangeDetectionStrategy, ChangeDetectorRef, OnInit } from '@angular/core';
import { Router, NavigationExtras, NavigationEnd } from '@angular/router';
import { Repository } from 'harbor-ui';
import { State } from 'clarity-angular';
@ -23,19 +23,33 @@ import { SearchTriggerService } from '../../base/global-search/search-trigger.se
templateUrl: 'list-repository-ro.component.html',
changeDetection: ChangeDetectionStrategy.OnPush
})
export class ListRepositoryROComponent {
export class ListRepositoryROComponent implements OnInit {
@Input() projectId: number;
@Input() repositories: Repository[];
@Output() paginate = new EventEmitter<State>();
constructor(
private router: Router,
private searchTrigger: SearchTriggerService,
private ref: ChangeDetectorRef) {
let hnd = setInterval(()=>ref.markForCheck(), 100);
setTimeout(()=>clearInterval(hnd), 1000);
this.router.routeReuseStrategy.shouldReuseRoute = function(){
return false;
};
this.router.events.subscribe((evt) => {
if (evt instanceof NavigationEnd) {
// trick the Router into believing it's last link wasn't previously loaded
this.router.navigated = false;
// if you need to scroll back to top, here is the right place
window.scrollTo(0, 0);
}
});
}
ngOnInit(): void {
let hnd = setInterval(() => this.ref.markForCheck(), 100);
setTimeout(() => clearInterval(hnd), 1000);
}
refresh(state: State) {