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
d1e1c4be
Commit
d1e1c4be
authored
Jun 18, 2017
by
Daniel Lee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP: refactor user group modal
parent
5cf63e37
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
58 additions
and
28 deletions
+58
-28
public/app/features/org/all.js
+1
-0
public/app/features/org/create_user_group_modal.ts
+38
-0
public/app/features/org/partials/create_user_group.html
+15
-12
public/app/features/org/user_groups_ctrl.ts
+4
-16
No files found.
public/app/features/org/all.js
View file @
d1e1c4be
...
...
@@ -10,4 +10,5 @@ define([
'./prefs_control'
,
'./user_groups_ctrl'
,
'./user_group_details_ctrl'
,
'./create_user_group_modal'
,
],
function
()
{});
public/app/features/org/create_user_group_modal.ts
0 → 100644
View file @
d1e1c4be
///<reference path="../../headers/common.d.ts" />
import
coreModule
from
'app/core/core_module'
;
import
appEvents
from
'app/core/app_events'
;
import
_
from
'lodash'
;
export
class
CreateUserGroupCtrl
{
userGroupName
=
''
;
/** @ngInject */
constructor
(
private
backendSrv
,
private
$scope
,
$sce
,
private
$location
)
{
}
createUserGroup
()
{
this
.
backendSrv
.
post
(
'/api/user-groups'
,
{
name
:
this
.
userGroupName
}).
then
((
result
)
=>
{
if
(
result
.
userGroupId
)
{
this
.
$location
.
path
(
'/org/user-groups/edit/'
+
result
.
userGroupId
);
}
this
.
dismiss
();
});
}
dismiss
()
{
appEvents
.
emit
(
'hide-modal'
);
}
}
export
function
createUserGroupModal
()
{
return
{
restrict
:
'E'
,
templateUrl
:
'public/app/features/org/partials/create_user_group.html'
,
controller
:
CreateUserGroupCtrl
,
bindToController
:
true
,
controllerAs
:
'ctrl'
,
};
}
coreModule
.
directive
(
'createUserGroupModal'
,
createUserGroupModal
);
public/app/features/org/partials/create_user_group.html
View file @
d1e1c4be
<div
class=
"modal-body"
ng-controller=
"UserGroupsCtrl"
>
<div
class=
"modal-body"
>
<div
class=
"modal-header"
>
<h2
class=
"modal-header-title"
>
Create User Group
<span
class=
"p-l-1"
>
Create User Group
</span>
</h2>
<a
class=
"modal-header-close"
ng-click=
"dismiss();"
>
<a
class=
"modal-header-close"
ng-click=
"ctrl.dismiss();"
>
<i
class=
"fa fa-remove"
></i>
</a>
</div>
<div
class=
"modal-content"
>
<form
name=
"createUserGroupForm"
class=
"gf-form-group"
>
<div
class=
"gf-form-inline"
>
<div
class=
"gf-form max-width-21"
>
<input
type=
"text"
class=
"gf-form-input"
ng-model=
'ctrl.userGroupName'
placeholder=
"Name"
></input>
</div>
<div
class=
"gf-form"
>
<button
class=
"btn gf-form-btn btn-success"
ng-click=
"ctrl.createUserGroup();dismiss();"
>
Create
</button>
</div>
</div>
<form
name=
"ctrl.createUserGroupForm"
class=
"gf-form-group"
novalidate
>
<div
class=
"p-t-2"
>
<div
class=
"gf-form-inline"
>
<div
class=
"gf-form max-width-21"
>
<input
type=
"text"
class=
"gf-form-input"
ng-model=
'ctrl.userGroupName'
required
give-focus=
"true"
placeholder=
"Enter User Group Name"
></input>
</div>
<div
class=
"gf-form"
>
<button
class=
"btn gf-form-btn btn-success"
ng-click=
"ctrl.createUserGroup();ctrl.dismiss();"
>
Create
</button>
</div>
</div>
</div>
</form>
</div>
</div>
public/app/features/org/user_groups_ctrl.ts
View file @
d1e1c4be
///<reference path="../../headers/common.d.ts" />
import
coreModule
from
'app/core/core_module'
;
import
{
appEvents
}
from
'app/core/core'
;
export
class
UserGroupsCtrl
{
userGroups
:
any
;
...
...
@@ -10,7 +11,6 @@ export class UserGroupsCtrl {
totalPages
:
number
;
showPaging
=
false
;
query
:
any
=
''
;
userGroupName
:
any
=
''
;
navModel
:
any
;
/** @ngInject */
...
...
@@ -40,14 +40,6 @@ export class UserGroupsCtrl {
this
.
get
();
}
createUserGroup
()
{
this
.
backendSrv
.
post
(
'/api/user-groups'
,
{
name
:
this
.
userGroupName
}).
then
((
result
)
=>
{
if
(
result
.
userGroupId
)
{
this
.
$location
.
path
(
'/org/user-groups/edit/'
+
result
.
userGroupId
);
}
});
}
deleteUserGroup
(
userGroup
)
{
this
.
$scope
.
appEvent
(
'confirm-modal'
,
{
title
:
'Delete'
,
...
...
@@ -66,13 +58,9 @@ export class UserGroupsCtrl {
}
openUserGroupModal
()
{
var
modalScope
=
this
.
$scope
.
$new
();
modalScope
.
createUserGroup
=
this
.
createUserGroup
.
bind
(
this
);
this
.
$scope
.
appEvent
(
'show-modal'
,
{
src
:
'public/app/features/org/partials/create_user_group.html'
,
modalClass
:
'modal--narrow'
,
scope
:
modalScope
appEvents
.
emit
(
'show-modal'
,
{
templateHtml
:
'<create-user-group-modal></create-user-group-modal>'
,
modalClass
:
'modal--narrow'
});
}
}
...
...
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