diff --git a/apollo-core/src/main/java/com/ctrip/apollo/core/dto/ItemDTO.java b/apollo-core/src/main/java/com/ctrip/apollo/core/dto/ItemDTO.java index 7ed48d5fcce6dabeb9b391ffff1c5cb4e74512ca..1d438cca892e3b3adf6adf30b41d1f5530f079a3 100644 --- a/apollo-core/src/main/java/com/ctrip/apollo/core/dto/ItemDTO.java +++ b/apollo-core/src/main/java/com/ctrip/apollo/core/dto/ItemDTO.java @@ -1,5 +1,7 @@ package com.ctrip.apollo.core.dto; +import java.util.Date; + public class ItemDTO { private long id; @@ -12,6 +14,10 @@ public class ItemDTO { private String comment; + private String dataChangeLastModifiedBy; + + private Date dataChangeLastModifiedTime; + public ItemDTO() { } @@ -60,4 +66,20 @@ public class ItemDTO { public void setValue(String value) { this.value = value; } + + public String getDataChangeLastModifiedBy() { + return dataChangeLastModifiedBy; + } + + public void setDataChangeLastModifiedBy(String dataChangeLastModifiedBy) { + this.dataChangeLastModifiedBy = dataChangeLastModifiedBy; + } + + public Date getDataChangeLastModifiedTime() { + return dataChangeLastModifiedTime; + } + + public void setDataChangeLastModifiedTime(Date dataChangeLastModifiedTime) { + this.dataChangeLastModifiedTime = dataChangeLastModifiedTime; + } } diff --git a/apollo-portal/src/main/java/com/ctrip/apollo/portal/service/ConfigService.java b/apollo-portal/src/main/java/com/ctrip/apollo/portal/service/ConfigService.java index a4b6ff15ed077aa35dd47f644498e2a34305dcbf..e8a77a1986ebb75a89f411f4edc568e9deb6ea35 100644 --- a/apollo-portal/src/main/java/com/ctrip/apollo/portal/service/ConfigService.java +++ b/apollo-portal/src/main/java/com/ctrip/apollo/portal/service/ConfigService.java @@ -97,12 +97,12 @@ public class ConfigService { NamespaceVO.ItemVO itemVO = new NamespaceVO.ItemVO(); itemVO.setItem(itemDTO); String key = itemDTO.getKey(); - String value = itemDTO.getValue(); + String newValue = itemDTO.getValue(); String oldValue = releaseItems.get(key); - if (value.equals(oldValue)) { + if (oldValue == null || !newValue.equals(oldValue)) { itemVO.setModified(true); - itemVO.setOldValue(oldValue); - itemVO.setNewValue(value); + itemVO.setOldValue(oldValue == null ? "" : oldValue); + itemVO.setNewValue(newValue); } return itemVO; } diff --git a/apollo-portal/src/main/resources/static/scripts/app.js b/apollo-portal/src/main/resources/static/scripts/app.js index 1efc92ad7fbe24806918196e687f40c1b40b267f..853f77caeca8725cedf97c34cb7a5bcc27e60910 100644 --- a/apollo-portal/src/main/resources/static/scripts/app.js +++ b/apollo-portal/src/main/resources/static/scripts/app.js @@ -3,7 +3,7 @@ var appService = angular.module('app.service', ['ngResource']); /** page module 定义*/ //项目主页 -var application_module = angular.module('application', ['ngResource','ui.router', 'app.service', 'toastr', 'angular-loading-bar', 'ngTable']); +var application_module = angular.module('application', ['ngResource','ui.router', 'app.service', 'toastr', 'angular-loading-bar']); //创建项目页面 var create_app_module = angular.module('create_app', ['ngResource', 'toastr', 'app.service', 'angular-loading-bar']); diff --git a/apollo-portal/src/main/resources/static/scripts/controller/app/AppConfigController.js b/apollo-portal/src/main/resources/static/scripts/controller/app/AppConfigController.js index eec52c3dec83d1b2dba9af9ef238d345777fa41e..b178a37432a975b098f52a7fae1a20a57fa19535 100644 --- a/apollo-portal/src/main/resources/static/scripts/controller/app/AppConfigController.js +++ b/apollo-portal/src/main/resources/static/scripts/controller/app/AppConfigController.js @@ -1,7 +1,6 @@ -"use strict"; application_module.controller("AppConfigController", - ['$scope', '$location', 'toastr', 'NgTableParams', 'AppService', 'ConfigService', - function ($scope, $location, toastr, NgTableParams, AppService, ConfigService) { + ['$scope', '$location', 'toastr', 'AppService', 'ConfigService', + function ($scope, $location, toastr, AppService, ConfigService) { $scope.appId = $location.$$url.split("=")[1]; @@ -38,374 +37,13 @@ application_module.controller("AppConfigController", /////////// $scope.env = 'LOCAL'; - $scope.clusterName = 'DEFAULT'; - ConfigService.load_all_namespaces($scope.appId, $scope.env, - $scope.clusterName).then(function (result) { - - }, function (result) { - toastr.error("加载配置信息出错"); - }); - - var simpleList = [{ - key: 'page', - value: 10, - comment: '页面大小', - dataChangeLastModifiedTime: '2016-02-23', - dataChangeLastModifiedBy: '网鱼' - }, - { - key: 'page', - value: 10, - comment: '页面大小', - dataChangeLastModifiedTime: '2016-02-23', - dataChangeLastModifiedBy: '网鱼' - }, - { - key: 'page', - value: 10, - comment: '页面大小', - dataChangeLastModifiedTime: '2016-02-23', - dataChangeLastModifiedBy: '网鱼' - }, - { - key: 'page', - value: 5, - comment: '页面大小', - modified: "true", - dataChangeLastModifiedTime: '2016-02-23', - dataChangeLastModifiedBy: '网鱼' - }, - { - key: 'ss', - value: 10, - comment: '页面大小', - dataChangeLastModifiedTime: '2016-02-23', - dataChangeLastModifiedBy: '网鱼' - }, - { - key: 'page', - value: 10, - comment: '页面大小', - dataChangeLastModifiedTime: '2016-02-23', - dataChangeLastModifiedBy: '网鱼' - }, - { - key: 'page', - value: 10, - comment: '页面大小', - dataChangeLastModifiedTime: '2016-02-23', - dataChangeLastModifiedBy: '网鱼' - }, - { - key: 'page', - value: 10, - comment: '页面大小', - dataChangeLastModifiedTime: '2016-02-23', - dataChangeLastModifiedBy: '网鱼' - }, - { - key: 'page', - value: 10, - comment: '页面大小', - dataChangeLastModifiedTime: '2016-02-23', - dataChangeLastModifiedBy: '网鱼' - }]; - - function Namespace(data) { - - Namespace.prototype.data = data; - Namespace.prototype.tableParams = new NgTableParams({ - count: 9999 - }, { - dataset: angular.copy(data) - }); - Namespace.prototype.deleteCount = 0; - Namespace.prototype.isEditing = false; - Namespace.prototype.isAdding = false; - - Namespace.prototype.add = function () { - this.isEditing = true; - this.isAdding = true; - this.tableParams.settings().dataset.unshift({ - name: "", - age: null, - money: null - }); - this.tableParams.sorting({}); - this.tableParams.page(1); - this.tableParams.reload(); - }; - - Namespace.prototype.cancelChanges = function () { - this.resetTableStatus(); - var currentPage = this.tableParams.page(); - this.tableParams.settings({ - dataset: angular.copy(this.data) - }); - // keep the user on the current page when we can - if (!this.isAdding) { - this.tableParams.page(currentPage); - } - }; - - Namespace.prototype.del = function () { - _.remove(this.tableParams.settings().dataset, - function (item) { - return row === item; - }); - this.deleteCount++; - this.tableTracker.untrack(row); - this.tableParams.reload().then(function (data) { - if (data.length === 0 && this.tableParams.total() > 0) { - this.tableParams.page(this.tableParams.page() - 1); - this.tableParams.reload(); - } - }); - }; - - Namespace.prototype.hasChanges = function () { - return this.tableForm.$dirty || this.deleteCount > 0 - }; - - Namespace.prototype.saveChanges = function () { - this.resetTableStatus(); - var currentPage = this.tableParams.page(); - this.data = angular.copy(this.tableParams.settings().dataset); - }; - - Namespace.prototype.resetTableStatus = function () { - this.isEditing = false; - this.isAdding = false; - this.deleteCount = 0; - this.tableTracker.reset(); - this.tableForm.$setPristine(); - } - } - - var space = new Namespace(simpleList); - $scope.cancelChanges = function () { - space.cancelChanges(); - }; + $scope.clusterName = 'default'; + ConfigService.load_all_namespaces($scope.appId, $scope.env, $scope.clusterName).then( + function (result) { + $scope.namespaces = result; + }, function (result) { + toastr.error("加载配置信息出错"); + }); - $scope.space = space; }]); -(function () { - "use strict"; - - application_module.run(configureDefaults); - configureDefaults.$inject = ["ngTableDefaults"]; - - function configureDefaults(ngTableDefaults) { - ngTableDefaults.params.count = 5; - ngTableDefaults.settings.counts = []; - } -})(); - -/********** - The following directives are necessary in order to track dirty state and validity of the rows - in the table as the user pages within the grid - ------------------------ - */ - - -(function () { - application_module.directive("trackedTable", trackedTable); - - trackedTable.$inject = []; - - function trackedTable() { - return { - restrict: "A", - priority: -1, - require: "ngForm", - controller: trackedTableController - }; - } - - trackedTableController.$inject = ["$attrs", "$element", "$parse", "$scope"]; - - function trackedTableController($attrs, $element, $parse, $scope) { - var self = this; - var tableForm = $element.controller("form"); - var dirtyCellsByRow = []; - var invalidCellsByRow = []; - - init(); - - //////// - - function init() { - var setter = $parse($attrs.trackedTable).assign; - setter($scope, self); - $scope.$on("$destroy", function () { - setter(null); - }); - - self.reset = reset; - self.isCellDirty = isCellDirty; - self.setCellDirty = setCellDirty; - self.setCellInvalid = setCellInvalid; - self.untrack = untrack; - } - - function getCellsForRow(row, cellsByRow) { - return _.find(cellsByRow, function (entry) { - return entry.row === row; - }) - } - - function isCellDirty(row, cell) { - var rowCells = getCellsForRow(row, dirtyCellsByRow); - return rowCells && rowCells.cells.indexOf(cell) !== -1; - } - - function reset() { - dirtyCellsByRow = []; - invalidCellsByRow = []; - setInvalid(false); - } - - function setCellDirty(row, cell, isDirty) { - setCellStatus(row, cell, isDirty, dirtyCellsByRow); - } - - function setCellInvalid(row, cell, isInvalid) { - setCellStatus(row, cell, isInvalid, invalidCellsByRow); - setInvalid(invalidCellsByRow.length > 0); - } - - function setCellStatus(row, cell, value, cellsByRow) { - var rowCells = getCellsForRow(row, cellsByRow); - if (!rowCells && !value) { - return; - } - - if (value) { - if (!rowCells) { - rowCells = { - row: row, - cells: [] - }; - cellsByRow.push(rowCells); - } - if (rowCells.cells.indexOf(cell) === -1) { - rowCells.cells.push(cell); - } - } else { - _.remove(rowCells.cells, function (item) { - return cell === item; - }); - if (rowCells.cells.length === 0) { - _.remove(cellsByRow, function (item) { - return rowCells === item; - }); - } - } - } - - function setInvalid(isInvalid) { - self.$invalid = isInvalid; - self.$valid = !isInvalid; - } - - function untrack(row) { - _.remove(invalidCellsByRow, function (item) { - return item.row === row; - }); - _.remove(dirtyCellsByRow, function (item) { - return item.row === row; - }); - setInvalid(invalidCellsByRow.length > 0); - } - } -})(); - -(function () { - application_module.directive("trackedTableRow", trackedTableRow); - - trackedTableRow.$inject = []; - - function trackedTableRow() { - return { - restrict: "A", - priority: -1, - require: ["^trackedTable", "ngForm"], - controller: trackedTableRowController - }; - } - - trackedTableRowController.$inject = ["$attrs", "$element", "$parse", "$scope"]; - - function trackedTableRowController($attrs, $element, $parse, $scope) { - var self = this; - var row = $parse($attrs.trackedTableRow)($scope); - var rowFormCtrl = $element.controller("form"); - var trackedTableCtrl = $element.controller("trackedTable"); - - self.isCellDirty = isCellDirty; - self.setCellDirty = setCellDirty; - self.setCellInvalid = setCellInvalid; - - function isCellDirty(cell) { - return trackedTableCtrl.isCellDirty(row, cell); - } - - function setCellDirty(cell, isDirty) { - trackedTableCtrl.setCellDirty(row, cell, isDirty) - } - - function setCellInvalid(cell, isInvalid) { - trackedTableCtrl.setCellInvalid(row, cell, isInvalid) - } - } -})(); - -(function() { - application_module.directive("trackedTableCell", trackedTableCell); - - trackedTableCell.$inject = []; - - function trackedTableCell() { - return { - restrict: "A", - priority: -1, - scope: true, - require: ["^trackedTableRow", "ngForm"], - controller: trackedTableCellController - }; - } - - trackedTableCellController.$inject = ["$attrs", "$element", "$scope"]; - - function trackedTableCellController($attrs, $element, $scope) { - var self = this; - var cellFormCtrl = $element.controller("form"); - var cellName = cellFormCtrl.$name; - var trackedTableRowCtrl = $element.controller("trackedTableRow"); - - if (trackedTableRowCtrl.isCellDirty(cellName)) { - cellFormCtrl.$setDirty(); - } else { - cellFormCtrl.$setPristine(); - } - // note: we don't have to force setting validaty as angular will run validations - // when we page back to a row that contains invalid data - - $scope.$watch(function() { - return cellFormCtrl.$dirty; - }, function(newValue, oldValue) { - if (newValue === oldValue) return; - - trackedTableRowCtrl.setCellDirty(cellName, newValue); - }); - - $scope.$watch(function() { - return cellFormCtrl.$invalid; - }, function(newValue, oldValue) { - if (newValue === oldValue) return; - - trackedTableRowCtrl.setCellInvalid(cellName, newValue); - }); - } -})(); diff --git a/apollo-portal/src/main/resources/static/styles/common-style.css b/apollo-portal/src/main/resources/static/styles/common-style.css index 3f3f157cb63800878580981daed246cb5468f60b..30f801a8125a5574031074f92342820d4fa5cb50 100644 --- a/apollo-portal/src/main/resources/static/styles/common-style.css +++ b/apollo-portal/src/main/resources/static/styles/common-style.css @@ -19,6 +19,9 @@ a{ } /*panel*/ +.panel{ + border: 1px solid #ddd; +} .panel-heading { height: 45px; font-size: 14px; diff --git a/apollo-portal/src/main/resources/static/views/app/index.html b/apollo-portal/src/main/resources/static/views/app/index.html index 94c93c265f69bd21b2451243dd65ca32f3f708a3..884e4b296434fbbd22d5b7f589c4506b439d0b58 100644 --- a/apollo-portal/src/main/resources/static/views/app/index.html +++ b/apollo-portal/src/main/resources/static/views/app/index.html @@ -13,261 +13,177 @@
-
-
- -
+
+
- -
- -
-
-
+ +
-
+ +
+ +
+
+
-
-
-
-
-
- hermas - 有修改,可发布 - 4 -
-
-
+ + + + + + + + + + + + + + + + + + + + + + + +
+ Key + + value + + 备注 + + 最后修改人 + + 最后修改时间 +
+ {{config.item.key}} + + {{config.item.value}} + + {{config.item.comment}} + + {{config.item.dataChangeLastModifiedBy}} + + {{config.item.dataChangeLastModifiedTime | date: 'yyyy-MM-dd HH:mm:ss'}} +
+ +
+
+
+
+ + +
+
2016-02-23 + 12:23 + 王玉
+ +

+ 修改comment +

+
+
-
-
- -
-
2016-02-23 - 12:23 - 王玉
-

- 修改comment -

-
- -
+
+
+
+ + +
+
2016-02-23 + 12:23 + 王玉
+ +

+ 修改comment +

+
+
- -
-
- - -
-
- - - -
-
-

Commit changes

- -
- -
-
-
+
+
+
@@ -282,7 +198,6 @@ -