mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
remove dead code, make label more flexible
This commit is contained in:
parent
85ab1cfa8f
commit
8ed210c8d5
@ -42,7 +42,8 @@ export class SqlPart {
|
|||||||
part: any;
|
part: any;
|
||||||
def: SqlPartDef;
|
def: SqlPartDef;
|
||||||
params: any[];
|
params: any[];
|
||||||
text: string;
|
label: string;
|
||||||
|
name: string;
|
||||||
|
|
||||||
constructor(part: any, def: any) {
|
constructor(part: any, def: any) {
|
||||||
this.part = part;
|
this.part = part;
|
||||||
@ -51,38 +52,21 @@ export class SqlPart {
|
|||||||
throw { message: 'Could not find sql part ' + part.type };
|
throw { message: 'Could not find sql part ' + part.type };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (part.name) {
|
||||||
|
this.name = part.name;
|
||||||
|
this.label = def.label + ' ' + part.name;
|
||||||
|
} else {
|
||||||
|
this.name = '';
|
||||||
|
this.label = def.label;
|
||||||
|
}
|
||||||
|
|
||||||
part.params = part.params || _.clone(this.def.defaultParams);
|
part.params = part.params || _.clone(this.def.defaultParams);
|
||||||
this.params = part.params;
|
this.params = part.params;
|
||||||
this.updateText();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
render(innerExpr: string) {
|
render(innerExpr: string) {
|
||||||
return this.def.renderer(this, innerExpr);
|
return this.def.renderer(this, innerExpr);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateParam(strValue, index) {
|
|
||||||
if (strValue === '' && this.def.params[index].optional) {
|
|
||||||
// XXX check if this is still required
|
|
||||||
this.params.splice(index, 1);
|
|
||||||
} else {
|
|
||||||
this.params[index] = strValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.part.params = this.params;
|
|
||||||
this.updateText();
|
|
||||||
}
|
|
||||||
|
|
||||||
updateText() {
|
|
||||||
if (this.params.length === 0) {
|
|
||||||
this.text = this.def.type + '()';
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var text = this.def.type + '(';
|
|
||||||
text += this.params.join(', ');
|
|
||||||
text += ')';
|
|
||||||
this.text = text;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function functionRenderer(part, innerExpr) {
|
export function functionRenderer(part, innerExpr) {
|
||||||
|
@ -4,7 +4,7 @@ import coreModule from 'app/core/core_module';
|
|||||||
|
|
||||||
var template = `
|
var template = `
|
||||||
<div class="dropdown cascade-open">
|
<div class="dropdown cascade-open">
|
||||||
<a ng-click="showActionsMenu()" class="query-part-name pointer dropdown-toggle" data-toggle="dropdown">{{part.def.label}}</a>
|
<a ng-click="showActionsMenu()" class="query-part-name pointer dropdown-toggle" data-toggle="dropdown">{{part.label}}</a>
|
||||||
<span>{{part.def.wrapOpen}}</span><span class="query-part-parameters"></span><span>{{part.def.wrapClose}}</span>
|
<span>{{part.def.wrapOpen}}</span><span class="query-part-parameters"></span><span>{{part.def.wrapClose}}</span>
|
||||||
<ul class="dropdown-menu">
|
<ul class="dropdown-menu">
|
||||||
<li ng-repeat="action in partActions">
|
<li ng-repeat="action in partActions">
|
||||||
|
Loading…
Reference in New Issue
Block a user