Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
zhangjian1949
apollo
提交
219aff4a
apollo
项目概览
zhangjian1949
/
apollo
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
apollo
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
219aff4a
编写于
6月 27, 2016
作者:
L
lepdou
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
用户模糊搜索 流程优化
上级
2f620e6f
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
231 addition
and
114 deletion
+231
-114
apollo-portal/src/main/resources/static/app/role.html
apollo-portal/src/main/resources/static/app/role.html
+4
-2
apollo-portal/src/main/resources/static/namespace.html
apollo-portal/src/main/resources/static/namespace.html
+21
-6
apollo-portal/src/main/resources/static/namespace/role.html
apollo-portal/src/main/resources/static/namespace/role.html
+8
-4
apollo-portal/src/main/resources/static/scripts/controller/NamespaceController.js
...esources/static/scripts/controller/NamespaceController.js
+105
-92
apollo-portal/src/main/resources/static/scripts/controller/role/AppRoleController.js
...urces/static/scripts/controller/role/AppRoleController.js
+5
-3
apollo-portal/src/main/resources/static/scripts/controller/role/NamespaceRoleController.js
...static/scripts/controller/role/NamespaceRoleController.js
+18
-7
apollo-portal/src/main/resources/static/scripts/directive.js
apollo-portal/src/main/resources/static/scripts/directive.js
+52
-0
apollo-portal/src/main/resources/static/scripts/services/UserService.js
...src/main/resources/static/scripts/services/UserService.js
+16
-0
apollo-portal/src/main/resources/static/views/component/user-selector.html
.../main/resources/static/views/component/user-selector.html
+2
-0
未找到文件。
apollo-portal/src/main/resources/static/app/role.html
浏览文件 @
219aff4a
...
...
@@ -7,6 +7,7 @@
<link
rel=
"stylesheet"
type=
"text/css"
href=
"../vendor/angular/angular-toastr-1.4.1.min.css"
>
<link
rel=
"stylesheet"
type=
"text/css"
media=
'all'
href=
"../vendor/angular/loading-bar.min.css"
>
<link
rel=
"stylesheet"
type=
"text/css"
href=
"../styles/common-style.css"
>
<link
rel=
"stylesheet"
type=
"text/css"
href=
"../vendor/select2/select2.min.css"
>
<title>
权限管理
</title>
</head>
...
...
@@ -37,9 +38,9 @@
<div
class=
"col-sm-8"
>
<form
class=
"form-inline"
ng-submit=
"assignMasterRoleToUser()"
>
<div
class=
"form-group"
>
<
input
type=
"text"
class=
"form-control"
placeholder=
"域账号"
required
ng-model=
"toAssignMasterRoleUser"
>
<
apollouserselector
apollo-id=
"userSelectWidgetId"
></apollouserselector
>
</div>
<button
type=
"submit"
class=
"btn btn-default"
>
添加
</button>
<button
type=
"submit"
class=
"btn btn-default"
style=
"margin-left: 20px;"
>
添加
</button>
</form>
<!-- Split button -->
<div
class=
"user-container"
>
...
...
@@ -88,6 +89,7 @@
<!--nicescroll-->
<script
src=
"../vendor/jquery.nicescroll.min.js"
></script>
<script
src=
"../vendor/select2/select2.min.js"
type=
"text/javascript"
></script>
<!--biz-->
<!--must import-->
<script
type=
"application/javascript"
src=
"../scripts/app.js"
></script>
...
...
apollo-portal/src/main/resources/static/namespace.html
浏览文件 @
219aff4a
...
...
@@ -32,15 +32,26 @@
</header>
<div
class=
"panel-body"
>
<form
class=
"form-horizontal"
ng-show=
"step == 1"
ng-submit=
"createNamespace()"
>
<div
class=
"row text-right"
style=
"padding-right: 20px;"
>
<div
class=
"btn-group btn-group-sm"
role=
"group"
aria-label=
"..."
>
<button
type=
"button"
class=
"btn btn-default"
ng-class=
"{active:type=='link'}"
ng-click=
"switchType('link')"
>
关联已存在的Namespace
</button>
<button
type=
"button"
class=
"btn btn-default"
ng-class=
"{active:type=='create'}"
ng-click=
"switchType('create')"
>
创建新的Namespace
</button>
</div>
</div>
<form
class=
"form-horizontal"
style=
"margin-top: 30px;"
ng-show=
"step == 1"
ng-submit=
"createNamespace()"
>
<div
class=
"form-group"
>
<label
class=
"col-sm-3 control-label"
>
应用ID
</label>
<div
class=
"col-sm-6"
ng-bind=
"appId"
>
<div
class=
"col-sm-6"
>
<label
ng-bind=
"appId"
></label>
</div>
</div>
<div
class=
"form-horizontal"
ng-show=
"type == 'link'"
>
<div
class=
"form-group"
>
<label
class=
"col-sm-3 control-label"
><apollorequiredfiled></apollorequiredfiled>
选择集群
</label>
<label
class=
"col-sm-3 control-label"
>
<apollorequiredfiled></apollorequiredfiled>
选择集群
</label>
<div
class=
"col-sm-6"
>
<apolloclusterselector
apollo-app-id=
"appId"
apollo-default-all-checked=
"true"
apollo-select=
"collectSelectedClusters"
></apolloclusterselector>
...
...
@@ -48,7 +59,9 @@
</div>
</div>
<div
class=
"form-group"
ng-show=
"type == 'create'"
>
<label
class=
"col-sm-3 control-label"
><apollorequiredfiled></apollorequiredfiled>
名称
</label>
<label
class=
"col-sm-3 control-label"
>
<apollorequiredfiled></apollorequiredfiled>
名称
</label>
<div
class=
"col-sm-4"
>
<div
class=
"input-group"
>
<span
class=
"input-group-addon"
ng-bind=
"appBaseInfo.namespacePrefix"
></span>
...
...
@@ -65,7 +78,9 @@
</div>
</div>
<div
class=
"form-group"
ng-show=
"type == 'link'"
>
<label
class=
"col-sm-3 control-label"
><apollorequiredfiled></apollorequiredfiled>
namespace
</label>
<label
class=
"col-sm-3 control-label"
>
<apollorequiredfiled></apollorequiredfiled>
namespace
</label>
<div
class=
"col-sm-4"
>
<select
id=
"namespaces"
>
<option></option>
...
...
@@ -75,7 +90,7 @@
<div
class=
"form-group"
>
<div
class=
"col-sm-offset-3 col-sm-10"
>
<button
type=
"submit"
class=
"btn btn-
default
"
>
提交
</button>
<button
type=
"submit"
class=
"btn btn-
primary
"
>
提交
</button>
</div>
</div>
</form>
...
...
apollo-portal/src/main/resources/static/namespace/role.html
浏览文件 @
219aff4a
...
...
@@ -7,6 +7,7 @@
<link
rel=
"stylesheet"
type=
"text/css"
href=
"../vendor/angular/angular-toastr-1.4.1.min.css"
>
<link
rel=
"stylesheet"
type=
"text/css"
media=
'all'
href=
"../vendor/angular/loading-bar.min.css"
>
<link
rel=
"stylesheet"
type=
"text/css"
href=
"../styles/common-style.css"
>
<link
rel=
"stylesheet"
type=
"text/css"
href=
"../vendor/select2/select2.min.css"
>
<title>
权限管理
</title>
</head>
...
...
@@ -37,9 +38,9 @@
<div
class=
"col-sm-8"
>
<form
class=
"form-inline"
ng-submit=
"assignRoleToUser('ModifyNamespace')"
>
<div
class=
"form-group"
>
<
input
type=
"text"
class=
"form-control"
placeholder=
"域账号"
required
ng-model=
"toAssignModifyNamespaceRoleUser"
>
<
apollouserselector
apollo-id=
"modifyRoleWidgetId"
></apollouserselector
>
</div>
<button
type=
"submit"
class=
"btn btn-default"
>
添加
</button>
<button
type=
"submit"
class=
"btn btn-default"
style=
"margin-left: 20px;"
>
添加
</button>
</form>
<!-- Split button -->
<div
class=
"user-container"
>
...
...
@@ -66,9 +67,10 @@
<div
class=
"col-sm-8"
>
<form
class=
"form-inline"
ng-submit=
"assignRoleToUser('ReleaseNamespace')"
>
<div
class=
"form-group"
>
<input
type=
"text"
class=
"form-control"
placeholder=
"域账号"
required
ng-model=
"toAssignReleaseNamespaceRoleUser"
>
<apollouserselector
apollo-id=
"releaseRoleWidgetId"
></apollouserselector>
</div>
<button
type=
"submit"
class=
"btn btn-default"
>
添加
</button>
<button
type=
"submit"
class=
"btn btn-default"
style=
"margin-left: 20px;"
>
添加
</button>
</form>
<!-- Split button -->
<div
style=
"margin-top: 15px;"
>
...
...
@@ -116,6 +118,8 @@
<!--nicescroll-->
<script
src=
"../vendor/jquery.nicescroll.min.js"
></script>
<script
src=
"../vendor/select2/select2.min.js"
type=
"text/javascript"
></script>
<!--biz-->
<!--must import-->
<script
type=
"application/javascript"
src=
"../scripts/app.js"
></script>
...
...
apollo-portal/src/main/resources/static/scripts/controller/NamespaceController.js
浏览文件 @
219aff4a
namespace_module
.
controller
(
"
LinkNamespaceController
"
,
[
'
$scope
'
,
'
$location
'
,
'
$window
'
,
'
toastr
'
,
'
AppService
'
,
'
AppUtil
'
,
'
NamespaceService
'
,
function
(
$scope
,
$location
,
$window
,
toastr
,
AppService
,
AppUtil
,
NamespaceService
)
{
[
'
$scope
'
,
'
$location
'
,
'
$window
'
,
'
toastr
'
,
'
AppService
'
,
'
AppUtil
'
,
'
NamespaceService
'
,
function
(
$scope
,
$location
,
$window
,
toastr
,
AppService
,
AppUtil
,
NamespaceService
)
{
var
params
=
AppUtil
.
parseParams
(
$location
.
$$url
);
$scope
.
appId
=
params
.
appid
;
$scope
.
type
=
params
.
type
;
var
params
=
AppUtil
.
parseParams
(
$location
.
$$url
);
$scope
.
appId
=
params
.
appid
;
$scope
.
type
=
params
.
type
;
$scope
.
step
=
1
;
$scope
.
step
=
1
;
NamespaceService
.
find_public_namespaces
().
then
(
function
(
result
)
{
var
publicNamespaces
=
[];
result
.
forEach
(
function
(
item
)
{
var
namespace
=
{};
namespace
.
id
=
item
.
name
;
namespace
.
text
=
item
.
name
;
publicNamespaces
.
push
(
namespace
);
});
$
(
'
#namespaces
'
).
select2
({
placeholder
:
'
请选择Namespace
'
,
width
:
'
100%
'
,
data
:
publicNamespaces
});
},
function
(
result
)
{
toastr
.
error
(
AppUtil
.
errorMsg
(
result
),
"
load public namespace error
"
);
});
NamespaceService
.
find_public_namespaces
().
then
(
function
(
result
)
{
var
publicNamespaces
=
[];
result
.
forEach
(
function
(
item
)
{
var
namespace
=
{};
namespace
.
id
=
item
.
name
;
namespace
.
text
=
item
.
name
;
publicNamespaces
.
push
(
namespace
);
});
$
(
'
#namespaces
'
).
select2
({
placeholder
:
'
请选择Namespace
'
,
width
:
'
100%
'
,
data
:
publicNamespaces
});
},
function
(
result
)
{
toastr
.
error
(
AppUtil
.
errorMsg
(
result
),
"
load public namespace error
"
);
});
AppService
.
load
(
$scope
.
appId
).
then
(
function
(
result
)
{
$scope
.
appBaseInfo
=
result
;
$scope
.
appBaseInfo
.
namespacePrefix
=
result
.
orgId
+
'
.
'
;
},
function
(
result
)
{
toastr
.
error
(
AppUtil
.
errorMsg
(
result
),
"
加载App信息出错
"
);
});
AppService
.
load
(
$scope
.
appId
).
then
(
function
(
result
)
{
$scope
.
appBaseInfo
=
result
;
$scope
.
appBaseInfo
.
namespacePrefix
=
result
.
orgId
+
'
.
'
;
},
function
(
result
)
{
toastr
.
error
(
AppUtil
.
errorMsg
(
result
),
"
加载App信息出错
"
);
});
$scope
.
appNamespace
=
{
appId
:
$scope
.
appId
,
name
:
''
,
comment
:
''
};
$scope
.
appNamespace
=
{
appId
:
$scope
.
appId
,
name
:
''
,
comment
:
''
};
$scope
.
concatNamespace
=
function
()
{
if
(
!
$scope
.
appBaseInfo
)
{
return
''
;
}
return
$scope
.
appBaseInfo
.
namespacePrefix
+
(
$scope
.
appNamespace
.
name
?
$scope
.
appNamespace
.
name
:
''
);
};
$scope
.
concatNamespace
=
function
()
{
if
(
!
$scope
.
appBaseInfo
)
{
return
''
;
}
return
$scope
.
appBaseInfo
.
namespacePrefix
+
(
$scope
.
appNamespace
.
name
?
$scope
.
appNamespace
.
name
:
''
);
};
var
selectedClusters
=
[];
$scope
.
collectSelectedClusters
=
function
(
data
)
{
selectedClusters
=
data
;
};
$scope
.
createNamespace
=
function
()
{
if
(
$scope
.
type
==
'
link
'
)
{
if
(
selectedClusters
.
length
==
0
)
{
toastr
.
warning
(
"
请选择集群
"
);
return
;
}
var
selectedClusters
=
[];
$scope
.
collectSelectedClusters
=
function
(
data
)
{
selectedClusters
=
data
;
};
$scope
.
createNamespace
=
function
()
{
if
(
$scope
.
type
==
'
link
'
)
{
if
(
selectedClusters
.
length
==
0
)
{
toastr
.
warning
(
"
请选择集群
"
);
return
;
}
if
(
$scope
.
namespaceType
==
1
)
{
var
selectedNamespaceName
=
$
(
'
#namespaces
'
).
select2
(
'
data
'
)[
0
].
id
;
if
(
!
selectedNamespaceName
)
{
toastr
.
warning
(
"
请选择Namespace
"
);
return
;
}
if
(
$scope
.
namespaceType
==
1
)
{
var
selectedNamespaceName
=
$
(
'
#namespaces
'
).
select2
(
'
data
'
)[
0
].
id
;
if
(
!
selectedNamespaceName
)
{
toastr
.
warning
(
"
请选择Namespace
"
);
return
;
}
$scope
.
namespaceName
=
selectedNamespaceName
;
}
$scope
.
namespaceName
=
selectedNamespaceName
;
}
var
namespaceCreationModels
=
[];
selectedClusters
.
forEach
(
function
(
cluster
)
{
namespaceCreationModels
.
push
({
env
:
cluster
.
env
,
namespace
:
{
appId
:
$scope
.
appId
,
clusterName
:
cluster
.
clusterName
,
namespaceName
:
$scope
.
namespaceName
}
});
});
NamespaceService
.
createNamespace
(
$scope
.
appId
,
namespaceCreationModels
)
.
then
(
function
(
result
)
{
toastr
.
success
(
"
创建成功
"
);
$scope
.
step
=
2
;
},
function
(
result
)
{
toastr
.
error
(
AppUtil
.
errorMsg
(
result
));
});
}
else
{
NamespaceService
.
createAppNamespace
(
$scope
.
appId
,
$scope
.
appNamespace
).
then
(
function
(
result
)
{
$scope
.
step
=
2
;
},
function
(
result
)
{
toastr
.
error
(
AppUtil
.
errorMsg
(
result
),
"
创建失败
"
);
});
}
var
namespaceCreationModels
=
[];
selectedClusters
.
forEach
(
function
(
cluster
)
{
namespaceCreationModels
.
push
({
env
:
cluster
.
env
,
namespace
:
{
appId
:
$scope
.
appId
,
clusterName
:
cluster
.
clusterName
,
namespaceName
:
$scope
.
namespaceName
}
});
});
NamespaceService
.
createNamespace
(
$scope
.
appId
,
namespaceCreationModels
)
.
then
(
function
(
result
)
{
toastr
.
success
(
"
创建成功
"
);
$scope
.
step
=
2
;
setInterval
(
function
()
{
$window
.
location
.
href
=
'
/namespace/role.html?#appid=
'
+
$scope
.
appId
+
"
&namespaceName=
"
+
$scope
.
namespaceName
;
},
1000
);
},
function
(
result
)
{
toastr
.
error
(
AppUtil
.
errorMsg
(
result
));
});
}
else
{
NamespaceService
.
createAppNamespace
(
$scope
.
appId
,
$scope
.
appNamespace
).
then
(
function
(
result
)
{
$scope
.
step
=
2
;
setInterval
(
function
()
{
$window
.
location
.
reload
();
},
1000
);
},
function
(
result
)
{
toastr
.
error
(
AppUtil
.
errorMsg
(
result
),
"
创建失败
"
);
});
}
};
};
$scope
.
namespaceType
=
1
;
$scope
.
selectNamespaceType
=
function
(
type
)
{
$scope
.
namespaceType
=
type
;
};
$scope
.
namespaceType
=
1
;
$scope
.
selectNamespaceType
=
function
(
type
)
{
$scope
.
namespaceType
=
type
;
};
$scope
.
back
=
function
()
{
$window
.
location
.
href
=
'
/config.html?#appid=
'
+
$scope
.
appId
;
};
}]);
$scope
.
back
=
function
()
{
$window
.
location
.
href
=
'
/config.html?#appid=
'
+
$scope
.
appId
;
};
$scope
.
switchType
=
function
(
type
)
{
$scope
.
type
=
type
;
};
}]);
apollo-portal/src/main/resources/static/scripts/controller/role/AppRoleController.js
浏览文件 @
219aff4a
...
...
@@ -7,6 +7,8 @@ role_module.controller('AppRoleController',
appId
:
params
.
appid
};
$scope
.
userSelectWidgetId
=
'
toAssignMasterRoleUser
'
;
PermissionService
.
has_assign_user_permission
(
$scope
.
pageContext
.
appId
)
.
then
(
function
(
result
)
{
$scope
.
hasAssignUserPermission
=
result
.
hasPermission
;
...
...
@@ -21,14 +23,14 @@ role_module.controller('AppRoleController',
});
$scope
.
toAssignMasterRoleUser
=
''
;
$scope
.
assignMasterRoleToUser
=
function
()
{
var
toAssignMasterRoleUser
=
$
(
'
.
'
+
$scope
.
userSelectWidgetId
).
select2
(
'
data
'
)[
0
].
id
;
PermissionService
.
assign_master_role
(
$scope
.
pageContext
.
appId
,
$scope
.
toAssignMasterRoleUser
)
toAssignMasterRoleUser
)
.
then
(
function
(
result
)
{
toastr
.
success
(
"
添加成功
"
);
$scope
.
appRoleUsers
.
masterUsers
.
push
({
userId
:
$scope
.
toAssignMasterRoleUser
});
$scope
.
appRoleUsers
.
masterUsers
.
push
({
userId
:
toAssignMasterRoleUser
});
},
function
(
result
)
{
toastr
.
error
(
AppUtil
.
errorMsg
(
result
),
"
添加失败
"
);
});
...
...
apollo-portal/src/main/resources/static/scripts/controller/role/NamespaceRoleController.js
浏览文件 @
219aff4a
role_module
.
controller
(
'
NamespaceRoleController
'
,
[
'
$scope
'
,
'
$location
'
,
'
$window
'
,
'
toastr
'
,
'
AppService
'
,
'
AppUtil
'
,
'
PermissionService
'
,
function
(
$scope
,
$location
,
$window
,
toastr
,
AppService
,
AppUtil
,
PermissionService
)
{
[
'
$scope
'
,
'
$location
'
,
'
$window
'
,
'
toastr
'
,
'
AppService
'
,
'
UserService
'
,
'
AppUtil
'
,
'
PermissionService
'
,
function
(
$scope
,
$location
,
$window
,
toastr
,
AppService
,
UserService
,
AppUtil
,
PermissionService
)
{
var
params
=
AppUtil
.
parseParams
(
$location
.
$$url
);
$scope
.
pageContext
=
{
appId
:
params
.
appid
,
namespaceName
:
params
.
namespaceName
};
$scope
.
releaseRoleWidgetId
=
'
releaseRoleWidgetId
'
;
$scope
.
modifyRoleWidgetId
=
'
modifyRoleWidgetId
'
;
PermissionService
.
has_assign_user_permission
(
$scope
.
pageContext
.
appId
)
.
then
(
function
(
result
)
{
...
...
@@ -24,26 +29,29 @@ role_module.controller('NamespaceRoleController',
toastr
.
error
(
AppUtil
.
errorMsg
(
result
),
"
加载授权用户出错
"
);
});
$scope
.
toAssignReleaseNamespaceRoleUser
=
''
,
$scope
.
toAssignModifyNamespaceRoleUser
=
''
;
$scope
.
assignRoleToUser
=
function
(
roleType
)
{
if
(
'
ReleaseNamespace
'
==
roleType
)
{
var
toAssignReleaseNamespaceRoleUser
=
$
(
'
.
'
+
$scope
.
releaseRoleWidgetId
).
select2
(
'
data
'
)[
0
].
id
;
PermissionService
.
assign_release_namespace_role
(
$scope
.
pageContext
.
appId
,
$scope
.
pageContext
.
namespaceName
,
$scope
.
toAssignReleaseNamespaceRoleUser
)
toAssignReleaseNamespaceRoleUser
)
.
then
(
function
(
result
)
{
toastr
.
success
(
"
添加成功
"
);
$scope
.
rolesAssignedUsers
.
releaseRoleUsers
.
push
({
userId
:
$scope
.
toAssignReleaseNamespaceRoleUser
});
$scope
.
rolesAssignedUsers
.
releaseRoleUsers
.
push
(
{
userId
:
toAssignReleaseNamespaceRoleUser
});
},
function
(
result
)
{
toastr
.
error
(
AppUtil
.
errorMsg
(
result
),
"
添加失败
"
);
});
}
else
{
var
toAssignModifyNamespaceRoleUser
=
$
(
'
.
'
+
$scope
.
modifyRoleWidgetId
).
select2
(
'
data
'
)[
0
].
id
;
PermissionService
.
assign_modify_namespace_role
(
$scope
.
pageContext
.
appId
,
$scope
.
pageContext
.
namespaceName
,
$scope
.
toAssignModifyNamespaceRoleUser
)
toAssignModifyNamespaceRoleUser
)
.
then
(
function
(
result
)
{
toastr
.
success
(
"
添加成功
"
);
$scope
.
rolesAssignedUsers
.
modifyRoleUsers
.
push
({
userId
:
$scope
.
toAssignModifyNamespaceRoleUser
});
$scope
.
rolesAssignedUsers
.
modifyRoleUsers
.
push
(
{
userId
:
toAssignModifyNamespaceRoleUser
});
},
function
(
result
)
{
toastr
.
error
(
AppUtil
.
errorMsg
(
result
),
"
添加失败
"
);
});
...
...
@@ -84,5 +92,8 @@ role_module.controller('NamespaceRoleController',
}
list
.
splice
(
index
,
1
);
}
$scope
.
modifyRoleUsersId
=
'
J_modify_role_users
'
;
$scope
.
releaseRoleUsersId
=
'
J_release_role_users
'
;
}]);
apollo-portal/src/main/resources/static/scripts/directive.js
浏览文件 @
219aff4a
...
...
@@ -258,3 +258,55 @@ directive_module.directive('apolloentrance', function ($compile, $window) {
});
/** entrance */
directive_module
.
directive
(
'
apollouserselector
'
,
function
(
$compile
,
$window
)
{
return
{
restrict
:
'
E
'
,
templateUrl
:
'
../views/component/user-selector.html
'
,
transclude
:
true
,
replace
:
true
,
scope
:
{
id
:
'
=apolloId
'
},
link
:
function
(
scope
,
element
,
attrs
)
{
scope
.
$watch
(
"
id
"
,
initSelect2
);
var
searchUsersAjax
=
{
ajax
:
{
url
:
'
/users
'
,
dataType
:
'
json
'
,
delay
:
250
,
data
:
function
(
params
)
{
return
{
keyword
:
params
.
term
?
params
.
term
:
''
,
limit
:
100
}
},
processResults
:
function
(
data
,
params
)
{
var
users
=
[];
data
.
forEach
(
function
(
user
)
{
users
.
push
({
id
:
user
.
userId
,
text
:
user
.
userId
+
"
|
"
+
user
.
name
+
"
|
"
+
user
.
email
})
});
return
{
results
:
users
}
},
cache
:
true
,
minimumInputLength
:
5
}
};
function
initSelect2
(){
$
(
'
.
'
+
scope
.
id
).
select2
(
searchUsersAjax
);
}
}
}
});
apollo-portal/src/main/resources/static/scripts/services/UserService.js
浏览文件 @
219aff4a
...
...
@@ -3,6 +3,10 @@ appService.service('UserService', ['$resource', '$q', function ($resource, $q) {
load_user
:{
method
:
'
GET
'
,
url
:
'
/user
'
},
find_users
:
{
method
:
'
GET
'
,
url
:
'
/users
'
}
});
return
{
...
...
@@ -16,6 +20,18 @@ appService.service('UserService', ['$resource', '$q', function ($resource, $q) {
d
.
reject
(
result
);
});
return
d
.
promise
;
},
find_users
:
function
(
keyword
)
{
var
d
=
$q
.
defer
();
user_resource
.
find_users
({
keyword
:
keyword
},
function
(
result
)
{
d
.
resolve
(
result
);
},
function
(
result
)
{
d
.
reject
(
result
);
});
return
d
.
promise
;
}
}
}]);
apollo-portal/src/main/resources/static/views/component/user-selector.html
0 → 100644
浏览文件 @
219aff4a
<select
class=
"{{id}}"
style=
"width: 450px;"
>
</select>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录