diff --git a/app/index.js b/app/index.js index 3ff948d4..156b8bb9 100644 --- a/app/index.js +++ b/app/index.js @@ -81,9 +81,14 @@ module.exports = yeoman.Base.extend({ } }, { name: 'alfrescoServerHost', - message: 'Which is your Alfresco platform server URL?', + message: 'What is your Alfresco platform server URL?', default: 'http://127.0.0.1:8080', store: true + }, { + name: 'activitiServerHost', + message: 'What is your Activiti platform server URL?', + default: 'http://127.0.0.1:9999', + store: true }]; this.prompt(prompts, function (props) { @@ -269,22 +274,39 @@ module.exports = yeoman.Base.extend({ this.destinationPath('app/main.ts'), { contentPage: this.props.contentPage, - searchBar: this.props.searchBar + searchBar: this.props.searchBar, + bpmTaskPage: this.props.bpmTaskPage } ); this.fs.copyTpl( - this.templatePath('app/_app.component.ts'), - this.destinationPath('app/app.component.ts'), + this.templatePath('app/components/_index.ts'), + this.destinationPath('app/components/index.ts'), + { + contentPage: this.props.contentPage, + searchBar: this.props.searchBar, + bpmTaskPage: this.props.bpmTaskPage + } + ); + + this.fs.copyTpl( + this.templatePath('app/_app.routes.ts'), + this.destinationPath('app/app.routes.ts'), { - projectName: this.props.projectName, - navigationBar: this.props.navigationBar, - drawerBar: this.props.drawer, searchBar: this.props.searchBar, contentPage: this.props.contentPage, bpmTaskPage: this.props.bpmTaskPage, - chartPage: this.props.chartPage, - alfrescoServerHost: this.props.alfrescoServerHost + chartPage: this.props.chartPage + } + ); + + this.fs.copyTpl( + this.templatePath('app/_app.component.ts'), + this.destinationPath('app/app.component.ts'), + { + searchBar: this.props.searchBar, + alfrescoServerHost: this.props.alfrescoServerHost, + activitiServerHost: this.props.activitiServerHost } ); @@ -317,6 +339,16 @@ module.exports = yeoman.Base.extend({ this.destinationPath('assets/material.orange-blue.min.css') ); + this.fs.copy( + this.templatePath('assets/_license_header.txt'), + this.destinationPath('assets/license_header.txt') + ); + + this.fs.copy( + this.templatePath('server/_versions.js'), + this.destinationPath('server/versions.js') + ); + this.fs.copy( this.templatePath('app/css/_muli-font.css'), this.destinationPath('app/css/muli-font.css') @@ -384,14 +416,20 @@ module.exports = yeoman.Base.extend({ if (this.props.bpmTaskPage) { this.fs.copy( - this.templatePath('app/components/tasks/_tasks-demo.component.ts'), - this.destinationPath('app/components/tasks/tasks-demo.component.ts') + this.templatePath('app/components/tasks/_activiti-demo.component.ts'), + this.destinationPath('app/components/tasks/activiti-demo.component.ts') ); this.fs.copy( - this.templatePath('app/components/tasks/_activiti.service.ts'), - this.destinationPath('app/components/tasks/activiti.service.ts') + this.templatePath('app/components/tasks/_activiti-demo.component.css'), + this.destinationPath('app/components/tasks/activiti-demo.component.css') ); + + this.fs.copy( + this.templatePath('app/components/tasks/_activiti-demo.component.html'), + this.destinationPath('app/components/tasks/activiti-demo.component.html') + ); + } if (this.props.chartPage) { diff --git a/app/templates/_index.html b/app/templates/_index.html index eaefd33a..65ee5b24 100644 --- a/app/templates/_index.html +++ b/app/templates/_index.html @@ -21,7 +21,7 @@ - + <% if (contentPage == true) { %> diff --git a/app/templates/_package.json b/app/templates/_package.json index 699ba3f9..068c5fd9 100644 --- a/app/templates/_package.json +++ b/app/templates/_package.json @@ -4,16 +4,17 @@ "version": "0.1.0", "author": "<%= authorName %>", "scripts": { + "postinstall": "typings install", "clean": "rimraf node_modules typings", - "postinstall" : "typings install && npm run tsc", - "start": "npm run tslint && typings install && concurrently \"npm run tsc:w\" \"npm run serve\" ", + "build": "npm run tslint && npm run tsc && npm run licensecheck", + "start": "npm run build && concurrently \"npm run tsc:w\" \"npm run serve\" ", + "aws": "node app.js", "tsc": "tsc", "tsc:w": "tsc -w", - "serve": "node browser-sync-config.js", + "serve": "wsrv -o -s -l -p 3000 -a 0.0.0.0 -x ./server/versions.js", "typings": "typings install", - "tslint": "npm run tslint-src && npm run tslint-root", - "tslint-src": "tslint -c tslint.json src/{,**/}**.ts", - "tslint-root": "tslint -c tslint.json *.ts" + "tslint": "tslint -c tslint.json *.ts && tslint -c tslint.json 'app/{,**/}**.ts'", + "licensecheck": "license-check" }, "repository": { "type": "git", @@ -39,34 +40,38 @@ "@angular/common": "2.0.0-rc.3", "@angular/compiler": "2.0.0-rc.3", "@angular/core": "2.0.0-rc.3", + "@angular/forms": "0.1.1", "@angular/http": "2.0.0-rc.3", "@angular/platform-browser": "2.0.0-rc.3", "@angular/platform-browser-dynamic": "2.0.0-rc.3", "@angular/router": "3.0.0-alpha.7", "@angular/router-deprecated": "2.0.0-rc.2", "@angular/upgrade": "2.0.0-rc.3", + "alfresco-js-api": "^0.3.0", "systemjs": "0.19.27", - "core-js": "^2.4.0", - "reflect-metadata": "^0.1.3", + "core-js": "2.4.0", + "reflect-metadata": "0.1.3", "rxjs": "5.0.0-beta.6", - "zone.js": "^0.6.12", - - "material-design-icons": "^2.2.3", - "material-design-lite": "^1.1.3", - "ng2-translate": "2.2.2", - "pdfjs-dist": "^1.5.258", - - "alfresco-js-api": "0.1.0", - "ng2-alfresco-core": "0.1.39", - "ng2-alfresco-datatable": "0.1.17", - "ng2-alfresco-documentlist": "0.1.37", - "ng2-alfresco-login": "0.1.32", - "ng2-alfresco-search": "0.1.25", - "ng2-alfresco-upload": "0.1.55", - "ng2-alfresco-viewer": "0.1.35", - "ng2-charts": "1.1.0", + "zone.js": "0.6.12", + "rimraf": "2.5.2", + "material-design-icons": "2.2.3", + "material-design-lite": "1.1.3", + "ng2-translate": "2.2.0", + "pdfjs-dist": "1.5.258", + "flag-icon-css": "2.3.0", "chart.js": "^2.1.4", - "rimraf": "^2.5.2" + "ng2-charts": "1.1.0", + "ng2-alfresco-core": "0.3.0", + "ng2-alfresco-datatable": "0.3.0", + "ng2-alfresco-documentlist": "0.3.0", + "ng2-alfresco-login": "0.3.0", + "ng2-alfresco-search": "0.3.0", + "ng2-alfresco-upload": "0.3.0", + "ng2-alfresco-viewer": "0.3.0", + "ng2-activiti-form": "0.3.0", + "ng2-activiti-tasklist": "0.3.0", + "ng2-activiti-processlist": "0.3.0", + "ng2-alfresco-webscript": "0.3.0" }, "devDependencies": { "angular-cli": "1.0.0-beta.9", @@ -77,7 +82,9 @@ "license-check": "^1.0.4", "tslint": "^3.8.1", "typescript": "^1.8.10", - "typings": "^1.0.4" + "typings": "^1.0.4", + "mime": "^1.3.4", + "wsrv": "0.1.4" }, "license-check-config": { "src": [ @@ -88,7 +95,8 @@ "!/**/node_modules/**/*", "!/**/typings/**/*", "!*.js", - "!app/js/xml2json.js" + "!app/js/xml2json.js", + "!server/versions.js" ], "path": "assets/license_header.txt", "blocking": false, diff --git a/app/templates/_systemjs.config.js b/app/templates/_systemjs.config.js index 253025f6..d4b21345 100644 --- a/app/templates/_systemjs.config.js +++ b/app/templates/_systemjs.config.js @@ -9,7 +9,7 @@ '@angular': 'node_modules/@angular', 'angular2-in-memory-web-api': 'node_modules/angular2-in-memory-web-api', 'rxjs': 'node_modules/rxjs', - 'ng2-charts': 'node_modules/ng2-charts', + 'ng2-translate': 'node_modules/ng2-translate', 'ng2-alfresco-core': 'node_modules/ng2-alfresco-core/dist', 'ng2-alfresco-datatable': 'node_modules/ng2-alfresco-datatable/dist', @@ -17,22 +17,33 @@ 'ng2-alfresco-login': 'node_modules/ng2-alfresco-login/dist', 'ng2-alfresco-search': 'node_modules/ng2-alfresco-search/dist', 'ng2-alfresco-upload': 'node_modules/ng2-alfresco-upload/dist', - 'ng2-alfresco-viewer': 'node_modules/ng2-alfresco-viewer/dist' + 'ng2-activiti-form': 'node_modules/ng2-activiti-form/dist', + 'ng2-alfresco-viewer': 'node_modules/ng2-alfresco-viewer/dist', + 'ng2-alfresco-webscript': 'node_modules/ng2-alfresco-webscript/dist', + 'ng2-activiti-processlist': 'node_modules/ng2-activiti-processlist/dist', + 'ng2-activiti-tasklist': 'node_modules/ng2-activiti-tasklist/dist', + 'ng2-charts': 'node_modules/ng2-charts' }; // packages tells the System loader how to load when no filename and/or no extension var packages = { 'app': { main: 'main.js', defaultExtension: 'js' }, 'rxjs': { defaultExtension: 'js' }, 'angular2-in-memory-web-api': { main: 'index.js', defaultExtension: 'js' }, + 'ng2-translate': { defaultExtension: 'js' }, - 'ng2-charts' : {defaultExtension: 'js'}, + 'ng2-alfresco-core': { main: 'index.js', defaultExtension: 'js'}, 'ng2-alfresco-datatable': { main: 'index.js', defaultExtension: 'js'}, 'ng2-alfresco-documentlist': { main: 'index.js', defaultExtension: 'js'}, 'ng2-alfresco-login': { main: 'index.js', defaultExtension: 'js'}, 'ng2-alfresco-search': { main: 'index.js', defaultExtension: 'js'}, 'ng2-alfresco-upload': { main: 'index.js', defaultExtension: 'js'}, - 'ng2-alfresco-viewer': { main: 'index.js', defaultExtension: 'js'} + 'ng2-alfresco-viewer': { main: 'index.js', defaultExtension: 'js'}, + 'ng2-activiti-form': { main: 'index.js', defaultExtension: 'js'}, + 'ng2-activiti-processlist': { main: 'index.js', defaultExtension: 'js'}, + 'ng2-activiti-tasklist': { main: 'index.js', defaultExtension: 'js'}, + 'ng2-alfresco-webscript': { main: 'index.js', defaultExtension: 'js'}, + 'ng2-charts': { main: 'ng2-charts.js', defaultExtension: 'js'} }; var ngPackageNames = [ 'common', @@ -55,8 +66,13 @@ } // Most environments should use UMD; some (Karma) need the individual index files var setPackageConfig = System.packageWithIndex ? packIndex : packUmd; + // Add package entries for angular packages ngPackageNames.forEach(setPackageConfig); + + // No umd for router yet + packages['@angular/router'] = { main: 'index.js', defaultExtension: 'js' }; + var config = { map: map, packages: packages diff --git a/app/templates/app/_app.component.html b/app/templates/app/_app.component.html index cbe8f0a2..edd0f47f 100644 --- a/app/templates/app/_app.component.html +++ b/app/templates/app/_app.component.html @@ -15,10 +15,9 @@ <% if (navigationBar == true) { %> <% } %> @@ -33,8 +32,8 @@
  • English
  • Greek
  • Italian
  • -
  • More
  • -
  • Login
  • +
  • More
  • + Login
  • Logout
  • @@ -45,10 +44,22 @@
    Components List + ECM host + + BPM host +
    <% } %> diff --git a/app/templates/app/_app.component.ts b/app/templates/app/_app.component.ts index 24371777..60a3947d 100644 --- a/app/templates/app/_app.component.ts +++ b/app/templates/app/_app.component.ts @@ -16,7 +16,8 @@ */ import { Component } from '@angular/core'; -import { Router, RouteConfig, ROUTER_DIRECTIVES } from '@angular/router-deprecated'; +import { ROUTER_DIRECTIVES, Router } from '@angular/router'; + import { MDL, AlfrescoSettingsService, @@ -24,48 +25,48 @@ import { AlfrescoPipeTranslate, AlfrescoAuthenticationService } from 'ng2-alfresco-core'; -<% if (contentPage == true) { %>import { UploadButtonComponent } from 'ng2-alfresco-upload'; -import { FilesComponent } from './components/files/files.component';<% } %> -<% if (searchBar == true) { %>import { SearchComponent } from './components/search/search.component'; -import { SearchBarComponent } from './components/search/search-bar.component';<% } %> -import { LoginDemoComponent } from './components/login/login-demo.component'; -<% if (bpmTaskPage == true) { %>import { TasksDemoComponent } from './components/tasks/tasks-demo.component';<% } %> -<% if (chartPage == true) { %>import { ChartComponent } from './components/chart/chart.component';<% } %> - +<% if (searchBar == true) { %> +import { SearchBarComponent } from './components/index'; +<% } %> declare var document: any; @Component({ selector: 'alfresco-app', templateUrl: 'app/app.component.html', - directives: [<% if (searchBar == true) { %>SearchBarComponent, <% } %>ROUTER_DIRECTIVES, MDL], + styleUrls: ['app/app.component.css'], + directives: [<% if (searchBar == true) { %>SearchBarComponent,<% } %> ROUTER_DIRECTIVES, MDL], pipes: [AlfrescoPipeTranslate] }) -@RouteConfig([ - {path: '/', name: 'Login', component: LoginDemoComponent, useAsDefault: true}, - <% if (contentPage == true) { %>{path: '/home', name: 'Home', component: FilesComponent}, - {path: '/files', name: 'Files', component: FilesComponent}, - {path: '/uploader', name: 'Uploader', component: UploadButtonComponent},<% } %> - <% if (searchBar == true) { %>{path: '/search', name: 'Search', component: SearchComponent},<% } %> - <% if (bpmTaskPage == true) { %>{path: '/tasks', name: 'Tasks', component: TasksDemoComponent},<% } %> - <% if (chartPage == true) { %>{path: '/chart', name: 'Chart', component: ChartComponent},<% } %> - {path: '/login', name: 'Login', component: LoginDemoComponent} -]) export class AppComponent { translate: AlfrescoTranslationService; -<% if (searchBar == true) { %> searchTerm: string = '';<% } %> + <% if (searchBar == true) { %> searchTerm: string = '';<% } %> + + ecmHost: string = '<%= alfrescoServerHost %>'; + bpmHost: string = '<%= activitiServerHost %>'; constructor(public auth: AlfrescoAuthenticationService, public router: Router, translate: AlfrescoTranslationService, - alfrescoSettingsService: AlfrescoSettingsService) { - alfrescoSettingsService.host = '<%= alfrescoServerHost %>'; + public alfrescoSettingsService: AlfrescoSettingsService) { + this.setEcmHost(); + this.setBpmHost(); this.translate = translate; this.translate.addTranslationFolder(); } - isActive(instruction: any[]): boolean { - return this.router.isRouteActive(this.router.generate(instruction)); + public onChangeECMHost(event: KeyboardEvent): void { + console.log((event.target).value); + this.ecmHost = (event.target).value; + this.alfrescoSettingsService.ecmHost = this.ecmHost; + localStorage.setItem(`ecmHost`, this.ecmHost); + } + + public onChangeBPMHost(event: KeyboardEvent): void { + console.log((event.target).value); + this.bpmHost = (event.target).value; + this.alfrescoSettingsService.bpmHost = this.bpmHost; + localStorage.setItem(`bpmHost`, this.bpmHost); } isLoggedIn(): boolean { @@ -76,10 +77,22 @@ export class AppComponent { event.preventDefault(); this.auth.logout() .subscribe( - () => this.router.navigate(['Login']) + () => this.router.navigate(['/login']) ); } +<% if (searchBar == true) { %> + onToggleSearch(event) { + let expandedHeaderClass = 'header-search-expanded', + header = document.querySelector('header'); + if (event.expanded) { + header.classList.add(expandedHeaderClass); + } else { + header.classList.remove(expandedHeaderClass); + } + } +<% } %> + changeLanguage(lang: string) { this.translate.use(lang); } @@ -89,4 +102,21 @@ export class AppComponent { document.querySelector('.mdl-layout').MaterialLayout.toggleDrawer(); } + private setEcmHost() { + if (localStorage.getItem(`ecmHost`)) { + this.alfrescoSettingsService.ecmHost = localStorage.getItem(`ecmHost`); + this.ecmHost = localStorage.getItem(`ecmHost`); + } else { + this.alfrescoSettingsService.ecmHost = this.ecmHost; + } + } + + private setBpmHost() { + if (localStorage.getItem(`bpmHost`)) { + this.alfrescoSettingsService.bpmHost = localStorage.getItem(`bpmHost`); + this.bpmHost = localStorage.getItem(`bpmHost`); + } else { + this.alfrescoSettingsService.bpmHost = this.bpmHost; + } + } } diff --git a/app/templates/app/_app.routes.ts b/app/templates/app/_app.routes.ts new file mode 100644 index 00000000..4a7266a5 --- /dev/null +++ b/app/templates/app/_app.routes.ts @@ -0,0 +1,40 @@ +/*! + * @license + * Copyright 2016 Alfresco Software, Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { provideRouter, RouterConfig } from '@angular/router'; + +import { +<% if (searchBar == true) { %> SearchComponent,<% } %> +<% if (contentPage == true) { %> FilesComponent,<% } %> +<% if (bpmTaskPage == true) { %> ActivitiDemoComponent,<% } %> +<% if (chartPage == true) { %> ChartComponent,<% } %> + LoginDemoComponent +} from './components/index'; + +export const routes: RouterConfig = [ + { path: 'home', component: FilesComponent }, + <% if (searchBar == true) { %> { path: 'search', component: SearchComponent }, <% } %> + <% if (contentPage == true) { %> { path: 'files', component: FilesComponent }, <% } %> + <% if (bpmTaskPage == true) { %> { path: 'activiti', component: ActivitiDemoComponent }, <% } %> + <% if (chartPage == true) { %> { path: 'chart', component: ChartComponent }, <% } %> + { path: '', component: LoginDemoComponent }, + { path: 'login', component: LoginDemoComponent } +]; + +export const appRouterProviders = [ + provideRouter(routes) +]; diff --git a/app/templates/app/_main.ts b/app/templates/app/_main.ts index 95498c0e..f2cccb90 100644 --- a/app/templates/app/_main.ts +++ b/app/templates/app/_main.ts @@ -1,3 +1,21 @@ +/*! + * @license + * Copyright 2016 Alfresco Software, Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + import { bootstrap } from '@angular/platform-browser-dynamic'; import { ROUTER_PROVIDERS } from '@angular/router-deprecated'; import { HTTP_PROVIDERS } from '@angular/http'; @@ -5,12 +23,16 @@ import { AppComponent } from './app.component'; import { ALFRESCO_CORE_PROVIDERS } from 'ng2-alfresco-core'; <% if (searchBar == true) { %>import { ALFRESCO_SEARCH_PROVIDERS } from 'ng2-alfresco-search';<% } %> <% if (contentPage == true) { %>import { UploadService } from 'ng2-alfresco-upload';<% } %> +<% if (bpmTaskPage == true) { %>import { ATIVITI_FORM_PROVIDERS } from 'ng2-activiti-form';<% } %> +import { appRouterProviders } from './app.routes'; bootstrap(AppComponent, [ + appRouterProviders, <% if (contentPage == true) { %>UploadService,<% } %> - ROUTER_PROVIDERS, +ROUTER_PROVIDERS, HTTP_PROVIDERS, - <% if (searchBar == true) { %>ALFRESCO_SEARCH_PROVIDERS,<% } %> - ALFRESCO_CORE_PROVIDERS +<% if (searchBar == true) { %>ALFRESCO_SEARCH_PROVIDERS,<% } %> +<% if (bpmTaskPage == true) { %>ATIVITI_FORM_PROVIDERS,<% } %> +ALFRESCO_CORE_PROVIDERS ]); diff --git a/app/templates/app/components/_index.ts b/app/templates/app/components/_index.ts new file mode 100644 index 00000000..a998ce64 --- /dev/null +++ b/app/templates/app/components/_index.ts @@ -0,0 +1,23 @@ +/*! + * @license + * Copyright 2016 Alfresco Software, Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export { SearchComponent } from './search/search.component'; +export { SearchBarComponent } from './search/search-bar.component'; +export { LoginDemoComponent } from './login/login-demo.component'; +export { ActivitiDemoComponent } from './tasks/activiti-demo.component'; +export { FilesComponent } from './files/files.component'; +export { ChartComponent } from './chart/chart.component'; diff --git a/app/templates/app/components/chart/_chart.component.ts b/app/templates/app/components/chart/_chart.component.ts index feff309e..cf39b56b 100644 --- a/app/templates/app/components/chart/_chart.component.ts +++ b/app/templates/app/components/chart/_chart.component.ts @@ -1,3 +1,20 @@ +/*! + * @license + * Copyright 2016 Alfresco Software, Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + import {Component} from '@angular/core'; import {CORE_DIRECTIVES, FORM_DIRECTIVES, NgClass} from '@angular/common'; diff --git a/app/templates/app/components/files/_files.component.css b/app/templates/app/components/files/_files.component.css index e69de29b..b786d6f9 100644 --- a/app/templates/app/components/files/_files.component.css +++ b/app/templates/app/components/files/_files.component.css @@ -0,0 +1,9 @@ +.container { + margin: 10px; +} + +@media only screen and (max-width: 640px) { + .container { + margin: 0; + } +} diff --git a/app/templates/app/components/files/_files.component.html b/app/templates/app/components/files/_files.component.html index 8c7b83d6..1c8393dc 100644 --- a/app/templates/app/components/files/_files.component.html +++ b/app/templates/app/components/files/_files.component.html @@ -1,118 +1,104 @@ - - + - - - - - - - + [uploaddirectory]="" + [versioning] = "versioning" + (onSuccess)="documentList.reload()"> + + + - - - - - - - - - - - - - - - - + + + + + + + + + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + @@ -135,37 +121,70 @@

    Sorry, no content here

    +

    + +

    -
    Single file upload
    - - -
    Folder upload
    - - +

    + +

    -
    Multiple file upload
    - - - +

    + +

    + +

    + +

    + +
    Upload
    +
    +
    + Extension accepted + +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    + diff --git a/app/templates/app/components/files/_files.component.ts b/app/templates/app/components/files/_files.component.ts index c3092a57..4bdc10ce 100644 --- a/app/templates/app/components/files/_files.component.ts +++ b/app/templates/app/components/files/_files.component.ts @@ -15,11 +15,15 @@ * limitations under the License. */ -import { Component } from '@angular/core'; +import { Component, OnInit, ViewChild } from '@angular/core'; import { DOCUMENT_LIST_DIRECTIVES, DOCUMENT_LIST_PROVIDERS, - DocumentActionsService + DocumentActionsService, + DocumentList, + ContentActionHandler, + DocumentActionModel, + FolderActionModel } from 'ng2-alfresco-documentlist'; import { MDL, @@ -27,8 +31,10 @@ import { CONTEXT_MENU_DIRECTIVES, AlfrescoPipeTranslate } from 'ng2-alfresco-core'; +import { PaginationComponent } from 'ng2-alfresco-datatable'; import { ALFRESCO_ULPOAD_COMPONENTS } from 'ng2-alfresco-upload'; import { VIEWERCOMPONENT } from 'ng2-alfresco-viewer'; +import { FormService } from 'ng2-activiti-form'; declare let __moduleName: string; @@ -42,24 +48,30 @@ declare let __moduleName: string; MDL, ALFRESCO_ULPOAD_COMPONENTS, VIEWERCOMPONENT, - CONTEXT_MENU_DIRECTIVES + CONTEXT_MENU_DIRECTIVES, + PaginationComponent ], - providers: [DOCUMENT_LIST_PROVIDERS], + providers: [DOCUMENT_LIST_PROVIDERS, FormService], pipes: [AlfrescoPipeTranslate] }) -export class FilesComponent { +export class FilesComponent implements OnInit { currentPath: string = '/Sites/swsdp/documentLibrary'; - urlFile: string; - fileName: string; - mimeType: string; + fileNodeId: any; fileShowed: boolean = false; + multipleFileUpload: boolean = false; + folderUpload: boolean = false; + acceptedFilesTypeShow: boolean = false; + versioning: boolean = false; acceptedFilesType: string = '.jpg,.pdf,.js'; - constructor( - private contentService: AlfrescoContentService, - documentActions: DocumentActionsService) { + @ViewChild(DocumentList) + documentList: DocumentList; + + constructor(private contentService: AlfrescoContentService, + private documentActions: DocumentActionsService, + private formService: FormService) { documentActions.setHandler('my-handler', this.myDocumentActionHandler.bind(this)); } @@ -77,9 +89,7 @@ export class FilesComponent { showFile(event) { if (event.value.entry.isFile) { - this.fileName = event.value.entry.name; - this.mimeType = event.value.entry.content.mimeType; - this.urlFile = this.contentService.getContentUrl(event.value); + this.fileNodeId = event.value.entry.id; this.fileShowed = true; } else { this.fileShowed = false; @@ -91,4 +101,52 @@ export class FilesComponent { this.currentPath = event.path; } } + + toggleMultipleFileUpload() { + this.multipleFileUpload = !this.multipleFileUpload; + return this.multipleFileUpload; + } + + toggleFolder() { + this.multipleFileUpload = false; + this.folderUpload = !this.folderUpload; + return this.folderUpload; + } + + toggleAcceptedFilesType() { + this.acceptedFilesTypeShow = !this.acceptedFilesTypeShow; + return this.acceptedFilesTypeShow; + } + + toggleVersioning() { + this.versioning = !this.versioning; + return this.versioning; + } + + ngOnInit() { + this.formService.getProcessDefinitions().subscribe( + defs => this.setupBpmActions(defs || []), + err => console.log(err) + ); + } + + private setupBpmActions(actions: any[]) { + actions.map(def => { + let documentAction = new DocumentActionModel(); + documentAction.title = 'Activiti: ' + (def.name || 'Unknown process'); + documentAction.handler = this.getBpmActionHandler(def); + this.documentList.actions.push(documentAction); + + let folderAction = new FolderActionModel(); + folderAction.title = 'Activiti: ' + (def.name || 'Unknown process'); + folderAction.handler = this.getBpmActionHandler(def); + this.documentList.actions.push(folderAction); + }); + } + + private getBpmActionHandler(processDefinition: any): ContentActionHandler { + return function (obj: any, target?: any) { + window.alert(`Starting BPM process: ${processDefinition.id}`); + }.bind(this); + } } diff --git a/app/templates/app/components/login/_login-demo.component.html b/app/templates/app/components/login/_login-demo.component.html index e9fe2b63..8bea101e 100644 --- a/app/templates/app/components/login/_login-demo.component.html +++ b/app/templates/app/components/login/_login-demo.component.html @@ -1 +1,15 @@ - +
    +

    + +

    +

    + +

    +
    + diff --git a/app/templates/app/components/login/_login-demo.component.ts b/app/templates/app/components/login/_login-demo.component.ts index f62dd07c..f93f1087 100644 --- a/app/templates/app/components/login/_login-demo.component.ts +++ b/app/templates/app/components/login/_login-demo.component.ts @@ -15,9 +15,9 @@ * limitations under the License. */ -import { Component } from '@angular/core'; -import { AlfrescoLoginComponent } from 'ng2-alfresco-login'; -import { Router, ROUTER_DIRECTIVES } from '@angular/router-deprecated'; +import {Component} from '@angular/core'; +import {AlfrescoLoginComponent} from 'ng2-alfresco-login'; +import {ROUTER_DIRECTIVES, Router} from '@angular/router'; declare let __moduleName: string; @@ -30,16 +30,37 @@ declare let __moduleName: string; }) export class LoginDemoComponent { + providers: string = 'ECM'; + constructor(public router: Router) { } onLogin($event) { console.log($event); - this.router.navigate(['Home']); + this.router.navigate(['/home']); } onError($event) { console.log($event); } + toggleECM(checked) { + if (checked && this.providers === 'BPM') { + this.providers = 'ALL'; + } else if (checked) { + this.providers = 'ECM'; + } else { + this.providers = undefined; + } + } + + toggleBPM(checked) { + if (checked && this.providers === 'ECM') { + this.providers = 'ALL'; + } else if (checked) { + this.providers = 'BPM'; + } else { + this.providers = undefined; + } + } } diff --git a/app/templates/app/components/tasks/_activiti-demo.component.css b/app/templates/app/components/tasks/_activiti-demo.component.css new file mode 100644 index 00000000..88261c85 --- /dev/null +++ b/app/templates/app/components/tasks/_activiti-demo.component.css @@ -0,0 +1,14 @@ +.activiti-task-list__item:hover { + cursor: pointer; + font-weight: bold; +} + +.activiti { + background-color: #f5f5f5; +} + +.task-column { + background-color: #f5f5f5; + padding: 10px 10px 10px 10px; + border: solid 2px rgb(31,188,210); +} diff --git a/app/templates/app/components/tasks/_activiti-demo.component.html b/app/templates/app/components/tasks/_activiti-demo.component.html new file mode 100644 index 00000000..988b2627 --- /dev/null +++ b/app/templates/app/components/tasks/_activiti-demo.component.html @@ -0,0 +1,65 @@ +
    +
    + + +
    +
    +
    +
    +
    +
    + Task Filters + +
    +
    + Task List + +
    +
    + Task Details + +
    +
    +
    +
    +
    +
    +
    +
    +
    + Process Filters + + +
    +
    + Process List + +
    +
    + Process Details + +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    diff --git a/app/templates/app/components/tasks/_activiti-demo.component.ts b/app/templates/app/components/tasks/_activiti-demo.component.ts new file mode 100644 index 00000000..a86a943e --- /dev/null +++ b/app/templates/app/components/tasks/_activiti-demo.component.ts @@ -0,0 +1,119 @@ +/*! + * @license + * Copyright 2016 Alfresco Software, Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Component, AfterViewChecked, ViewChild, Input } from '@angular/core'; +import { ALFRESCO_TASKLIST_DIRECTIVES } from 'ng2-activiti-tasklist'; +import { ACTIVITI_PROCESSLIST_DIRECTIVES } from 'ng2-activiti-processlist'; +import { ActivitiForm } from 'ng2-activiti-form'; + +declare let __moduleName: string; +declare var componentHandler; + +@Component({ + moduleId: __moduleName, + selector: 'activiti-demo', + templateUrl: './activiti-demo.component.html', + styleUrls: ['./activiti-demo.component.css'], + directives: [ALFRESCO_TASKLIST_DIRECTIVES, ACTIVITI_PROCESSLIST_DIRECTIVES, ActivitiForm] +}) +export class ActivitiDemoComponent implements AfterViewChecked { + + currentChoice: string = 'task-list'; + + @ViewChild('activitidetails') + activitidetails: any; + + @ViewChild('activititasklist') + activititasklist: any; + + @ViewChild('activitiprocesslist') + activitiprocesslist: any; + + @ViewChild('activitiprocessdetails') + activitiprocessdetails: any; + + currentTaskId: string; + currentProcessInstanceId: string; + + taskSchemaColumns: any [] = []; + processSchemaColumns: any [] = []; + + taskFilter: any; + processFilter: any; + + @Input() + appId: string; + + setChoice($event) { + this.currentChoice = $event.target.value; + } + + isProcessListSelected() { + return this.currentChoice === 'process-list'; + } + + isTaskListSelected() { + return this.currentChoice === 'task-list'; + } + + constructor() { + this.taskSchemaColumns = [ + {type: 'text', key: 'name', title: 'Name', cssClass: 'full-width name-column', sortable: true} + // {type: 'text', key: 'created', title: 'Created', sortable: true} + ]; + this.processSchemaColumns = [ + {type: 'text', key: 'name', title: 'Name', cssClass: 'full-width name-column', sortable: true} + ]; + } + + onTaskFilterClick(event: any) { + this.taskFilter = event; + this.activititasklist.load(this.taskFilter); + } + + onProcessFilterClick(event: any) { + this.processFilter = event.filter; + this.activitiprocesslist.load(this.processFilter); + } + + onTaskRowClick(taskId) { + this.currentTaskId = taskId; + this.activitidetails.loadDetails(this.currentTaskId); + } + + onProcessRowClick(processInstanceId) { + this.currentProcessInstanceId = processInstanceId; + this.activitiprocessdetails.load(this.currentProcessInstanceId); + } + + processCancelled(data: any) { + this.currentProcessInstanceId = null; + this.activitiprocesslist.reload(); + } + + taskFormCompleted(data: any) { + this.activitiprocesslist.reload(); + } + + ngAfterViewChecked() { + // workaround for MDL issues with dynamic components + if (componentHandler) { + componentHandler.upgradeAllRegistered(); + } + } + +} diff --git a/app/templates/app/components/tasks/_activiti.service.ts b/app/templates/app/components/tasks/_activiti.service.ts deleted file mode 100644 index 53b83401..00000000 --- a/app/templates/app/components/tasks/_activiti.service.ts +++ /dev/null @@ -1,85 +0,0 @@ -/*! - * @license - * Copyright 2016 Alfresco Software, Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { Injectable } from '@angular/core'; -import { Http, Headers, RequestOptions, Response } from '@angular/http'; -// import { Observable } from 'rxjs/Rx'; - -@Injectable() -export class ActivitiService { - - constructor(private http: Http) {} - - login(username: string, password: string) { - let url = 'http://localhost:9999/activiti-app/app/authentication'; - let headers = new Headers({ - 'Content-Type': 'application/x-www-form-urlencoded', - 'Cache-Control': 'no-cache' - }); - let options = new RequestOptions({ headers: headers }); - let data = 'j_username=' - + encodeURIComponent(username) - + '&j_password=' - + encodeURIComponent(password) - + '&_spring_security_remember_me=true&submit=Login'; - - return this.http - .post(url, data, options) - .toPromise() - // .then(res => console.log(res)) - .catch(this.handleError); - } - - getTasks() { - // emulate filter value - let data = JSON.stringify({ - 'page': 0, - 'filterId': 3, - 'filter': { - 'sort': 'created-desc', - 'name': '', - 'state': 'open', - 'assignment': 'involved' - }, - 'appDefinitionId': null - }); - - let url = 'http://localhost:9999/activiti-app/app/rest/filter/tasks'; - let headers = new Headers({ - 'Content-Type': 'application/json', - 'Cache-Control': 'no-cache' - }); - let options = new RequestOptions({ headers: headers }); - - return this.http - .post(url, data, options) - .toPromise() - .then(this.parseJSON) - .catch(this.handleError); - } - - private parseJSON(res: Response) { - let body = res.json(); - return body.data || { }; - } - - private handleError(error: any) { - console.error('An error occurred', error); - return Promise.reject(error.message || error); - } - -} diff --git a/app/templates/app/components/tasks/_tasks-demo.component.ts b/app/templates/app/components/tasks/_tasks-demo.component.ts deleted file mode 100644 index ac269506..00000000 --- a/app/templates/app/components/tasks/_tasks-demo.component.ts +++ /dev/null @@ -1,74 +0,0 @@ -/*! - * @license - * Copyright 2016 Alfresco Software, Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { Component, OnInit } from '@angular/core'; -import { ActivitiService } from './activiti.service'; -import { - ALFRESCO_DATATABLE_DIRECTIVES, - ObjectDataTableAdapter -} from 'ng2-alfresco-datatable'; - -@Component({ - selector: 'tasks-demo', - template: ` -
    - -
    - `, - directives: [ALFRESCO_DATATABLE_DIRECTIVES], - providers: [ActivitiService], - styles: [':host > .container { padding: 10px; }'] -}) -export class TasksDemoComponent implements OnInit { - - tasks: ObjectDataTableAdapter; - - constructor( - private activitiService: ActivitiService) {} - - ngOnInit() { - this.activitiService - .login('denys.vuika@alfresco.com', 'test') - .then(() => { - this.activitiService - .getTasks() - .then((data) => { - let tasks = data || []; - console.log(tasks); - this.loadTasks(tasks); - }); - }); - } - - private loadTasks(tasks: any[]) { - tasks = tasks.map(t => { - t.name = t.name || 'Nameless task'; - if (t.name.length > 50) { - t.name = t.name.substring(0, 50) + '...'; - } - return t; - }); - - this.tasks = new ObjectDataTableAdapter(tasks, [ - { type: 'text', key: 'id', title: 'Id'}, - { type: 'text', key: 'name', title: 'Name', cssClass: 'full-width name-column', sortable: true }, - { type: 'text', key: 'formKey', title: 'Form Key', sortable: true }, - { type: 'text', key: 'created', title: 'Created', sortable: true } - ]); - } - -} diff --git a/app/templates/assets/_license_header.txt b/app/templates/assets/_license_header.txt new file mode 100644 index 00000000..83fd1531 --- /dev/null +++ b/app/templates/assets/_license_header.txt @@ -0,0 +1,16 @@ +/*! + * @license + * Copyright 2016 Alfresco Software, Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ \ No newline at end of file diff --git a/app/templates/server/_versions.js b/app/templates/server/_versions.js new file mode 100644 index 00000000..020843cf --- /dev/null +++ b/app/templates/server/_versions.js @@ -0,0 +1,42 @@ +'use strict'; + +// wsrv extension that provides dynamic '/versions' route + +exports.register = function (server, options, next) { + + var packages = [ + 'ng2-activiti-form', + 'ng2-alfresco-core', + 'ng2-alfresco-datatable', + 'ng2-alfresco-documentlist', + 'ng2-alfresco-login', + 'ng2-alfresco-search', + 'ng2-alfresco-upload', + 'ng2-alfresco-viewer', + 'ng2-alfresco-webscript' + ]; + + server.route({ + method: 'GET', + path: '/versions', + handler: function (request, reply) { + var result = { + packages: packages.map(function (packageName) { + return { + name: packageName, + version: require('./../node_modules/' + packageName + '/package.json').version + } + }) + }; + + return reply(result).type('application/json'); + } + }); + + next(); +}; + +exports.register.attributes = { + name: 'ng2-module-versions', + version: '1.0.0' +}; diff --git a/package.json b/package.json index b8f0de09..0a315bdf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "generator-ng2-alfresco-app", - "version": "0.0.22", + "version": "0.3.0", "description": "Yeoman generator generating angular 2 Alfresco App", "homepage": "https://github.com/Alfresco/generator-ng2-alfresco-app", "author": { diff --git a/test/app.js b/test/app.js index 52800087..9a9abb46 100644 --- a/test/app.js +++ b/test/app.js @@ -51,8 +51,9 @@ describe('Alfresco component generator', function () { var expected = [ 'app/components/chart/chart.component.ts', 'app/components/chart/chart.component.html', - 'app/components/tasks/tasks-demo.component.ts', - 'app/components/tasks/activiti.service.ts', + 'app/components/tasks/activiti-demo.component.ts', + 'app/components/tasks/activiti-demo.component.html', + 'app/components/tasks/activiti-demo.component.css', 'app/components/files/files.component.html', 'app/components/files/files.component.ts', 'app/components/search/search.component.html', @@ -76,16 +77,12 @@ describe('Alfresco component generator', function () { assert.noFileContent('app/app.component.html', 'id="drawer-bar"'); }); - it('not fill the app.component.ts with the search bar', function () { - assert.noFileContent('app/app.component.ts', 'SearchComponent'); + it('not fill the app.routes.ts with the search bar', function () { + assert.noFileContent('app/app.routes.ts', 'SearchComponent'); }); - it('not fill the app.component.ts with the files component', function () { - assert.noFileContent('app/app.component.ts', 'FilesComponent'); - }); - - it('not fill the app.component.ts with the UploadButtonComponent', function () { - assert.noFileContent('app/app.component.ts', 'UploadButtonComponent'); + it('not fill the app.routes.ts with the UploadButtonComponent', function () { + assert.noFileContent('app/app.routes.ts', 'UploadButtonComponent'); }); it('not fill the app.main.ts with the UploadService', function () { @@ -154,12 +151,15 @@ describe('Alfresco component generator', function () { 'app/css/app.css', 'app/fonts/Muli-Regular.ttf', 'app/main.ts', + 'app/components/index.ts', + 'app/app.routes.ts', 'app/app.component.ts', 'app/app.component.html', 'app/components/chart/chart.component.ts', 'app/components/chart/chart.component.html', - 'app/components/tasks/tasks-demo.component.ts', - 'app/components/tasks/activiti.service.ts', + 'app/components/tasks/activiti-demo.component.html', + 'app/components/tasks/activiti-demo.component.css', + 'app/components/tasks/activiti-demo.component.ts', 'app/components/files/files.component.html', 'app/components/files/files.component.ts', 'app/components/search/search.component.html', @@ -205,27 +205,16 @@ describe('Alfresco component generator', function () { assert.fileContent('app/app.component.html', 'id="drawer-bar"'); }); - it('fill the app.component.ts with the search bar', function () { - assert.fileContent('app/app.component.ts', 'SearchComponent'); - }); - - it('sill the app.component.ts with the files component', function () { - assert.fileContent('app/app.component.ts', 'FilesComponent'); - assert.fileContent('app/app.component.ts', '\'http://servertTest:8080/share\''); + it('fill the app.routes.ts with the search bar', function () { + assert.fileContent('app/app.routes.ts', 'SearchComponent'); }); - it('fill the app.component with the UploadButtonComponent', function () { - assert.fileContent('app/app.component.ts', 'UploadButtonComponent'); + it('fill the app.routes.ts with the files component', function () { + assert.fileContent('app/app.routes.ts', 'FilesComponent'); }); - it('fill the app.component with the UploadService', function () { - assert.fileContent('app/main.ts', 'UploadService'); - assert.fileContent('app/main.ts', 'ng2-alfresco-upload'); - }); - - it('fill the app.component with the TasksDemoComponent', function () { - assert.fileContent('app/app.component.ts', '/components/tasks/tasks-demo.component'); - assert.fileContent('app/app.component.ts', 'component: TasksDemoComponent'); + it('fill the routes with the ActivitiDemoComponent', function () { + assert.fileContent('app/app.routes.ts', 'component: ActivitiDemoComponent'); }); it('fill the index.html with pdf library', function () { @@ -233,7 +222,5 @@ describe('Alfresco component generator', function () { assert.fileContent('index.html', 'pdf.worker.js'); assert.fileContent('index.html', 'pdf_viewer.js'); }); - }); - });