Commit 437026f3 authored by Jason Song's avatar Jason Song Committed by Jared Tan

add i18n support and English translations (#2641)

* init i18n support

* polish translations and fix some bugs introduced
parent f050e44d
......@@ -45,6 +45,7 @@ public class WebMvcConfig implements WebMvcConfigurer, WebServerFactoryCustomize
addCacheControl(registry, "scripts", 86400);
addCacheControl(registry, "styles", 86400);
addCacheControl(registry, "views", 86400);
addCacheControl(registry, "i18n", 86400);
}
private void addCacheControl(ResourceHandlerRegistry registry, String folder, int cachePeriod) {
......
......@@ -11,7 +11,7 @@ public class AppDTO extends BaseDTO{
@Pattern(
regexp = InputValidator.CLUSTER_NAMESPACE_VALIDATOR,
message = "AppId格式错误: " + InputValidator.INVALID_CLUSTER_NAMESPACE_MESSAGE
message = "Invalid AppId format: " + InputValidator.INVALID_CLUSTER_NAMESPACE_MESSAGE
)
private String appId;
......
......@@ -11,7 +11,7 @@ public class ClusterDTO extends BaseDTO{
@NotBlank(message = "cluster name cannot be blank")
@Pattern(
regexp = InputValidator.CLUSTER_NAMESPACE_VALIDATOR,
message = "Cluster格式错误: " + InputValidator.INVALID_CLUSTER_NAMESPACE_MESSAGE
message = "Invalid Cluster format: " + InputValidator.INVALID_CLUSTER_NAMESPACE_MESSAGE
)
private String name;
......
......@@ -12,7 +12,7 @@ public class NamespaceDTO extends BaseDTO{
@Pattern(
regexp = InputValidator.CLUSTER_NAMESPACE_VALIDATOR,
message = "Namespace格式错误: " + InputValidator.INVALID_CLUSTER_NAMESPACE_MESSAGE
message = "Invalid Namespace format: " + InputValidator.INVALID_CLUSTER_NAMESPACE_MESSAGE
)
private String namespaceName;
......
......@@ -22,7 +22,7 @@ public class AppNamespace extends BaseEntity {
@NotBlank(message = "AppNamespace Name cannot be blank")
@Pattern(
regexp = InputValidator.CLUSTER_NAMESPACE_VALIDATOR,
message = "Namespace格式错误: " + InputValidator.INVALID_CLUSTER_NAMESPACE_MESSAGE + " & " + InputValidator.INVALID_NAMESPACE_NAMESPACE_MESSAGE
message = "Invalid Namespace format: " + InputValidator.INVALID_CLUSTER_NAMESPACE_MESSAGE + " & " + InputValidator.INVALID_NAMESPACE_NAMESPACE_MESSAGE
)
@Column(name = "Name", nullable = false)
private String name;
......
......@@ -8,8 +8,8 @@ import java.util.regex.Pattern;
* @author Jason Song(song_s@ctrip.com)
*/
public class InputValidator {
public static final String INVALID_CLUSTER_NAMESPACE_MESSAGE = "只允许输入数字,字母和符号 - _ .";
public static final String INVALID_NAMESPACE_NAMESPACE_MESSAGE = "不允许以.json, .yml, .yaml, .xml, .properties结尾";
public static final String INVALID_CLUSTER_NAMESPACE_MESSAGE = "Only digits, alphabets and symbol - _ . are allowed";
public static final String INVALID_NAMESPACE_NAMESPACE_MESSAGE = "not allowed to end with .json, .yml, .yaml, .xml, .properties";
public static final String CLUSTER_NAMESPACE_VALIDATOR = "[0-9a-zA-Z_.-]+";
private static final String APP_NAMESPACE_VALIDATOR = "[a-zA-Z0-9._-]+(?<!\\.(json|yml|yaml|xml|properties))$";
private static final Pattern CLUSTER_NAMESPACE_PATTERN = Pattern.compile(CLUSTER_NAMESPACE_VALIDATOR);
......
......@@ -59,7 +59,7 @@ public class ClusterController {
if (!InputValidator.isValidClusterNamespace(clusterName)) {
throw new BadRequestException(
String.format("Cluster Name 格式错误: %s", InputValidator.INVALID_CLUSTER_NAMESPACE_MESSAGE));
String.format("Invalid ClusterName format: %s", InputValidator.INVALID_CLUSTER_NAMESPACE_MESSAGE));
}
if (userService.findByUserId(operator) == null) {
......
......@@ -68,7 +68,7 @@ public class NamespaceController {
appNamespaceDTO.getFormat(), appNamespaceDTO.getDataChangeCreatedBy());
if (!InputValidator.isValidAppNamespace(appNamespaceDTO.getName())) {
throw new BadRequestException(String.format("Namespace格式错误: %s",
throw new BadRequestException(String.format("Invalid Namespace format: %s",
InputValidator.INVALID_CLUSTER_NAMESPACE_MESSAGE + " & "
+ InputValidator.INVALID_NAMESPACE_NAMESPACE_MESSAGE));
}
......
......@@ -193,7 +193,7 @@ public class NamespaceController {
@RequestParam(defaultValue = "true") boolean appendNamespacePrefix,
@Valid @RequestBody AppNamespace appNamespace) {
if (!InputValidator.isValidAppNamespace(appNamespace.getName())) {
throw new BadRequestException(String.format("Namespace格式错误: %s",
throw new BadRequestException(String.format("Invalid Namespace format: %s",
InputValidator.INVALID_CLUSTER_NAMESPACE_MESSAGE + " & " + InputValidator.INVALID_NAMESPACE_NAMESPACE_MESSAGE));
}
......
......@@ -154,7 +154,7 @@ public class PermissionController {
Set<String> assignedUser = rolePermissionService.assignRoleToUsers(RoleUtils.buildNamespaceRoleName(appId, namespaceName, roleType, env),
Sets.newHashSet(user), userInfoHolder.getUser().getUserId());
if (CollectionUtils.isEmpty(assignedUser)) {
throw new BadRequestException(user + "已授权");
throw new BadRequestException(user + " already authorized");
}
return ResponseEntity.ok().build();
......@@ -209,7 +209,7 @@ public class PermissionController {
Set<String> assignedUser = rolePermissionService.assignRoleToUsers(RoleUtils.buildNamespaceRoleName(appId, namespaceName, roleType),
Sets.newHashSet(user), userInfoHolder.getUser().getUserId());
if (CollectionUtils.isEmpty(assignedUser)) {
throw new BadRequestException(user + "已授权");
throw new BadRequestException(user + " already authorized");
}
return ResponseEntity.ok().build();
......@@ -253,7 +253,7 @@ public class PermissionController {
Set<String> assignedUsers = rolePermissionService.assignRoleToUsers(RoleUtils.buildAppRoleName(appId, roleType),
Sets.newHashSet(user), userInfoHolder.getUser().getUserId());
if (CollectionUtils.isEmpty(assignedUsers)) {
throw new BadRequestException(user + "已授权");
throw new BadRequestException(user + " already authorized");
}
return ResponseEntity.ok().build();
......
......@@ -14,7 +14,7 @@ public class AppModel {
@NotBlank(message = "appId cannot be blank")
@Pattern(
regexp = InputValidator.CLUSTER_NAMESPACE_VALIDATOR,
message = "AppId格式错误: " + InputValidator.INVALID_CLUSTER_NAMESPACE_MESSAGE
message = "Invalid AppId format: " + InputValidator.INVALID_CLUSTER_NAMESPACE_MESSAGE
)
private String appId;
......
......@@ -271,7 +271,7 @@ public class AuthConfiguration {
http.csrf().disable();
http.headers().frameOptions().sameOrigin();
http.authorizeRequests()
.antMatchers("/prometheus/**","/metrics/**","/openapi/**", "/vendor/**", "/styles/**", "/scripts/**", "/views/**", "/img/**").permitAll()
.antMatchers("/prometheus/**","/metrics/**","/openapi/**", "/vendor/**", "/styles/**", "/scripts/**", "/views/**", "/img/**", "/i18n/**").permitAll()
.antMatchers("/**").hasAnyRole(USER_ROLE);
http.formLogin().loginPage("/signin").defaultSuccessUrl("/", true).permitAll().failureUrl("/signin?#/error").and()
.httpBasic();
......@@ -403,7 +403,7 @@ public class AuthConfiguration {
http.csrf().disable();
http.headers().frameOptions().sameOrigin();
http.authorizeRequests()
.antMatchers("/prometheus/**","/metrics/**","/openapi/**", "/vendor/**", "/styles/**", "/scripts/**", "/views/**", "/img/**").permitAll()
.antMatchers("/prometheus/**","/metrics/**","/openapi/**", "/vendor/**", "/styles/**", "/scripts/**", "/views/**", "/img/**", "/i18n/**").permitAll()
.antMatchers("/**").authenticated();
http.formLogin().loginPage("/signin").defaultSuccessUrl("/", true).permitAll().failureUrl("/signin?#/error").and()
.httpBasic();
......
......@@ -12,11 +12,11 @@ public class RelativeDateFormat {
private static final long ONE_HOUR = 3600000L;
private static final long ONE_DAY = 86400000L;
private static final String ONE_SECOND_AGO = "秒前";
private static final String ONE_MINUTE_AGO = "分钟前";
private static final String ONE_HOUR_AGO = "小时前";
private static final String ONE_DAY_AGO = "天前";
private static final String ONE_MONTH_AGO = "月前";
private static final String ONE_SECOND_AGO = " seconds ago";
private static final String ONE_MINUTE_AGO = " minutes ago";
private static final String ONE_HOUR_AGO = " hours ago";
private static final String ONE_DAY_AGO = " days ago";
private static final String ONE_MONTH_AGO = " months ago";
public static String format(Date date) {
if (date.after(new Date())) {
......@@ -39,11 +39,11 @@ public class RelativeDateFormat {
Date lastDayBeginTime = getDateOffset(-1);
if (date.after(lastDayBeginTime)) {
return "昨天";
return "yesterday";
}
Date lastTwoDaysBeginTime = getDateOffset(-2);
if (date.after(lastTwoDaysBeginTime)) {
return "前天";
return "the day before yesterday";
}
if (delta < 30L * ONE_DAY) {
long days = toDays(delta);
......
......@@ -10,7 +10,7 @@
<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">
<title>新建项目</title>
<title>{{'App.CreateProject' | translate }}</title>
</head>
<body>
......@@ -22,7 +22,7 @@
<div class="col-md-8 col-md-offset-2">
<div class="panel">
<header class="panel-heading">
创建项目
{{'App.CreateProject' | translate }}
</header>
<form class="form-horizontal panel-body" name="appForm" ng-controller="CreateAppController"
......@@ -31,7 +31,7 @@
<div class="form-group">
<label class="col-sm-3 control-label">
<apollorequiredfield></apollorequiredfield>
部门</label>
{{'Common.Department' | translate }}</label>
<div class="col-sm-3">
<select id="organization">
<option></option>
......@@ -41,43 +41,44 @@
<div class="form-group" valdr-form-group>
<label class="col-sm-3 control-label">
<apollorequiredfield></apollorequiredfield>
应用Id</label>
{{'Common.AppId' | translate }}</label>
<div class="col-sm-3">
<input type="text" class="form-control" name="appId" ng-model="app.appId">
<small>(应用唯一标识)</small>
<small>{{'App.AppIdTips' | translate }}
</small>
</div>
</div>
<div class="form-group" valdr-form-group>
<label class="col-sm-3 control-label">
<apollorequiredfield></apollorequiredfield>
应用名称</label>
{{'Common.AppName' | translate }}</label>
<div class="col-sm-5">
<input type="text" class="form-control" name="appName" ng-model="app.name">
<small>(建议格式 xx-yy-zz 例:apollo-server)</small>
<small>{{'App.AppNameTips' | translate }}</small>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">
<apollorequiredfield></apollorequiredfield>
应用负责人</label>
{{'Common.AppOwnerLong' | translate }}</label>
<div class="col-sm-6 J_ownerSelectorPanel">
<apollouserselector apollo-id="'ownerSelector'" disabled="isOpenManageAppMasterRoleLimit"></apollouserselector>
<small style="color: maroon" ng-if="isOpenManageAppMasterRoleLimit">(开启项目管理员分配权限控制后,应用负责人和项目管理员默认为本账号,不可选择)</small>
<small style="color: maroon" ng-if="isOpenManageAppMasterRoleLimit">{{'App.AppOwnerTips' | translate }}</small>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">项目管理员<br>
<label class="col-sm-3 control-label">{{'Common.AppAdmin' | translate }}<br>
</label>
<div class="col-sm-9 J_adminSelectorPanel">
<apollomultipleuserselector apollo-id="'adminSelector'" ng-disabled="isOpenManageAppMasterRoleLimit"></apollomultipleuserselector>
<br>
<small>(应用负责人默认具有项目管理员权限,</small>
<small>{{'App.AppAdminTips1' | translate }}</small>
<br>
<small>项目管理员可以创建Namespace和集群、分配用户权限)</small>
<small>{{'App.AppAdminTips2' | translate }}</small>
</div>
</div>
......@@ -86,7 +87,7 @@
<div class="col-sm-offset-3 col-sm-9">
<button type="submit" class="btn btn-primary"
ng-disabled="appForm.$invalid || submitBtnDisabled">提交
ng-disabled="appForm.$invalid || submitBtnDisabled">{{'Common.Submit' | translate }}
</button>
</div>
</div>
......@@ -104,6 +105,11 @@
<script src="vendor/angular/angular-resource.min.js"></script>
<script src="vendor/angular/angular-toastr-1.4.1.tpls.min.js"></script>
<script src="vendor/angular/loading-bar.min.js"></script>
<script src="vendor/angular/angular-cookies.min.js"></script>
<script src="vendor/angular/angular-translate.2.18.1/angular-translate.min.js"></script>
<script src="vendor/angular/angular-translate.2.18.1/angular-translate-loader-static-files.min.js"></script>
<script src="vendor/angular/angular-translate.2.18.1/angular-translate-storage-cookie.min.js"></script>
<!-- jquery.js -->
<script src="vendor/jquery.min.js" type="text/javascript"></script>
......
......@@ -9,7 +9,7 @@
<link rel="stylesheet" type="text/css" href="vendor/select2/select2.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">
<title>新建集群</title>
<title>{{'Cluster.CreateCluster' | translate }}</title>
</head>
<body>
......@@ -23,10 +23,10 @@
<header class="panel-heading">
<div class="row">
<div class="col-md-6">
<h4>创建集群</h4>
<h4>{{'Cluster.CreateCluster' | translate }}</h4>
</div>
<div class="col-md-6 text-right">
<a type="button" class="btn btn-info" href="/config.html?#/appid={{appId}}">返回到项目首页
<a type="button" class="btn btn-info" href="/config.html?#/appid={{appId}}">{{'Common.ReturnToIndex' | translate }}
</a>
</div>
</div>
......@@ -39,13 +39,10 @@
<div class="alert alert-info no-radius" role="alert">
<strong>Tips:</strong>
<ul>
<li>通过添加集群,可以使同一份程序在不同的集群(如不同的数据中心)使用不同的配置</li>
<li>如果不同集群使用一样的配置,则没有必要创建集群</li>
<li>
Apollo默认会读取机器上/opt/settings/server.properties(linux)或C:\opt\settings\server.properties(windows)文件中的idc属性作为集群名字,
如SHAJQ(金桥数据中心)、SHAOY(欧阳数据中心)
</li>
<li>在这里创建的集群名字需要和机器上server.properties中的idc属性一致</li>
<li>{{'Cluster.Tips.1' | translate }}</li>
<li>{{'Cluster.Tips.2' | translate }}</li>
<li>{{'Cluster.Tips.3' | translate }}</li>
<li>{{'Cluster.Tips.4' | translate }}</li>
</ul>
</div>
<form class="form-horizontal" name="clusterForm" valdr-type="Cluster" ng-show="step == 1"
......@@ -53,7 +50,7 @@
<div class="form-group">
<label class="col-sm-2 control-label">
<apollorequiredfield></apollorequiredfield>
应用AppId</label>
{{'Common.AppId' | translate }}</label>
<div class="col-sm-6">
<label class="form-control-static" ng-bind="appId"></label>
</div>
......@@ -61,16 +58,16 @@
<div class="form-group" valdr-form-group>
<label class="col-sm-2 control-label">
<apollorequiredfield></apollorequiredfield>
集群名称</label>
{{'Common.ClusterName' | translate }}</label>
<div class="col-sm-6">
<input type="text" class="form-control" name="clusterName" ng-model="clusterName">
<small>(部署集群如:SHAJQ,SHAOY 或自定义集群如:SHAJQ-xx,SHAJQ-yy)</small>
<small>{{'Cluster.CreateNameTips' | translate }}</small>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">
<apollorequiredfield></apollorequiredfield>
选择环境</label>
{{'Cluster.ChooseEnvironment' | translate }}</label>
<div class="col-sm-5">
<table class="table table-hover" style="width: 100px">
<tbody>
......@@ -89,14 +86,14 @@
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-primary"
ng-disabled="clusterForm.$invalid || submitBtnDisabled">提交
ng-disabled="clusterForm.$invalid || submitBtnDisabled">{{'Common.Submit' | translate }}
</button>
</div>
</div>
</form>
<div class="row text-center" ng-show="step == 2">
<img src="img/sync-succ.png" style="height: 100px; width: 100px">
<h3>创建成功!</h3>
<h3>{{'Common.Created' | translate }}!</h3>
</div>
</div>
</div>
......@@ -111,6 +108,11 @@
<script src="vendor/angular/angular-resource.min.js"></script>
<script src="vendor/angular/angular-toastr-1.4.1.tpls.min.js"></script>
<script src="vendor/angular/loading-bar.min.js"></script>
<script src="vendor/angular/angular-cookies.min.js"></script>
<script src="vendor/angular/angular-translate.2.18.1/angular-translate.min.js"></script>
<script src="vendor/angular/angular-translate.2.18.1/angular-translate-loader-static-files.min.js"></script>
<script src="vendor/angular/angular-translate.2.18.1/angular-translate-storage-cookie.min.js"></script>
<!-- jquery.js -->
<script src="vendor/jquery.min.js" type="text/javascript"></script>
......
This diff is collapsed.
This diff is collapsed.
<!doctype html>
<html ng-app="index">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="icon" href="./img/config.png">
......@@ -11,24 +12,25 @@
<link rel="stylesheet" type="text/css" media='all' href="vendor/font-awesome.min.css">
<link rel="stylesheet" type="text/css" href="styles/common-style.css">
<title>Apollo配置中心</title>
<title>{{'Common.Title' | translate }}</title>
</head>
<body>
<apollonav></apollonav>
<apollonav></apollonav>
<div id="app-list" class="hidden" ng-controller="IndexController">
<div id="app-list" class="hidden" ng-controller="IndexController">
<section class="media create-app-list">
<aside class="media-left text-center">
<h5>我的项目</h5>
<h5>{{'Index.MyProject' | translate }}</h5>
</aside>
<aside class="media-body">
<div class="app-panel col-md-2 text-center" ng-click="goToCreateAppPage()" ng-if="hasCreateApplicationPermission">
<div class="app-panel col-md-2 text-center" ng-click="goToCreateAppPage()"
ng-if="hasCreateApplicationPermission">
<div href="#" class="thumbnail create-btn hover cursor-pointer">
<img src="img/plus-white.png"/>
<h5>创建项目</h5>
<img src="img/plus-white.png" />
<h5>{{'Index.CreateProject' | translate }}</h5>
</div>
</div>
<div class="app-panel col-md-2 text-center" ng-repeat="app in createdApps"
......@@ -41,8 +43,8 @@
<div class="app-panel col-md-2 text-center" ng-show="hasMoreCreatedApps"
ng-click="getUserCreatedApps()">
<div href="#" class="thumbnail hover cursor-pointer">
<img class="more-img" src="img/more.png"/>
<h5>加载更多</h5>
<img class="more-img" src="img/more.png" />
<h5>{{'Index.LoadMore' | translate }}</h5>
</div>
</div>
</aside>
......@@ -50,39 +52,36 @@
<section class="media favorites-app-list">
<aside class="media-left text-center">
<h5>收藏的项目</h5>
<h5>{{'Index.FavoriteItems' | translate }}</h5>
</aside>
<aside class="media-body">
<div class="app-panel col-md-2 text-center"
ng-repeat="app in favorites"
ng-click="goToAppHomePage(app.appId)"
ng-mouseover="toggleOperationBtn(app)"
<div class="app-panel col-md-2 text-center" ng-repeat="app in favorites"
ng-click="goToAppHomePage(app.appId)" ng-mouseover="toggleOperationBtn(app)"
ng-mouseout="toggleOperationBtn(app)">
<div class="thumbnail hover">
<h4 ng-bind="app.appId"></h4>
<h5 ng-bind="app.name"></h5>
<p class="operate-panel" ng-show="app.showOperationBtn">
<button class="btn btn-default btn-xs" title="置顶"
<button class="btn btn-default btn-xs" title="{{'Index.Topping' | translate }}"
ng-click="toTop(app.favoriteId);$event.stopPropagation();">
<img src="img/top.png" class="i-15">
</button>
<button class="btn btn-default btn-xs" title="取消收藏"
<button class="btn btn-default btn-xs" title="{{'Index.FavoriteCancel' | translate }}"
ng-click="deleteFavorite(app.favoriteId);$event.stopPropagation();">
<img src="img/like.png" class="i-15">
</button>
</p>
</div>
</div>
<div class="col-md-2 text-center" ng-show="hasMoreFavorites"
ng-click="getUserFavorites()">
<div class="col-md-2 text-center" ng-show="hasMoreFavorites" ng-click="getUserFavorites()">
<div href="#" class="thumbnail hover cursor-pointer">
<img class="more-img" src="img/more.png"/>
<h5>加载更多</h5>
<img class="more-img" src="img/more.png" />
<h5>{{'Index.LoadMore' | translate }}</h5>
</div>
</div>
<div class="no-favorites text-center" ng-show="!favorites || favorites.length == 0">
<h4>您还没有收藏过任何项目,在项目主页可以收藏项目哟~</h4>
<h4>{{'Index.FavoriteTip' | translate }}</h4>
</div>
</aside>
......@@ -90,11 +89,10 @@
<section class="media visit-app-list" ng-show="visitedApps && visitedApps.length">
<aside class="media-left text-center">
<h5>最近浏览的项目</h5>
<h5>{{'Index.RecentlyViewedItems' | translate }}</h5>
</aside>
<aside class="media-body">
<div class="app-panel col-md-2 text-center"
ng-repeat="app in visitedApps"
<div class="app-panel col-md-2 text-center" ng-repeat="app in visitedApps"
ng-click="goToAppHomePage(app.appId)">
<div class="thumbnail hover">
<h4 ng-bind="app.appId"></h4>
......@@ -103,35 +101,41 @@
</div>
</aside>
</section>
</div>
</div>
<div ng-include="'views/common/footer.html'"></div>
<div ng-include="'views/common/footer.html'"></div>
<!--angular-->
<script src="vendor/angular/angular.min.js"></script>
<script src="vendor/angular/angular-resource.min.js"></script>
<script src="vendor/angular/angular-toastr-1.4.1.tpls.min.js"></script>
<script src="vendor/angular/loading-bar.min.js"></script>
<!--angular-->
<script src="vendor/angular/angular.min.js"></script>
<script src="vendor/angular/angular-resource.min.js"></script>
<script src="vendor/angular/angular-toastr-1.4.1.tpls.min.js"></script>
<script src="vendor/angular/loading-bar.min.js"></script>
<script src="vendor/angular/angular-cookies.min.js"></script>
<!-- jquery.js -->
<script src="vendor/jquery.min.js" type="text/javascript"></script>
<script src="vendor/select2/select2.min.js" type="text/javascript"></script>
<script src="vendor/angular/angular-translate.2.18.1/angular-translate.min.js"></script>
<script src="vendor/angular/angular-translate.2.18.1/angular-translate-loader-static-files.min.js"></script>
<script src="vendor/angular/angular-translate.2.18.1/angular-translate-storage-cookie.min.js"></script>
<!-- bootstrap.js -->
<script src="vendor/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
<!-- jquery.js -->
<script src="vendor/jquery.min.js" type="text/javascript"></script>
<script src="vendor/select2/select2.min.js" type="text/javascript"></script>
<script type="application/javascript" src="scripts/app.js"></script>
<script type="application/javascript" src="scripts/services/AppService.js"></script>
<script type="application/javascript" src="scripts/services/EnvService.js"></script>
<script type="application/javascript" src="scripts/services/UserService.js"></script>
<script type="application/javascript" src="scripts/services/CommonService.js"></script>
<script type="application/javascript" src="scripts/services/FavoriteService.js"></script>
<script type="application/javascript" src="scripts/services/PermissionService.js"></script>
<script type="application/javascript" src="scripts/AppUtils.js"></script>
<script type="application/javascript" src="scripts/directive/directive.js"></script>
<!-- bootstrap.js -->
<script src="vendor/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
<script type="application/javascript" src="scripts/controller/IndexController.js"></script>
<script type="application/javascript" src="scripts/app.js"></script>
<script type="application/javascript" src="scripts/services/AppService.js"></script>
<script type="application/javascript" src="scripts/services/EnvService.js"></script>
<script type="application/javascript" src="scripts/services/UserService.js"></script>
<script type="application/javascript" src="scripts/services/CommonService.js"></script>
<script type="application/javascript" src="scripts/services/FavoriteService.js"></script>
<script type="application/javascript" src="scripts/services/PermissionService.js"></script>
<script type="application/javascript" src="scripts/AppUtils.js"></script>
<script type="application/javascript" src="scripts/directive/directive.js"></script>
<script type="application/javascript" src="scripts/controller/IndexController.js"></script>
</body>
</html>
\ No newline at end of file
......@@ -2,7 +2,7 @@
<html lang="en" ng-app="login">
<head>
<meta charset="UTF-8">
<title>Apollo配置中心</title>
<title>{{ 'Common.Title' | translate }}</title>
<link rel="icon" href="./img/config.png">
<link rel="stylesheet" type="text/css" href="vendor/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="vendor/font-awesome.min.css">
......@@ -257,7 +257,7 @@
</div>
<div class="col-xs-12 form-group pull-right">
<input type="submit" name="login-submit" id="login-submit" tabindex="4"
class="form-control btn btn-login" value="登录">
class="form-control btn btn-login" value="{{'Login.Login' | translate }}">
</div>
</form>
</div>
......@@ -277,6 +277,11 @@
<script src="vendor/angular/angular-resource.min.js"></script>
<script src="vendor/angular/angular-toastr-1.4.1.tpls.min.js"></script>
<script src="vendor/angular/loading-bar.min.js"></script>
<script src="vendor/angular/angular-cookies.min.js"></script>
<script src="vendor/angular/angular-translate.2.18.1/angular-translate.min.js"></script>
<script src="vendor/angular/angular-translate.2.18.1/angular-translate-loader-static-files.min.js"></script>
<script src="vendor/angular/angular-translate.2.18.1/angular-translate-storage-cookie.min.js"></script>
<script type="application/javascript" src="scripts/app.js"></script>
<script type="application/javascript" src="scripts/AppUtils.js"></script>
......
appUtil.service('AppUtil', ['toastr', '$window', '$q', function (toastr, $window, $q) {
appUtil.service('AppUtil', ['toastr', '$window', '$q', '$translate', function (toastr, $window, $q, $translate) {
function parseErrorMsg(response) {
if (response.status == -1) {
return "您的登录信息已过期,请刷新页面后重试";
return $translate.instant('Common.LoginExpiredTips');
}
var msg = "Code:" + response.status;
if (response.data.message != null) {
......@@ -13,7 +13,7 @@ appUtil.service('AppUtil', ['toastr', '$window', '$q', function (toastr, $window
function parsePureErrorMsg(response) {
if (response.status == -1) {
return "您的登录信息已过期,请刷新页面后重试";
return $translate.instant('Common.LoginExpiredTips');
}
if (response.data.message != null) {
return response.data.message;
......@@ -92,7 +92,7 @@ appUtil.service('AppUtil', ['toastr', '$window', '$q', function (toastr, $window
hideModal: function (modal) {
$(modal).modal("hide");
},
checkIPV4:function (ip) {
checkIPV4: function (ip) {
return /^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$|^(([a-zA-Z]|[a-zA-Z][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z]|[A-Za-z][A-Za-z0-9\-]*[A-Za-z0-9])$|^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$/.test(ip);
}
}
......
/**utils*/
var appUtil = angular.module('app.util', ['toastr']);
var appUtil = angular.module('app.util', ['toastr', 'ngCookies', 'pascalprecht.translate'])
.config(['$translateProvider', function ($translateProvider) {
$translateProvider.useSanitizeValueStrategy(null); // disable sanitization by default
$translateProvider.useCookieStorage();
$translateProvider.useStaticFilesLoader({
prefix: '/i18n/',
suffix: '.json'
});
$translateProvider.registerAvailableLanguageKeys(['en', 'zh-CN'], {
'zh-*': 'zh-CN',
'zh': 'zh-CN',
'en-*': 'en',
"*": "en"
})
$translateProvider.uniformLanguageTag('bcp47').determinePreferredLanguage();
}]);
/**service module 定义*/
var appService = angular.module('app.service', ['ngResource']);
var appService = angular.module('app.service', ['ngResource', 'app.util'])
/** directive */
var directive_module = angular.module('apollo.directive', ['app.service', 'app.util', 'toastr']);
var directive_module = angular.module('apollo.directive', ['app.service', 'app.util', 'toastr', 'pascalprecht.translate']);
/** page module 定义*/
// 首页
var index_module = angular.module('index', ['toastr', 'app.service', 'apollo.directive', 'app.util', 'angular-loading-bar']);
var index_module = angular.module('index', ['toastr', 'app.service', 'apollo.directive', 'app.util', 'angular-loading-bar', 'pascalprecht.translate']);
//项目主页
var application_module = angular.module('application', ['app.service', 'apollo.directive', 'app.util', 'toastr', 'angular-loading-bar', 'valdr', 'ui.ace']);
var application_module = angular.module('application', ['app.service', 'apollo.directive', 'app.util', 'toastr', 'angular-loading-bar', 'valdr', 'ui.ace', 'ngSanitize']);
//创建项目页面
var app_module = angular.module('create_app', ['apollo.directive', 'toastr', 'app.service', 'app.util', 'angular-loading-bar', 'valdr']);
var app_module = angular.module('create_app', ['apollo.directive', 'toastr', 'app.service', 'app.util', 'angular-loading-bar', 'valdr','pascalprecht.translate']);
//配置同步页面
var sync_item_module = angular.module('sync_item', ['app.service', 'apollo.directive', 'app.util', 'toastr', 'angular-loading-bar']);
// 比较页面
......@@ -27,7 +43,7 @@ var setting_module = angular.module('setting', ['app.service', 'apollo.directive
//role
var role_module = angular.module('role', ['app.service', 'apollo.directive', 'app.util', 'toastr', 'angular-loading-bar']);
//cluster
var cluster_module = angular.module('cluster', ['app.service', 'apollo.directive', 'app.util', 'toastr', 'angular-loading-bar' , 'valdr']);
var cluster_module = angular.module('cluster', ['app.service', 'apollo.directive', 'app.util', 'toastr', 'angular-loading-bar', 'valdr']);
//release history
var release_history_module = angular.module('release_history', ['app.service', 'apollo.directive', 'app.util', 'toastr', 'angular-loading-bar']);
//open manage
......@@ -35,7 +51,7 @@ var open_manage_module = angular.module('open_manage', ['app.service', 'apollo.d
//user
var user_module = angular.module('user', ['apollo.directive', 'toastr', 'app.service', 'app.util', 'angular-loading-bar', 'valdr']);
//login
var login_module = angular.module('login', ['toastr', 'app.util']);
var login_module = angular.module('login', ['app.service', 'toastr', 'app.util', 'pascalprecht.translate']);
//delete app cluster namespace
var delete_app_cluster_namespace_module = angular.module('delete_app_cluster_namespace', ['app.service', 'apollo.directive', 'app.util', 'toastr', 'angular-loading-bar']);
//system info
......
app_module.controller('CreateAppController',
['$scope', '$window', 'toastr', 'AppService', 'AppUtil', 'OrganizationService','SystemRoleService','UserService',
['$scope', '$window', '$translate', 'toastr', 'AppService', 'AppUtil', 'OrganizationService', 'SystemRoleService', 'UserService',
createAppController]);
function createAppController($scope, $window, toastr, AppService, AppUtil, OrganizationService, SystemRoleService, UserService) {
function createAppController($scope, $window, $translate, toastr, AppService, AppUtil, OrganizationService, SystemRoleService, UserService) {
$scope.app = {};
$scope.submitBtnDisabled = false;
......@@ -27,7 +27,7 @@ function createAppController($scope, $window, toastr, AppService, AppUtil, Organ
organizations.push(org);
});
$('#organization').select2({
placeholder: '请选择部门',
placeholder: $translate.instant('Common.PleaseChooseDepartment'),
width: '100%',
data: organizations
});
......@@ -60,7 +60,7 @@ function createAppController($scope, $window, toastr, AppService, AppUtil, Organ
var selectedOrg = $('#organization').select2('data')[0];
if (!selectedOrg.id) {
toastr.warning("请选择部门");
toastr.warning($translate.instant('Common.PleaseChooseDepartment'));
$scope.submitBtnDisabled = false;
return;
}
......@@ -71,10 +71,10 @@ function createAppController($scope, $window, toastr, AppService, AppUtil, Organ
// owner
var owner = $('.ownerSelector').select2('data')[0];
if ($scope.isOpenManageAppMasterRoleLimit) {
owner = {id: $scope.currentUser.userId};
owner = { id: $scope.currentUser.userId };
}
if (!owner) {
toastr.warning("请选择应用负责人");
toastr.warning($translate.instant('Common.PleaseChooseOwner'));
$scope.submitBtnDisabled = false;
return;
}
......@@ -84,7 +84,7 @@ function createAppController($scope, $window, toastr, AppService, AppUtil, Organ
$scope.app.admins = [];
var admins = $(".adminSelector").select2('data');
if ($scope.isOpenManageAppMasterRoleLimit) {
admins = [{id: $scope.currentUser.userId}];
admins = [{ id: $scope.currentUser.userId }];
}
if (admins) {
admins.forEach(function (admin) {
......@@ -93,14 +93,14 @@ function createAppController($scope, $window, toastr, AppService, AppUtil, Organ
}
AppService.create($scope.app).then(function (result) {
toastr.success('创建成功!');
toastr.success($translate.instant('Common.Created'));
setInterval(function () {
$scope.submitBtnDisabled = false;
$window.location.href = '/config.html?#appid=' + result.appId;
}, 1000);
}, function (result) {
$scope.submitBtnDisabled = false;
toastr.error(AppUtil.errorMsg(result), '创建失败!');
toastr.error(AppUtil.errorMsg(result), $translate.instant('Common.CreateFailed'));
});
}
......
cluster_module.controller('ClusterController',
['$scope', '$location', '$window', 'toastr', 'AppService', 'EnvService', 'ClusterService',
['$scope', '$location', '$window', '$translate', 'toastr', 'AppService', 'EnvService', 'ClusterService',
'AppUtil',
function ($scope, $location, $window, toastr, AppService, EnvService, ClusterService,
function ($scope, $location, $window, $translate, toastr, AppService, EnvService, ClusterService,
AppUtil) {
var params = AppUtil.parseParams($location.$$url);
......@@ -14,12 +14,12 @@ cluster_module.controller('ClusterController',
EnvService.find_all_envs().then(function (result) {
$scope.envs = [];
result.forEach(function (env) {
$scope.envs.push({name: env, checked: false});
$scope.envs.push({ name: env, checked: false });
});
$(".apollo-container").removeClass("hidden");
}, function (result) {
toastr.error(AppUtil.errorMsg(result), "加载环境信息出错");
toastr.error(AppUtil.errorMsg(result), $translate.instant('Cluster.LoadingEnvironmentError'));
});
$scope.clusterName = '';
......@@ -45,18 +45,18 @@ cluster_module.controller('ClusterController',
name: $scope.clusterName,
appId: $scope.appId
}).then(function (result) {
toastr.success(env.name, "集群创建成功");
toastr.success(env.name, $translate.instant('Cluster.ClusterCreated'));
$scope.step = 2;
$scope.submitBtnDisabled = false;
}, function (result) {
toastr.error(AppUtil.errorMsg(result), "集群创建失败");
toastr.error(AppUtil.errorMsg(result), $translate.instant('Cluster.ClusterCreateFailed'));
$scope.submitBtnDisabled = false;
})
}
});
if (noEnvChecked){
toastr.warning("请选择环境");
if (noEnvChecked) {
toastr.warning($translate.instant('Cluster.PleaseChooseEnvironment'));
}
};
......
index_module.controller('IndexController', ['$scope', '$window', 'toastr', 'AppUtil', 'AppService',
index_module.controller('IndexController', ['$scope', '$window', '$translate', 'toastr', 'AppUtil', 'AppService',
'UserService', 'FavoriteService',
IndexController]);
function IndexController($scope, $window, toastr, AppUtil, AppService, UserService, FavoriteService) {
function IndexController($scope, $window, $translate, toastr, AppUtil, AppService, UserService, FavoriteService) {
$scope.userId = '';
......@@ -21,7 +21,7 @@ function IndexController($scope, $window, toastr, AppUtil, AppService, UserServi
$scope.hasCreateApplicationPermission = value.hasCreateApplicationPermission;
},
function (reason) {
toastr.warning(AppUtil.errorMsg(reason), "获取创建应用权限信息失败");
toastr.warning(AppUtil.errorMsg(reason), $translate.instant('Index.GetCreateAppRoleFailed'));
}
)
}
......@@ -70,7 +70,7 @@ function IndexController($scope, $window, toastr, AppUtil, AppService, UserServi
$scope.favoritesPage += 1;
$scope.hasMoreFavorites = result.length == size;
if ($scope.favoritesPage == 1){
if ($scope.favoritesPage == 1) {
$("#app-list").removeClass("hidden");
}
......@@ -92,7 +92,7 @@ function IndexController($scope, $window, toastr, AppUtil, AppService, UserServi
});
result.forEach(function (favorite) {
var app = appIdMapApp[favorite.appId];
if (!app){
if (!app) {
return;
}
app.favoriteId = favorite.id;
......@@ -122,7 +122,7 @@ function IndexController($scope, $window, toastr, AppUtil, AppService, UserServi
userVisitedApps.forEach(function (appId) {
var app = appIdMapApp[appId];
if (app){
if (app) {
$scope.visitedApps.push(app);
}
});
......@@ -145,7 +145,7 @@ function IndexController($scope, $window, toastr, AppUtil, AppService, UserServi
function toTop(favoriteId) {
FavoriteService.toTop(favoriteId).then(function () {
toastr.success("置顶成功");
toastr.success($translate.instant('Index.Topped'));
refreshFavorites();
})
......@@ -153,7 +153,7 @@ function IndexController($scope, $window, toastr, AppUtil, AppService, UserServi
function deleteFavorite(favoriteId) {
FavoriteService.deleteFavorite(favoriteId).then(function () {
toastr.success("取消收藏成功");
toastr.success($translate.instant('Index.CancelledFavorite'));
refreshFavorites();
})
}
......
login_module.controller('LoginController',
['$scope', '$window', '$location', 'toastr', 'AppUtil',
['$scope', '$window', '$location', '$translate', 'toastr', 'AppUtil',
LoginController]);
function LoginController($scope, $window, $location, toastr, AppUtil) {
function LoginController($scope, $window, $location, $translate, toastr, AppUtil) {
if ($location.$$url) {
var params = AppUtil.parseParams($location.$$url);
if (params.error) {
$scope.info = "用户名或密码错误";
$translate('Login.UserNameOrPasswordIncorrect').then(function(result) {
$scope.info = result;
});
}
if (params.logout) {
$scope.info = "登出成功";
$translate('Login.LogoutSuccessfully').then(function(result) {
$scope.info = result;
});
}
}
......
......@@ -19,7 +19,7 @@ directive_module.directive('apollodiff',
function makeDiff() {
var displayArea = document.getElementById(scope.apolloId);
if (!displayArea){
if (!displayArea) {
return;
}
//clear
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment