Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
534bc831
Commit
534bc831
authored
Jan 13, 2016
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
temp work on dynamic directives
parent
87f6d7da
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
86 additions
and
69 deletions
+86
-69
pkg/api/dtos/apps.go
+2
-0
public/app/core/services/all.js
+1
-0
public/app/core/services/dynamic_directive_srv.ts
+37
-0
public/app/features/annotations/partials/editor.html
+3
-0
public/app/features/apps/all.ts
+1
-0
public/app/features/apps/app_srv.ts
+0
-43
public/app/features/apps/config_loader.ts
+36
-0
public/app/features/apps/partials/edit.html
+6
-1
public/app/features/panel/panel_directive.js
+0
-25
No files found.
pkg/api/dtos/apps.go
View file @
534bc831
...
...
@@ -10,6 +10,7 @@ type AppSettings struct {
AppId
string
`json:"appId"`
Enabled
bool
`json:"enabled"`
Pinned
bool
`json:"pinned"`
Module
string
`json:"module"`
Info
*
plugins
.
PluginInfo
`json:"info"`
Pages
[]
*
plugins
.
AppPluginPage
`json:"pages"`
JsonData
map
[
string
]
interface
{}
`json:"jsonData"`
...
...
@@ -20,6 +21,7 @@ func NewAppSettingsDto(def *plugins.AppPlugin, data *models.AppSettings) *AppSet
AppId
:
def
.
Id
,
Name
:
def
.
Name
,
Info
:
&
def
.
Info
,
Module
:
def
.
Module
,
Pages
:
def
.
Pages
,
}
...
...
public/app/core/services/all.js
View file @
534bc831
...
...
@@ -9,5 +9,6 @@ define([
'./popover_srv'
,
'./segment_srv'
,
'./backend_srv'
,
'./dynamic_directive_srv'
,
],
function
()
{});
public/app/core/services/dynamic_directive_srv.ts
0 → 100644
View file @
534bc831
///<reference path="../../headers/common.d.ts" />
import
_
from
'lodash'
;
import
angular
from
'angular'
;
import
coreModule
from
'../core_module'
;
class
DynamicDirectiveSrv
{
/** @ngInject */
constructor
(
private
$compile
,
private
$parse
,
private
datasourceSrv
)
{
}
addDirective
(
element
,
name
,
scope
)
{
element
.
empty
();
element
.
append
(
angular
.
element
(
document
.
createElement
(
name
)));
this
.
$compile
(
element
)(
scope
);
}
define
(
options
)
{
var
editorScope
;
options
.
scope
.
$watch
(
options
.
datasourceProperty
,
newVal
=>
{
if
(
editorScope
)
{
editorScope
.
$destroy
();
options
.
parentElem
.
empty
();
}
editorScope
=
options
.
scope
.
$new
();
this
.
datasourceSrv
.
get
(
newVal
).
then
(
ds
=>
{
this
.
addDirective
(
options
.
parentElem
,
options
.
name
+
'-'
+
ds
.
meta
.
id
,
editorScope
);
});
});
}
}
coreModule
.
service
(
'dynamicDirectiveSrv'
,
DynamicDirectiveSrv
);
public/app/features/annotations/partials/editor.html
View file @
534bc831
...
...
@@ -91,6 +91,9 @@
</div>
</div>
<annnotations-ds-query-editor
datasource=
"currentAnnotation.datasource"
current-annotation=
"currentAnnotation"
></annotations-ds-query-editor>
<datasource-editor-view
datasource=
"currentAnnotation.datasource"
name=
"annotations-query-editor"
></datasource-editor-view>
<br>
...
...
public/app/features/apps/all.ts
View file @
534bc831
import
'./edit_ctrl'
;
import
'./list_ctrl'
;
import
'./config_loader'
;
public/app/features/apps/app_srv.ts
deleted
100644 → 0
View file @
87f6d7da
///<reference path="../../headers/common.d.ts" />
import
_
from
'lodash'
;
import
angular
from
'angular'
;
export
class
AppSrv
{
apps
:
any
=
{};
/** @ngInject */
constructor
(
private
$rootScope
,
private
$timeout
,
private
$q
,
private
backendSrv
)
{
}
get
(
type
)
{
return
this
.
getAll
().
then
(()
=>
{
return
this
.
apps
[
type
];
});
}
getAll
()
{
if
(
!
_
.
isEmpty
(
this
.
apps
))
{
return
this
.
$q
.
when
(
this
.
apps
);
}
return
this
.
backendSrv
.
get
(
'api/org/apps'
).
then
(
results
=>
{
return
results
.
reduce
((
prev
,
current
)
=>
{
prev
[
current
.
type
]
=
current
;
return
prev
;
},
this
.
apps
);
});
}
update
(
app
)
{
return
this
.
backendSrv
.
post
(
'api/org/apps'
,
app
).
then
(
resp
=>
{
});
}
}
angular
.
module
(
'grafana.services'
).
service
(
'appSrv'
,
AppSrv
);
public/app/features/apps/config_loader.ts
0 → 100644
View file @
534bc831
///<reference path="../../headers/common.d.ts" />
import
_
from
'lodash'
;
import
angular
from
'angular'
;
function
appConfigLoader
(
$compile
,
$parse
)
{
return
{
restrict
:
'E'
,
scope
:
{
appModel
:
"="
},
link
:
function
(
scope
,
elem
,
attr
)
{
debugger
;
System
.
import
(
scope
.
appModel
.
module
).
then
(
function
(
appModule
)
{
var
directive
=
appModule
.
directives
.
configView
;
if
(
!
directive
)
{
return
;
}
if
(
!
directive
.
hasBeenRegistered
)
{
angular
.
module
(
'grafana.directives'
).
directive
(
'nginxConfig'
,
directive
);
directive
.
hasBeenRegistered
=
true
;
}
var
panelEl
=
angular
.
element
(
document
.
createElement
(
'nginx-config'
));
elem
.
append
(
panelEl
);
$compile
(
panelEl
)(
scope
);
}).
catch
(
function
(
err
)
{
console
.
log
(
'Failed to load panel:'
,
err
);
scope
.
appEvent
(
'alert-error'
,
[
'App Error'
,
err
.
toString
()]);
});
}
};
}
angular
.
module
(
'grafana.directives'
).
directive
(
'appConfigLoader'
,
appConfigLoader
);
public/app/features/apps/partials/edit.html
View file @
534bc831
...
...
@@ -97,6 +97,11 @@
</div>
</section>
<app-config-loader></app-config-loader>
<nginx-config></nginx-config>
<div
ng-if=
"ctrl.appModel.appId"
>
<app-config-loader
app-model=
"ctrl.appModel"
></app-config-loader>
</div>
</div>
</div>
public/app/features/panel/panel_directive.js
View file @
534bc831
...
...
@@ -70,31 +70,6 @@ function (angular, $, config) {
};
});
module
.
service
(
'dynamicDirectiveSrv'
,
function
(
$compile
,
$parse
,
datasourceSrv
)
{
var
self
=
this
;
this
.
addDirective
=
function
(
options
,
type
,
editorScope
)
{
var
panelEl
=
angular
.
element
(
document
.
createElement
(
options
.
name
+
'-'
+
type
));
options
.
parentElem
.
append
(
panelEl
);
$compile
(
panelEl
)(
editorScope
);
};
this
.
define
=
function
(
options
)
{
var
editorScope
;
options
.
scope
.
$watch
(
options
.
datasourceProperty
,
function
(
newVal
)
{
if
(
editorScope
)
{
editorScope
.
$destroy
();
options
.
parentElem
.
empty
();
}
editorScope
=
options
.
scope
.
$new
();
datasourceSrv
.
get
(
newVal
).
then
(
function
(
ds
)
{
self
.
addDirective
(
options
,
ds
.
meta
.
id
,
editorScope
);
});
});
};
});
module
.
directive
(
'datasourceEditorView'
,
function
(
dynamicDirectiveSrv
)
{
return
{
restrict
:
'E'
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment