Skip to content

Commit

Permalink
fix: reset kind field to input in annotations
Browse files Browse the repository at this point in the history
This allows you to use variables in the kind field, such as $kind.

Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>
  • Loading branch information
g1eny0ung committed Jul 28, 2022
1 parent 6c2e2c2 commit 46fb45d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
5 changes: 2 additions & 3 deletions src/AnnotationQueryEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,18 @@
* limitations under the License.
*
*/
import { defaultQuery, kinds } from './types';
import { defaultQuery } from './types';

export class AnnotationQueryEditor {
static templateUrl = 'partials/annotations.editor.html';

annotation: any;
kinds = kinds;

constructor() {
this.annotation.object_id = this.annotation.object_id || '';
this.annotation.namespace = this.annotation.namespace || '';
this.annotation.eventName = this.annotation.eventName || ''; // There is a conflict with annotation name, so rename it to eventName.
this.annotation.kind = this.annotation.kind || kinds[0];
this.annotation.kind = this.annotation.kind || '';
this.annotation.limit = this.annotation.limit || defaultQuery.limit;
}
}
1 change: 1 addition & 0 deletions src/datasource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ export class DataSource extends DataSourceApi<EventsQuery, ChaosMeshOptions> {

const val = (queryCloned as any)[q];

// Handle variables.
if (typeof val === 'string' && val.startsWith('$') && vars[val]) {
(queryCloned as any)[q] = vars[val];
}
Expand Down
6 changes: 1 addition & 5 deletions src/partials/annotations.editor.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@

<div class="gf-form">
<label class="gf-form-label width-6">Kind</label>
<select
class="gf-form-input width-12"
ng-model="ctrl.annotation.kind"
ng-options="kind for kind in ctrl.kinds"
></select>
<input class="gf-form-input width-12" ng-model="ctrl.annotation.kind" />
</div>

<div class="gf-form">
Expand Down

0 comments on commit 46fb45d

Please sign in to comment.