Commit 503ee73e authored by Floyd Hightower's avatar Floyd Hightower

Initial commit

parents
Pipeline #31514078 (#1) failed with stages
in 65 minutes and 48 seconds
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"project": {
"name": "note-taker"
},
"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": "",
"styles": [
"styles.less"
],
"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": "less",
"component": {}
}
}
# 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
# See http://help.github.com/ignore-files/ for more about ignoring files.
# compiled output
/dist
/dist-server
/tmp
/out-tsc
# dependencies
/node_modules
# IDEs and editors
/.idea
.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
yarn-error.log
testem.log
/typings
# e2e
/e2e/*.js
/e2e/*.map
# System Files
.DS_Store
Thumbs.db
target/
# Node generated files
node_modules
npm-debug.log
# OS generated files
Thumbs.db
.DS_Store
# Ignored files
*.ts
!*.d.ts
var grunt = require('grunt');
var path = require('path');
var mkdirp = require('mkdirp');
grunt.initConfig({
app: {
name: 'Note_Taker',
version: '1.0'
},
copy: {
main: {
cwd: 'target/dist/',
src: ['**', '!*.eot', '!*.svg', '!*.ttf', '!*.woff'],
dest: 'target/<%= app.name %>_v<%= app.version %>/ui/',
expand: true
},
installJson: {
src: 'install.json',
dest: 'target/<%= app.name %>_v<%= app.version %>',
expand: true
},
readme: {
src: 'README.md',
dest: 'target/<%= app.name %>_v<%= app.version %>',
expand: true
},
parameters: {
src: 'install.json',
dest: 'target/<%= app.name %>_v<%= app.version %>/ui',
expand: true
}
},
clean: {
bundle: {
src: [
'target/'
],
options: {
expand: true
}
}
},
exec: {
createDirectory: {
cmd: function() {
var dir = 'target/dist';
mkdirp(dir, console.log);
return 'ls';
}
},
buildProd: path.relative('', 'node_modules/.bin/ng build') + ' --aot --prod --output-path target/dist --base-href .',
buildDev: path.relative('', 'node_modules/.bin/ng build') + ' --aot --output-path target/dist --base-href .',
serve: path.relative('', 'node_modules/.bin/ng serve')
},
tslint: {
options: {
configuration: grunt.file.readJSON('tslint.json')
},
files: {
src: ['app/**/*.ts']
}
},
compress: {
main: {
options: {
archive: 'target/<%= app.name %>_v<%= app.version %>.tcx',
pretty: true,
mode: 'zip'
},
expand: true,
cwd: 'target/<%= app.name %>_v<%= app.version %>/',
src: ['**/*'],
dest: '/<%= app.name %>_v<%= app.version %>/'
}
}
});
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-compress');
grunt.loadNpmTasks('grunt-exec');
grunt.registerTask(
'buildProd',
'Compiles all assets and source files into build directory.',
[
'clean',
'exec:createDirectory',
'exec:buildProd',
'copy',
'compress',
]
);
grunt.registerTask(
'buildDev',
'Compiles all assets and source files into build directory.',
[
'clean',
'exec:createDirectory',
'exec:buildDev',
'copy',
'compress'
]
);
grunt.registerTask(
'serve',
'Runs the build, then serves the project locally.',
[
'exec:serve'
]
);
grunt.registerTask(
'default',
'Run default build',
[
'buildProd'
]
);
.DEFAULT_GOAL := help
define PRINT_HELP_PYSCRIPT
import re, sys
for line in sys.stdin:
match = re.match(r'^([a-zA-Z_-]+):.*?## (.*)$$', line)
if match:
target, help = match.groups()
print("%-20s %s" % (target, help))
endef
export PRINT_HELP_PYSCRIPT
help:
@python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST)
setup: ## prepare app for local testing or deployment
npm install
pack: ## package the app for PRODUCTION
grunt buildProd
pack-dev: ## package the app for DEVELOPMENT
grunt buildDev
run: ## run the app locally
ng serve -o
# Note Taking App
ThreatConnect spaces apps for taking notes.
![Demo of note taking app](demo.gif)
## Getting Started
To get started, the code for the app is in the `src/` folder. To setup your environment for testing, run:
```
make setup
```
## Build App For Release
```
make pack
```
This will package the app as `target/TCS_-_Note_Taker.tcx`.
## Build App in Development Mode (does not minify or uglify code, so it can be debugged in browser)
```
make pack-dev
```
## Deploy
In the ThreatConnect UI install the App (the `.tcx` file) created in the [Build App for Release](#build-app-for-release) section.
## Credits
This package was created with [Cookiecutter](https://github.com/audreyr/cookiecutter) and [Floyd Hightower's Spaces App Template](https://gitlab.com/fhightower-templates/threatconnect-angular-spaces-template).
demo.gif

258 KB

{
"allowOnDemand": true,
"languageVersion": "7",
"params": [{
"encrypt": false,
"label": "Api User",
"name": "api_user",
"sequence": 1,
"type": "String",
"validValues": ["${USER:TEXT}", "${ORGANIZATION:TEXT}"]
}, {
"encrypt": true,
"label": "API Token",
"name": "api_token",
"sequence": 2,
"type": "String",
"validValues": ["${USER:KEYCHAIN}", "${ORGANIZATION:KEYCHAIN}"]
}, {
"default": "info",
"encrypt": false,
"label": "Logging Level",
"name": "logging",
"sequence": 3,
"type": "Choice",
"validValues": [
"debug",
"info",
"warn",
"error",
"critical"
]
}],
"programLanguage": "NONE",
"programVersion": "1.0.0",
"runtimeContext": [],
"runtimeLevel": "SpaceOrganization"
}
// Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular/cli'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('@angular/cli/plugins/karma')
],
client:{
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
coverageIstanbulReporter: {
reports: [ 'html', 'lcovonly' ],
fixWebpackSourcePaths: true
},
angularCli: {
environment: 'dev'
},
reporters: ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false
});
};
This diff is collapsed.
{
"name": "note-taker",
"version": "1.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build --prod",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "^5.2.0",
"@angular/common": "^5.2.0",
"@angular/compiler": "^5.2.0",
"@angular/core": "^5.2.0",
"@angular/forms": "^5.2.0",
"@angular/http": "^5.2.0",
"@angular/platform-browser": "^5.2.0",
"@angular/platform-browser-dynamic": "^5.2.0",
"@angular/router": "^5.2.0",
"core-js": "^2.4.1",
"font-awesome": "^4.7.0",
"primeng": "^5.2.4",
"rxjs": "^5.5.6",
"spaces-ng": "^5.0.2",
"threatconnect-ng": "^5.0.2",
"zone.js": "^0.8.19"
},
"devDependencies": {
"@angular/cli": "~1.7.3",
"@angular/compiler-cli": "^5.2.0",
"@angular/language-service": "^5.2.0",
"@types/jasmine": "~2.8.3",
"@types/jasminewd2": "~2.0.2",
"@types/node": "~6.0.60",
"codelyzer": "^4.0.1",
"grunt": "^1.0.1",
"grunt-cli": "^1.2.0",
"grunt-contrib-clean": "^1.1.0",
"grunt-contrib-compress": "^1.4.3",
"grunt-contrib-copy": "^1.0.0",
"grunt-exec": "^3.0.0",
"jasmine-core": "~2.8.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~2.0.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "^1.2.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"materialize-css": "^0.100.2",
"ngx-bowser": "^0.1.0",
"protractor": "~5.1.2",
"ts-node": "~4.1.0",
"tslint": "~5.9.1",
"typescript": "~2.5.3"
}
}
// Protractor configuration file, see link for more information
// https://github.com/angular/protractor/blob/master/lib/config.ts
const { SpecReporter } = require('jasmine-spec-reporter');
exports.config = {
allScriptsTimeout: 11000,
specs: [
'./e2e/**/*.e2e-spec.ts'
],
capabilities: {
'browserName': 'chrome'
},
directConnect: true,
baseUrl: 'http://localhost:4200/',
framework: 'jasmine',
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000,
print: function() {}
},
onPrepare() {
require('ts-node').register({
project: 'e2e/tsconfig.e2e.json'
});
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
}
};
import { NgModule } from '@angular/core';
import {
RouterModule,
Routes
}
from '@angular/router';
import { MainComponent } from './main.component';
import { SpacesBaseService } from 'spaces-ng';
const routes: Routes = [{
path: '',
component: MainComponent,
resolve: {base: SpacesBaseService},
}, {
path: 'index.html',
component: MainComponent,
resolve: {base: SpacesBaseService},
}];
@NgModule({
imports: [ RouterModule.forRoot(routes) ],
exports: [ RouterModule ]
})
export class AppRoutingModule {}
<div class="spaces-content">
<p-growl [value]="msgs"></p-growl>
<router-outlet></router-outlet>
</div>
import { TestBed, async } from '@angular/core/testing';
import { AppComponent } from './app.component';
describe('AppComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [
AppComponent
],
}).compileComponents();
}));
it('should create the app', async(() => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
expect(app).toBeTruthy();
}));
it(`should have as title 'app'`, async(() => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
expect(app.title).toEqual('app');
}));
it('should render title in a h1 tag', async(() => {
const fixture = TestBed.createComponent(AppComponent);
fixture.detectChanges();
const compiled = fixture.debugElement.nativeElement;
expect(compiled.querySelector('h1').textContent).toContain('Welcome to app!');
}));
});
import {
Component,
} from '@angular/core';
import {
SpacesBaseService,
SpacesLoggingService,
SpacesMessagesService,
SpacesStorageService
} from 'spaces-ng/';
import {Message} from 'primeng/api';
@Component({
templateUrl: './app.component.html',
selector: 'tc-app'
})
export class AppComponent {
constructor(
private logging: SpacesLoggingService,
private messages: SpacesMessagesService,
private spacesBase: SpacesBaseService,
private storage: SpacesStorageService
) {
this.logging.logLevel = 'debug'; // set app default logging level
this.logging.moduleColor('#633974', '#fff', 'AppComponent'); // set logging console colors
}
get msgs(): Message[] {
return this.messages.msgs;
}
}
/* Core */
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { CommonModule } from '@angular/common';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
/* Routing */
import { AppRoutingModule } from './app-routing.module';
/* Third-Party */
import {
BowserModule,
BowserService
} from 'ngx-bowser';
import {
AccordionModule,
ButtonModule,
DataTableModule,
DialogModule,
DropdownModule,
GrowlModule,
InputTextModule,
PanelModule,
SharedModule,
StepsModule,
TabViewModule
} from 'primeng/primeng';
import { TableModule } from 'primeng/table';
/* Components */
import { AppComponent } from './app.component';
import { MainComponent } from './main.component';
/* Services */
import {
SpacesBaseService,
SpacesLoggingService,
SpacesMessagesService,
SpacesRequestService,
SpacesStorageService,
SpacesUtilityService
} from 'spaces-ng';
import {
// Address,
// EmailAddress,
// Host,
TcExchangeDbService,
TcGroupService,
TcIndicatorService,
TcOwnerService
// Url
} from 'threatconnect-ng';
import { DatastoreService } from './services/datastore.service';
import { NoteTakerComponent } from './components/note-taker/note-taker.component';
@NgModule({
imports: [
/* Core */
AppRoutingModule,
BrowserModule,
CommonModule,
FormsModule,
HttpModule,
BrowserAnimationsModule,
/* Bowser */
BowserModule,
/* PrimeNG */
AccordionModule,
ButtonModule,
DataTableModule,
DialogModule,
DropdownModule,
GrowlModule,
InputTextModule,
PanelModule,
SharedModule,
StepsModule,
TabViewModule,
TableModule
],
declarations: [
AppComponent,
MainComponent,
NoteTakerComponent,
],
providers: [
/* Bowser Service */
BowserService,
/* TC Service */
DatastoreService,
SpacesBaseService,
SpacesLoggingService,
SpacesMessagesService,
SpacesRequestService,
SpacesStorageService,
SpacesUtilityService,
TcExchangeDbService,
TcGroupService,
TcIndicatorService,
TcOwnerService
],
bootstrap: [AppComponent]
})
export class AppModule {}
<div>
<div class="columns large-2 medium-2 small-4">
<ul>
<li class="listedNote" *ngFor="let note of datastore.notes"><span class="listedNoteTitle" (click)="openNote(note.text, note.id)">{{ note.text | slice:0:50 }}</span>&nbsp;&nbsp;<i class="fa fa-trash-o" (click)="deleteNote(note.text, note.id)"></i></li>
</ul>
</div>
<div class="columns large-10 medium-10 small-8">
<textarea id="noteInput" [(ngModel)]="noteText" placeholder="Type a note here..." rows="26" (keyup)="datastore.saved = false"></textarea>
<br><br>
<button class="button primary" type="button" (click)="updateNote()" *ngIf="noteId !== ''">Save existing note <b *ngIf="!datastore.saved">*</b></button>