Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pure uml component #73

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
396 changes: 396 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
"@types/hammerjs": "^2.0.36",
"@types/jasmine": "^3.5.10",
"@types/jasminewd2": "^2.0.8",
"@types/jest": "^27.4.1",
"@types/node": "^12.11.1",
"codelyzer": "^5.1.2",
"cypress": "^7.6.0",
Expand Down
2 changes: 1 addition & 1 deletion src/app/components/data-view/data-view.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {WebuiSettingsService} from '../../services/webui-settings.service';
import {WebSocket} from '../../services/webSocket';
import {HttpEventType} from '@angular/common/http';
import * as $ from 'jquery';
import {DbTable} from '../../views/uml/uml.model';
import {DbTable} from '../../views/uml/api/uml.model';
import {TableModel} from '../../views/schema-editing/edit-tables/edit-tables.component';
import {Store} from '../../views/adapters/adapter.model';
import {LeftSidebarService} from '../left-sidebar/left-sidebar.service';
Expand Down
3 changes: 3 additions & 0 deletions src/app/pipes/pipes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import {Pipe, PipeTransform} from '@angular/core';
@Pipe({ name: 'value' })
export class ValuePipe implements PipeTransform {
transform(value: any): any {
if(!value){

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would turn this to use a conditional operator !value ? value : Object.values(value)

return value;
}
return Object.values( value );
}
}
Expand Down
17 changes: 16 additions & 1 deletion src/app/services/crud.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {WebuiSettingsService} from './webui-settings.service';
import {Index, ModifyPartitionRequest, PartitionFunctionModel, PartitioningRequest} from '../components/data-view/models/result-set.model';
import {webSocket} from 'rxjs/webSocket';
import {ColumnRequest, ConstraintRequest, DeleteRequest, EditCollectionRequest, EditTableRequest, ExploreTable, MaterializedRequest, MonitoringRequest, QueryRequest, RelAlgRequest, Schema, SchemaRequest, StatisticRequest, TableRequest} from '../models/ui-request.model';
import {ForeignKey} from '../views/uml/uml.model';
import {ForeignKey} from '../views/uml/api/uml.model';
import {Validators} from '@angular/forms';
import {HubService} from './hub.service';
import {Adapter} from '../views/adapters/adapter.model';
Expand Down Expand Up @@ -501,6 +501,9 @@ export class CrudService {
});
}

/**
* @deprecated use utils/validation.ts instead
*/
getNameValidator ( required: boolean = false ) {
if ( required ){
return [Validators.pattern('^[a-zA-Z_][a-zA-Z0-9_]*$'), Validators.required, Validators.max(100)];
Expand All @@ -509,20 +512,32 @@ export class CrudService {
}
}

/**
* @deprecated use utils/validation.ts instead
*/
invalidNameMessage ( type: string = '' ) {
type = type + ' ';
return `Please provide a valid ${type}name`;
}

/**
* @deprecated use utils/validation.ts instead
*/
getValidationRegex(){
return new RegExp( '^[a-zA-Z_][a-zA-Z0-9_]*$' );
}

/**
* @deprecated use utils/validation.ts instead
*/
nameIsValid( name: string ) {
const regex = this.getValidationRegex();
return regex.test( name ) && name.length <= 100;
}

/**
* @deprecated use utils/validation.ts instead
*/
getValidationClass( name: string ){
const regex = this.getValidationRegex();
if( name === '' ){
Expand Down
43 changes: 43 additions & 0 deletions src/app/utils/validation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { Validators } from "@angular/forms";

const getNameValidator = (required: boolean = false) => {
if (required) {
return [Validators.pattern('^[a-zA-Z_][a-zA-Z0-9_]*$'), Validators.required, Validators.max(100)];
} else {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The else here is not necessary, right?

return [Validators.pattern('^[a-zA-Z_][a-zA-Z0-9_]*$'), Validators.max(100)];
}
}

const invalidNameMessage = (type: string = '') => {
type = type + ' ';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modifying an input parameter?

return `Please provide a valid ${type}name`;
}

const getValidationRegex = () => {
return new RegExp('^[a-zA-Z_][a-zA-Z0-9_]*$');
}

const nameIsValid = (name: string) => {
const regex = getValidationRegex();
return regex.test(name) && name.length <= 100;
}

const getValidationClass = (name: string) => {
const regex = getValidationRegex();
if (name === '') {
return '';
}
else if (regex.test(name) && name.length <= 100) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flatten the conditions, what is worse then else is else if ;)

return 'is-valid';
} else {
return 'is-invalid';
}
}

export {
getNameValidator,
invalidNameMessage,
getValidationRegex,
nameIsValid,
getValidationClass,
};
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {ResultSet} from '../../../components/data-view/models/result-set.model';
import {ToastService} from '../../../components/toast/toast.service';
import {DataTableComponent} from '../../../components/data-view/data-table/data-table.component';
import {SidebarNode} from '../../../models/sidebar-node.model';
import {ForeignKey, Uml} from '../../uml/uml.model';
import {ForeignKey, Uml} from '../../uml/api/uml.model';
import {BsModalRef, BsModalService} from 'ngx-bootstrap/modal';
import {Subscription} from 'rxjs';
import {TableConfig} from '../../../components/data-view/data-table/table-config';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {LeftSidebarService} from '../../../components/left-sidebar/left-sidebar.
import {ToastService} from '../../../components/toast/toast.service';
import {EditTableRequest, QueryRequest, SchemaRequest} from '../../../models/ui-request.model';
import {SidebarNode} from '../../../models/sidebar-node.model';
import {ForeignKey, Uml} from '../../uml/uml.model';
import {ForeignKey, Uml} from '../../uml/api/uml.model';
import {Router} from '@angular/router';
import {Subscription} from 'rxjs';
import {WebuiSettingsService} from '../../../services/webui-settings.service';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import * as $ from 'jquery';
import 'jquery-ui/ui/widget';
import 'jquery-ui/ui/widgets/draggable';
import 'jquery-ui/ui/widgets/droppable';
import {SvgLine} from '../../uml/uml.model';
import {SvgLine} from '../../uml/api/uml.model';
import {SchemaRequest} from '../../../models/ui-request.model';
import {SidebarNode} from '../../../models/sidebar-node.model';
import {WebSocketService} from '../../../services/web-socket.service';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {CatalogColumnPlacement, Placements, PlacementType, Store} from '../../ad
import {ModalDirective} from 'ngx-bootstrap/modal';
import * as _ from 'lodash';
import {Subscription} from 'rxjs';
import {DbTable, ForeignKey, SvgLine, Uml} from '../../../views/uml/uml.model';
import {DbTable, ForeignKey, SvgLine, Uml} from '../../uml/api/uml.model';

@Component({
selector: 'app-document-edit-collection',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {Subscription} from 'rxjs';
import {ModalDirective} from 'ngx-bootstrap/modal';
import {UtilService} from '../../../services/util.service';
import * as $ from 'jquery';
import {DbTable} from '../../uml/uml.model';
import {DbTable} from '../../uml/api/uml.model';

@Component({
selector: 'app-document-edit-collections',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {CatalogColumnPlacement, MaterializedInfos, Placements, PlacementType, St
import {ModalDirective} from 'ngx-bootstrap/modal';
import * as _ from 'lodash';
import {Subscription} from 'rxjs';
import {ForeignKey, Uml} from '../../../views/uml/uml.model';
import {ForeignKey, Uml} from '../../uml/api/uml.model';

@Component({
selector: 'app-edit-columns',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {ToastService} from '../../../components/toast/toast.service';
import {Placements, UnderlyingTables} from '../../adapters/adapter.model';
import {Subscription} from 'rxjs';
import {DbmsTypesService} from '../../../services/dbms-types.service';
import {ForeignKey, Uml} from '../../../views/uml/uml.model';
import {ForeignKey, Uml} from '../../uml/api/uml.model';

@Component({
selector: 'app-edit-source-columns',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {Subscription} from 'rxjs';
import {ModalDirective} from 'ngx-bootstrap/modal';
import {UtilService} from '../../../services/util.service';
import * as $ from 'jquery';
import {DbTable} from '../../uml/uml.model';
import {DbTable} from '../../uml/api/uml.model';

@Component({
selector: 'app-edit-tables',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {DbColumn} from '../../components/data-view/models/result-set.model';
import {DbColumn} from '../../../components/data-view/models/result-set.model';

export class Uml {
constructor(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { UmlComponent } from './uml.component';
import { UmlComponent } from '../uml.component';

describe('UmlComponent', () => {
let component: UmlComponent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
<h5 *ngIf="schema">{{schema}}</h5>
<p *ngIf="uml">Drag a connection from a column to a <span class="badge" id="badge-pk">primary key</span> or <span class="badge" id="badge-unique">unique column</span> to create a new foreign key.</p>
<span *ngIf="!schema">Please select a schema in the left sidebar. Document schemas and tables originating from a data source are not supported.</span>
<span *ngIf="schemaType.toLowerCase() === 'document'"><i>Document schemas do not support the UML builder.</i></span>
<span *ngIf="schemaType?.toLowerCase() === 'document'"><i>Document schemas do not support the UML builder.</i></span>
</div>
<div id="drag-container" class="col-lg-12" *ngIf="uml">
<div class="card uml" *ngFor="let table of uml.tables | value" [id]="table.schema+'_'+table.tableName" [attr.tableName]="table.schema+'.'+table.tableName" cdkDragBoundary="#drag-container" cdkDrag (cdkDragEnded)="updateZIndex($event)" (cdkDragStarted)="onDragging($event)">
<div class="card uml" *ngFor="let table of uml.tables | value" [id]="table.schema+'_'+table.tableName" [attr.tableName]="table.schema+'.'+table.tableName" cdkDragBoundary="#drag-container" cdkDrag (cdkDragEnded)="updateZIndex($event)" (cdkDragStarted)="onDragStart($event)" (cdkDragMoved)="onDragging()">
<div class="card-header tableName" cdkDragHandle>{{table.tableName}}</div>
<div class="list-group list-group-flush">
<div class="list-group-item cols"
Expand Down Expand Up @@ -79,7 +79,7 @@ <h4 class="modal-title">Create foreign key</h4>
<div>
constraint name<br><input type="text" [(ngModel)]="constraintName" [placeholder]="proposedConstraintName"
class="form-control form-control-sm"
[ngClass]="_crud.getValidationClass(constraintName)">
[ngClass]="getValidationClass(constraintName)">
<div class="invalid-feedback">invalid name</div>
</div>
</div>
Expand Down
Loading