Updates for clearing filter values after actions.

This commit is contained in:
kunw 2017-03-31 18:28:21 +08:00
parent 551ce63927
commit a8233a5b9a
14 changed files with 48 additions and 40 deletions

View File

@ -11,7 +11,7 @@
</select> </select>
</div> </div>
<div class="item-divider"></div> <div class="item-divider"></div>
<grid-filter filterPlaceholder='{{"AUDIT_LOG.FILTER_PLACEHOLDER" | translate}}' (filter)="doFilter($event)"></grid-filter> <grid-filter filterPlaceholder='{{"AUDIT_LOG.FILTER_PLACEHOLDER" | translate}}' (filter)="doFilter($event)" [currentValue]="currentTerm"></grid-filter>
<span (click)="refresh()" class="refresh-btn"> <span (click)="refresh()" class="refresh-btn">
<clr-icon shape="refresh" [hidden]="inProgress" ng-disabled="inProgress"></clr-icon> <clr-icon shape="refresh" [hidden]="inProgress" ng-disabled="inProgress"></clr-icon>
<span class="spinner spinner-inline" [hidden]="inProgress === false"></span> <span class="spinner spinner-inline" [hidden]="inProgress === false"></span>

View File

@ -22,6 +22,7 @@ export class RecentLogComponent implements OnInit {
private logsCache: AuditLog[]; private logsCache: AuditLog[];
private onGoing: boolean = false; private onGoing: boolean = false;
private lines: number = 10; //Support 10, 25 and 50 private lines: number = 10; //Support 10, 25 and 50
currentTerm: string;
constructor( constructor(
private session: SessionService, private session: SessionService,
@ -35,6 +36,7 @@ export class RecentLogComponent implements OnInit {
} }
private handleOnchange($event: any) { private handleOnchange($event: any) {
this.currentTerm = '';
if ($event && $event.target && $event.target["value"]) { if ($event && $event.target && $event.target["value"]) {
this.lines = $event.target["value"]; this.lines = $event.target["value"];
if (this.lines < 10) { if (this.lines < 10) {
@ -57,7 +59,7 @@ export class RecentLogComponent implements OnInit {
this.recentLogs = this.logsCache.filter(log => log.username != ""); this.recentLogs = this.logsCache.filter(log => log.username != "");
return; return;
} }
this.currentTerm = terms;
this.recentLogs = this.logsCache.filter(log => this.isMatched(terms, log)); this.recentLogs = this.logsCache.filter(log => this.isMatched(terms, log));
} }

View File

@ -6,7 +6,7 @@
<add-member [projectId]="projectId" (added)="addedMember($event)"></add-member> <add-member [projectId]="projectId" (added)="addedMember($event)"></add-member>
</div> </div>
<div class="flex-xs-middle option-right"> <div class="flex-xs-middle option-right">
<grid-filter filterPlaceholder='{{"MEMBER.FILTER_PLACEHOLDER" | translate}}' (filter)="doSearch($event)"></grid-filter> <grid-filter filterPlaceholder='{{"MEMBER.FILTER_PLACEHOLDER" | translate}}' (filter)="doSearch($event)" [currentValue]="searchMember"></grid-filter>
<a href="javascript:void(0)" (click)="refresh()"> <a href="javascript:void(0)" (click)="refresh()">
<clr-icon shape="refresh"></clr-icon> <clr-icon shape="refresh"></clr-icon>
</a> </a>

View File

@ -43,6 +43,8 @@ export class MemberComponent implements OnInit, OnDestroy {
currentUser: SessionUser; currentUser: SessionUser;
hasProjectAdminRole: boolean; hasProjectAdminRole: boolean;
searchMember: string;
constructor( constructor(
private route: ActivatedRoute, private route: ActivatedRoute,
private router: Router, private router: Router,
@ -108,6 +110,7 @@ export class MemberComponent implements OnInit, OnDestroy {
} }
addedMember() { addedMember() {
this.searchMember = '';
this.retrieve(this.projectId, ''); this.retrieve(this.projectId, '');
} }
@ -138,7 +141,8 @@ export class MemberComponent implements OnInit, OnDestroy {
} }
doSearch(searchMember) { doSearch(searchMember) {
this.retrieve(this.projectId, searchMember); this.searchMember = searchMember;
this.retrieve(this.projectId, this.searchMember);
} }
refresh() { refresh() {

View File

@ -20,7 +20,7 @@
<a href="javascript:void(0)" clrDropdownItem (click)="doFilterProjects(1)">{{projectTypes[1] | translate}}</a> <a href="javascript:void(0)" clrDropdownItem (click)="doFilterProjects(1)">{{projectTypes[1] | translate}}</a>
</div> </div>
</clr-dropdown> </clr-dropdown>
<grid-filter filterPlaceholder='{{"PROJECT.FILTER_PLACEHOLDER" | translate}}' (filter)="doSearchProjects($event)"></grid-filter> <grid-filter filterPlaceholder='{{"PROJECT.FILTER_PLACEHOLDER" | translate}}' (filter)="doSearchProjects($event)" [currentValue]="projectName"></grid-filter>
<a href="javascript:void(0)" (click)="refresh()"> <a href="javascript:void(0)" (click)="refresh()">
<clr-icon shape="refresh"></clr-icon> <clr-icon shape="refresh"></clr-icon>
</a> </a>

View File

@ -6,7 +6,7 @@
<create-edit-destination (reload)="reload($event)"></create-edit-destination> <create-edit-destination (reload)="reload($event)"></create-edit-destination>
</div> </div>
<div class="flex-items-xs-middle option-right"> <div class="flex-items-xs-middle option-right">
<grid-filter filterPlaceholder='{{"REPLICATION.FILTER_TARGETS_PLACEHOLDER" | translate}}' (filter)="doSearchTargets($event)"></grid-filter> <grid-filter filterPlaceholder='{{"REPLICATION.FILTER_TARGETS_PLACEHOLDER" | translate}}' (filter)="doSearchTargets($event)" [currentValue]="targetName"></grid-filter>
<a href="javascript:void(0)" (click)="refreshTargets()"> <a href="javascript:void(0)" (click)="refreshTargets()">
<clr-icon shape="refresh"></clr-icon> <clr-icon shape="refresh"></clr-icon>
</a> </a>

View File

@ -87,6 +87,7 @@ export class DestinationComponent implements OnInit {
} }
reload() { reload() {
this.targetName = '';
this.retrieve(''); this.retrieve('');
} }

View File

@ -15,7 +15,7 @@
<a href="javascript:void(0)" clrDropdownItem *ngFor="let r of ruleStatus" (click)="doFilterPolicyStatus(r.key)"> {{r.description | translate}}</a> <a href="javascript:void(0)" clrDropdownItem *ngFor="let r of ruleStatus" (click)="doFilterPolicyStatus(r.key)"> {{r.description | translate}}</a>
</div> </div>
</clr-dropdown> </clr-dropdown>
<grid-filter filterPlaceholder='{{"REPLICATION.FILTER_POLICIES_PLACEHOLDER" | translate}}' (filter)="doSearchPolicies($event)"></grid-filter> <grid-filter filterPlaceholder='{{"REPLICATION.FILTER_POLICIES_PLACEHOLDER" | translate}}' (filter)="doSearchPolicies($event)" [currentValue]="search.policyName"></grid-filter>
<a href="javascript:void(0)" (click)="refreshPolicies()"> <a href="javascript:void(0)" (click)="refreshPolicies()">
<clr-icon shape="refresh"></clr-icon> <clr-icon shape="refresh"></clr-icon>
</a> </a>
@ -23,14 +23,14 @@
</div> </div>
</div> </div>
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12"> <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
<list-policy [policies]="changedPolicies" [projectless]="false" [selectedId]="initSelectedId" (selectOne)="selectOne($event)" (editOne)="openEditPolicy($event)" (reload)="reloadPolicies($event)"></list-policy> <list-policy [policies]="changedPolicies" [projectless]="false" [selectedId]="initSelectedId" (selectOne)="selectOnePolicy($event)" (editOne)="openEditPolicy($event)" (reload)="reloadPolicies($event)"></list-policy>
</div> </div>
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12"> <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
<div class="row flex-items-xs-between"> <div class="row flex-items-xs-between">
<h5 class="flex-items-xs-bottom option-left-down" style="margin-left: 14px;">{{'REPLICATION.REPLICATION_JOBS' | translate}}</h5> <h5 class="flex-items-xs-bottom option-left-down" style="margin-left: 14px;">{{'REPLICATION.REPLICATION_JOBS' | translate}}</h5>
<div class="flex-items-xs-bottom option-right-down"> <div class="flex-items-xs-bottom option-right-down">
<button class="btn btn-link" (click)="toggleSearchJobOptionalName(currentJobSearchOption)">{{toggleJobSearchOption[currentJobSearchOption] | translate}}</button> <button class="btn btn-link" (click)="toggleSearchJobOptionalName(currentJobSearchOption)">{{toggleJobSearchOption[currentJobSearchOption] | translate}}</button>
<grid-filter filterPlaceholder='{{"REPLICATION.FILTER_JOBS_PLACEHOLDER" | translate}}' (filter)="doSearchJobs($event)"></grid-filter> <grid-filter filterPlaceholder='{{"REPLICATION.FILTER_JOBS_PLACEHOLDER" | translate}}' (filter)="doSearchJobs($event)" [currentValue]="search.repoName" ></grid-filter>
<a href="javascript:void(0)" (click)="refreshJobs()"> <a href="javascript:void(0)" (click)="refreshJobs()">
<clr-icon shape="refresh"></clr-icon> <clr-icon shape="refresh"></clr-icon>
</a> </a>
@ -47,8 +47,8 @@
</div> </div>
</clr-dropdown> </clr-dropdown>
<div class="flex-items-xs-middle"> <div class="flex-items-xs-middle">
<clr-icon shape="date"></clr-icon><input type="date" #fromTime (change)="doJobSearchByTimeRange(fromTime.value, 'begin')"> <clr-icon shape="date"></clr-icon><input type="date" #fromTime (change)="doJobSearchByStartTime(fromTime.value)">
<clr-icon shape="date"></clr-icon><input type="date" #toTime (change)="doJobSearchByTimeRange(toTime.value, 'end')"> <clr-icon shape="date"></clr-icon><input type="date" #toTime (change)="doJobSearchByEndTime(toTime.value)">
</div> </div>
</div> </div>
</div> </div>

View File

@ -68,7 +68,7 @@ export class ReplicationComponent implements OnInit {
changedJobs: Job[]; changedJobs: Job[];
initSelectedId: number; initSelectedId: number;
policies: Policy[]; policies: Policy[];retrieve
jobs: Job[]; jobs: Job[];
jobsTotalRecordCount: number; jobsTotalRecordCount: number;
@ -144,7 +144,6 @@ export class ReplicationComponent implements OnInit {
if(state) { if(state) {
this.search.page = state.page.to + 1; this.search.page = state.page.to + 1;
} }
console.log('Received policy ID ' + this.search.policyId + ' by clicked row.');
this.replicationService this.replicationService
.listJobs(this.search.policyId, this.search.status, this.search.repoName, .listJobs(this.search.policyId, this.search.status, this.search.repoName,
this.search.startTime, this.search.endTime, this.search.page, this.search.pageSize) this.search.startTime, this.search.endTime, this.search.page, this.search.pageSize)
@ -157,7 +156,6 @@ export class ReplicationComponent implements OnInit {
for(let i = 0; i < this.jobs.length; i++) { for(let i = 0; i < this.jobs.length; i++) {
let j = this.jobs[i]; let j = this.jobs[i];
if(j.status == 'retrying' || j.status == 'error') { if(j.status == 'retrying' || j.status == 'error') {
console.log('Error in jobs were found.')
this.messageHandlerService.showError('REPLICATION.FOUND_ERROR_IN_JOBS', ''); this.messageHandlerService.showError('REPLICATION.FOUND_ERROR_IN_JOBS', '');
break; break;
} }
@ -167,9 +165,13 @@ export class ReplicationComponent implements OnInit {
); );
} }
selectOne(policy: Policy) { selectOnePolicy(policy: Policy) {
if(policy) { if(policy) {
this.search.policyId = policy.id; this.search.policyId = policy.id;
this.search.repoName = '';
this.search.status = ''
this.currentJobSearchOption = 0;
this.currentJobStatus = { 'key': '', 'description': 'REPLICATION.ALL'};
this.fetchPolicyJobs(); this.fetchPolicyJobs();
} }
} }
@ -180,7 +182,6 @@ export class ReplicationComponent implements OnInit {
} }
doFilterPolicyStatus(status: string) { doFilterPolicyStatus(status: string) {
console.log('Do filter policies with status:' + status);
this.currentRuleStatus = this.ruleStatus.find(r=>r.key === status); this.currentRuleStatus = this.ruleStatus.find(r=>r.key === status);
if(status.trim() === '') { if(status.trim() === '') {
this.changedPolicies = this.policies; this.changedPolicies = this.policies;
@ -190,13 +191,9 @@ export class ReplicationComponent implements OnInit {
} }
doFilterJobStatus(status: string) { doFilterJobStatus(status: string) {
console.log('Do filter jobs with status:' + status);
this.currentJobStatus = this.jobStatus.find(r=>r.key === status); this.currentJobStatus = this.jobStatus.find(r=>r.key === status);
if(status.trim() === '') { this.search.status = status;
this.changedJobs = this.jobs; this.doSearchJobs(this.search.repoName);
} else {
this.changedJobs = this.jobs.filter(job=>job.status === status);
}
} }
doSearchJobs(repoName: string) { doSearchJobs(repoName: string) {
@ -223,21 +220,20 @@ export class ReplicationComponent implements OnInit {
(option === 1) ? this.currentJobSearchOption = 0 : this.currentJobSearchOption = 1; (option === 1) ? this.currentJobSearchOption = 0 : this.currentJobSearchOption = 1;
} }
doJobSearchByTimeRange(strDate: string, target: string) { doJobSearchByStartTime(strDate: string) {
if(!strDate || strDate.trim() === '') {
strDate = 0 + '';
}
(strDate === '0') ? this.search.startTime = '' : this.search.startTime = (new Date(strDate).getTime() / 1000) + '';
this.fetchPolicyJobs();
}
doJobSearchByEndTime(strDate: string) {
if(!strDate || strDate.trim() === '') { if(!strDate || strDate.trim() === '') {
strDate = 0 + ''; strDate = 0 + '';
} }
let oneDayOffset = 3600 * 24; let oneDayOffset = 3600 * 24;
switch(target) { (strDate === '0') ? this.search.endTime = '' : this.search.endTime = (new Date(strDate).getTime() / 1000 + oneDayOffset) + '';
case 'begin':
this.search.startTime = (new Date(strDate).getTime() / 1000) + '';
break;
case 'end':
this.search.endTime = (new Date(strDate).getTime() / 1000 + oneDayOffset) + '';
break;
}
console.log('Search jobs filtered by time range, begin: ' + this.search.startTime + ', end:' + this.search.endTime);
this.fetchPolicyJobs(); this.fetchPolicyJobs();
} }
} }

View File

@ -2,7 +2,7 @@
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12"> <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
<div class="row flex-items-xs-right option-right"> <div class="row flex-items-xs-right option-right">
<div class="flex-items-xs-middle"> <div class="flex-items-xs-middle">
<grid-filter filterPlaceholder='{{"REPLICATION.FILTER_POLICIES_PLACEHOLDER" | translate}}' (filter)="doSearchPolicies($event)"></grid-filter> <grid-filter filterPlaceholder='{{"REPLICATION.FILTER_POLICIES_PLACEHOLDER" | translate}}' (filter)="doSearchPolicies($event)" [currentValue]="policyName"></grid-filter>
<a href="javascript:void(0)" (click)="refreshPolicies()"><clr-icon shape="refresh"></clr-icon></a> <a href="javascript:void(0)" (click)="refreshPolicies()"><clr-icon shape="refresh"></clr-icon></a>
</div> </div>
<create-edit-policy [projectId]="projectId" (reload)="reloadPolicies($event)"></create-edit-policy> <create-edit-policy [projectId]="projectId" (reload)="reloadPolicies($event)"></create-edit-policy>

View File

@ -71,6 +71,7 @@ export class TotalReplicationComponent implements OnInit {
reloadPolicies(isReady: boolean) { reloadPolicies(isReady: boolean) {
if(isReady) { if(isReady) {
this.policyName = '';
this.retrievePolicies(); this.retrievePolicies();
} }
} }

View File

@ -13,15 +13,13 @@ import 'rxjs/add/operator/distinctUntilChanged';
}) })
export class FilterComponent implements OnInit { export class FilterComponent implements OnInit {
private placeHolder: string = "";
private currentValue: string = "";
private leadingSpacesAdded: boolean = false;
private filerAction: Function;
private placeHolder: string = "";
private filterTerms = new Subject<string>(); private filterTerms = new Subject<string>();
@Output("filter") private filterEvt = new EventEmitter<string>(); @Output("filter") private filterEvt = new EventEmitter<string>();
@Input() currentValue;
@Input("filterPlaceholder") @Input("filterPlaceholder")
public set flPlaceholder(placeHolder: string) { public set flPlaceholder(placeHolder: string) {
this.placeHolder = placeHolder; this.placeHolder = placeHolder;
@ -34,6 +32,7 @@ export class FilterComponent implements OnInit{
.subscribe(terms => { .subscribe(terms => {
this.filterEvt.emit(terms); this.filterEvt.emit(terms);
}); });
} }
valueChange(): void { valueChange(): void {

View File

@ -5,7 +5,7 @@
<span> <span>
<button [class.hide-create]="!canCreateUser" type="submit" class="btn btn-link custom-add-button" (click)="addNewUser()"><clr-icon shape="add"></clr-icon> {{'USER.ADD_ACTION' | translate}}</button> <button [class.hide-create]="!canCreateUser" type="submit" class="btn btn-link custom-add-button" (click)="addNewUser()"><clr-icon shape="add"></clr-icon> {{'USER.ADD_ACTION' | translate}}</button>
</span> </span>
<grid-filter class="filter-pos" filterPlaceholder='{{"USER.FILTER_PLACEHOLDER" | translate}}' (filter)="doFilter($event)"></grid-filter> <grid-filter class="filter-pos" filterPlaceholder='{{"USER.FILTER_PLACEHOLDER" | translate}}' (filter)="doFilter($event)" [currentValue]="currentTerm"></grid-filter>
<span class="refresh-btn" (click)="refreshUser()"> <span class="refresh-btn" (click)="refreshUser()">
<clr-icon shape="refresh" [hidden]="inProgress" ng-disabled="inProgress"></clr-icon> <clr-icon shape="refresh" [hidden]="inProgress" ng-disabled="inProgress"></clr-icon>
<span class="spinner spinner-inline" [hidden]="inProgress === false"></span> <span class="spinner spinner-inline" [hidden]="inProgress === false"></span>

View File

@ -30,6 +30,8 @@ export class UserComponent implements OnInit, OnDestroy {
private adminColumn: string = ""; private adminColumn: string = "";
private deletionSubscription: Subscription; private deletionSubscription: Subscription;
currentTerm: string;
@ViewChild(NewUserModalComponent) @ViewChild(NewUserModalComponent)
private newUserDialog: NewUserModalComponent; private newUserDialog: NewUserModalComponent;
@ -107,6 +109,7 @@ export class UserComponent implements OnInit, OnDestroy {
//Filter items by keywords //Filter items by keywords
doFilter(terms: string): void { doFilter(terms: string): void {
this.currentTerm = terms;
this.originalUsers.then(users => { this.originalUsers.then(users => {
if (terms.trim() === "") { if (terms.trim() === "") {
this.users = users; this.users = users;
@ -175,6 +178,7 @@ export class UserComponent implements OnInit, OnDestroy {
.then(() => { .then(() => {
//Remove it from current user list //Remove it from current user list
//and then view refreshed //and then view refreshed
this.currentTerm = '';
this.originalUsers.then(users => { this.originalUsers.then(users => {
this.users = users.filter(u => u.user_id != user.user_id); this.users = users.filter(u => u.user_id != user.user_id);
this.msgHandler.showSuccess("USER.DELETE_SUCCESS"); this.msgHandler.showSuccess("USER.DELETE_SUCCESS");
@ -188,6 +192,7 @@ export class UserComponent implements OnInit, OnDestroy {
//Refresh the user list //Refresh the user list
refreshUser(): void { refreshUser(): void {
//Start to get //Start to get
this.currentTerm = '';
this.onGoing = true; this.onGoing = true;
this.originalUsers = this.userService.getUsers() this.originalUsers = this.userService.getUsers()