Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
凌波微步_大先生
dashboard
提交
a511969a
D
dashboard
项目概览
凌波微步_大先生
/
dashboard
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dashboard
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
a511969a
编写于
12月 14, 2015
作者:
P
Piotr Bryk
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #163 from bryk/move-namespace-select
Move namespace select to deploy from settings
上级
3e91d830
b13140a0
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
140 addition
and
123 deletion
+140
-123
src/app/frontend/deploy/deploy.html
src/app/frontend/deploy/deploy.html
+1
-13
src/app/frontend/deploy/deploy_controller.js
src/app/frontend/deploy/deploy_controller.js
+18
-49
src/app/frontend/deploy/deployfromfile_directive.js
src/app/frontend/deploy/deployfromfile_directive.js
+0
-1
src/app/frontend/deploy/deployfromsettings.html
src/app/frontend/deploy/deployfromsettings.html
+43
-32
src/app/frontend/deploy/deployfromsettings_controller.js
src/app/frontend/deploy/deployfromsettings_controller.js
+61
-16
src/app/frontend/deploy/deployfromsettings_directive.js
src/app/frontend/deploy/deployfromsettings_directive.js
+1
-1
src/app/frontend/deploy/upload_controller.js
src/app/frontend/deploy/upload_controller.js
+9
-4
src/test/frontend/deploy/deploy_controller_test.js
src/test/frontend/deploy/deploy_controller_test.js
+3
-3
src/test/frontend/deploy/deployfromsettings_controller_test.js
...est/frontend/deploy/deployfromsettings_controller_test.js
+2
-2
src/test/frontend/deploy/deploylabel_controller_test.js
src/test/frontend/deploy/deploylabel_controller_test.js
+1
-1
src/test/integration/zerostate/zerostate_test.js
src/test/integration/zerostate/zerostate_test.js
+1
-1
未找到文件。
src/app/frontend/deploy/deploy.html
浏览文件 @
a511969a
...
...
@@ -33,26 +33,14 @@ limitations under the License.
<div
ng-switch=
"ctrl.selection"
>
<deploy-from-settings
ng-switch-when=
"Settings"
name=
"ctrl.name"
namespace
=
"ctrl.namespace
"
namespace
s=
"ctrl.namespaces
"
detail=
"ctrl.detail"
>
</deploy-from-settings>
<deploy-from-file
ng-switch-when=
"File"
name=
"ctrl.name"
namespace=
"ctrl.namespace"
detail=
"ctrl.detail"
>
</deploy-from-file>
</div>
<md-input-container
class=
"md-block"
>
<label>
Namespace
</label>
<md-select
ng-model=
"ctrl.namespace"
required
>
<md-option
ng-repeat=
"namespace in ctrl.namespaces"
ng-value=
"namespace"
>
{{namespace}}
</md-option>
<md-option
ng-click=
"ctrl.handleNamespaceDialog($event)"
>
Create a new namespace...
</md-option>
</md-select>
</md-input-container>
<md-button
class=
"md-raised md-primary"
type=
"submit"
ng-disabled=
"ctrl.isDeployDisabled()"
>
Deploy
</md-button>
...
...
src/app/frontend/deploy/deploy_controller.js
浏览文件 @
a511969a
...
...
@@ -13,7 +13,6 @@
// limitations under the License.
import
{
stateName
as
zerostate
}
from
'
zerostate/zerostate_state
'
;
import
showNamespaceDialog
from
'
deploy/createnamespace_dialog
'
;
/**
* Controller for the deploy view.
...
...
@@ -25,11 +24,10 @@ export default class DeployController {
* @param {!angular.$resource} $resource
* @param {!angular.$log} $log
* @param {!ui.router.$state} $state
* @param {!md.$dialog} $mdDialog
* @param {!backendApi.NamespaceList} namespaces
* @ngInject
*/
constructor
(
$resource
,
$log
,
$state
,
$mdDialog
,
namespaces
)
{
constructor
(
$resource
,
$log
,
$state
,
namespaces
)
{
/** @export {!angular.FormController} Initialized from the template */
this
.
deployForm
;
...
...
@@ -38,15 +36,26 @@ export default class DeployController {
/**
* List of available namespaces.
* TODO(bryk): Move this to deploy from settings directive. E.g., use activate method when
* switching to Angular 1.5.
* @export {!Array<string>}
*/
this
.
namespaces
=
namespaces
.
namespaces
;
/**
* Currently chosen namespace.
* @export {(string|undefined)}
* Contains the selected directive's controller which has its own deploy logic
*
* Initialized from the template.
* @export {{deploy:function()}|undefined}
*/
this
.
detail
;
/**
* Child directive selection model. The list of possible values is in template. This value
* represents the default selection.
* @export {string}
*/
this
.
namespace
=
this
.
namespaces
.
length
>
0
?
this
.
namespaces
[
0
]
:
undefined
;
this
.
selection
=
"
Settings
"
;
/** @private {!angular.$resource} */
this
.
resource_
=
$resource
;
...
...
@@ -57,25 +66,8 @@ export default class DeployController {
/** @private {!ui.router.$state} */
this
.
state_
=
$state
;
/** @private {!md.$dialog} */
this
.
mdDialog_
=
$mdDialog
;
/** @private {boolean} */
this
.
isDeployInProgress_
=
false
;
/**
* Contains the selected directive's controller which has its own deploy logic
*
* @export {{deploy:function()}}
*/
this
.
detail
=
{
deploy
:
function
()
{}};
/**
* Child directive selection model. The list of possible values is in template. This value
* represents the default selection.
* @export {string}
*/
this
.
selection
=
"
Settings
"
;
}
/**
...
...
@@ -87,37 +79,14 @@ export default class DeployController {
this
.
detail
.
deploy
().
finally
(()
=>
{
this
.
isDeployInProgress_
=
false
;
});
}
/**
* Displays new namespace creation dialog.
* @param {!angular.Scope.Event} event
* @export
*/
handleNamespaceDialog
(
event
)
{
showNamespaceDialog
(
this
.
mdDialog_
,
event
,
this
.
namespaces
)
.
then
(
/**
* Handles namespace dialog result. If namespace was created successfully then it
* will be selected, otherwise first namespace will be selected.
*
* @param {string|undefined} answer
*/
(
answer
)
=>
{
if
(
answer
)
{
this
.
namespace
=
answer
;
this
.
namespaces
=
this
.
namespaces
.
concat
(
answer
);
}
else
{
this
.
namespace
=
this
.
namespaces
[
0
];
}
},
()
=>
{
this
.
namespace
=
this
.
namespaces
[
0
];
});
}
/**
* Returns true when the deploy action should be enabled.
* @return {boolean}
* @export
*/
isDeployDisabled
()
{
return
this
.
isDeployInProgress_
||
this
.
deployForm
.
$invalid
;
}
isDeployDisabled
()
{
return
this
.
isDeployInProgress_
||
this
.
deployForm
.
$invalid
||
!
this
.
detail
;
}
/**
* Cancels the deployment form.
...
...
src/app/frontend/deploy/deployfromfile_directive.js
浏览文件 @
a511969a
...
...
@@ -19,7 +19,6 @@ export default function deployFromFileDirective() {
scope
:
{},
bindToController
:
{
'
name
'
:
'
=
'
,
'
namespace
'
:
'
=
'
,
'
detail
'
:
'
=
'
,
},
controller
:
DeployFromFileController
,
...
...
src/app/frontend/deploy/deployfromsettings.html
浏览文件 @
a511969a
...
...
@@ -15,47 +15,58 @@ limitations under the License.
-->
<md-input-container
class=
"md-block"
>
<label>
Container image
</label>
<input
ng-model=
"ctrl.containerImage"
required
>
<label>
Container image
</label>
<input
ng-model=
"ctrl.containerImage"
required
>
</md-input-container>
<md-input-container
class=
"md-block"
>
<label>
Number of pods
</label>
<input
ng-model=
"ctrl.replicas"
type=
"number"
required
min=
"1"
>
<label>
Number of pods
</label>
<input
ng-model=
"ctrl.replicas"
type=
"number"
required
min=
"1"
>
</md-input-container>
<div
layout=
"row"
ng-repeat=
"portMapping in ctrl.portMappings"
>
<md-input-container
flex
>
<label>
Port
</label>
<input
ng-model=
"portMapping.port"
type=
"number"
min=
"0"
>
</md-input-container>
<md-input-container
flex
>
<label>
Target port
</label>
<input
ng-model=
"portMapping.targetPort"
type=
"number"
min=
"0"
>
</md-input-container>
<md-input-container
flex=
"none"
>
<label>
Protocol
</label>
<md-select
ng-model=
"portMapping.protocol"
required
>
<md-option
ng-repeat=
"protocol in ctrl.protocols"
ng-value=
"protocol"
>
{{protocol}}
</md-option>
</md-select>
</md-input-container>
<md-input-container
flex
>
<label>
Port
</label>
<input
ng-model=
"portMapping.port"
type=
"number"
min=
"0"
>
</md-input-container>
<md-input-container
flex
>
<label>
Target port
</label>
<input
ng-model=
"portMapping.targetPort"
type=
"number"
min=
"0"
>
</md-input-container>
<md-input-container
flex=
"none"
>
<label>
Protocol
</label>
<md-select
ng-model=
"portMapping.protocol"
required
>
<md-option
ng-repeat=
"protocol in ctrl.protocols"
ng-value=
"protocol"
>
{{protocol}}
</md-option>
</md-select>
</md-input-container>
</div>
<md-switch
ng-model=
"ctrl.isExternal"
class=
"md-primary"
>
Expose service externally
Expose service externally
</md-switch>
<md-input-container>
<label>
Description (optional)
</label>
<textarea
ng-model=
"ctrl.description"
></textarea>
<label>
Description (optional)
</label>
<textarea
ng-model=
"ctrl.description"
></textarea>
</md-input-container>
<div>
<div>
Labels (optional)
</div>
<div
layout=
"column"
>
<div
layout=
"row"
>
<p
flex
>
Key
</p>
<p
flex
>
Value
</p>
</div>
<div
ng-repeat=
"label in ctrl.labels"
>
<kd-label
layout=
"row"
flex
label=
"label"
labels=
"ctrl.labels"
></kd-label>
</div>
<div>
Labels (optional)
</div>
<div
layout=
"column"
>
<div
layout=
"row"
>
<p
flex
>
Key
</p>
<p
flex
>
Value
</p>
</div>
<div
ng-repeat=
"label in ctrl.labels"
>
<kd-label
layout=
"row"
flex
label=
"label"
labels=
"ctrl.labels"
></kd-label>
</div>
</div>
</div>
<md-input-container
class=
"md-block"
>
<label>
Namespace
</label>
<md-select
ng-model=
"ctrl.namespace"
required
>
<md-option
ng-repeat=
"namespace in ctrl.namespaces"
ng-value=
"namespace"
>
{{namespace}}
</md-option>
<md-option
ng-click=
"ctrl.handleNamespaceDialog($event)"
>
Create a new namespace...
</md-option>
</md-select>
</md-input-container>
src/app/frontend/deploy/deployfromsettings_controller.js
浏览文件 @
a511969a
...
...
@@ -12,12 +12,13 @@
// See the License for the specific language governing permissions and
// limitations under the License.
import
showNamespaceDialog
from
'
./createnamespace_dialog
'
;
import
DeployLabel
from
'
./deploylabel
'
;
import
{
stateName
as
replicasetliststate
}
from
'
replicasetlist/replicasetlist_state
'
;
// Label keys for predefined labels
export
const
APP_LABEL_KEY
=
'
app
'
;
export
const
VERSION_LABEL_KEY
=
'
version
'
;
const
APP_LABEL_KEY
=
'
app
'
;
const
VERSION_LABEL_KEY
=
'
version
'
;
/**
* Controller for the deploy from settings directive.
...
...
@@ -30,9 +31,10 @@ export default class DeployFromSettingsController {
* @param {!ui.router.$state} $state
* @param {!angular.$resource} $resource
* @param {!angular.$q} $q
* @param {!md.$dialog} $mdDialog
* @ngInject
*/
constructor
(
$log
,
$state
,
$resource
,
$q
)
{
constructor
(
$log
,
$state
,
$resource
,
$q
,
$mdDialog
)
{
/**
* It initializes the scope output parameter
*
...
...
@@ -40,18 +42,6 @@ export default class DeployFromSettingsController {
*/
this
.
detail
=
this
;
/** @private {!angular.$q} */
this
.
q_
=
$q
;
/** @private {!angular.$resource} */
this
.
resource_
=
$resource
;
/** @private {!angular.$log} */
this
.
log_
=
$log
;
/** @private {!ui.router.$state} */
this
.
state_
=
$state
;
/** @export {string} */
this
.
containerImage
=
''
;
...
...
@@ -80,13 +70,42 @@ export default class DeployFromSettingsController {
new
DeployLabel
(
VERSION_LABEL_KEY
,
''
,
false
,
this
.
getContainerImageVersion_
.
bind
(
this
)),
new
DeployLabel
(),
];
/**
* List of available namespaces.
*
* Initialized from the scope.
* @export {!Array<string>}
*/
this
.
namespaces
;
/**
* Currently chosen namespace.
* @export {(string|undefined)}
*/
this
.
namespace
=
this
.
namespaces
.
length
>
0
?
this
.
namespaces
[
0
]
:
undefined
;
/** @private {!angular.$q} */
this
.
q_
=
$q
;
/** @private {!angular.$resource} */
this
.
resource_
=
$resource
;
/** @private {!angular.$log} */
this
.
log_
=
$log
;
/** @private {!ui.router.$state} */
this
.
state_
=
$state
;
/** @private {!md.$dialog} */
this
.
mdDialog_
=
$mdDialog
;
}
/**
* Deploys the application based on the state of the controller.
*
* @export
* @return {angular.$q.Promise}
* @export
*/
deploy
()
{
// TODO(bryk): Validate input data before sending to the server.
...
...
@@ -120,6 +139,32 @@ export default class DeployFromSettingsController {
return
defer
.
promise
;
}
/**
* Displays new namespace creation dialog.
*
* @param {!angular.Scope.Event} event
* @export
*/
handleNamespaceDialog
(
event
)
{
showNamespaceDialog
(
this
.
mdDialog_
,
event
,
this
.
namespaces
)
.
then
(
/**
* Handles namespace dialog result. If namespace was created successfully then it
* will be selected, otherwise first namespace will be selected.
*
* @param {string|undefined} answer
*/
(
answer
)
=>
{
if
(
answer
)
{
this
.
namespace
=
answer
;
this
.
namespaces
=
this
.
namespaces
.
concat
(
answer
);
}
else
{
this
.
namespace
=
this
.
namespaces
[
0
];
}
},
()
=>
{
this
.
namespace
=
this
.
namespaces
[
0
];
});
}
/**
* Converts array of DeployLabel to array of backend api label
* @param {!Array<!DeployLabel>} labels
...
...
src/app/frontend/deploy/deployfromsettings_directive.js
浏览文件 @
a511969a
...
...
@@ -23,7 +23,7 @@ export default function deployFromSettingsDirective() {
scope
:
{},
bindToController
:
{
'
name
'
:
'
=
'
,
'
namespace
'
:
'
=
'
,
'
namespace
s
'
:
'
=
'
,
'
detail
'
:
'
=
'
,
},
controller
:
DeployFromSettingsController
,
...
...
src/app/frontend/deploy/upload_controller.js
浏览文件 @
a511969a
...
...
@@ -26,12 +26,13 @@ export default class UploadController {
/**
* Browse file function which is defined by the clients.
*
* @private {Function} */
this
.
browseFileFunc_
=
function
()
{};
* Initialized from the registerBrowseFileFunction method.
* @private {(function())|undefined} */
this
.
browseFileFunc_
;
}
/**
* @param {
Function
} func
* @param {
function()
} func
* @export
*/
registerBrowseFileFunction
(
func
)
{
...
...
@@ -47,5 +48,9 @@ export default class UploadController {
*
* @export
*/
browseFile
()
{
this
.
browseFileFunc_
();
}
browseFile
()
{
if
(
this
.
browseFileFunc_
)
{
this
.
browseFileFunc_
();
}
}
}
src/test/frontend/deploy/deploy_controller_test.js
浏览文件 @
a511969a
...
...
@@ -28,10 +28,10 @@ describe('Deploy controller', () => {
beforeEach
(()
=>
{
angular
.
mock
.
module
(
deployModule
.
name
);
angular
.
mock
.
inject
((
$
resource
,
$log
,
$state
,
$mdDialog
,
$q
)
=>
{
angular
.
mock
.
inject
((
$
controller
,
$state
)
=>
{
state
=
$state
;
ctrl
=
new
DeployController
(
$resource
,
$log
,
state
,
$mdDialog
,
{
namespaces
:
[]});
settingsCtrl
=
new
DeployFromSettingController
(
$log
,
$state
,
$resource
,
$q
);
ctrl
=
$controller
(
DeployController
,
{
namespaces
:
[]});
settingsCtrl
=
$controller
(
DeployFromSettingController
,
{},
{
namespaces
:
[]}
);
});
// prepare and mock
...
...
src/test/frontend/deploy/deployfromsettings_controller_test.js
浏览文件 @
a511969a
...
...
@@ -22,8 +22,8 @@ describe('DeployFromSettings controller', () => {
beforeEach
(()
=>
{
angular
.
mock
.
module
(
deployModule
.
name
);
angular
.
mock
.
inject
((
$
log
,
$state
,
$resource
,
$q
)
=>
{
ctrl
=
new
DeployFromSettingController
(
$log
,
$state
,
$resource
,
$q
);
angular
.
mock
.
inject
((
$
controller
)
=>
{
ctrl
=
$controller
(
DeployFromSettingController
,
{},
{
namespaces
:
[]}
);
});
});
...
...
src/test/frontend/deploy/deploylabel_controller_test.js
浏览文件 @
a511969a
...
...
@@ -15,7 +15,7 @@
import
DeployLabelController
from
'
deploy/deploylabel_controller
'
;
import
DeployLabel
from
'
deploy/deploylabel
'
;
describe
(
'
Deploy
FromSettings
controller
'
,
()
=>
{
describe
(
'
Deploy
Label
controller
'
,
()
=>
{
let
ctrl
;
let
labelForm
;
...
...
src/test/integration/zerostate/zerostate_test.js
浏览文件 @
a511969a
...
...
@@ -18,7 +18,7 @@ describe('Zero state view', () => {
let
page
;
beforeEach
(()
=>
{
browser
.
get
(
'
/index.html
'
);
browser
.
get
(
'
/index.html
/#zerostate
'
);
page
=
new
PageObject
();
});
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录