Skip to content

Commit

Permalink
feat(api): add filter on worker model to filter by official worker mo…
Browse files Browse the repository at this point in the history
…del #3733 (#3734)

Signed-off-by: Benjamin Coenen <[email protected]>
  • Loading branch information
bnjjj authored and sguiheux committed Dec 17, 2018
1 parent 050268f commit f535713
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions engine/api/worker/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ const (
StateRegister StateLoadOption = "register"
StateDeprecated StateLoadOption = "deprecated"
StateActive StateLoadOption = "active"
StateOfficial StateLoadOption = "official"
)

// InsertWorkerModel insert a new worker model in database
Expand Down Expand Up @@ -514,6 +515,8 @@ func getAdditionalSQLFilters(opts *StateLoadOption) []string {
additionalFilters = append(additionalFilters, "worker_model.is_deprecated = true")
case *opts == StateActive:
additionalFilters = append(additionalFilters, "worker_model.is_deprecated = false")
case *opts == StateOfficial:
additionalFilters = append(additionalFilters, fmt.Sprintf("worker_model.group_id = %d", group.SharedInfraGroup.ID))
}
}
return additionalFilters
Expand Down
2 changes: 1 addition & 1 deletion engine/api/worker_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ func (api *API) getWorkerModelsHandler() service.Handler {
state := r.FormValue("state")
var opt *worker.StateLoadOption
switch state {
case "", worker.StateDisabled.String(), worker.StateError.String(), worker.StateRegister.String(), worker.StateDeprecated.String(), worker.StateActive.String():
case "", worker.StateDisabled.String(), worker.StateOfficial.String(), worker.StateError.String(), worker.StateRegister.String(), worker.StateDeprecated.String(), worker.StateActive.String():
opt = new(worker.StateLoadOption)
*opt = worker.StateLoadOption(state)
break
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<div class="ui one wide column"></div>
<div class="ui four wide column">
<sui-select class="selection" [placeholder]="'worker_model_state' | translate" [(ngModel)]="selectedFilter"
[options]="['', 'disabled', 'register', 'error', 'deprecated']" [isSearchable]="true" #selectFilter>
[options]="['', 'official', 'disabled', 'register', 'error', 'deprecated']" [isSearchable]="true" #selectFilter>
<sui-select-option *ngFor="let option of selectFilter.filteredOptions" [value]="option">
</sui-select-option>
</sui-select>
Expand Down

0 comments on commit f535713

Please sign in to comment.