Skip to content
This repository has been archived by the owner on Nov 22, 2019. It is now read-only.

Commit

Permalink
Merge pull request #78 from rareddy/NEW_BEETLE
Browse files Browse the repository at this point in the history
TEIIDTOOLS-523
  • Loading branch information
rareddy committed Nov 1, 2018
2 parents 7188f63 + 65decef commit 2f4dea6
Show file tree
Hide file tree
Showing 390 changed files with 47,655 additions and 0 deletions.
46 changes: 46 additions & 0 deletions .gitignore
Expand Up @@ -18,3 +18,49 @@ tmp
**/_remote.repositories
.metadata/
.recommenders/

# compiled output
/dist
/tmp
/out-tsc
/src/main/ngapp/dist

# dependencies
node_modules/

# IDEs and editors
/.idea
*.iml
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json

# misc
/.sass-cache
/connect.lock
/coverage
/libpeerconnection.log
npm-debug.log
testem.log
/typings
yarn-error.log

# e2e
/e2e/*.js
/e2e/*.map

# System Files
.DS_Store
Thumbs.db

target/
38 changes: 38 additions & 0 deletions documentation/dev-notes/dev-notes.md
@@ -0,0 +1,38 @@
# Beetle Studio Developer Notes

This document is intended to be the "landing place" for information that would make a Beetle Studio
developer's life easier. Each note should highlight in **bold** the keywords. Developers should add
to this document any task steps, processes, debugging steps, URLs, or anything else to save the
"next" developer time and effort.

- When upgrading `patternfly-ng`, you will also need to update the version of the **Patternfly** stylesheets referenced
in `src/index.html`. One thing that may happen when the stylesheet version and the library version
are not in sync is the components may not display.

- If running tests in the **IDE** and the **test** immediately aborts, kill the **Karma** server and rerun
the test.

- If a variable of a class is `nil` when you know it really isn't, you are probably trying to
access it from a `callback` handler. Change your code to save the object reference
in a constant and use that in the handler code. Here is an example:

```typescript
const self = this;

this.connectionService
.getAllConnections()
.subscribe(
(connections) => {
self.allConns = connections;
self.filteredConns = this.filterConnections();
self.loaded("connections");
},
(error) => {
self.logger.error("[ConnectionsComponent] Error getting connections.");
self.error(error);
}
);
```

- When using `Response` and `ResponseOptions` classes, make sure you use the version from the
`@angular/http` library.
39 changes: 39 additions & 0 deletions documentation/i18n/README.md
@@ -0,0 +1,39 @@
# Internationalization in Beetle

`Beetle` uses the built-in i8n functionality provided by **Angular**. It is well-documented here: https://angular.io/guide/i18n, but we document the steps here as well for purposes of brevity and clarity as i18n applies to `Beetle`.

The steps to i8n are as follows:

1. Add your attribute. Adding the **`i18n`** you would like made available for translation.

For example:

`<h1 i18n="@@id">Hello text</h1>`

`<h1 i18n="meaning|description@@id">Hello text</h1>`

`<h1 i18n="meaning@@id">Hello text</h1>`

`<h1 i18n="Hello Name|Describe source of {name}@@formName.helloName">Hello {name}</h1>`

Where **meaning** is the name of the text field to translate, **description** is short description of the text and the **id** is a unique value we specify to easily identify the text in the i18n file and in code.

If the **id** is omitted, one will be generated for you, but it is long, complex and not easily identifiable as to it's association. The format for the id is file name of the html where the translation lives, a dot(.), filed by the meaning value CamelCase and without dashes or spaces. For Example: If the **id** is omitted, one will be generated for you, but it is long, complex and not easily identifiable as to it's association. The format for the id is file name of the html where the translation lives, a dot, filed by the meaning value CamelCase and without dashes. For Example:
`i18n="Connection Properties|Properties for a connection@@addConnectionForm.connectionProperties"`

There are other acceptable formats such as for plural values and image titles. Please see the Angular documentation for these additional formats.

2. Run the messages generator. Open a terminal window at /src/main/ngapp/ of the application project and enter the ng-xi18n command: `./node_modules/.bin/ng-xi18n --i18nFormat=xlf --outFile=messages.xlf` which will generate `messages.xlf` in the root folder of project. This file will contain all the translatable fields. You will need to compare this `messages.xlf` to the latest in `master`. Add any new translations to each messages.{language}.xlf file in {root}/src/locale. For example, messages.es.xlf for Spanish translations. If this is the first time a translation file is being generated for a language, just copy the generates message file over to the src/locale folder, rename the new file messages.{languagecode}.xlf.

You will then need to add the correct translation:

<trans-unit id="introductionHeader" datatype="html">
<source>Hello i18n!</source>
<target>¡Hola i18n!</target>
<note priority="1" from="description">An introduction header for this sample</note>
<note priority="1" from="meaning">User welcome</note>
</trans-unit>

3. Generate the war for each language. Run `ng serve --aot --locale es --i18n-format xlf --i18n-file ./locale/messages.{languageCode}.xlf`
Running the maven build will likely handle this step as well.

62 changes: 62 additions & 0 deletions documentation/ide/webstorm-guide.md
@@ -0,0 +1,62 @@
# Beetle Studio WebStorm IDE Guide

## Settings and Preferences:

- Enable TSLint. Select menu item `WebStorm > Preferences... > Languages & Frameworks > Typescript > TSLint`
Make sure the `Enabled` checkbox is selected.
- Exclude the `target/` directory from being looked at by TSLint. Go to menu item `WebStorm > Preferences... > Directories`.
Add the `target/` directory as being `Excluded`. If the directory does not exist, run a maven build
first.

## TSLint

TSLint is a code analysis tool used during development to facilitate the improvement of TypeScript
code quality. TSLint should be run before checking in any code. Any errors or warnings that TSLint
identifies should be fixed prior to promoting any code to the Github repository. Errors and warnings
in the `Spelling` category can generally be ignored though can be fixed if it would improve code quality.

To run TSLint, select the `Code > Inspect Code...` menu item. Make sure `Whole project` and
`Include test sources` are both selected and then `OK` the dialog. The errors and warnings found will
be displayed in the `Inspection Results` panel which is displayed at the bottom of the IDE window.

The TSLint rule configuration file is located here: `.../beetle-studio/src/main/ngapp/tslint.json`. See
our [Beetle Studio Style Guide](https://github.com/teiid/beetle-studio/documentation/style-guide/style-guide.md)
for more information on our TypeScript style guidelines.

## Angular CLI

_WebStorm_ has builtin support for [Angular CLI](https://cli.angular.io). As the name suggests _Angular CLI_
is a command line interface for Angular. _Beetle Studio_ has been created as an _Angular CLI_ project so using
_Angular CLI_ commands is something you will do daily. These CLI commands will be executed in the
_.../beetle-studio/src/main/ngapp_ directory.

Here are 2 commands that are used a lot:

- **ng serve** - runs the debug test server.
- **ng test** - runs the tests found in the project

_WebStorm_ has a menu that uses other CLI commands to create components, services, modules, and
other object types. Select _File > New > Angular CLI..._ when needing to create a new object. Then
select the appropriate type. _WebStorm_ then executes the appropriate _Angular CLI_ command to create
the object and related objects (test, css, html) in the recommended directories.

## Debugging

1. Create Debug Configuration. To create a debug configuration, select the menu item `Run > Edit Configurations...`. In the
`Run/Debug Configurations` dialog, select the `+` in the menubar and then the `JavaScript Debug` type. Name the
configuration and set the `URL` to `http://localhost:4200/`.
1. Start the debug server by opening a terminal in the `.../beetle-studio/src/main/ngapp` directory
and running the following command: `ng serve`.
1. Set your breakpoints by clicking in the left margin of the line of code you want the breakpoint to be on.
1. Open browser to `http://localhost:4200/` to see _Beetle Studio_.
1. Select the `Run > Debug...` menu item and then on the popup select your debug configuration. _Shortcut: the "bug"
in the toolbar starts the last debug configuration that was run._
1. Now interact with _Beetle Studio_ so that your breakpoints are hit.

## TODO Comments

`TODO` comments should be used when there is some task that should be done at a future date. If the
task is a blocker or critical to the software a Jira issue should be created instead of, or in addition
to, this type of comment. The format of a `TODO` comment is this:

`// TODO description of task goes here`
30 changes: 30 additions & 0 deletions documentation/openshift-setup/openshift-setup.md
@@ -0,0 +1,30 @@
# Openshift Setup

_Beetle Studio_ requires an Openshift instance for deployment. A number of Openshift installations are available to install and any one can be used as the application platform. _Beetle Studio_ can then access datasources provisioned from the Openshift Service Catalog. If you already have a shared Openshift installation, you can install _Beetle Studio_ to the shared installation.

## Openshift CDK Installation

A self-contained installation of the Openshift container platform has been published: [Openshift CDK Installation](http://www.schabell.org/2017/12/cloud-happiness-how-to-install-new-openshift-v37-in-minutes.html) . This is an excellent option for getting an Openshift installation up-and-running quickly.

## Minishift

[Minishift](https://github.com/minishift/minishift) can also be used to provide your local installation. See the [Minishift README](https://github.com/minishift/minishift/blob/master/README.adoc) for installation instructions.

By default, minishift is configured to use 2GB of memory and 20GB of storage space. For serious development, since 4 pods are required to be deployed (requiring 0.5GB each), this has proven insufficient. Therefore, it is recommended to configure minishift with 6GB of memory and 50GB of storage space. If this proves problematic then lower values may be sufficient but will require some experimentation. These configuration options can only be configured when minishift is not running. They can be set with the following commands:
```bash
$ minishift config set disk-size 60GB
$ minishfit config set memory 6GB
```
Minishift provides a virtual machine (VM) with the Openshift installation installed and configured. Once installed, all that remains is to start minishift. The configuration options should be observed when minishift is started. Once the VM has started, it is possible to remote-login to the VM using the command:
```bash
$ minishift ssh
```
This is useful for problem-finding.

To update to minishift’s latest release requires executing the update command.
```bash
$ minishift update
```
Once minishift has been started, Openshift should be available for access on the ip address assigned, eg. https://192.168.42.143:8443.
To ensure command-line access to Openshift, the oc application should be added to the PATH environment variable. A copy of this binary is available from minishift for example at ${HOME}/.minishift/cache/oc/v3.6.1/linux/oc.

71 changes: 71 additions & 0 deletions documentation/style-guide/style-guide.md
@@ -0,0 +1,71 @@
# Beetle Studio Style Guide

_Beetle Studio_'s TypeScript style conventions are based on the [angular.io style guide](https://angular.io/guide/styleguide).
The _Beetle Studio_'s [tslint.json](https://github.com/teiid/beetle-studio/src/main/ngapp/tslint.json) file describes the
rules used to "enforce" the guidelines and project structure recommended by the _angular.io_ document.

The goal of having style guidelines and conventions is to increase maintainability and readability.

## Project Structure

_Beetle Studio_ has tried to use the file structure recommended by _angular.io_, with minor
modifications due to facilitating a maven build process.

So _Beetle Studio_ has feature modules (connections, dataservices), a _CoreModule_ (for singletons and
single use objects), and a _SharedModule_ (for reusable objects). Within each feature
module there may be a _shared_ folder for services and other shared objects). See the
_Overall structural guidelines_ section of the [angular.io style guide](https://angular.io/guide/styleguide)
for more details.

## Naming Conventions

In general, file names have the following syntax: <feature>.<type>.ts. _Note: if <feature> has
multiple words, separate words by dashes. Uppercase letters should not be used._

Here are some examples:

- connection.service.ts - a service name `ConnectionService`.
- connection.service.spec.ts - a test for the `ConnectionService`.
- connections.module.ts - a feature module called `ConnectionsModule`.
- add-connection.component.ts - a component called `AddConnectionComponent`.
- connection.model.ts - a class called `Connection`.

See the _Naming_ section of the [angular.io style guide](https://angular.io/guide/styleguide)
for more details.

## TSLint Settings

Our _TSLint_ configuration file (`tslint.json`) inherits recommended rules. We also have included added and overwritten
rules. _Note: Rules can be overridden on a case by case if needed by adding a special comment to the
offending line of code. WebStorm has a quick fix that will do this for you._

Here are a **few** of the TSLint rules defined in our configuration file used:

- **align** - used to align member properties and statements.
- **component-class-suffix** - all components need to have `Component` as the name suffix.
- **directive-class-suffix** - all directives need to have `Directive` as the name suffix.
- **max-classes-per-file** - value is set to one so that classes, enums, types, etc. can easily be found.
- **max-line-length** - set to 140. (which is plenty long!)
- **member-ordering** - public declarations must come before private declarations, static declarations
must come before instance declarations, and variables must come before functions.
- **no-consecutive-blank-lines** - only one blank line can appear together.
- **no-empty** - empty blocks are not allowed. Fill in with a comment like `// nothing to do` if you
really need an empty block.
- **one-variable-per-declaration** - promotes better readability and maintenance.
- **ordered-imports** - imports are ordered alphabetically so that they can be found easier.
- **quotemark** - set to use double quotes. Prevents both single and double being used and mixed within the codebase.
- **typedef** - return type, parameter type, property type must be explicitly set if an initializer is not used.

## Notable Style Guidelines

- **Style 01-01** - Limit files to 400 lines.
- **Style 01-02** - Limit functions to 75 lines.
- **Style 02-01** - Use consistent names for all symbols.
- **Style 03-01** - Use upper camel case when naming classes.
- **Style 03-02** - Spell `const` variables in lower camel case.
- **Style 03-03** - Do not name with an `I` prefix.
- **Style 03-04** - Do use lower camel case to name properties and methods.
- **Style 05-04** - Extract templates and styles into a separate file, when more than 3 lines.
- **Style 05-16** - Do name events without the prefix `on`. Do name event handler methods with the
prefix `on` followed by the event name.
- **Style 05-17** -
1 change: 1 addition & 0 deletions pom.xml
Expand Up @@ -126,6 +126,7 @@

<modules>
<module>server</module>
<module>ui</module>
</modules>

<profiles>
Expand Down
60 changes: 60 additions & 0 deletions ui/.angular-cli.json
@@ -0,0 +1,60 @@
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"project": {
"name": "beetle-studio"
},
"apps": [
{
"root": "src",
"outDir": "dist",
"assets": [
"assets",
"favicon.ico"
],
"index": "index.html",
"main": "main.ts",
"polyfills": "polyfills.ts",
"test": "test.ts",
"tsconfig": "tsconfig.app.json",
"testTsconfig": "tsconfig.spec.json",
"prefix": "app",
"styles": [
"styles.css"
],
"scripts": [],
"environmentSource": "environments/environment.ts",
"environments": {
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts"
}
}
],
"e2e": {
"protractor": {
"config": "./protractor.conf.js"
}
},
"lint": [
{
"project": "src/tsconfig.app.json",
"exclude": "**/node_modules/**"
},
{
"project": "src/tsconfig.spec.json",
"exclude": "**/node_modules/**"
},
{
"project": "e2e/tsconfig.e2e.json",
"exclude": "**/node_modules/**"
}
],
"test": {
"karma": {
"config": "./karma.conf.js"
}
},
"defaults": {
"styleExt": "css",
"component": {}
}
}
13 changes: 13 additions & 0 deletions ui/.editorconfig
@@ -0,0 +1,13 @@
# Editor configuration, see http://editorconfig.org
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
max_line_length = off
trim_trailing_whitespace = false

0 comments on commit 2f4dea6

Please sign in to comment.