diff --git a/README.md b/README.md index 30ca1abd..cc21b1ae 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ consistency between process cache and Redis. > Kotlin DSL ``` kotlin - val governVersion = "0.9.12"; + val governVersion = "0.9.13"; implementation("me.ahoo.govern:spring-cloud-starter-config:${governVersion}") implementation("me.ahoo.govern:spring-cloud-starter-discovery:${governVersion}") ``` @@ -33,7 +33,7 @@ consistency between process cache and Redis. 4.0.0 demo - 0.9.12 + 0.9.13 @@ -74,31 +74,31 @@ spring: #### Option 1:Download the executable file -> Download [rest-api-server](https://github.com/Ahoo-Wang/govern-service/releases/download/0.9.12/rest-api-0.9.12.tar) +> Download [rest-api-server](https://github.com/Ahoo-Wang/govern-service/releases/download/0.9.13/rest-api-0.9.13.tar) -> tar *rest-api-0.9.12.tar* +> tar *rest-api-0.9.13.tar* ```shell -cd rest-api-0.9.12 -# Working directory: rest-api-0.9.12 +cd rest-api-0.9.13 +# Working directory: rest-api-0.9.13 bin/rest-api --server.port=8080 --govern.redis.uri=redis://localhost:6379 ``` #### Option 2:Docker run ```shell -docker pull ahoowang/govern-service:0.9.12 -docker run --name govern-service -d -p 8080:8080 --link redis -e GOVERN_REDIS_URI=redis://redis:6379 ahoowang/govern-service:0.9.12 +docker pull ahoowang/govern-service:0.9.13 +docker run --name govern-service -d -p 8080:8080 --link redis -e GOVERN_REDIS_URI=redis://redis:6379 ahoowang/govern-service:0.9.13 ``` --- > MacBook Pro (M1) > -> Please use *ahoowang/govern-service:0.9.12-armv7* +> Please use *ahoowang/govern-service:0.9.13-armv7* ```shell -docker pull ahoowang/govern-service:0.9.12-armv7 -docker run --name govern-service -d -p 8080:8080 --link redis -e GOVERN_REDIS_URI=redis://redis:6379 ahoowang/govern-service:0.9.12-armv7 +docker pull ahoowang/govern-service:0.9.13-armv7 +docker run --name govern-service -d -p 8080:8080 --link redis -e GOVERN_REDIS_URI=redis://redis:6379 ahoowang/govern-service:0.9.13-armv7 ``` --- diff --git a/README.zh-CN.md b/README.zh-CN.md index 996076c3..d0c66eda 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -11,7 +11,7 @@ > Kotlin DSL ``` kotlin - val governVersion = "0.9.12"; + val governVersion = "0.9.13"; implementation("me.ahoo.govern:spring-cloud-starter-config:${governVersion}") implementation("me.ahoo.govern:spring-cloud-starter-discovery:${governVersion}") ``` @@ -28,7 +28,7 @@ 4.0.0 demo - 0.9.12 + 0.9.13 @@ -73,31 +73,31 @@ logging: #### 方式一:下载可执行文件 -> 下载 [rest-api-server](https://github.com/Ahoo-Wang/govern-service/releases/download/0.9.12/rest-api-0.9.12.tar) +> 下载 [rest-api-server](https://github.com/Ahoo-Wang/govern-service/releases/download/0.9.13/rest-api-0.9.13.tar) -> 解压 *rest-api-0.9.12.tar* +> 解压 *rest-api-0.9.13.tar* ```shell -cd rest-api-0.9.12 -# 工作目录: rest-api-0.9.12 +cd rest-api-0.9.13 +# 工作目录: rest-api-0.9.13 bin/rest-api --server.port=8080 --govern.redis.uri=redis://localhost:6379 ``` #### 方式二:Docker run ```shell -docker pull ahoowang/govern-service:0.9.12 -docker run --name govern-service -d -p 8080:8080 --link redis -e GOVERN_REDIS_URI=redis://redis:6379 ahoowang/govern-service:0.9.12 +docker pull ahoowang/govern-service:0.9.13 +docker run --name govern-service -d -p 8080:8080 --link redis -e GOVERN_REDIS_URI=redis://redis:6379 ahoowang/govern-service:0.9.13 ``` --- > MacBook Pro (M1) > -> 请使用 *ahoowang/govern-service:0.9.12-armv7* +> 请使用 *ahoowang/govern-service:0.9.13-armv7* ```shell -docker pull ahoowang/govern-service:0.9.12-armv7 -docker run --name govern-service -d -p 8080:8080 --link redis -e GOVERN_REDIS_URI=redis://redis:6379 ahoowang/govern-service:0.9.12-armv7 +docker pull ahoowang/govern-service:0.9.13-armv7 +docker run --name govern-service -d -p 8080:8080 --link redis -e GOVERN_REDIS_URI=redis://redis:6379 ahoowang/govern-service:0.9.13-armv7 ``` --- diff --git a/dashboard/angular.json b/dashboard/angular.json index 203099fa..716c5e6f 100644 --- a/dashboard/angular.json +++ b/dashboard/angular.json @@ -36,7 +36,8 @@ "glob": "**/*", "input": "./node_modules/@ant-design/icons-angular/src/inline-svg/", "output": "/assets/" - } + }, + { "glob": "**/*", "input": "node_modules/ngx-monaco-editor/assets/monaco", "output": "./assets/monaco/" } ], "styles": [ "./node_modules/ng-zorro-antd/ng-zorro-antd.min.css", diff --git a/dashboard/package.json b/dashboard/package.json index 97a98e30..54556523 100644 --- a/dashboard/package.json +++ b/dashboard/package.json @@ -19,7 +19,9 @@ "@angular/platform-browser": "~11.2.13", "@angular/platform-browser-dynamic": "~11.2.13", "@angular/router": "~11.2.13", + "monaco-editor": "^0.24.0", "ng-zorro-antd": "^11.4.1", + "ngx-monaco-editor": "^9.0.0", "rxjs": "~6.6.0", "tslib": "^2.0.0", "zone.js": "~0.11.3" diff --git a/dashboard/src/app/api/config/Configs.ts b/dashboard/src/app/api/config/Configs.ts index f7dacfb9..295ebc25 100644 --- a/dashboard/src/app/api/config/Configs.ts +++ b/dashboard/src/app/api/config/Configs.ts @@ -23,4 +23,45 @@ export class Configs { opTime: 0 }; } + + static extAsLang(configExt: string): string { + switch (configExt) { + case 'yml': { + return 'yaml'; + } + default: + return configExt; + } + } } + +export type ConfigExt = 'text' | 'json' | 'xml' | 'yaml' | 'properties'; + +export class ConfigName { + name: string; + ext: string; + + constructor(name: string, ext: string) { + this.name = name; + this.ext = ext; + } + + static of(configId: string): ConfigName { + const idx = configId.lastIndexOf('.'); + if (idx < 0) { + return new ConfigName(configId, ''); + } + const name = configId.substring(0, idx); + const ext = configId.substring(idx + 1); + + return new ConfigName(name, ext); + } + + toId(): string { + if (this.ext.length === 0) { + return this.name; + } + return `${this.name}.${this.ext}`; + } +} + diff --git a/dashboard/src/app/app.module.ts b/dashboard/src/app/app.module.ts index 6cd3af3f..d38a79e3 100644 --- a/dashboard/src/app/app.module.ts +++ b/dashboard/src/app/app.module.ts @@ -27,6 +27,7 @@ import {NzSwitchModule} from 'ng-zorro-antd/switch'; import {NzDropDownModule} from 'ng-zorro-antd/dropdown'; import {NzStatisticModule} from 'ng-zorro-antd/statistic'; import {NzUploadModule} from 'ng-zorro-antd/upload'; +import {MonacoEditorModule} from 'ngx-monaco-editor'; import {NamespaceSelectorComponent} from './components/namespace/namespace-selector/namespace-selector.component'; import {NamespaceComponent} from './components/namespace/namespace.component'; @@ -82,7 +83,9 @@ registerLocaleData(zh); NzSwitchModule, NzDropDownModule, NzStatisticModule, - NzUploadModule + NzUploadModule, + MonacoEditorModule, + MonacoEditorModule.forRoot() ], providers: [{provide: NZ_I18N, useValue: zh_CN}], bootstrap: [AppComponent] diff --git a/dashboard/src/app/components/config/config-editor.service.ts b/dashboard/src/app/components/config/config-editor.service.ts index a6fdda2b..13f97296 100644 --- a/dashboard/src/app/components/config/config-editor.service.ts +++ b/dashboard/src/app/components/config/config-editor.service.ts @@ -24,7 +24,7 @@ export class ConfigEditorService { } const drawerRef = this.drawerService.create({ nzTitle: editorTitle, - nzWidth: '40%', + nzWidth: '880px', nzContent: ConfigEditorComponent, nzContentParams: { configId @@ -65,7 +65,7 @@ export class ConfigEditorService { const drawerRef = this.drawerService.create({ nzTitle: `Config [${configId}] Version [${version}]`, - nzWidth: '40%', + nzWidth: '880px', nzContent: ConfigVersionComponent, nzContentParams: { configId, diff --git a/dashboard/src/app/components/config/config-editor/config-editor.component.html b/dashboard/src/app/components/config/config-editor/config-editor.component.html index e42378c2..102e398e 100644 --- a/dashboard/src/app/components/config/config-editor/config-editor.component.html +++ b/dashboard/src/app/components/config/config-editor/config-editor.component.html @@ -1,16 +1,28 @@
- ConfigId - - + ConfigId + + + + + + + + + + + + + - ConfigId - + ConfigId + - hash - + hash + - version - + version + - createTime - + CreateTime + - - - Data - - - - + + + diff --git a/dashboard/src/app/components/config/config-editor/config-editor.component.scss b/dashboard/src/app/components/config/config-editor/config-editor.component.scss index e69de29b..71df0b14 100644 --- a/dashboard/src/app/components/config/config-editor/config-editor.component.scss +++ b/dashboard/src/app/components/config/config-editor/config-editor.component.scss @@ -0,0 +1,3 @@ +nz-select { + width: 220px; +} diff --git a/dashboard/src/app/components/config/config-editor/config-editor.component.ts b/dashboard/src/app/components/config/config-editor/config-editor.component.ts index 19ff535d..e711a75c 100644 --- a/dashboard/src/app/components/config/config-editor/config-editor.component.ts +++ b/dashboard/src/app/components/config/config-editor/config-editor.component.ts @@ -4,7 +4,8 @@ import {ConfigDto} from '../../../api/config/ConfigDto'; import {NamespaceContext} from '../../../core/NamespaceContext'; import {NzMessageService} from 'ng-zorro-antd/message'; import {ConfigClient} from '../../../api/config/ConfigClient'; -import {Configs} from '../../../api/config/Configs'; +import {ConfigName, Configs} from '../../../api/config/Configs'; + @Component({ selector: 'app-config-editor', @@ -15,40 +16,48 @@ export class ConfigEditorComponent implements OnInit { validateForm!: FormGroup; @Input() configId?: string; @Output() afterSet: EventEmitter = new EventEmitter(); - config: ConfigDto; + config!: ConfigDto; isAdd = true; + editorOptions = {theme: 'vs-dark', language: 'yaml'}; + configName!: ConfigName; constructor(private namespaceContext: NamespaceContext, private configClient: ConfigClient, private messageService: NzMessageService, private formBuilder: FormBuilder) { - this.config = Configs.of(); + } ngOnInit(): void { + this.config = Configs.of(); + this.configName = ConfigName.of('.yaml'); + if (this.configId) { this.isAdd = false; this.configClient.getConfig(this.namespaceContext.ensureCurrentNamespace(), this.configId) .subscribe(config => { this.config = config; + this.configName = ConfigName.of(config.configId); + this.onExtChanged(this.configName.ext); }); } const controlsConfig = { - configId: [this.config.configId, [Validators.required]], + configName: [this.configName.name, [Validators.required]], version: [this.config.version], hash: [this.config.hash], - data: [this.config.data, [Validators.required]], + data: [this.config.data], createTime: [this.config.createTime] }; if (!this.isAdd) { - controlsConfig.configId = [this.config.configId]; + controlsConfig.configName = [this.configName.name]; } this.validateForm = this.formBuilder.group(controlsConfig); } setConfig(): void { + this.config.configId = this.configName.toId(); this.configClient.setConfig(this.namespaceContext.ensureCurrentNamespace(), this.config.configId, this.config.data) .subscribe(result => { this.messageService.success(`Config[${this.config.configId}] added successfull!`); @@ -59,4 +68,9 @@ export class ConfigEditorComponent implements OnInit { }); } + onExtChanged(configExt: string): void { + this.configName.ext = configExt; + const language = Configs.extAsLang(configExt); + this.editorOptions = Object.assign({}, this.editorOptions, {language}); + } } diff --git a/dashboard/src/app/components/config/config-version/config-version.component.html b/dashboard/src/app/components/config/config-version/config-version.component.html index dd928e47..a6786076 100644 --- a/dashboard/src/app/components/config/config-version/config-version.component.html +++ b/dashboard/src/app/components/config/config-version/config-version.component.html @@ -1,7 +1,7 @@ - ConfigId - + ConfigId + - hash - + hash + - version - + version + - createTime - + createTime + - op - + op + - opTime - + opTime + - - - Data - - - - + + - + diff --git a/dashboard/src/app/components/config/config-version/config-version.component.ts b/dashboard/src/app/components/config/config-version/config-version.component.ts index c891d8ec..1a3be002 100644 --- a/dashboard/src/app/components/config/config-version/config-version.component.ts +++ b/dashboard/src/app/components/config/config-version/config-version.component.ts @@ -2,7 +2,8 @@ import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core'; import {ConfigHistoryDto} from '../../../api/config/ConfigHistoryDto'; import {NamespaceContext} from '../../../core/NamespaceContext'; import {ConfigClient} from '../../../api/config/ConfigClient'; -import {Configs} from '../../../api/config/Configs'; +import {ConfigName, Configs} from '../../../api/config/Configs'; +import {ConfigDto} from '../../../api/config/ConfigDto'; @Component({ selector: 'app-config-version', @@ -13,7 +14,10 @@ export class ConfigVersionComponent implements OnInit { @Input() configId!: string; @Input() version!: number; configHistory!: ConfigHistoryDto; + configCurrent!: ConfigDto; @Output() rollbackAfter: EventEmitter = new EventEmitter(); + configHistoryCode: any = {code: ''}; + configCurrentCode: any = {code: ''}; constructor(private namespaceContext: NamespaceContext, private configClient: ConfigClient) { @@ -21,9 +25,17 @@ export class ConfigVersionComponent implements OnInit { } ngOnInit(): void { + const configName = ConfigName.of(this.configId); + const lang = Configs.extAsLang(configName.ext); this.configClient.getConfigHistory(this.namespaceContext.ensureCurrentNamespace(), this.configId, this.version) .subscribe(configHistory => { this.configHistory = configHistory; + this.configHistoryCode = Object.assign({}, this.configHistoryCode, {language: lang, code: configHistory.data}); + }); + this.configClient.getConfig(this.namespaceContext.ensureCurrentNamespace(), this.configId) + .subscribe(config => { + this.configCurrent = config; + this.configCurrentCode = Object.assign({}, this.configCurrentCode, {language: lang, code: config.data}); }); } @@ -34,4 +46,7 @@ export class ConfigVersionComponent implements OnInit { }); } + onInitDiffEditor($event: any): void { + console.log($event); + } } diff --git a/dashboard/src/app/components/namespace/namespace-selector/namespace-selector.component.css b/dashboard/src/app/components/namespace/namespace-selector/namespace-selector.component.css index e69de29b..8b137891 100644 --- a/dashboard/src/app/components/namespace/namespace-selector/namespace-selector.component.css +++ b/dashboard/src/app/components/namespace/namespace-selector/namespace-selector.component.css @@ -0,0 +1 @@ + diff --git a/dashboard/src/app/components/service/instance-editor.service.ts b/dashboard/src/app/components/service/instance-editor.service.ts index 767fb4fb..68a03a1b 100644 --- a/dashboard/src/app/components/service/instance-editor.service.ts +++ b/dashboard/src/app/components/service/instance-editor.service.ts @@ -23,7 +23,7 @@ export class InstanceEditorService { editInstance.ephemeral = false; const drawerRef = this.drawerService.create({ nzTitle: `Managing service[${serviceId}] instances`, - nzWidth: '40%', + nzWidth: '550px', nzContent: InstanceEditorComponent, nzContentParams: { instance: editInstance diff --git a/dashboard/src/app/components/service/instance-editor/instance-editor.component.html b/dashboard/src/app/components/service/instance-editor/instance-editor.component.html index b42de93b..59403501 100644 --- a/dashboard/src/app/components/service/instance-editor/instance-editor.component.html +++ b/dashboard/src/app/components/service/instance-editor/instance-editor.component.html @@ -1,4 +1,4 @@ -
+ ServiceId @@ -55,13 +55,10 @@ nzCheckedChildren="ephemeral"> - - Metadata (JSON) - - - - + + diff --git a/docs/dashboard-config-edit.png b/docs/dashboard-config-edit.png index 2a020698..5e958569 100644 Binary files a/docs/dashboard-config-edit.png and b/docs/dashboard-config-edit.png differ diff --git a/docs/dashboard-config-rollback.png b/docs/dashboard-config-rollback.png index 530be2f4..e203913c 100644 Binary files a/docs/dashboard-config-rollback.png and b/docs/dashboard-config-rollback.png differ diff --git a/docs/dashboard-service-edit.png b/docs/dashboard-service-edit.png index 1bb033b5..ec624dd0 100644 Binary files a/docs/dashboard-service-edit.png and b/docs/dashboard-service-edit.png differ diff --git a/gradle.properties b/gradle.properties index 9f26936a..42263eae 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ group=me.ahoo.govern -version=0.9.12 +version=0.9.13 description=Govern Service On Redis website=https://github.com/Ahoo-Wang/govern-service diff --git a/k8s/deployment/govern-servce-rest-api.yml b/k8s/deployment/govern-servce-rest-api.yml index 675d055b..088b712b 100644 --- a/k8s/deployment/govern-servce-rest-api.yml +++ b/k8s/deployment/govern-servce-rest-api.yml @@ -18,7 +18,7 @@ spec: value: cluster - name: GOVERN_REDIS_URI value: redis://redis-url:6379 - image: ahoowang/govern-service:0.9.11 + image: ahoowang/govern-service:0.9.13 name: govern-service resources: limits: diff --git a/k8s/docker/rest-api-local/Dockerfile b/k8s/docker/rest-api-local/Dockerfile index dddc4718..4f3cce03 100644 --- a/k8s/docker/rest-api-local/Dockerfile +++ b/k8s/docker/rest-api-local/Dockerfile @@ -1,8 +1,8 @@ -# docker buildx build --push --platform linux/arm/v7 --build-arg GOVERN_VERSION=0.9.12 --build-arg JDK_VERSION=armv7l-centos-jdk-11.0.11_9-slim -t ahoowang/govern-service:0.9.12-armv7 . -# docker buildx build --push --platform linux/amd64,linux/arm64 --build-arg GOVERN_VERSION=0.9.12 --build-arg JDK_VERSION=jdk11u-centos-nightly-slim -t ahoowang/govern-service:0.9.12 . +# docker buildx build --push --platform linux/arm/v7 --build-arg GOVERN_VERSION=0.9.13 --build-arg JDK_VERSION=armv7l-centos-jdk-11.0.11_9-slim -t ahoowang/govern-service:0.9.13-armv7 . +# docker buildx build --push --platform linux/amd64,linux/arm64 --build-arg GOVERN_VERSION=0.9.13 --build-arg JDK_VERSION=jdk11u-centos-nightly-slim -t ahoowang/govern-service:0.9.13 . ARG JDK_VERSION=jdk11u-centos-nightly -ARG GOVERN_VERSION=0.9.12 +ARG GOVERN_VERSION=0.9.13 ARG GOVERN_SERVICE_HOME=/govern-service FROM adoptopenjdk/openjdk11:${JDK_VERSION} AS base diff --git a/k8s/docker/rest-api/Dockerfile b/k8s/docker/rest-api/Dockerfile index 61ee873d..2fd22ec4 100644 --- a/k8s/docker/rest-api/Dockerfile +++ b/k8s/docker/rest-api/Dockerfile @@ -1,8 +1,8 @@ -# docker buildx build --push --platform linux/arm/v7 --build-arg GOVERN_VERSION=0.9.12 --build-arg JDK_VERSION=armv7l-centos-jdk-11.0.11_9-slim -t ahoowang/govern-service:0.9.12-armv7 . -# docker buildx build --push --platform linux/amd64,linux/arm64 --build-arg GOVERN_VERSION=0.9.12 --build-arg JDK_VERSION=jdk11u-centos-nightly-slim -t ahoowang/govern-service:0.9.12 . +# docker buildx build --push --platform linux/arm/v7 --build-arg GOVERN_VERSION=0.9.13 --build-arg JDK_VERSION=armv7l-centos-jdk-11.0.11_9-slim -t ahoowang/govern-service:0.9.13-armv7 . +# docker buildx build --push --platform linux/amd64,linux/arm64 --build-arg GOVERN_VERSION=0.9.13 --build-arg JDK_VERSION=jdk11u-centos-nightly-slim -t ahoowang/govern-service:0.9.13 . ARG JDK_VERSION=jdk11u-centos-nightly -ARG GOVERN_VERSION=0.9.12 +ARG GOVERN_VERSION=0.9.13 ARG GOVERN_SERVICE_HOME=/govern-service FROM adoptopenjdk/openjdk11:${JDK_VERSION} AS base