From e577f59a7e7fd72cb58321b85da53a9b8d635f1f Mon Sep 17 00:00:00 2001 From: jenkinsci Date: Mon, 30 Oct 2017 09:24:29 +0000 Subject: [PATCH 1/6] Development version increased: 0.0.14-SNAPSHOT --- version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version b/version index 2c25603d..27b1cbf2 100644 --- a/version +++ b/version @@ -1 +1 @@ -0.0.13-SNAPSHOT \ No newline at end of file +0.0.14-SNAPSHOT \ No newline at end of file From 43f354b7d59b46ae014215601d4d26b59747e235 Mon Sep 17 00:00:00 2001 From: Andrey Esmeneev Date: Mon, 30 Oct 2017 20:29:49 +0300 Subject: [PATCH 2/6] model filter --- .../model-details.component.html | 3 +- .../components/sidebar/sidebar.component.html | 86 +++++++++++-------- .../components/sidebar/sidebar.component.scss | 45 +++++++++- .../components/sidebar/sidebar.component.ts | 6 +- src/modules/shared/pipes/_index.ts | 3 +- .../shared/pipes/model-filter.pipe.spec.ts | 8 ++ src/modules/shared/pipes/model-filter.pipe.ts | 18 ++++ src/modules/shared/shared.module.ts | 3 + 8 files changed, 132 insertions(+), 40 deletions(-) create mode 100644 src/modules/shared/pipes/model-filter.pipe.spec.ts create mode 100644 src/modules/shared/pipes/model-filter.pipe.ts diff --git a/src/modules/models/model-details/model-details.component.html b/src/modules/models/model-details/model-details.component.html index c7ad8af0..188255f2 100644 --- a/src/modules/models/model-details/model-details.component.html +++ b/src/modules/models/model-details/model-details.component.html @@ -94,7 +94,8 @@
Versions
-
+ +
{{ weightedService.serviceName }} diff --git a/src/modules/shared/components/sidebar/sidebar.component.html b/src/modules/shared/components/sidebar/sidebar.component.html index 8b5fece1..d4d812c7 100644 --- a/src/modules/shared/components/sidebar/sidebar.component.html +++ b/src/modules/shared/components/sidebar/sidebar.component.html @@ -1,42 +1,56 @@ diff --git a/src/modules/shared/components/sidebar/sidebar.component.scss b/src/modules/shared/components/sidebar/sidebar.component.scss index 878ff44c..18fb6f89 100644 --- a/src/modules/shared/components/sidebar/sidebar.component.scss +++ b/src/modules/shared/components/sidebar/sidebar.component.scss @@ -3,7 +3,7 @@ .sidebar { height: 100%; &-header { - padding: 45px 32px 42px; + padding: 45px 32px 26px; border-bottom: 2px solid #d4d7d9; &__row { display: flex; @@ -35,6 +35,7 @@ margin: 0; padding: 0; &__item { + height: 0px; line-height: 15px; border-bottom: 1px solid $secondary-color; padding: 23px 36px; @@ -76,6 +77,44 @@ } } } + &-filter { + display: flex; + flex-direction: row; + align-items: center; + &__label { + color: #818994; + font-size: 12px; + font-weight: 400; + line-height: 24px; + text-transform: uppercase; + letter-spacing: 1.2px; + padding-right: 10px; + } + &__button { + height: 33px; + border-radius: 5px; + background-color: #e6e9ed; + border: none; + cursor: pointer; + margin-right: 10px; + display: inline-flex; + &--label { + font-family: $main-font-family; + color: #818994; + font-size: 14px; + font-weight: 400; + line-height: 24px; + letter-spacing: 0.35px; + } + &--icon { + margin-top: 5px; + margin-right: 5px; + } + } + &__selected { + background: none; + } + } } ::-webkit-scrollbar { @@ -99,6 +138,10 @@ svg { fill: #e1e4eb; } +.undeployed-filter { + fill: #d2d5d9; +} + .version-new { padding-right: 26px!important; color: #f28a03; diff --git a/src/modules/shared/components/sidebar/sidebar.component.ts b/src/modules/shared/components/sidebar/sidebar.component.ts index 1b780b20..a27edbc5 100644 --- a/src/modules/shared/components/sidebar/sidebar.component.ts +++ b/src/modules/shared/components/sidebar/sidebar.component.ts @@ -27,7 +27,7 @@ export class SidebarComponent implements OnInit, OnChanges, OnDestroy { private title = ''; public searchQ: string; private needsToGo = false; - + public deployedFilter = {'deployed': true, 'undeployed': true}; @Input() isAddBtnEnabled: boolean; @Input() isModels: boolean; @Input() sidebarTitle: string; @@ -97,6 +97,10 @@ export class SidebarComponent implements OnInit, OnChanges, OnDestroy { } + toggleModelFilter(option) { + this.deployedFilter[option] = !this.deployedFilter[option]; + } + public isDeployable(model) { if (!model || !model.lastModelRuntime.created) { return true; diff --git a/src/modules/shared/pipes/_index.ts b/src/modules/shared/pipes/_index.ts index c18acd90..20bd4b3c 100644 --- a/src/modules/shared/pipes/_index.ts +++ b/src/modules/shared/pipes/_index.ts @@ -1,7 +1,8 @@ +export * from './model-filter.pipe'; export * from './model-status.pipe'; export * from './positive-numbers.pipe'; export * from './search.pipe'; export * from './sort-by.pipe'; export * from './utc-to-local.pipe'; export * from './iterate-as-array.pipe'; -export * from './remove-dublicates.pipe'; \ No newline at end of file +export * from './remove-dublicates.pipe'; diff --git a/src/modules/shared/pipes/model-filter.pipe.spec.ts b/src/modules/shared/pipes/model-filter.pipe.spec.ts new file mode 100644 index 00000000..67f25c3e --- /dev/null +++ b/src/modules/shared/pipes/model-filter.pipe.spec.ts @@ -0,0 +1,8 @@ +import { ModelFilterPipe } from './model-filter.pipe'; + +describe('ModelFilterPipe', () => { + it('create an instance', () => { + const pipe = new ModelFilterPipe(); + expect(true).toBeTruthy(); + }); +}); diff --git a/src/modules/shared/pipes/model-filter.pipe.ts b/src/modules/shared/pipes/model-filter.pipe.ts new file mode 100644 index 00000000..2e3f53b2 --- /dev/null +++ b/src/modules/shared/pipes/model-filter.pipe.ts @@ -0,0 +1,18 @@ +import { Pipe, PipeTransform } from '@angular/core'; + +@Pipe({ + name: 'modelFilter', + pure: false +}) +export class ModelFilterPipe implements PipeTransform { + + transform(models: any, filterStatus: any): any { + return models.filter(model => { + let result = false; + result = result || filterStatus['deployed'] && model.currentServices && model.currentServices.length > 0; + result = result || filterStatus['undeployed'] && (!model.currentServices || model.currentServices.length < 1); + return result; + }); + } + +} diff --git a/src/modules/shared/shared.module.ts b/src/modules/shared/shared.module.ts index a3ef4330..c7baa806 100644 --- a/src/modules/shared/shared.module.ts +++ b/src/modules/shared/shared.module.ts @@ -29,6 +29,7 @@ import { // Pipes import { + ModelFilterPipe, ModelStatusPipe, PositiveNumbersPipe, SearchPipe, @@ -76,6 +77,7 @@ import { ], declarations: [ // Pipes + ModelFilterPipe, ModelStatusPipe, PositiveNumbersPipe, SearchPipe, @@ -118,6 +120,7 @@ import { ], exports: [ // Pipes + ModelFilterPipe, ModelStatusPipe, PositiveNumbersPipe, SearchPipe, From f059bac9f23697986858a69171421e163a63c634 Mon Sep 17 00:00:00 2001 From: Andrey Esmeneev Date: Mon, 30 Oct 2017 20:47:11 +0300 Subject: [PATCH 3/6] test modal styles and icon --- .../dialog-test.component/dialog-test.component.scss | 8 ++++++++ src/assets/images/copy.svg | 1 + 2 files changed, 9 insertions(+) create mode 100644 src/assets/images/copy.svg diff --git a/src/app/components/dialogs/dialog-test.component/dialog-test.component.scss b/src/app/components/dialogs/dialog-test.component/dialog-test.component.scss index d57f92e8..60aed060 100644 --- a/src/app/components/dialogs/dialog-test.component/dialog-test.component.scss +++ b/src/app/components/dialogs/dialog-test.component/dialog-test.component.scss @@ -14,3 +14,11 @@ margin-top: 20px; margin-bottom: 10px; } + +.input { + &-text { + &__input { + font-family: monospace; + } + } +} diff --git a/src/assets/images/copy.svg b/src/assets/images/copy.svg new file mode 100644 index 00000000..27bd1269 --- /dev/null +++ b/src/assets/images/copy.svg @@ -0,0 +1 @@ + \ No newline at end of file From 0ba81e8e9d3e08187d3c830aaa681933bbcb08df Mon Sep 17 00:00:00 2001 From: Andrey Esmeneev Date: Tue, 31 Oct 2017 18:46:44 +0300 Subject: [PATCH 4/6] wider runtimetype select in model deploy --- src/assets/styles/_mdl-textfieled.scss | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/assets/styles/_mdl-textfieled.scss b/src/assets/styles/_mdl-textfieled.scss index 721d5268..975873b3 100644 --- a/src/assets/styles/_mdl-textfieled.scss +++ b/src/assets/styles/_mdl-textfieled.scss @@ -19,4 +19,8 @@ border-radius: 5px; color: #04143c; } -} \ No newline at end of file +} +// hack for dialog-model-build +.runtime-select > .mdl-textfield { + width:60%; +} From a98cb7e57e1be15b911396af121a992b6654f271 Mon Sep 17 00:00:00 2001 From: Andrey Esmeneev Date: Tue, 31 Oct 2017 22:17:34 +0300 Subject: [PATCH 5/6] test models WIP --- .../dialog-test.component.html | 2 +- .../dialog-test.component.ts | 85 ++++++++++--------- .../shared/services/model-runtimes.service.ts | 6 ++ 3 files changed, 50 insertions(+), 43 deletions(-) diff --git a/src/app/components/dialogs/dialog-test.component/dialog-test.component.html b/src/app/components/dialogs/dialog-test.component/dialog-test.component.html index 82ae18bf..3267de1d 100644 --- a/src/app/components/dialogs/dialog-test.component/dialog-test.component.html +++ b/src/app/components/dialogs/dialog-test.component/dialog-test.component.html @@ -1,6 +1,6 @@

{{testTitle}}

-
+
diff --git a/src/app/components/dialogs/dialog-test.component/dialog-test.component.ts b/src/app/components/dialogs/dialog-test.component/dialog-test.component.ts index f37fdf9c..75e3c345 100644 --- a/src/app/components/dialogs/dialog-test.component/dialog-test.component.ts +++ b/src/app/components/dialogs/dialog-test.component/dialog-test.component.ts @@ -7,7 +7,7 @@ import 'codemirror/addon/edit/matchbrackets.js'; import 'codemirror/addon/edit/closebrackets.js'; import 'codemirror/addon/display/placeholder.js'; import { Model, ModelService, Service } from '@shared/models/_index'; -import { ServicesService, ModelServicesService } from '@shared/services/_index'; +import { ServicesService, ModelServicesService, ModelRuntimesService } from '@shared/services/_index'; import { environment } from 'environments/environment'; import { Location } from '@angular/common'; @@ -26,6 +26,7 @@ export class DialogTestComponent implements OnInit { public testForm: FormGroup; public codeMirrorInputOptions: {}; public codeMirrorOutputOptions: {}; + public input: {}; public output: {}; public testBtn: string; public testTitle: string; @@ -38,6 +39,7 @@ export class DialogTestComponent implements OnInit { private fb: FormBuilder, private mdlSnackbarService: MdlSnackbarService, private modelServicesService: ModelServicesService, + private modelRuntimesService: ModelRuntimesService, private location: Location, private servicesService: ServicesService ) { @@ -50,34 +52,45 @@ export class DialogTestComponent implements OnInit { ngOnInit() { - if (!this.model.id || this.model instanceof Model) { - this.testTitle = `Test model "${this.model.modelRuntime.modelName}"`; - this.testBtn = 'Test model'; - } else { - this.testTitle = `Test service "${this.model.serviceName}"`; - this.testBtn = `Test service`; + if (this.model instanceof Service) { + this.input = {} + } + else { + this.modelRuntimesService.generateInputs(this.model.modelRuntime.id).first() + .subscribe(data => { + this.input = data; + if (!this.model.id || this.model instanceof Model) { + this.testTitle = `Test model "${this.model.modelRuntime.modelName}"`; + this.testBtn = 'Test model'; + } else { + this.testTitle = `Test service "${this.model.serviceName}"`; + this.testBtn = `Test service`; + } + console.log(this.input); + this.createTestForm(); + this.requestBody = this.createCURLString(this.testForm); + this.testForm.valueChanges.subscribe(form => { + this.requestBody = this.createCURLString(this.testForm); + }); + this.codeMirrorInputOptions = { + matchBrackets: true, + autoCloseBrackets: true, + mode: { name: 'javascript', json: true }, + lineWrapping: true, + readOnly: false, + scrollbarStyle: 'null' + }; + this.codeMirrorOutputOptions = { + matchBrackets: true, + autoCloseBrackets: true, + mode: { name: 'javascript', json: true }, + lineWrapping: true, + readOnly: true, + scrollbarStyle: 'null' + }; + }); } - this.createTestForm(); - this.requestBody = this.createCURLString(this.testForm); - this.testForm.valueChanges.subscribe(form => { - this.requestBody = this.createCURLString(this.testForm); - }); - this.codeMirrorInputOptions = { - matchBrackets: true, - autoCloseBrackets: true, - mode: { name: 'javascript', json: true }, - lineWrapping: true, - readOnly: false, - scrollbarStyle: 'null' - }; - this.codeMirrorOutputOptions = { - matchBrackets: true, - autoCloseBrackets: true, - mode: { name: 'javascript', json: true }, - lineWrapping: true, - readOnly: true, - scrollbarStyle: 'null' - }; + } @@ -103,25 +116,13 @@ export class DialogTestComponent implements OnInit { private createTestForm() { this.testForm = this.fb.group({ - data: [this.extractModelInputFields(this.model), [Validators.required, this.validateInput]], + data: [JSON.stringify(this.input), [Validators.required, this.validateInput]], path: ['/serve', [Validators.required]], }); } private extractModelInputFields(model): string { - let inputFields; - if (model.inputFields) { - inputFields = model.inputFields; - } else if (model.modelRuntime && model.modelRuntime.inputFields) { - inputFields = model.modelRuntime.inputFields; - } else { - return JSON.stringify([{}]); - } - const reducedFields = inputFields.reduce((payload, field) => { - payload[field] = ''; - return payload; - }, {}); - return JSON.stringify([reducedFields], undefined, 2); + return '{}'; } private validateInput(input) { diff --git a/src/modules/shared/services/model-runtimes.service.ts b/src/modules/shared/services/model-runtimes.service.ts index 29622603..ddc00464 100644 --- a/src/modules/shared/services/model-runtimes.service.ts +++ b/src/modules/shared/services/model-runtimes.service.ts @@ -43,6 +43,12 @@ export class ModelRuntimesService { return res.json(); }); } + generateInputs(id: number): Observable{ + const url = `${this.baseAPIUrl}/generateInputs/${id}`; + return this.http.get(url).map((res: Response) => { + return res.json(); + }) + } createModelRuntime() {} removeModelRuntime() {} updateModelRuntime() {} From ab40770d74a9956adf8ec9a4a7cca85c577999ea Mon Sep 17 00:00:00 2001 From: Andrey Esmeneev Date: Wed, 1 Nov 2017 18:01:53 +0300 Subject: [PATCH 6/6] proper input for testing models --- .../dialog-test.component.ts | 69 ++++++++++--------- 1 file changed, 35 insertions(+), 34 deletions(-) diff --git a/src/app/components/dialogs/dialog-test.component/dialog-test.component.ts b/src/app/components/dialogs/dialog-test.component/dialog-test.component.ts index 75e3c345..51ed3acd 100644 --- a/src/app/components/dialogs/dialog-test.component/dialog-test.component.ts +++ b/src/app/components/dialogs/dialog-test.component/dialog-test.component.ts @@ -52,48 +52,45 @@ export class DialogTestComponent implements OnInit { ngOnInit() { + this.codeMirrorInputOptions = { + matchBrackets: true, + autoCloseBrackets: true, + mode: { name: 'javascript', json: true }, + lineWrapping: true, + readOnly: false, + scrollbarStyle: 'null' + }; + this.codeMirrorOutputOptions = { + matchBrackets: true, + autoCloseBrackets: true, + mode: { name: 'javascript', json: true }, + lineWrapping: true, + readOnly: true, + scrollbarStyle: 'null' + }; + + if (this.model instanceof Service) { - this.input = {} - } - else { - this.modelRuntimesService.generateInputs(this.model.modelRuntime.id).first() - .subscribe(data => { - this.input = data; - if (!this.model.id || this.model instanceof Model) { + this.input = [{}]; + this.testTitle = `Test service "${this.model.serviceName}"`; + this.testBtn = `Test service`; + this.createTestForm(); + } else { + // TODO: come up with better way of sending async data into formbuilder + this.modelRuntimesService.generateInputs(this.model.modelRuntime.id).first() + .subscribe(data => { + this.input = data; this.testTitle = `Test model "${this.model.modelRuntime.modelName}"`; this.testBtn = 'Test model'; - } else { - this.testTitle = `Test service "${this.model.serviceName}"`; - this.testBtn = `Test service`; - } - console.log(this.input); - this.createTestForm(); - this.requestBody = this.createCURLString(this.testForm); - this.testForm.valueChanges.subscribe(form => { - this.requestBody = this.createCURLString(this.testForm); + this.createTestForm(); }); - this.codeMirrorInputOptions = { - matchBrackets: true, - autoCloseBrackets: true, - mode: { name: 'javascript', json: true }, - lineWrapping: true, - readOnly: false, - scrollbarStyle: 'null' - }; - this.codeMirrorOutputOptions = { - matchBrackets: true, - autoCloseBrackets: true, - mode: { name: 'javascript', json: true }, - lineWrapping: true, - readOnly: true, - scrollbarStyle: 'null' - }; - }); } } + + private createCURLString(form) { let path = ''; let payload = ''; @@ -116,9 +113,13 @@ export class DialogTestComponent implements OnInit { private createTestForm() { this.testForm = this.fb.group({ - data: [JSON.stringify(this.input), [Validators.required, this.validateInput]], + data: [JSON.stringify(this.input, null, 2), [Validators.required, this.validateInput]], path: ['/serve', [Validators.required]], }); + this.requestBody = this.createCURLString(this.testForm); + this.testForm.valueChanges.subscribe(form => { + this.requestBody = this.createCURLString(this.testForm); + }); } private extractModelInputFields(model): string {