Gathering detailed insights and metrics for ng2-alfresco-core
Gathering detailed insights and metrics for ng2-alfresco-core
Gathering detailed insights and metrics for ng2-alfresco-core
Gathering detailed insights and metrics for ng2-alfresco-core
npm install ng2-alfresco-core
Typescript
Module System
Node Version
NPM Version
TypeScript (91.2%)
HTML (4.28%)
SCSS (2.5%)
JavaScript (1.69%)
Shell (0.13%)
Rich Text Format (0.11%)
EJS (0.06%)
CSS (0.02%)
Total Downloads
3,741,913
Last Day
11
Last Week
43
Last Month
168
Last Year
7,359
294 Stars
10,802 Commits
268 Forks
104 Watching
261 Branches
487 Contributors
Minified
Minified + Gzipped
Latest Version
1.9.0
Package Id
ng2-alfresco-core@1.9.0
Size
756.44 kB
NPM Version
5.3.0
Node Version
8.6.0
Cumulative downloads
Total Downloads
Last day
22.2%
11
Compared to previous day
Last week
72%
43
Compared to previous week
Last month
-84%
168
Compared to previous month
Last year
-51.2%
7,359
Compared to previous year
22
56
Before you start using this development framework, make sure you have installed all required software and done all the necessary configuration, see this page.
If you plan using this component with projects generated by Angular CLI, please refer to the following article: Using ADF with Angular CLI
1npm install ng2-alfresco-core
1<adf-toolbar title="Toolbar"> 2 <button md-icon-button> 3 <md-icon>create_new_folder</md-icon> 4 </button> 5 <button md-icon-button> 6 <md-icon>delete</md-icon> 7 </button> 8</adf-toolbar>
Name | Type | Default | Description |
---|---|---|---|
title | string | Toolbar title | |
color | string | Toolbar color, can be changed to empty value (default), primary , accent or warn . |
Allows your components or common HTML elements reacting on File drag and drop in order to upload content. Used by attaching to an element or component.
The directive itself does not do any file management process, but collects information on dropped files and raises corresponding events instead.
1<div style="width:100px; height:100px" 2 [adf-upload]="true" 3 [adf-upload-data]="{ some: 'data' }"> 4 Drop files here... 5</div>
It is possible controlling when upload behaviour is enabled/disabled by binding directive to a boolean
value or expression:
1<div [adf-upload]="true">...</div> 2<div [adf-upload]="allowUpload">...</div> 3<div [adf-upload]="isUploadEnabled()">...</div>
You can decorate any element including buttons, for example:
1<button [adf-upload]="true" [multiple]="true" [accept]="'image/*'"> 2 Upload photos 3</button>
Directive supports several modes:
It is also possible combining modes together.
1<div [adf-upload]="true" mode="['click']">...</div> 2<div [adf-upload]="true" mode="['drop']">...</div> 3<div [adf-upload]="true" mode="['click', 'drop']">...</div>
For the click mode you can provide additional attributes for the File Dialog:
1<div style="width: 50px; height: 50px; background-color: brown" 2 [adf-upload]="true" 3 [multiple]="true" 4 [accept]="'image/*'"> 5</div> 6 7<div style="width: 50px; height: 50px; background-color: blueviolet" 8 [adf-upload]="true" 9 [multiple]="true" 10 [directory]="true"> 11</div>
For the moment upload directive supports only Files (single or multiple).
Support for Folders and accept
filters is subject to implement.
Once a single or multiple files are dropped on the decorated element the upload-files
CustomEvent is raised.
The DOM event is configured to have bubbling
enabled, so any component up the component tree can handle, process or prevent it:
1<div (upload-files)="onUploadFiles($event)"> 2 <div [adf-upload]="true"></div> 3</div>
1onUploadFiles(e: CustomEvent) { 2 console.log(e.detail.files); 3 4 // your code 5}
Please note that event will be raised only if valid Files were dropped onto the decorated element.
The upload-files
event is cancellable, so you can stop propagation of the drop event to uppper levels in case it has been already handled by your code:
1onUploadFiles(e: CustomEvent) { 2 e.stopPropagation(); 3 e.preventDefault(); 4 5 // your code 6}
It is also possible attaching arbitrary data to each event in order to access it from within external event handlers. A typical scenario is data tables where you may want to handle also the data row and/or underlying data to be accessible upon files drop.
You may be using adf-upload-data
to bind custom values or objects for every event raised:
1<div [adf-upload]="true" [adf-upload-data]="dataRow"></div> 2<div [adf-upload]="true" [adf-upload-data]="'string value'"></div> 3<div [adf-upload]="true" [adf-upload-data]="{ name: 'custom object' }"></div> 4<div [adf-upload]="true" [adf-upload-data]="getUploadData()"></div>
As part of the details
property of the CustomEvent you can get access to the following:
1detail: { 2 sender: UploadDirective, // directive that raised given event 3 data: any, // arbitrary data associated (bound) 4 files: File[] // dropped files 5}
The decorated element gets adf-upload__dragging
CSS class name in the class list every time files are dragged over it.
This allows changing look and feel of your components in case additional visual indication is required,
for example you may want drawing a dashed border around the table row on drag:
1<table> 2 <tr [adf-upload]="true"> 3 ... 4 </tr> 5</table>
1.adf-upload__dragging > td:first-child { 2 border-left: 1px dashed rgb(68,138,255); 3} 4 5.adf-upload__dragging > td { 6 border-top: 1px dashed rgb(68,138,255); 7 border-bottom: 1px dashed rgb(68,138,255); 8} 9 10.adf-upload__dragging > td:last-child { 11 border-right: 1px dashed rgb(68,138,255); 12}
Provides access to initialized AlfrescoJSApi instance.
1export class MyComponent implements OnInit { 2 3 constructor(private apiService: AlfrescoApiService) { 4 } 5 6 ngOnInit() { 7 let nodeId = 'some-node-id'; 8 let params = {}; 9 this.apiService.getInstance().nodes 10 .getNodeChildren(nodeId, params) 11 .then(result => console.log(result)); 12 } 13}
Note for developers: the TypeScript declaration files for Alfresco JS API
are still under development and some Alfresco APIs may not be accessed
via your favourite IDE's intellisense or TypeScript compiler.
In case of any TypeScript type check errors you can still call any supported
Alfresco JS api by casting the instance to any
type like the following:
1let api: any = this.apiService.getInstance(); 2api.nodes.addNode('-root-', body, {});
The AppConfigService
service provides support for loading and accessing global application configuration settings that you store on the server side in the form of a JSON file.
You may need this service when deploying your ADF-based application to production servers. There can be more than one server running web apps with different settings, like different addresses for Alfreco Content/Process services. Or there is a need to change global settings for all the clients.
The service is already pre-configured to look for the "app.config.json" file in the application root address.
That allows deploying ADF-based web applications to multiple servers together with different settings files, for example having development, staging or production environments.
Example of the default settings file content:
app.config.json
1{ 2 "ecmHost": "http://localhost:3000/ecm", 3 "bpmHost": "http://localhost:3000/bpm", 4 "application": { 5 "name": "Alfresco" 6 } 7}
Please note that settings above are default ones coming with the server.
You can override the values in your custom app.config.json
file if needed.
You can also change the path or name of the configuration file when importing the CoreModule in your main application.
1... 2@NgModule({ 3 imports: [ 4 ... 5 CoreModule.forRoot({ 6 appConfigFile: 'app.production.config.json' 7 }) 8 ], 9 ... 10} 11export class AppModule { }
Below is a simple example of using the AppConfigService in practice.
app.component.ts
1import { AppConfigService } from 'ng2-alfresco-core'; 2 3@Component({...}) 4export class AppComponent { 5 6 constructor(appConfig: AppConfigService) { 7 8 // get nested properties by the path 9 console.log(appConfig.get('application.name')); 10 11 // use generics for type safety 12 let version: number = appConfig.get<number>('version'); 13 console.log(version); 14 } 15}
You custom components can also benefit from the AppConfigService
,
you can put an unlimited number of settings and optionally a nested JSON hierarchy.
The CoreModule allows you to provide custom application configuration path. That means you can evaluate the final file name based on conditions, for example environment settings:
1let appConfigFile = 'app.config-dev.json'; 2if (process.env.ENV === 'production') { 3 appConfigFile = 'app.config-prod.json'; 4} 5 6@NgModule({ 7 imports: [ 8 ... 9 CoreModule.forRoot({ 10 appConfigFile: appConfigFile 11 }), 12 ... 13 ] 14})
The Notification Service is implemented on top of the Angular 2 Material Design snackbar. Use this service to show a notification message, and optionaly get feedback from it.
1import { NotificationService } from 'ng2-alfresco-core'; 2 3export class MyComponent implements OnInit { 4 5 constructor(private notificationService: NotificationService) { 6 } 7 8 ngOnInit() { 9 this.notificationService.openSnackMessage('test', 200000).afterDismissed().subscribe(() => { 10 console.log('The snack-bar was dismissed'); 11 }); 12 } 13}
1import { NotificationService } from 'ng2-alfresco-core'; 2 3export class MyComponent implements OnInit { 4 5 constructor(private notificationService: NotificationService) { 6 } 7 8 ngOnInit() { 9 this.notificationService.openSnackMessageAction('Do you want to report this issue?', 'send', 200000).afterDismissed().subscribe(() => { 10 console.log('The snack-bar was dismissed'); 11 }); 12 } 13}
See Demo Shell or DocumentList implementation for more details and use cases.
1<my-component [context-menu]="menuItems"></my-component> 2<context-menu-holder></context-menu-holder>
1@Component({ 2 selector: 'my-component' 3}) 4export class MyComponent implements OnInit { 5 6 menuItems: any[]; 7 8 constructor() { 9 this.menuItems = [ 10 { title: 'Item 1', subject: new Subject() }, 11 { title: 'Item 2', subject: new Subject() }, 12 { title: 'Item 3', subject: new Subject() } 13 ]; 14 } 15 16 ngOnInit() { 17 this.menuItems.forEach(l => l.subject.subscribe(item => this.commandCallback(item))); 18 } 19 20 commandCallback(item) { 21 alert(`Executing ${item.title} command.`); 22 } 23 24}
The component provide a way to easy create an accordion menu. You can customize the header and the icon.
1<adf-accordion> 2 <adf-accordion-group [heading]="titleHeading" [isSelected]="true" [headingIcon]="'assignment'"> 3 <my-list></my-list> 4 </adf-accordion-group> 5</adf-accordion>
1@Component({ 2 selector: 'my-component' 3}) 4export class MyComponent implements OnInit { 5 6 titleHeading: string; 7 8 constructor() { 9 this.titleHeading = 'My Group'; 10 } 11 12}
Name | Type | Description |
---|---|---|
heading | string | The header title. |
isSelected | boolean | Define if the accordion group is selected or not. |
headingIcon | string | The material design icon. |
hasAccordionIcon | boolean | Define if the accordion (expand) icon needs to be shown or not, the default value is true |
The authentication service is used inside the login component and is possible to find there an example of how to use it.
Name | Description |
---|---|
onLogin | Raised when user logs in |
onLogout | Raised when user logs out |
app.component.ts
1import { AlfrescoAuthenticationService } from 'ng2-alfresco-core'; 2 3@Component({...}) 4export class AppComponent { 5 constructor(authService: AlfrescoAuthenticationService) { 6 this.alfrescoAuthenticationService.login('admin', 'admin').subscribe( 7 token => { 8 console.log(token); 9 }, 10 error => { 11 console.log(error); 12 } 13 ); 14 } 15}
The component shows the CardViewModel} object.
1<adf-card-view 2 [properties]="[{label: 'My Label', value: 'My value'}]"> 3</adf-card-view> 4
Name | Type | Description |
---|---|---|
properties | {arrayCardViewModel} | (required) The custom view to render |
1{ 2 "label": "string", 3 "value": "any", 4 "format": "string", 5 "default": "string" 6}
Name | Type | Description |
---|---|---|
label | string | The label to render |
value | string | The value to render |
format | string | The format to use in case the value is a date |
default | string | The default value to render in case the value is empty |
In order to enable localisation support you will need creating a /resources/i18n/en.json
file
and registering path to it's parent i18n
folder:
1class MainApplication { 2 constructor(translateService: AlfrescoTranslationService) { 3 translateService.addTranslationFolder('app', 'resources'); 4 } 5}
Service also allows changing current language for entire application.
Imagine you got a language picker that invokes onLanguageClicked
method:
1class MyComponent { 2 constructor(private translateService: AlfrescoTranslationService) { 3 } 4 5 onLanguageClicked(lang: string) { 6 this.translateService.use('en'); 7 } 8}
It is also possible providing custom translations for existing components by overriding their resource paths:
1class MyComponent {
2 constructor(private translateService: AlfrescoTranslationService) {
3 translateService.addTranslationFolder(
4 'ng2-alfresco-login',
5 'i18n/custom-translation/alfresco-login'
6 );
7 }
8}
Important note: addTranslationFolder
method redirects all languages to a new folder, you may need implementing multiple languages
or copying existing translation files to a new path.
Alternatively you can build component from sources with the following commands:
1npm install 2npm run build
You can build component from sources with the following commands:
1npm install 2npm run build
The
build
task rebuilds all the code, runs tslint, license checks and other quality check tools before performing unit testing.
Command | Description |
---|---|
npm run build | Build component |
npm run test | Run unit tests in the console |
npm run test-browser | Run unit tests in the browser |
npm run coverage | Run unit tests and display code coverage report |
Please check the demo folder for a demo project
1cd demo 2npm install 3npm start
No vulnerabilities found.
Reason
all changesets reviewed
Reason
30 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 10
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
no binaries found in the repo
Reason
SAST tool is run on all commits
Details
Reason
dependency not pinned by hash detected -- score normalized to 8
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
project is not fuzzed
Details
Reason
14 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-12-09
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More