Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
凌波微步_大先生
dashboard
提交
7d09144b
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,体验更适合开发者的 AI 搜索 >>
提交
7d09144b
编写于
1月 15, 2016
作者:
U
urcan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
file name validation before upload
上级
d5883b7a
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
99 addition
and
5 deletion
+99
-5
src/app/frontend/deploy/deploy.html
src/app/frontend/deploy/deploy.html
+1
-1
src/app/frontend/deploy/deployfromfile_controller.js
src/app/frontend/deploy/deployfromfile_controller.js
+2
-1
src/app/frontend/deploy/deployfromfile_directive.js
src/app/frontend/deploy/deployfromfile_directive.js
+2
-1
src/app/frontend/deploy/upload.html
src/app/frontend/deploy/upload.html
+6
-2
src/app/frontend/deploy/upload_controller.js
src/app/frontend/deploy/upload_controller.js
+18
-0
src/app/frontend/deploy/upload_directive.js
src/app/frontend/deploy/upload_directive.js
+1
-0
src/test/frontend/deploy/upload_controller_test.js
src/test/frontend/deploy/upload_controller_test.js
+69
-0
未找到文件。
src/app/frontend/deploy/deploy.html
浏览文件 @
7d09144b
...
...
@@ -34,7 +34,7 @@ limitations under the License.
<deploy-from-settings
ng-switch-when=
"Settings"
name=
"ctrl.name"
namespaces=
"ctrl.namespaces"
detail=
"ctrl.detail"
form=
"ctrl.deployForm"
>
</deploy-from-settings>
<deploy-from-file
ng-switch-when=
"File"
name=
"ctrl.name"
detail=
"ctrl.detail"
>
<deploy-from-file
ng-switch-when=
"File"
name=
"ctrl.name"
detail=
"ctrl.detail"
form=
"ctrl.deployForm"
>
</deploy-from-file>
</div>
...
...
src/app/frontend/deploy/deployfromfile_controller.js
浏览文件 @
7d09144b
...
...
@@ -30,7 +30,8 @@ export default class DeployFromFileController {
/**
* Custom file model for the selected file
*
* @export {{name:string, content:string}} */
* @export {{name:string, content:string}}
*/
this
.
file
=
{
name
:
''
,
content
:
''
};
}
}
src/app/frontend/deploy/deployfromfile_directive.js
浏览文件 @
7d09144b
...
...
@@ -19,9 +19,10 @@ export default function deployFromFileDirective() {
scope
:
{},
bindToController
:
{
'
detail
'
:
'
=
'
,
'
form
'
:
'
=
'
,
},
controller
:
DeployFromFileController
,
controllerAs
:
'
ctrl
'
,
template
:
'
<kd-upload file="ctrl.file"></kd-upload>
'
,
template
:
'
<kd-upload file="ctrl.file"
form="ctrl.form"
></kd-upload>
'
,
};
}
src/app/frontend/deploy/upload.html
浏览文件 @
7d09144b
...
...
@@ -17,10 +17,14 @@ limitations under the License.
<kd-help-section>
<div
layout=
"row"
layout-align=
"space-between start"
>
<div
flex
>
<md-input-container
class=
"md-block"
>
<md-input-container
class=
"md-block"
md-is-error=
"ctrl.isFileNameError()"
>
<label>
YAML or JSON file
</label>
<!--TODO: Browse file on focus doesn't work in Firefox. It is to be investigated.-->
<input
ng-model=
"ctrl.file.name"
ng-focus=
"ctrl.browseFile()"
ng-readonly=
"true"
/>
<input
ng-model=
"ctrl.file.name"
ng-focus=
"ctrl.browseFile()"
ng-readonly=
"true"
name=
"fileName"
required
/>
<ng-messages
for=
"ctrl.form.fileName.$error"
role=
"alert"
multiple
>
<ng-message
when=
"required"
>
File is required.
</ng-message>
</ng-message>
</ng-messages>
</md-input-container>
</div>
<md-button
type=
"button"
class=
"md-raised kd-upload-button"
ng-click=
"ctrl.browseFile()"
>
...
...
src/app/frontend/deploy/upload_controller.js
浏览文件 @
7d09144b
...
...
@@ -29,6 +29,12 @@ export default class UploadController {
* Initialized from the registerBrowseFileFunction method.
* @private {(function())|undefined} */
this
.
browseFileFunc_
;
/**
* Initialized from the scope.
* @export {!angular.FormController}
*/
this
.
form
;
}
/**
...
...
@@ -53,4 +59,16 @@ export default class UploadController {
this
.
browseFileFunc_
();
}
}
/**
* Used to deactivate the invalid file name report if the form is not submitted yet.
*
* @returns {boolean}
* @export
*/
isFileNameError
()
{
/** @type {!angular.NgModelController} */
let
fileName
=
this
.
form
[
'
fileName
'
];
return
this
.
form
.
$submitted
&&
fileName
.
$invalid
;
}
}
src/app/frontend/deploy/upload_directive.js
浏览文件 @
7d09144b
...
...
@@ -25,6 +25,7 @@ export default function uploadDirective() {
scope
:
{},
bindToController
:
{
'
file
'
:
'
=
'
,
'
form
'
:
'
=
'
,
},
controller
:
UploadController
,
controllerAs
:
'
ctrl
'
,
...
...
src/test/frontend/deploy/upload_controller_test.js
0 → 100644
浏览文件 @
7d09144b
// Copyright 2015 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
import
UploadController
from
'
deploy/upload_controller.js
'
;
describe
(
'
Upload Controller
'
,
()
=>
{
/** @type {!UploadController} */
let
ctrl
;
/** @type {!angular.FormController} */
let
form
;
beforeEach
(()
=>
{
angular
.
mock
.
inject
((
$controller
)
=>
{
form
=
{
$submitted
:
false
,
fileName
:
{
$invalid
:
false
,
$error
:
{
required
:
false
,
},
},
};
ctrl
=
$controller
(
UploadController
,
{
/* no locals */
},
{
form
:
form
});
});
});
it
(
'
should return false when the from is not submitted and there is no error
'
,
()
=>
{
// when
let
result
=
ctrl
.
isFileNameError
();
// then
expect
(
result
).
toEqual
(
false
);
});
it
(
'
should return false when the from is not submitted and there is an error
'
,
()
=>
{
// given
form
.
fileName
.
$error
.
required
=
true
;
// when
let
result
=
ctrl
.
isFileNameError
();
// then
expect
(
result
).
toEqual
(
false
);
});
it
(
'
should return true when the from is submitted and there is an error
'
,
()
=>
{
// given
form
.
fileName
.
$error
.
required
=
true
;
form
.
$submitted
=
true
;
// when
let
result
=
ctrl
.
isFileNameError
();
// then
expect
(
result
).
toEqual
(
false
);
});
});
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录