2016-09-01 15:21:04 +01:00
..
2016-05-12 19:35:41 +01:00
2016-08-26 00:24:50 +01:00
2016-06-14 18:36:46 +01:00
2016-05-23 11:12:01 +01:00
2016-08-23 16:56:02 +01:00
2016-08-29 23:46:29 -04:00
2016-09-01 15:21:04 +01:00
2016-05-21 04:25:44 +01:00
2016-08-23 16:56:01 +01:00
2016-06-14 12:36:15 +01:00

Alfresco Angular2 Components core

travis
    Status travis
    Status Coverage Status npm downloads license alfresco component angular 2 typescript node version

Core library for other ng2-alfresco components. This should be added as a dependency for any project using the components.

Prerequisites

Before you start using this development framework, make sure you have installed all required software and done all the necessary configuration, see this page.

Install

npm install --save ng2-alfresco-core

Main components and services

Components

  • Context Menu directive

Context Menu directive

See Demo Shell or DocumentList implementation for more details and use cases.

<my-component [context-menu]="menuItems"></my-component>
<context-menu-holder></context-menu-holder>
@Component({
    selector: 'my-component
})
export class MyComponent implements OnInit {

    menuItems: any[];
    
    constructor() {
        this.menuItems = [
            { title: 'Item 1', subject: new Subject() },
            { title: 'Item 2', subject: new Subject() },
            { title: 'Item 3', subject: new Subject() }
        ];
    }
    
    ngOnInit() {
        this.menuItems.forEach(l => l.subject.subscribe(item => this.commandCallback(item)));
    }
    
    commandCallback(item) {
        alert(`Executing ${item.title} command.`);
    }

}

Services

  • Authentication Service
  • Translation Service
  • Context Menu Service

Authentication Service

The authentication service is used inside the login component and is possible to find there an example of how to use it.

import { Component } from '@angular/core';
import { bootstrap } from '@angular/platform-browser-dynamic';
import { HTTP_PROVIDERS } from '@angular/http';

import {
    ALFRESCO_CORE_PROVIDERS,
    AlfrescoSettingsService,
    AlfrescoAuthenticationService
} from 'ng2-alfresco-core';

@Component({
    selector: 'my-app',
    template: `
               <div *ngIf="!authenticated" >
                    Authentication failed to ip {{ ecmHost }} with user: admin, admin
               </div>
               <div *ngIf="authenticated">
                    Authentication successfull to ip {{ ecmHost }} with user: admin, admin, your token is {{ token }}
               </div>`
})
class MyDemoApp {
    authenticated: boolean = false;

    ecmHost: string = 'http://127.0.0.1:8080';

    token: string;

    constructor(public alfrescoAuthenticationService: AlfrescoAuthenticationService,
                private alfrescoSettingsService: AlfrescoSettingsService) {

        alfrescoSettingsService.ecmHost = this.ecmHost;
        alfrescoSettingsService.setProviders('ECM');
    }

    ngOnInit() {
        this.login();
    }

    login() {
        this.alfrescoAuthenticationService.login('admin', 'admin').subscribe(
            token => {
                this.token = token.ticket;
                this.authenticated = true;
            },
            error => {
                console.log(error);
                this.authenticated = false;
            });
    }
}
bootstrap(MyDemoApp, [
    HTTP_PROVIDERS,
    ALFRESCO_CORE_PROVIDERS
]);

Build from sources

Alternatively you can build component from sources with the following commands:

npm install
npm run build

Build the files and keep watching for changes

$ npm run build:w

Running unit tests

npm test

Running unit tests in browser

npm test-browser

This task rebuilds all the code, runs tslint, license checks and other quality check tools before performing unit testing.

Code coverage

npm run coverage