Commit 77cd568c by Jason Song Committed by GitHub

Merge pull request #384 from lepdou/0818

add delete cluster and namespace rest api
parents 92a90e90 2fcabd36
......@@ -88,7 +88,11 @@ public class ItemController {
Item beforeUpdateItem = BeanUtils.transfrom(Item.class, managedEntity);
BeanUtils.copyEntityProperties(entity, managedEntity);
//protect. only value,comment,lastModifiedBy can be modified
managedEntity.setValue(entity.getValue());
managedEntity.setComment(entity.getComment());
managedEntity.setDataChangeLastModifiedBy(entity.getDataChangeLastModifiedBy());
entity = itemService.update(managedEntity);
builder.updateItem(beforeUpdateItem, entity);
itemDTO = BeanUtils.transfrom(ItemDTO.class, entity);
......
......@@ -49,7 +49,8 @@ public class NamespaceController {
Namespace entity = namespaceService.findOne(appId, clusterName, namespaceName);
if (entity == null) throw new NotFoundException(
String.format("namespace not found for %s %s %s", appId, clusterName, namespaceName));
namespaceService.delete(entity.getId(), operator);
namespaceService.deleteNamespace(entity, operator);
}
@RequestMapping("/apps/{appId}/clusters/{clusterName}/namespaces")
......
......@@ -4,7 +4,9 @@
<property name="LOG_FILE"
value="${LOG_FILE:-${LOG_PATH:-${LOG_TEMP:-${java.io.tmpdir:-/tmp}}/}apollo-assembly.log}" />
<include resource="org/springframework/boot/logging/logback/file-appender.xml" />
<include resource="org/springframework/boot/logging/logback/console-appender.xml" />
<root level="INFO">
<appender-ref ref="FILE" />
<appender-ref ref="CONSOLE" />
</root>
</configuration>
......@@ -10,8 +10,8 @@ import javax.persistence.Entity;
import javax.persistence.Table;
@Entity
@Table(name = "commit")
@SQLDelete(sql = "Update commit set isDeleted = 1 where id = ?")
@Table(name = "Commit")
@SQLDelete(sql = "Update Commit set isDeleted = 1 where id = ?")
@Where(clause = "isDeleted = 0")
public class Commit extends BaseEntity {
......
......@@ -3,6 +3,8 @@ package com.ctrip.framework.apollo.biz.repository;
import com.ctrip.framework.apollo.biz.entity.Commit;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
......@@ -10,6 +12,10 @@ import java.util.List;
public interface CommitRepository extends PagingAndSortingRepository<Commit, Long> {
List<Commit> findByAppIdAndClusterNameAndNamespaceNameOrderByIdDesc(String appId, String clusterName,
String namespaceName, Pageable pageable);
String namespaceName, Pageable pageable);
@Modifying
@Query("update Commit set isdeleted=1,DataChange_LastModifiedBy = ?4 where appId=?1 and clusterName=?2 and namespaceName = ?3")
int batchDelete(String appId, String clusterName, String namespaceName, String operator);
}
......@@ -2,6 +2,8 @@ package com.ctrip.framework.apollo.biz.repository;
import java.util.List;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import com.ctrip.framework.apollo.biz.entity.Item;
......@@ -14,4 +16,8 @@ public interface ItemRepository extends PagingAndSortingRepository<Item, Long> {
Item findFirst1ByNamespaceIdOrderByLineNumDesc(Long namespaceId);
@Modifying
@Query("update Item set isdeleted=1,DataChange_LastModifiedBy = ?2 where namespaceId = ?1")
int deleteByNamespaceId(long namespaceId, String operator);
}
......@@ -2,6 +2,8 @@ package com.ctrip.framework.apollo.biz.repository;
import java.util.List;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import com.ctrip.framework.apollo.biz.entity.Namespace;
......@@ -11,4 +13,9 @@ public interface NamespaceRepository extends PagingAndSortingRepository<Namespac
List<Namespace> findByAppIdAndClusterNameOrderByIdAsc(String appId, String clusterName);
Namespace findByAppIdAndClusterNameAndNamespaceName(String appId, String clusterName, String namespaceName);
@Modifying
@Query("update Namespace set isdeleted=1,DataChange_LastModifiedBy = ?3 where appId=?1 and clusterName=?2")
int batchDelete(String appId, String clusterName, String operator);
}
......@@ -3,6 +3,8 @@ package com.ctrip.framework.apollo.biz.repository;
import java.util.List;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;
......@@ -19,4 +21,8 @@ public interface ReleaseRepository extends PagingAndSortingRepository<Release, L
List<Release> findByAppIdAndClusterNameAndNamespaceNameOrderByIdDesc(String appId, String clusterName, String namespaceName, Pageable page);
List<Release> findByAppIdAndClusterNameAndNamespaceNameAndIsAbandonedFalseOrderByIdDesc(String appId, String clusterName, String namespaceName, Pageable page);
@Modifying
@Query("update Release set isdeleted=1,DataChange_LastModifiedBy = ?4 where appId=?1 and clusterName=?2 and namespaceName = ?3")
int batchDelete(String appId, String clusterName, String namespaceName, String operator);
}
......@@ -11,6 +11,7 @@ import org.springframework.transaction.annotation.Transactional;
import com.ctrip.framework.apollo.biz.entity.Audit;
import com.ctrip.framework.apollo.biz.entity.Cluster;
import com.ctrip.framework.apollo.biz.repository.ClusterRepository;
import com.ctrip.framework.apollo.common.exception.BadRequestException;
import com.ctrip.framework.apollo.common.utils.BeanUtils;
import com.ctrip.framework.apollo.core.ConfigConsts;
import com.ctrip.framework.apollo.common.exception.ServiceException;
......@@ -26,8 +27,6 @@ public class ClusterService {
private AuditService auditService;
@Autowired
private NamespaceService namespaceService;
@Autowired
private AppNamespaceService appNamespaceService;
public boolean isClusterNameUnique(String appId, String clusterName) {
......@@ -75,9 +74,12 @@ public class ClusterService {
public void delete(long id, String operator) {
Cluster cluster = clusterRepository.findOne(id);
if (cluster == null) {
return;
throw new BadRequestException("cluster not exist");
}
//delete linked namespaces
namespaceService.deleteByAppIdAndClusterName(cluster.getAppId(), cluster.getName(), operator);
cluster.setDeleted(true);
cluster.setDataChangeLastModifiedBy(operator);
clusterRepository.save(cluster);
......
......@@ -26,4 +26,9 @@ public class CommitService {
return commitRepository.findByAppIdAndClusterNameAndNamespaceNameOrderByIdDesc(appId, clusterName, namespaceName, page);
}
@Transactional
public int batchDelete(String appId, String clusterName, String namespaceName, String operator){
return commitRepository.batchDelete(appId, clusterName, namespaceName, operator);
}
}
......@@ -47,6 +47,12 @@ public class ItemService {
return deletedItem;
}
@Transactional
public int batchDelete(long namespaceId, String operator) {
return itemRepository.deleteByNamespaceId(namespaceId, operator);
}
public Item findOne(String appId, String clusterName, String namespaceName, String key) {
Namespace namespace = namespaceRepository.findByAppIdAndClusterNameAndNamespaceName(appId,
clusterName, namespaceName);
......
......@@ -13,7 +13,6 @@ import com.ctrip.framework.apollo.common.utils.BeanUtils;
import com.ctrip.framework.apollo.common.dto.ItemChangeSets;
import com.ctrip.framework.apollo.common.dto.ItemDTO;
import com.ctrip.framework.apollo.common.exception.NotFoundException;
import com.ctrip.framework.apollo.core.utils.StringUtils;
@Service
......@@ -50,14 +49,19 @@ public class ItemSetService {
for (ItemDTO item : changeSet.getUpdateItems()) {
Item entity = BeanUtils.transfrom(Item.class, item);
Item beforeUpdateItem = itemService.findOne(entity.getId());
if (beforeUpdateItem == null) {
Item managedItem = itemService.findOne(entity.getId());
if (managedItem == null) {
throw new NotFoundException(String.format("item not found.(key=%s)", entity.getKey()));
}
beforeUpdateItem = BeanUtils.transfrom(Item.class, beforeUpdateItem);
Item beforeUpdateItem = BeanUtils.transfrom(Item.class, managedItem);
//protect. only value,comment,lastModifiedBy,lineNum can be modified
managedItem.setValue(entity.getValue());
managedItem.setComment(entity.getComment());
managedItem.setLineNum(entity.getLineNum());
entity.setDataChangeLastModifiedBy(operator);
Item updatedItem = itemService.update(entity);
Item updatedItem = itemService.update(managedItem);
configChangeContentBuilder.updateItem(beforeUpdateItem, updatedItem);
}
......@@ -72,8 +76,7 @@ public class ItemSetService {
auditService.audit("ItemSet", null, Audit.OP.DELETE, operator);
}
String configChangeContent = configChangeContentBuilder.build();
if (!StringUtils.isEmpty(configChangeContent)) {
if (configChangeContentBuilder.hasContent()){
createCommit(appId, clusterName, namespaceName, configChangeContentBuilder.build(),
changeSet.getDataChangeLastModifiedBy());
}
......
......@@ -24,6 +24,13 @@ public class NamespaceService {
private AuditService auditService;
@Autowired
private AppNamespaceService appNamespaceService;
@Autowired
private ItemService itemService;
@Autowired
private CommitService commitService;
@Autowired
private ReleaseService releaseService;
public boolean isNamespaceUnique(String appId, String cluster, String namespace) {
Objects.requireNonNull(appId, "AppId must not be null");
......@@ -34,17 +41,32 @@ public class NamespaceService {
}
@Transactional
public void delete(long id, String operator) {
Namespace namespace = namespaceRepository.findOne(id);
if (namespace == null) {
return;
public void deleteByAppIdAndClusterName(String appId, String clusterName, String operator){
List<Namespace> toDeleteNamespaces = findNamespaces(appId, clusterName);
for (Namespace namespace: toDeleteNamespaces){
deleteNamespace(namespace, operator);
}
}
@Transactional
public Namespace deleteNamespace(Namespace namespace, String operator){
String appId = namespace.getAppId();
String clusterName = namespace.getClusterName();
itemService.batchDelete(namespace.getId(), operator);
commitService.batchDelete(appId, clusterName, namespace.getNamespaceName(), operator);
releaseService.batchDelete(appId, clusterName, namespace.getNamespaceName(), operator);
namespace.setDeleted(true);
namespace.setDataChangeLastModifiedBy(operator);
namespaceRepository.save(namespace);
auditService.audit(Namespace.class.getSimpleName(), id, Audit.OP.DELETE, operator);
auditService.audit(Namespace.class.getSimpleName(), namespace.getId(), Audit.OP.DELETE, operator);
return namespaceRepository.save(namespace);
}
public Namespace findOne(Long namespaceId) {
......
......@@ -142,4 +142,9 @@ public class ReleaseService {
return releaseRepository.save(release);
}
@Transactional
public int batchDelete(String appId, String clusterName, String namespaceName, String operator){
return releaseRepository.batchDelete(appId, clusterName, namespaceName, operator);
}
}
......@@ -4,7 +4,9 @@ import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.ctrip.framework.apollo.biz.entity.Item;
import com.ctrip.framework.apollo.core.utils.StringUtils;
import java.util.Collections;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
......@@ -20,7 +22,9 @@ public class ConfigChangeContentBuilder {
public ConfigChangeContentBuilder createItem(Item item) {
createItems.add(item);
if (!StringUtils.isEmpty(item.getKey())){
createItems.add(item);
}
return this;
}
......@@ -33,10 +37,16 @@ public class ConfigChangeContentBuilder {
}
public ConfigChangeContentBuilder deleteItem(Item item) {
deleteItems.add(item);
if (!StringUtils.isEmpty(item.getKey())) {
deleteItems.add(item);
}
return this;
}
public boolean hasContent(){
return !createItems.isEmpty() || !updateItems.isEmpty() || !deleteItems.isEmpty();
}
public String build() {
//因为事务第一段提交并没有更新时间,所以build时统一更新
for (Item item : createItems) {
......
......@@ -53,8 +53,8 @@ public class AdminServiceAPI {
public List<NamespaceDTO> findNamespaceByCluster(String appId, Env env, String clusterName) {
NamespaceDTO[] namespaceDTOs = restTemplate.get(env, "apps/{appId}/clusters/{clusterName}/namespaces",
NamespaceDTO[].class, appId,
clusterName);
NamespaceDTO[].class, appId,
clusterName);
return Arrays.asList(namespaceDTOs);
}
......@@ -62,7 +62,7 @@ public class AdminServiceAPI {
String namespaceName) {
NamespaceDTO dto =
restTemplate.get(env, "apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}",
NamespaceDTO.class, appId, clusterName, namespaceName);
NamespaceDTO.class, appId, clusterName, namespaceName);
return dto;
}
......@@ -70,7 +70,7 @@ public class AdminServiceAPI {
public NamespaceDTO createNamespace(Env env, NamespaceDTO namespace) {
return restTemplate
.post(env, "apps/{appId}/clusters/{clusterName}/namespaces", namespace, NamespaceDTO.class,
namespace.getAppId(), namespace.getClusterName());
namespace.getAppId(), namespace.getClusterName());
}
public AppNamespaceDTO createAppNamespace(Env env, AppNamespaceDTO appNamespace) {
......@@ -78,6 +78,11 @@ public class AdminServiceAPI {
.post(env, "apps/{appId}/appnamespaces", appNamespace, AppNamespaceDTO.class, appNamespace.getAppId());
}
public void deleteNamespace(Env env, String appId, String clusterName, String namespaceName, String operator) {
restTemplate.delete(env, "apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}?operator={operator}", appId, clusterName,
namespaceName, operator);
}
}
@Service
......@@ -86,7 +91,7 @@ public class AdminServiceAPI {
public List<ItemDTO> findItems(String appId, Env env, String clusterName, String namespaceName) {
ItemDTO[] itemDTOs =
restTemplate.get(env, "apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/items",
ItemDTO[].class, appId, clusterName, namespaceName);
ItemDTO[].class, appId, clusterName, namespaceName);
return Arrays.asList(itemDTOs);
}
......@@ -98,18 +103,18 @@ public class AdminServiceAPI {
public void updateItemsByChangeSet(String appId, Env env, String clusterName, String namespace,
ItemChangeSets changeSets) {
restTemplate.post(env, "apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/itemset",
changeSets, Void.class, appId, clusterName, namespace);
changeSets, Void.class, appId, clusterName, namespace);
}
public void updateItem(String appId, Env env, String clusterName, String namespace, long itemId, ItemDTO item) {
restTemplate.put(env, "apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/items/{itemId}",
item, appId, clusterName, namespace, itemId);
item, appId, clusterName, namespace, itemId);
}
public ItemDTO createItem(String appId, Env env, String clusterName, String namespace, ItemDTO item) {
return restTemplate.post(env, "apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/items",
item, ItemDTO.class, appId, clusterName, namespace);
item, ItemDTO.class, appId, clusterName, namespace);
}
public void deleteItem(Env env, long itemId, String operator) {
......@@ -123,25 +128,29 @@ public class AdminServiceAPI {
public List<ClusterDTO> findClustersByApp(String appId, Env env) {
ClusterDTO[] clusterDTOs = restTemplate.get(env, "apps/{appId}/clusters", ClusterDTO[].class,
appId);
appId);
return Arrays.asList(clusterDTOs);
}
public ClusterDTO loadCluster(String appId, Env env, String clusterName) {
return restTemplate.get(env, "apps/{appId}/clusters/{clusterName}", ClusterDTO.class,
appId, clusterName);
appId, clusterName);
}
public boolean isClusterUnique(String appId, Env env, String clusterName) {
return restTemplate
.get(env, "apps/{appId}/cluster/{clusterName}/unique", Boolean.class,
appId, clusterName);
appId, clusterName);
}
public ClusterDTO create(Env env, ClusterDTO cluster) {
return restTemplate.post(env, "apps/{appId}/clusters", cluster, ClusterDTO.class,
cluster.getAppId());
cluster.getAppId());
}
public void delete(Env env, String appId, String clusterName, String operator) {
restTemplate.delete(env, "apps/{appId}/clusters/{clusterName}?operator={operator}", appId, clusterName, operator);
}
}
......@@ -175,7 +184,7 @@ public class AdminServiceAPI {
String namespace) {
ReleaseDTO releaseDTO = restTemplate
.get(env, "apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/releases/latest",
ReleaseDTO.class, appId, clusterName, namespace);
ReleaseDTO.class, appId, clusterName, namespace);
return releaseDTO;
}
......@@ -198,8 +207,8 @@ public class AdminServiceAPI {
public void rollback(Env env, long releaseId, String operator) {
restTemplate.put(env,
"releases/{releaseId}/rollback?operator={operator}",
null, releaseId, operator);
"releases/{releaseId}/rollback?operator={operator}",
null, releaseId, operator);
}
}
......@@ -209,9 +218,9 @@ public class AdminServiceAPI {
public List<CommitDTO> find(String appId, Env env, String clusterName, String namespaceName, int page, int size) {
CommitDTO[] commitDTOs = restTemplate.get(env,
"apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/commit?page={page}&size={size}",
CommitDTO[].class,
appId, clusterName, namespaceName, page, size);
"apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/commit?page={page}&size={size}",
CommitDTO[].class,
appId, clusterName, namespaceName, page, size);
return Arrays.asList(commitDTOs);
}
......@@ -222,8 +231,8 @@ public class AdminServiceAPI {
public NamespaceLockDTO getNamespaceLockOwner(String appId, Env env, String clusterName, String namespaceName) {
return restTemplate.get(env, "apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/lock",
NamespaceLockDTO.class,
appId, clusterName, namespaceName);
NamespaceLockDTO.class,
appId, clusterName, namespaceName);
}
}
......
......@@ -9,6 +9,7 @@ import com.ctrip.framework.apollo.portal.auth.UserInfoHolder;
import com.ctrip.framework.apollo.portal.service.ClusterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
......@@ -45,4 +46,13 @@ public class ClusterController {
return clusterService.createCluster(Env.valueOf(env), cluster);
}
@PreAuthorize(value = "@permissionValidator.isSuperAdmin()")
@RequestMapping(value = "apps/{appId}/envs/{env}/clusters/{clusterName:.+}", method = RequestMethod.DELETE)
public ResponseEntity<Void> deleteCluster(@PathVariable String appId, @PathVariable String env,
@PathVariable String clusterName){
clusterService.deleteCluster(Env.valueOf(env), appId, clusterName);
return ResponseEntity.ok().build();
}
}
......@@ -43,7 +43,6 @@ public class NamespaceController {
@Autowired
private AppService appService;
@Autowired
private ApplicationEventPublisher publisher;
@Autowired
......@@ -86,6 +85,14 @@ public class NamespaceController {
return ResponseEntity.ok().build();
}
@PreAuthorize(value = "@permissionValidator.isSuperAdmin()")
@RequestMapping(value = "/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName:.+}", method = RequestMethod.DELETE)
public ResponseEntity<Void> deleteNamespace(@PathVariable String appId, @PathVariable String env,
@PathVariable String clusterName, @PathVariable String namespaceName){
namespaceService.deleteNamespace(appId, Env.valueOf(env), clusterName, namespaceName);
return ResponseEntity.ok().build();
}
@PreAuthorize(value = "@permissionValidator.hasCreateAppNamespacePermission(#appId, #appNamespace)")
@RequestMapping(value = "/apps/{appId}/appnamespaces", method = RequestMethod.POST)
public AppNamespace createAppNamespace(@PathVariable String appId, @RequestBody AppNamespace appNamespace) {
......
......@@ -4,6 +4,7 @@ import com.ctrip.framework.apollo.common.dto.ClusterDTO;
import com.ctrip.framework.apollo.common.exception.BadRequestException;
import com.ctrip.framework.apollo.core.enums.Env;
import com.ctrip.framework.apollo.portal.api.AdminServiceAPI;
import com.ctrip.framework.apollo.portal.auth.UserInfoHolder;
import com.ctrip.framework.apollo.portal.constant.CatEventType;
import com.dianping.cat.Cat;
......@@ -16,6 +17,8 @@ import java.util.List;
public class ClusterService {
@Autowired
private UserInfoHolder userInfoHolder;
@Autowired
private AdminServiceAPI.ClusterAPI clusterAPI;
public List<ClusterDTO> findClusters(Env env, String appId) {
......@@ -33,4 +36,8 @@ public class ClusterService {
return clusterDTO;
}
public void deleteCluster(Env env, String appId, String clusterName){
clusterAPI.delete(env, appId, clusterName, userInfoHolder.getUser().getUserId());
}
}
package com.ctrip.framework.apollo.portal.service;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.ctrip.framework.apollo.common.dto.ItemDTO;
import com.ctrip.framework.apollo.common.dto.NamespaceDTO;
......@@ -22,6 +23,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
......@@ -32,6 +34,8 @@ public class NamespaceService {
private Logger logger = LoggerFactory.getLogger(NamespaceService.class);
private Gson gson = new Gson();
private static Type mapType = new TypeToken<Map<String, String>>() {
}.getType();
@Autowired
private UserInfoHolder userInfoHolder;
......@@ -58,6 +62,10 @@ public class NamespaceService {
return createdNamespace;
}
public void deleteNamespace(String appId, Env env, String clusterName, String namespaceName){
namespaceAPI.deleteNamespace(env, appId, clusterName, namespaceName, userInfoHolder.getUser().getUserId());
}
public NamespaceDTO loadNamespaceBaseInfo(String appId, Env env, String clusterName, String namespaceName) {
NamespaceDTO namespace = namespaceAPI.loadNamespace(appId, env, clusterName, namespaceName);
if (namespace == null) {
......@@ -101,7 +109,6 @@ public class NamespaceService {
return parseNamespace(appId, env, clusterName, namespace);
}
@SuppressWarnings("unchecked")
private NamespaceVO parseNamespace(String appId, Env env, String clusterName, NamespaceDTO namespace) {
NamespaceVO namespaceVO = new NamespaceVO();
namespaceVO.setBaseInfo(namespace);
......@@ -118,7 +125,7 @@ public class NamespaceService {
Map<String, String> releaseItems = new HashMap<>();
latestRelease = releaseService.loadLatestRelease(appId, env, clusterName, namespaceName);
if (latestRelease != null) {
releaseItems = gson.fromJson(latestRelease.getConfigurations(), Map.class);
releaseItems = gson.fromJson(latestRelease.getConfigurations(), mapType);
}
//not Release config items
......
......@@ -24,9 +24,6 @@
</header>
<div class="panel-body">
<div class="alert alert-info" role="alert">
apollo系统目前正在框架部门内测阶段,如非框架项目接入请先联系song_s@ctrip.com,zhanglea@ctrip.com
</div>
<form class="form-horizontal" name="appForm" ng-controller="CreateAppController" valdr-type="App"
ng-submit="create()">
<div class="form-group">
......
......@@ -118,8 +118,9 @@
apollo-show-cancel-btn="true" apollo-confirm="rollback"></apolloconfirmdialog>
<!--create createRelease modal-->
<form class="modal fade form-horizontal" name="releaseForm" valdr-type="Release" id="releaseModal" tabindex="-1" role="dialog"
<!--create release modal-->
<form class="modal fade form-horizontal" name="releaseForm" valdr-type="Release" id="releaseModal"
tabindex="-1" role="dialog"
ng-submit="release()">
<div class="modal-dialog" role="document" style="width: 960px">
<div class="modal-content">
......@@ -130,8 +131,19 @@
</div>
<div class="modal-body">
<div class="form-group">
<label class="col-sm-2 control-label">
Changes:</label>
<div class="col-sm-2 control-label" ng-if="!toReleaseNamespace.isPropertiesFormat">
<div class="row">
<div class="btn-group btn-group-xs" style="padding-right: 10px" role="group">
<button type="button" class="btn btn-default" ng-class="{active:releaseChangeViewType=='change'}"
ng-click="switchReleaseChangeViewType('change')">查看变更
</button>
<button type="button" class="btn btn-default" ng-class="{active:releaseChangeViewType=='release'}"
ng-click="switchReleaseChangeViewType('release')">发布的值
</button>
</div>
</div>
</div>
<label class="col-sm-2 control-label" ng-if="toReleaseNamespace.isPropertiesFormat">Changes</label>
<div class="col-sm-10" ng-if="toReleaseNamespace.itemModifiedCnt" valdr-form-group>
<!--properites format-->
......@@ -186,17 +198,15 @@
<!--file format -->
<div ng-repeat="item in toReleaseNamespace.items"
ng-if="!toReleaseNamespace.isPropertiesFormat">
<h3>new value</h3>
<textarea class="form-control" rows="20" style="border-radius: 0px"
ng-disabled="true" ng-show="item.newValue" ng-bind="item.newValue">
</textarea>
<hr>
<h3>old value</h3>
ng-if="!toReleaseNamespace.isPropertiesFormat" ng-show="releaseChangeViewType=='change'">
<apollodiff old-str="item.oldValue" new-str="item.newValue"
apollo-id="'releaseStrDiff'"></apollodiff>
</div>
<div ng-repeat="item in toReleaseNamespace.items"
ng-if="!toReleaseNamespace.isPropertiesFormat" ng-show="releaseChangeViewType=='release'">
<textarea class="form-control" rows="20" style="border-radius: 0px"
ng-disabled="true" ng-show="item.oldValue" ng-bind="item.oldValue">
</textarea>
<h4 ng-show="!item.oldValue"></h4>
ng-disabled="true" ng-show="item.newValue" ng-bind="item.newValue">
</textarea>
</div>
</div>
......@@ -205,21 +215,22 @@
配置没有变化
</span>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">
<apollorequiredfiled></apollorequiredfiled>
Release Name:</label>
<div class="col-sm-5" valdr-form-group>
<input type="text" name="releaseName" class="form-control" placeholder="input release name"
<input type="text" name="releaseName" class="form-control"
placeholder="input release name"
ng-model="releaseTitle" ng-required="true">
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">Comment:</label>
<div class="col-sm-10" valdr-form-group>
<textarea rows="4" name="comment" class="form-control" style="margin-top: 15px;"
<textarea rows="4" name="comment" class="form-control"
style="margin-top: 15px;"
ng-model="releaseComment"
placeholder="Add an optional extended description..."></textarea>
</div>
......@@ -229,7 +240,8 @@
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
<button type="submit" class="btn btn-primary" ng-disabled="releaseForm.$invalid || releaseBtnDisabled">发布
<button type="submit" class="btn btn-primary"
ng-disabled="releaseForm.$invalid || releaseBtnDisabled">发布
</button>
</div>
</div>
......@@ -237,15 +249,16 @@
</form>
<!--table mode item modal-->
<form class="modal fade form-horizontal" name="itemForm" valdr-type="Item" id="itemModal" role="dialog" ng-submit="doItem()">
<form class="modal fade form-horizontal" name="itemForm" valdr-type="Item" id="itemModal" role="dialog"
ng-submit="doItem()">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header panel-primary">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
<button type="button" class="close" data-dismiss="modal" aria-label="Close"
ng-click="cancelEdit()"><span
aria-hidden="true">&times;</span></button>
<h4 class="modal-title">
<span ng-show="tableViewOperType == 'create'"> 添加配置项</span>
<span ng-show="tableViewOperType == 'retrieve'"> 查看配置项</span>
<span ng-show="tableViewOperType == 'update'"> 修改配置项</span>
</h4>
</div>
......@@ -253,7 +266,7 @@
<div class="form-group">
<label class="col-sm-2 control-label">
<apollorequiredfiled
ng-show="tableViewOperType != 'retrieve'"></apollorequiredfiled>
ng-show="tableViewOperType == 'create'"></apollorequiredfiled>
Key
</label>
<div class="col-sm-10" valdr-form-group>
......@@ -263,19 +276,20 @@
</div>
<div class="form-group">
<label class="col-sm-2 control-label">
<apollorequiredfiled
ng-show="tableViewOperType != 'retrieve'"></apollorequiredfiled>
<apollorequiredfiled></apollorequiredfiled>
Value
</label>
<div class="col-sm-10" valdr-form-group>
<textarea type="text" name="value" class="form-control" rows="6" ng-model="item.value">
<textarea type="text" name="value" class="form-control" rows="6"
ng-model="item.value">
</textarea>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">Comment</label>
<div class="col-sm-10" valdr-form-group>
<textarea class="form-control" name="comment" ng-model="item.comment" rows="2">
<textarea class="form-control" name="comment" ng-model="item.comment"
rows="2">
</textarea>
</div>
</div>
......@@ -295,14 +309,13 @@
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" ng-click="switchToEdit()"
ng-show="tableViewOperType == 'retrieve' && hasModifyPermission">修改
</button>
<button type="button" class="btn btn-default" data-dismiss="modal">关闭
<button type="button" class="btn btn-default" data-dismiss="modal" ng-click="cancelEdit()">
关闭
</button>
<button type="submit" class="btn btn-primary"
ng-show="tableViewOperType != 'retrieve'"
ng-disabled="itemForm.$invalid || (addItemBtnDisabled && tableViewOperType == 'create')">提交
ng-disabled="itemForm.$invalid || (addItemBtnDisabled && tableViewOperType == 'create')">
提交
</button>
</div>
</div>
......@@ -438,6 +451,8 @@
<script src="vendor/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
<script src="vendor/bootstrap/js/bootstrap-treeview.min.js" type="text/javascript"></script>
<script src="vendor/diff.min.js" type="text/javascript"></script>
<!--valdr-->
<script src="vendor/valdr/valdr.min.js" type="text/javascript"></script>
......@@ -462,6 +477,7 @@
<!--directive-->
<script type="application/javascript" src="scripts/directive/directive.js"></script>
<script type="application/javascript" src="scripts/directive/namespace-panel-directive.js"></script>
<script type="application/javascript" src="scripts/directive/diff-directive.js"></script>
<!--controller-->
<script type="application/javascript" src="scripts/controller/config/ConfigNamespaceController.js"></script>
......
......@@ -17,6 +17,7 @@ $(document).ready(function () {
$('[data-tooltip="tooltip"]').tooltip();
$("textarea").niceScroll({styler: "fb", cursorcolor: "#fff"});
$("pre").niceScroll({styler: "fb", cursorcolor: "#fff"});
}, 2500);
});
......
......@@ -13,7 +13,6 @@ application_module.controller("ConfigNamespaceController",
};
var TABLE_VIEW_OPER_TYPE = {
RETRIEVE: 'retrieve',
CREATE: 'create',
UPDATE: 'update'
};
......@@ -25,6 +24,8 @@ application_module.controller("ConfigNamespaceController",
$scope.prepareReleaseNamespace = prepareReleaseNamespace;
$scope.release = release;
$scope.switchReleaseChangeViewType = switchReleaseChangeViewType;
$scope.showRollbackAlertDialog = showRollbackAlertDialog;
......@@ -32,13 +33,13 @@ application_module.controller("ConfigNamespaceController",
$scope.rollback = rollback;
$scope.retrieveItem = retrieveItem;
$scope.preDeleteItem = preDeleteItem;
$scope.deleteItem = deleteItem;
$scope.editItem = editItem;
$scope.cancelEdit = cancelEdit;
$scope.createItem = createItem;
......@@ -152,6 +153,11 @@ application_module.controller("ConfigNamespaceController",
}
);
}
$scope.releaseChangeViewType = 'change';
function switchReleaseChangeViewType(type) {
$scope.releaseChangeViewType = type;
}
function showRollbackAlertDialog() {
$("#rollbackModal").modal('hide');
......@@ -209,15 +215,6 @@ application_module.controller("ConfigNamespaceController",
$scope.tableViewOperType = '', $scope.item = {};
var toOperationNamespace;
//查看配置
function retrieveItem(namespace, item, oldValue) {
switchTableViewOperType(TABLE_VIEW_OPER_TYPE.RETRIEVE);
$scope.item = item;
$scope.item.oldValue = oldValue;
toOperationNamespace = namespace;
$scope.hasModifyPermission = namespace.hasModifyPermission;
}
var toDeleteItemId = 0;
function preDeleteItem(namespace, itemId) {
......@@ -245,6 +242,7 @@ application_module.controller("ConfigNamespaceController",
});
}
var backupItem = {};
//修改配置
function editItem(namespace, item) {
if (!lockCheck(namespace)) {
......@@ -252,10 +250,19 @@ application_module.controller("ConfigNamespaceController",
}
switchTableViewOperType(TABLE_VIEW_OPER_TYPE.UPDATE);
$scope.item = item;
backupItem.value = item.value;
backupItem.comment = item.comment;
toOperationNamespace = namespace;
$("#itemModal").modal("show");
}
function cancelEdit() {
if($scope.tableViewOperType = TABLE_VIEW_OPER_TYPE.UPDATE){
$scope.item.value = backupItem.value;
$scope.item.comment = backupItem.comment;
}
}
//新增配置
function createItem(namespace) {
......
directive_module.directive('apollodiff',
function ($compile, $window) {
return {
restrict: 'E',
templateUrl: '../../views/component/diff.html',
transclude: true,
replace: true,
scope: {
oldStr: '=',
newStr: '=',
apolloId: '='
},
link: function (scope, element, attrs) {
scope.$watch('oldStr', makeDiff);
scope.$watch('newStr', makeDiff);
function makeDiff() {
var displayArea = document.getElementById(scope.apolloId);
if (!displayArea){
return;
}
//clear
displayArea.innerHTML = '';
var color = '',
span = null,
pre = '';
var diff = JsDiff.diffLines(scope.oldStr, scope.newStr),
fragment = document.createDocumentFragment();
diff.forEach(function (part) {
// green for additions, red for deletions
// grey for common parts
color = part.added ? 'green' :
part.removed ? 'red' : 'grey';
span = document.createElement('span');
span.style.color = color;
pre = part.added ? '+' :
part.removed ? '-' : '';
span.appendChild(document.createTextNode(pre + part.value));
fragment.appendChild(span);
});
displayArea.appendChild(fragment);
}
}
}
});
/*!
diff v2.2.3
Software License Agreement (BSD License)
Copyright (c) 2009-2015, Kevin Decker <kpdecker@gmail.com>
All rights reserved.
Redistribution and use of this software in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of Kevin Decker nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@license
*/
!function(a,b){"object"==typeof exports&&"object"==typeof module?module.exports=b():"function"==typeof define&&define.amd?define([],b):"object"==typeof exports?exports.JsDiff=b():a.JsDiff=b()}(this,function(){/******/
return function(a){/******/
// The require function
/******/
function b(d){/******/
// Check if module is in cache
/******/
if(c[d])/******/
return c[d].exports;/******/
// Create a new module (and put it into the cache)
/******/
var e=c[d]={/******/
exports:{},/******/
id:d,/******/
loaded:!1};/******/
// Return the exports of the module
/******/
/******/
// Execute the module function
/******/
/******/
// Flag the module as loaded
/******/
return a[d].call(e.exports,e,e.exports,b),e.loaded=!0,e.exports}// webpackBootstrap
/******/
// The module cache
/******/
var c={};/******/
// Load entry module and return exports
/******/
/******/
// expose the modules object (__webpack_modules__)
/******/
/******/
// expose the module cache
/******/
/******/
// __webpack_public_path__
/******/
return b.m=a,b.c=c,b.p="",b(0)}([/* 0 */
/***/
function(a,b,c){/*istanbul ignore start*/
"use strict";/*istanbul ignore start*/
function d(a){return a&&a.__esModule?a:{"default":a}}b.__esModule=!0,b.canonicalize=b.convertChangesToXML=b.convertChangesToDMP=b.parsePatch=b.applyPatches=b.applyPatch=b.createPatch=b.createTwoFilesPatch=b.structuredPatch=b.diffJson=b.diffCss=b.diffSentences=b.diffTrimmedLines=b.diffLines=b.diffWordsWithSpace=b.diffWords=b.diffChars=b.Diff=void 0;/*istanbul ignore end*/
var/*istanbul ignore start*/e=c(1),f=d(e),/*istanbul ignore start*/g=c(2),/*istanbul ignore start*/h=c(3),/*istanbul ignore start*/i=c(5),/*istanbul ignore start*/j=c(6),/*istanbul ignore start*/k=c(7),/*istanbul ignore start*/l=c(8),/*istanbul ignore start*/m=c(9),/*istanbul ignore start*/n=c(10),/*istanbul ignore start*/o=c(12),/*istanbul ignore start*/p=c(13),/*istanbul ignore start*/q=c(14);/* See LICENSE file for terms of use */
/*
* Text diff implementation.
*
* This library supports the following APIS:
* JsDiff.diffChars: Character by character diff
* JsDiff.diffWords: Word (as defined by \b regex) diff which ignores whitespace
* JsDiff.diffLines: Line based diff
*
* JsDiff.diffCss: Diff targeted at CSS content
*
* These methods are based on the implementation proposed in
* "An O(ND) Difference Algorithm and its Variations" (Myers, 1986).
* http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.4.6927
*/
b.Diff=f["default"],/*istanbul ignore start*/
b.diffChars=g.diffChars,/*istanbul ignore start*/
b.diffWords=h.diffWords,/*istanbul ignore start*/
b.diffWordsWithSpace=h.diffWordsWithSpace,/*istanbul ignore start*/
b.diffLines=i.diffLines,/*istanbul ignore start*/
b.diffTrimmedLines=i.diffTrimmedLines,/*istanbul ignore start*/
b.diffSentences=j.diffSentences,/*istanbul ignore start*/
b.diffCss=k.diffCss,/*istanbul ignore start*/
b.diffJson=l.diffJson,/*istanbul ignore start*/
b.structuredPatch=o.structuredPatch,/*istanbul ignore start*/
b.createTwoFilesPatch=o.createTwoFilesPatch,/*istanbul ignore start*/
b.createPatch=o.createPatch,/*istanbul ignore start*/
b.applyPatch=m.applyPatch,/*istanbul ignore start*/
b.applyPatches=m.applyPatches,/*istanbul ignore start*/
b.parsePatch=n.parsePatch,/*istanbul ignore start*/
b.convertChangesToDMP=p.convertChangesToDMP,/*istanbul ignore start*/
b.convertChangesToXML=q.convertChangesToXML,/*istanbul ignore start*/
b.canonicalize=l.canonicalize},/* 1 */
/***/
function(a,b){/*istanbul ignore start*/
"use strict";function c(){}function d(a,b,c,d,e){for(var f=0,g=b.length,h=0,i=0;g>f;f++){var j=b[f];if(j.removed){
// Reverse add and remove so removes are output first to match common convention
// The diffing algorithm is tied to add then remove output and this is the simplest
// route to get the desired output with minimal overhead.
if(j.value=d.slice(i,i+j.count).join(""),i+=j.count,f&&b[f-1].added){var k=b[f-1];b[f-1]=b[f],b[f]=k}}else{if(!j.added&&e){var l=c.slice(h,h+j.count);l=l.map(function(a,b){var c=d[i+b];return c.length>a.length?c:a}),j.value=l.join("")}else j.value=c.slice(h,h+j.count).join("");h+=j.count,
// Common case
j.added||(i+=j.count)}}
// Special case handle for when one terminal is ignored. For this case we merge the
// terminal into the prior string and drop the change.
var m=b[g-1];return g>1&&(m.added||m.removed)&&a.equals("",m.value)&&(b[g-2].value+=m.value,b.pop()),b}function e(a){return{newPos:a.newPos,components:a.components.slice(0)}}b.__esModule=!0,b["default"]=/*istanbul ignore end*/c,c.prototype={/*istanbul ignore start*/
/*istanbul ignore end*/
diff:function(a,b){function c(a){return h?(setTimeout(function(){h(void 0,a)},0),!0):a}
// Main worker method. checks all permutations of a given edit length for acceptance.
function f(){for(var f=-1*l;l>=f;f+=2){var g=void 0,h=n[f-1],m=n[f+1],o=(m?m.newPos:0)-f;h&&(
// No one else is going to attempt to use this value, clear it
n[f-1]=void 0);var p=h&&h.newPos+1<j,q=m&&o>=0&&k>o;if(p||q){
// If we have hit the end of both strings, then we are done
if(
// Select the diagonal that we want to branch from. We select the prior
// path whose position in the new string is the farthest from the origin
// and does not pass the bounds of the diff graph
!p||q&&h.newPos<m.newPos?(g=e(m),i.pushComponent(g.components,void 0,!0)):(g=h,g.newPos++,i.pushComponent(g.components,!0,void 0)),o=i.extractCommon(g,b,a,f),g.newPos+1>=j&&o+1>=k)return c(d(i,g.components,b,a,i.useLongestToken));
// Otherwise track this path as a potential candidate and continue.
n[f]=g}else
// If this path is a terminal then prune
n[f]=void 0}l++}/*istanbul ignore start*/
var/*istanbul ignore end*/g=arguments.length<=2||void 0===arguments[2]?{}:arguments[2],h=g.callback;"function"==typeof g&&(h=g,g={}),this.options=g;var i=this;a=this.castInput(a),b=this.castInput(b),a=this.removeEmpty(this.tokenize(a)),b=this.removeEmpty(this.tokenize(b));var j=b.length,k=a.length,l=1,m=j+k,n=[{newPos:-1,components:[]}],o=this.extractCommon(n[0],b,a,0);if(n[0].newPos+1>=j&&o+1>=k)
// Identity per the equality and tokenizer
return c([{value:b.join(""),count:b.length}]);
// Performs the length of edit iteration. Is a bit fugly as this has to support the
// sync and async mode which is never fun. Loops over execEditLength until a value
// is produced.
if(h)!function q(){setTimeout(function(){
// This should not happen, but we want to be safe.
/* istanbul ignore next */
// This should not happen, but we want to be safe.
/* istanbul ignore next */
return l>m?h():void(f()||q())},0)}();else for(;m>=l;){var p=f();if(p)return p}},/*istanbul ignore start*/
/*istanbul ignore end*/
pushComponent:function(a,b,c){var d=a[a.length-1];d&&d.added===b&&d.removed===c?
// We need to clone here as the component clone operation is just
// as shallow array clone
a[a.length-1]={count:d.count+1,added:b,removed:c}:a.push({count:1,added:b,removed:c})},/*istanbul ignore start*/
/*istanbul ignore end*/
extractCommon:function(a,b,c,d){for(var e=b.length,f=c.length,g=a.newPos,h=g-d,i=0;e>g+1&&f>h+1&&this.equals(b[g+1],c[h+1]);)g++,h++,i++;return i&&a.components.push({count:i}),a.newPos=g,h},/*istanbul ignore start*/
/*istanbul ignore end*/
equals:function(a,b){return a===b},/*istanbul ignore start*/
/*istanbul ignore end*/
removeEmpty:function(a){for(var b=[],c=0;c<a.length;c++)a[c]&&b.push(a[c]);return b},/*istanbul ignore start*/
/*istanbul ignore end*/
castInput:function(a){return a},/*istanbul ignore start*/
/*istanbul ignore end*/
tokenize:function(a){return a.split("")}}},/* 2 */
/***/
function(a,b,c){/*istanbul ignore start*/
"use strict";function d(a){return a&&a.__esModule?a:{"default":a}}function e(a,b,c){return h.diff(a,b,c)}b.__esModule=!0,b.characterDiff=void 0,b.diffChars=e;var/*istanbul ignore start*/f=c(1),g=d(f),h=/*istanbul ignore start*/b.characterDiff=new/*istanbul ignore start*/g["default"]},/* 3 */
/***/
function(a,b,c){/*istanbul ignore start*/
"use strict";/*istanbul ignore start*/
function d(a){return a&&a.__esModule?a:{"default":a}}function e(a,b,c){var d=/*istanbul ignore start*/(0,i.generateOptions)(c,{ignoreWhitespace:!0});return l.diff(a,b,d)}function f(a,b,c){return l.diff(a,b,c)}b.__esModule=!0,b.wordDiff=void 0,b.diffWords=e,/*istanbul ignore start*/
b.diffWordsWithSpace=f;var/*istanbul ignore start*/g=c(1),h=d(g),/*istanbul ignore start*/i=c(4),j=/^[A-Za-z\xC0-\u02C6\u02C8-\u02D7\u02DE-\u02FF\u1E00-\u1EFF]+$/,k=/\S/,l=/*istanbul ignore start*/b.wordDiff=new/*istanbul ignore start*/h["default"];l.equals=function(a,b){return a===b||this.options.ignoreWhitespace&&!k.test(a)&&!k.test(b)},l.tokenize=function(a){
// Join the boundary splits that we do not consider to be boundaries. This is primarily the extended Latin character set.
for(var b=a.split(/(\s+|\b)/),c=0;c<b.length-1;c++)
// If we have an empty string in the next field and we have only word chars before and after, merge
!b[c+1]&&b[c+2]&&j.test(b[c])&&j.test(b[c+2])&&(b[c]+=b[c+2],b.splice(c+1,2),c--);return b}},/* 4 */
/***/
function(a,b){/*istanbul ignore start*/
"use strict";function c(a,b){if("function"==typeof a)b.callback=a;else if(a)for(var c in a)/* istanbul ignore else */
a.hasOwnProperty(c)&&(b[c]=a[c]);return b}b.__esModule=!0,b.generateOptions=c},/* 5 */
/***/
function(a,b,c){/*istanbul ignore start*/
"use strict";/*istanbul ignore start*/
function d(a){return a&&a.__esModule?a:{"default":a}}function e(a,b,c){return j.diff(a,b,c)}function f(a,b,c){var d=/*istanbul ignore start*/(0,i.generateOptions)(c,{ignoreWhitespace:!0});return j.diff(a,b,d)}b.__esModule=!0,b.lineDiff=void 0,b.diffLines=e,/*istanbul ignore start*/
b.diffTrimmedLines=f;var/*istanbul ignore start*/g=c(1),h=d(g),/*istanbul ignore start*/i=c(4),j=/*istanbul ignore start*/b.lineDiff=new/*istanbul ignore start*/h["default"];j.tokenize=function(a){var b=[],c=a.split(/(\n|\r\n)/);
// Ignore the final empty token that occurs if the string ends with a new line
c[c.length-1]||c.pop();
// Merge the content and line separators into single tokens
for(var d=0;d<c.length;d++){var e=c[d];d%2&&!this.options.newlineIsToken?b[b.length-1]+=e:(this.options.ignoreWhitespace&&(e=e.trim()),b.push(e))}return b}},/* 6 */
/***/
function(a,b,c){/*istanbul ignore start*/
"use strict";function d(a){return a&&a.__esModule?a:{"default":a}}function e(a,b,c){return h.diff(a,b,c)}b.__esModule=!0,b.sentenceDiff=void 0,b.diffSentences=e;var/*istanbul ignore start*/f=c(1),g=d(f),h=/*istanbul ignore start*/b.sentenceDiff=new/*istanbul ignore start*/g["default"];h.tokenize=function(a){return a.split(/(\S.+?[.!?])(?=\s+|$)/)}},/* 7 */
/***/
function(a,b,c){/*istanbul ignore start*/
"use strict";function d(a){return a&&a.__esModule?a:{"default":a}}function e(a,b,c){return h.diff(a,b,c)}b.__esModule=!0,b.cssDiff=void 0,b.diffCss=e;var/*istanbul ignore start*/f=c(1),g=d(f),h=/*istanbul ignore start*/b.cssDiff=new/*istanbul ignore start*/g["default"];h.tokenize=function(a){return a.split(/([{}:;,]|\s+)/)}},/* 8 */
/***/
function(a,b,c){/*istanbul ignore start*/
"use strict";/*istanbul ignore start*/
function d(a){return a&&a.__esModule?a:{"default":a}}function e(a,b,c){return l.diff(a,b,c)}
// This function handles the presence of circular references by bailing out when encountering an
// object that is already on the "stack" of items being processed.
function f(a,b,c){b=b||[],c=c||[];var d=void 0;for(d=0;d<b.length;d+=1)if(b[d]===a)return c[d];var e=void 0;if("[object Array]"===k.call(a)){for(b.push(a),e=new Array(a.length),c.push(e),d=0;d<a.length;d+=1)e[d]=f(a[d],b,c);return b.pop(),c.pop(),e}if(a&&a.toJSON&&(a=a.toJSON()),"object"===("undefined"==typeof a?"undefined":g(a))&&null!==a){b.push(a),e={},c.push(e);var h=[],i=void 0;for(i in a)/* istanbul ignore else */
a.hasOwnProperty(i)&&h.push(i);for(h.sort(),d=0;d<h.length;d+=1)i=h[d],e[i]=f(a[i],b,c);b.pop(),c.pop()}else e=a;return e}b.__esModule=!0,b.jsonDiff=void 0;var g="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol?"symbol":typeof a};b.diffJson=e,/*istanbul ignore start*/
b.canonicalize=f;var/*istanbul ignore start*/h=c(1),i=d(h),/*istanbul ignore start*/j=c(5),k=Object.prototype.toString,l=/*istanbul ignore start*/b.jsonDiff=new/*istanbul ignore start*/i["default"];
// Discriminate between two lines of pretty-printed, serialized JSON where one of them has a
// dangling comma and the other doesn't. Turns out including the dangling comma yields the nicest output:
l.useLongestToken=!0,l.tokenize=/*istanbul ignore start*/j.lineDiff.tokenize,l.castInput=function(a){return"string"==typeof a?a:JSON.stringify(f(a),void 0," ")},l.equals=function(a,b){/*istanbul ignore start*/
return i["default"].prototype.equals(a.replace(/,([\r\n])/g,"$1"),b.replace(/,([\r\n])/g,"$1"))}},/* 9 */
/***/
function(a,b,c){/*istanbul ignore start*/
"use strict";function d(a){return a&&a.__esModule?a:{"default":a}}/*istanbul ignore end*/
function e(a,b){/**
* Checks if the hunk exactly fits on the provided location
*/
function c(a,b){for(var c=0;c<a.lines.length;c++){var d=a.lines[c],f=d[0],g=d.substr(1);if(" "===f||"-"===f){
// Context sanity check
if(!h(b+1,e[b],f,g)&&(j++,j>k))return!1;b++}}return!0}/*istanbul ignore start*/
var/*istanbul ignore end*/d=arguments.length<=2||void 0===arguments[2]?{}:arguments[2];if("string"==typeof b&&(b=/*istanbul ignore start*/(0,g.parsePatch)(b)),Array.isArray(b)){if(b.length>1)throw new Error("applyPatch only works with a single input.");b=b[0]}
// Search best fit offsets for each hunk based on the previous ones
for(var e=a.split("\n"),f=b.hunks,h=d.compareLine||function(a,b,c,d){/*istanbul ignore end*/
return b===d},j=0,k=d.fuzzFactor||0,l=0,m=0,n=void 0,o=void 0,p=0;p<f.length;p++){for(var q=f[p],r=e.length-q.oldLines,s=0,t=m+q.oldStart-1,u=/*istanbul ignore start*/(0,i["default"])(t,l,r);void 0!==s;s=u())if(c(q,t+s)){q.offset=m+=s;break}if(void 0===s)return!1;
// Set lower text limit to end of the current hunk, so next ones don't try
// to fit over already patched text
l=q.offset+q.oldStart+q.oldLines}
// Apply patch hunks
for(var v=0;v<f.length;v++){var w=f[v],x=w.offset+w.newStart-1;0==w.newLines&&x++;for(var y=0;y<w.lines.length;y++){var z=w.lines[y],A=z[0],B=z.substr(1);if(" "===A)x++;else if("-"===A)e.splice(x,1);else if("+"===A)e.splice(x,0,B),x++;else if("\\"===A){var C=w.lines[y-1]?w.lines[y-1][0]:null;"+"===C?n=!0:"-"===C&&(o=!0)}}}
// Handle EOFNL insertion/removal
if(n)for(;!e[e.length-1];)e.pop();else o&&e.push("");return e.join("\n")}
// Wrapper that supports multiple file patches via callbacks.
function f(a,b){function c(){var f=a[d++];return f?void b.loadFile(f,function(a,d){if(a)return b.complete(a);var g=e(d,f,b);b.patched(f,g),setTimeout(c,0)}):b.complete()}"string"==typeof a&&(a=/*istanbul ignore start*/(0,g.parsePatch)(a));var d=0;c()}b.__esModule=!0,b.applyPatch=e,/*istanbul ignore start*/
b.applyPatches=f;var/*istanbul ignore start*/g=c(10),/*istanbul ignore start*/h=c(11),i=d(h)},/* 10 */
/***/
function(a,b){/*istanbul ignore start*/
"use strict";function c(a){function b(){var a={};
// Parse diff metadata
for(g.push(a);h<f.length;){var b=f[h];
// File header found, end parsing diff metadata
if(/^(\-\-\-|\+\+\+|@@)\s/.test(b))break;
// Diff index
var i=/^(?:Index:|diff(?: -r \w+)+)\s+(.+?)\s*$/.exec(b);i&&(a.index=i[1]),h++}for(
// Parse file headers if they are defined. Unified diff requires them, but
// there's no technical issues to have an isolated hunk without file header
c(a),c(a),
// Parse hunks
a.hunks=[];h<f.length;){var j=f[h];if(/^(Index:|diff|\-\-\-|\+\+\+)\s/.test(j))break;if(/^@@/.test(j))a.hunks.push(d());else{if(j&&e.strict)
// Ignore unexpected content unless in strict mode
throw new Error("Unknown line "+(h+1)+" "+JSON.stringify(j));h++}}}
// Parses the --- and +++ headers, if none are found, no lines
// are consumed.
function c(a){var b=/^(\-\-\-|\+\+\+)\s+(\S*)\s?(.*?)\s*$/.exec(f[h]);if(b){var c="---"===b[1]?"old":"new";a[c+"FileName"]=b[2],a[c+"Header"]=b[3],h++}}
// Parses a hunk
// This assumes that we are at the start of a hunk.
function d(){for(var a=h,b=f[h++],c=b.split(/@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/),d={oldStart:+c[1],oldLines:+c[2]||1,newStart:+c[3],newLines:+c[4]||1,lines:[]},g=0,i=0;h<f.length;h++){var j=f[h][0];if("+"!==j&&"-"!==j&&" "!==j&&"\\"!==j)break;d.lines.push(f[h]),"+"===j?g++:"-"===j?i++:" "===j&&(g++,i++)}
// Perform optional sanity checking
if(
// Handle the empty block count case
g||1!==d.newLines||(d.newLines=0),i||1!==d.oldLines||(d.oldLines=0),e.strict){if(g!==d.newLines)throw new Error("Added line count did not match for hunk at line "+(a+1));if(i!==d.oldLines)throw new Error("Removed line count did not match for hunk at line "+(a+1))}return d}for(/*istanbul ignore start*/
var/*istanbul ignore end*/e=arguments.length<=1||void 0===arguments[1]?{}:arguments[1],f=a.split("\n"),g=[],h=0;h<f.length;)b();return g}b.__esModule=!0,b.parsePatch=c},/* 11 */
/***/
function(a,b){/*istanbul ignore start*/
"use strict";b.__esModule=!0,b["default"]=/*istanbul ignore end*/function(a,b,c){var d=!0,e=!1,f=!1,g=1;return function h(){if(d&&!f){
// Check if trying to fit beyond text length, and if not, check it fits
// after offset location (or desired location on first iteration)
if(e?g++:d=!1,c>=a+g)return g;f=!0}
// Check if trying to fit before text beginning, and if not, check it fits
// before offset location
return e?void 0:(f||(d=!0),a-g>=b?-g++:(e=!0,h()))}}},/* 12 */
/***/
function(a,b,c){/*istanbul ignore start*/
"use strict";/*istanbul ignore start*/
function d(a){if(Array.isArray(a)){for(var b=0,c=Array(a.length);b<a.length;b++)c[b]=a[b];return c}return Array.from(a)}/*istanbul ignore end*/
function e(a,b,c,e,f,g,i){// Append an empty value to make cleanup easier
function j(a){return a.map(function(a){return" "+a})}i||(i={context:4});var k=/*istanbul ignore start*/(0,h.diffLines)(c,e);k.push({value:"",lines:[]});for(var l=[],m=0,n=0,o=[],p=1,q=1,r=function(/*istanbul ignore end*/a){var b=k[a],f=b.lines||b.value.replace(/\n$/,"").split("\n");if(b.lines=f,b.added||b.removed){/*istanbul ignore start*/
var g;/*istanbul ignore end*/
// If we have previous context, start with that
if(!m){var h=k[a-1];m=p,n=q,h&&(o=i.context>0?j(h.lines.slice(-i.context)):[],m-=o.length,n-=o.length)}
// Output our changes
/*istanbul ignore start*/
(g=/*istanbul ignore end*/o).push.apply(/*istanbul ignore start*/g,/*istanbul ignore start*/d(/*istanbul ignore end*/f.map(function(a){return(b.added?"+":"-")+a}))),
// Track the updated file position
b.added?q+=f.length:p+=f.length}else{
// Identical context lines. Track line changes
if(m)
// Close out any changes that have been output (or join overlapping)
if(f.length<=2*i.context&&a<k.length-2){/*istanbul ignore start*/
var r;/*istanbul ignore end*/
// Overlapping
/*istanbul ignore start*/
(r=/*istanbul ignore end*/o).push.apply(/*istanbul ignore start*/r,/*istanbul ignore start*/d(/*istanbul ignore end*/j(f)))}else{/*istanbul ignore start*/
var s,t=Math.min(f.length,i.context);/*istanbul ignore start*/
(s=/*istanbul ignore end*/o).push.apply(/*istanbul ignore start*/s,/*istanbul ignore start*/d(/*istanbul ignore end*/j(f.slice(0,t))));var u={oldStart:m,oldLines:p-m+t,newStart:n,newLines:q-n+t,lines:o};if(a>=k.length-2&&f.length<=i.context){
// EOF is inside this hunk
var v=/\n$/.test(c),w=/\n$/.test(e);0!=f.length||v?v&&w||o.push("\\ No newline at end of file"):
// special case: old has no eol and no trailing context; no-nl can end up before adds
o.splice(u.oldLines,0,"\\ No newline at end of file")}l.push(u),m=0,n=0,o=[]}p+=f.length,q+=f.length}},s=0;s<k.length;s++)/*istanbul ignore start*/
r(/*istanbul ignore end*/s);return{oldFileName:a,newFileName:b,oldHeader:f,newHeader:g,hunks:l}}function f(a,b,c,d,f,g,h){var i=e(a,b,c,d,f,g,h),j=[];a==b&&j.push("Index: "+a),j.push("==================================================================="),j.push("--- "+i.oldFileName+("undefined"==typeof i.oldHeader?"":" "+i.oldHeader)),j.push("+++ "+i.newFileName+("undefined"==typeof i.newHeader?"":" "+i.newHeader));for(var k=0;k<i.hunks.length;k++){var l=i.hunks[k];j.push("@@ -"+l.oldStart+","+l.oldLines+" +"+l.newStart+","+l.newLines+" @@"),j.push.apply(j,l.lines)}return j.join("\n")+"\n"}function g(a,b,c,d,e,g){return f(a,a,b,c,d,e,g)}b.__esModule=!0,b.structuredPatch=e,/*istanbul ignore start*/
b.createTwoFilesPatch=f,/*istanbul ignore start*/
b.createPatch=g;var/*istanbul ignore start*/h=c(5)},/* 13 */
/***/
function(a,b){/*istanbul ignore start*/
"use strict";
// See: http://code.google.com/p/google-diff-match-patch/wiki/API
function c(a){for(var b=[],c=void 0,d=void 0,e=0;e<a.length;e++)c=a[e],d=c.added?1:c.removed?-1:0,b.push([d,c.value]);return b}b.__esModule=!0,b.convertChangesToDMP=c},/* 14 */
/***/
function(a,b){/*istanbul ignore start*/
"use strict";function c(a){for(var b=[],c=0;c<a.length;c++){var e=a[c];e.added?b.push("<ins>"):e.removed&&b.push("<del>"),b.push(d(e.value)),e.added?b.push("</ins>"):e.removed&&b.push("</del>")}return b.join("")}function d(a){var b=a;return b=b.replace(/&/g,"&amp;"),b=b.replace(/</g,"&lt;"),b=b.replace(/>/g,"&gt;"),b=b.replace(/"/g,"&quot;")}b.__esModule=!0,b.convertChangesToXML=c}])});
\ No newline at end of file
......@@ -232,8 +232,8 @@
</thead>
<tbody>
<tr ng-repeat="item in commits.changeSets.createItems"
ng-show="item.key || item.comment">
<!--兼容老数据,不显示item类型为空行和注释的item-->
<tr ng-repeat="item in commits.changeSets.createItems" ng-show="item.key">
<td width="2%">
新增
</td>
......
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