mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
committed by
Mario Romano
parent
1d45089125
commit
e25b05d991
@@ -25,6 +25,7 @@ env:
|
|||||||
- MODULE=ng2-activiti-diagrams
|
- MODULE=ng2-activiti-diagrams
|
||||||
- MODULE=ng2-activiti-analytics
|
- MODULE=ng2-activiti-analytics
|
||||||
- MODULE=ng2-alfresco-userinfo
|
- MODULE=ng2-alfresco-userinfo
|
||||||
|
- MODULE=ng2-alfresco-social
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
- if ([ "$MODULE" != "ng2-alfresco-core" ]); then
|
- if ([ "$MODULE" != "ng2-alfresco-core" ]); then
|
||||||
|
@@ -24,6 +24,7 @@ environment:
|
|||||||
- COMPONENT_NAME: ng2-activiti-diagrams
|
- COMPONENT_NAME: ng2-activiti-diagrams
|
||||||
- COMPONENT_NAME: ng2-activiti-analytics
|
- COMPONENT_NAME: ng2-activiti-analytics
|
||||||
- COMPONENT_NAME: ng2-alfresco-userinfo
|
- COMPONENT_NAME: ng2-alfresco-userinfo
|
||||||
|
- COMPONENT_NAME: ng2-alfresco-social
|
||||||
|
|
||||||
# Install scripts. (runs after repo cloning)
|
# Install scripts. (runs after repo cloning)
|
||||||
install:
|
install:
|
||||||
|
@@ -58,6 +58,7 @@
|
|||||||
<a class="mdl-navigation__link" href="" routerLink="/activiti" (click)="hideDrawer()">Process Services</a>
|
<a class="mdl-navigation__link" href="" routerLink="/activiti" (click)="hideDrawer()">Process Services</a>
|
||||||
<a class="mdl-navigation__link" href="" routerLink="/webscript" (click)="hideDrawer()">Webscript</a>
|
<a class="mdl-navigation__link" href="" routerLink="/webscript" (click)="hideDrawer()">Webscript</a>
|
||||||
<a class="mdl-navigation__link" href="" routerLink="/tag" (click)="hideDrawer()">Tag</a>
|
<a class="mdl-navigation__link" href="" routerLink="/tag" (click)="hideDrawer()">Tag</a>
|
||||||
|
<a class="mdl-navigation__link" href="" routerLink="/social" (click)="hideDrawer()">Social</a>
|
||||||
<a class="mdl-navigation__link" href="" routerLink="/about" (click)="hideDrawer()">About</a>
|
<a class="mdl-navigation__link" href="" routerLink="/about" (click)="hideDrawer()">About</a>
|
||||||
<a class="mdl-navigation__link" href="" routerLink="/settings" (click)="hideDrawer()">Settings</a>
|
<a class="mdl-navigation__link" href="" routerLink="/settings" (click)="hideDrawer()">Settings</a>
|
||||||
</nav>
|
</nav>
|
||||||
|
@@ -25,6 +25,7 @@ import { DataTableModule } from 'ng2-alfresco-datatable';
|
|||||||
import { DocumentListModule } from 'ng2-alfresco-documentlist';
|
import { DocumentListModule } from 'ng2-alfresco-documentlist';
|
||||||
import { UploadModule } from 'ng2-alfresco-upload';
|
import { UploadModule } from 'ng2-alfresco-upload';
|
||||||
import { TagModule } from 'ng2-alfresco-tag';
|
import { TagModule } from 'ng2-alfresco-tag';
|
||||||
|
import { SocialModule } from 'ng2-alfresco-social';
|
||||||
import { WebScriptModule } from 'ng2-alfresco-webscript';
|
import { WebScriptModule } from 'ng2-alfresco-webscript';
|
||||||
import { ViewerModule } from 'ng2-alfresco-viewer';
|
import { ViewerModule } from 'ng2-alfresco-viewer';
|
||||||
import { ActivitiFormModule } from 'ng2-activiti-form';
|
import { ActivitiFormModule } from 'ng2-activiti-form';
|
||||||
@@ -50,6 +51,7 @@ import {
|
|||||||
FormViewer,
|
FormViewer,
|
||||||
WebscriptComponent,
|
WebscriptComponent,
|
||||||
TagComponent,
|
TagComponent,
|
||||||
|
SocialComponent,
|
||||||
AboutComponent,
|
AboutComponent,
|
||||||
FilesComponent,
|
FilesComponent,
|
||||||
FormNodeViewer,
|
FormNodeViewer,
|
||||||
@@ -68,6 +70,7 @@ import {
|
|||||||
DocumentListModule.forRoot(),
|
DocumentListModule.forRoot(),
|
||||||
UploadModule.forRoot(),
|
UploadModule.forRoot(),
|
||||||
TagModule.forRoot(),
|
TagModule.forRoot(),
|
||||||
|
SocialModule.forRoot(),
|
||||||
WebScriptModule.forRoot(),
|
WebScriptModule.forRoot(),
|
||||||
ViewerModule.forRoot(),
|
ViewerModule.forRoot(),
|
||||||
ActivitiFormModule.forRoot(),
|
ActivitiFormModule.forRoot(),
|
||||||
@@ -91,6 +94,7 @@ import {
|
|||||||
FormViewer,
|
FormViewer,
|
||||||
WebscriptComponent,
|
WebscriptComponent,
|
||||||
TagComponent,
|
TagComponent,
|
||||||
|
SocialComponent,
|
||||||
AboutComponent,
|
AboutComponent,
|
||||||
FilesComponent,
|
FilesComponent,
|
||||||
FormNodeViewer,
|
FormNodeViewer,
|
||||||
|
@@ -29,6 +29,7 @@ import {
|
|||||||
ActivitiAppsView,
|
ActivitiAppsView,
|
||||||
WebscriptComponent,
|
WebscriptComponent,
|
||||||
TagComponent,
|
TagComponent,
|
||||||
|
SocialComponent,
|
||||||
AboutComponent,
|
AboutComponent,
|
||||||
FormViewer,
|
FormViewer,
|
||||||
FormNodeViewer,
|
FormNodeViewer,
|
||||||
@@ -117,6 +118,11 @@ export const appRoutes: Routes = [
|
|||||||
component: TagComponent,
|
component: TagComponent,
|
||||||
canActivate: [AuthGuardEcm]
|
canActivate: [AuthGuardEcm]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: 'social',
|
||||||
|
component: SocialComponent,
|
||||||
|
canActivate: [AuthGuardEcm]
|
||||||
|
},
|
||||||
{ path: 'about', component: AboutComponent },
|
{ path: 'about', component: AboutComponent },
|
||||||
{ path: 'settings', component: SettingComponent }
|
{ path: 'settings', component: SettingComponent }
|
||||||
];
|
];
|
||||||
|
@@ -24,6 +24,7 @@ export { ActivitiDemoComponent } from './activiti/activiti-demo.component';
|
|||||||
export { FormViewer } from './activiti/form-viewer.component';
|
export { FormViewer } from './activiti/form-viewer.component';
|
||||||
export { WebscriptComponent } from './webscript/webscript.component';
|
export { WebscriptComponent } from './webscript/webscript.component';
|
||||||
export { TagComponent } from './tag/tag.component';
|
export { TagComponent } from './tag/tag.component';
|
||||||
|
export { SocialComponent } from './social/social.component';
|
||||||
export { AboutComponent } from './about/about.component';
|
export { AboutComponent } from './about/about.component';
|
||||||
export { FilesComponent } from './files/files.component';
|
export { FilesComponent } from './files/files.component';
|
||||||
export { FormNodeViewer } from './activiti/form-node-viewer.component';
|
export { FormNodeViewer } from './activiti/form-node-viewer.component';
|
||||||
|
39
demo-shell-ng2/app/components/social/social.component.ts
Normal file
39
demo-shell-ng2/app/components/social/social.component.ts
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
/*!
|
||||||
|
* @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';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'alfresco-social-demo',
|
||||||
|
template: `
|
||||||
|
<label for="nodeId"><b>Insert Node Id</b></label><br>
|
||||||
|
<input id="nodeId" type="text" size="48" [(ngModel)]="nodeId"><br>
|
||||||
|
<div class="mdl-grid">
|
||||||
|
<div class="mdl-cell mdl-cell--4-col">
|
||||||
|
Like component
|
||||||
|
<adf-like [nodeId]="nodeId"></adf-like></div>
|
||||||
|
<div class="mdl-cell mdl-cell--4-col">
|
||||||
|
Rating component
|
||||||
|
<adf-rating [nodeId]="nodeId"></adf-rating>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`
|
||||||
|
})
|
||||||
|
export class SocialComponent {
|
||||||
|
|
||||||
|
nodeId: string = '74cd8a96-8a21-47e5-9b3b-a1b3e296787d';
|
||||||
|
}
|
@@ -25,6 +25,7 @@ import 'ng2-alfresco-documentlist';
|
|||||||
import 'ng2-alfresco-login';
|
import 'ng2-alfresco-login';
|
||||||
import 'ng2-alfresco-search';
|
import 'ng2-alfresco-search';
|
||||||
import 'ng2-alfresco-tag';
|
import 'ng2-alfresco-tag';
|
||||||
|
import 'ng2-alfresco-social';
|
||||||
import 'ng2-alfresco-upload';
|
import 'ng2-alfresco-upload';
|
||||||
import 'ng2-alfresco-viewer';
|
import 'ng2-alfresco-viewer';
|
||||||
import 'ng2-alfresco-webscript';
|
import 'ng2-alfresco-webscript';
|
||||||
|
@@ -85,6 +85,7 @@
|
|||||||
"ng2-alfresco-login": "1.3.0",
|
"ng2-alfresco-login": "1.3.0",
|
||||||
"ng2-alfresco-search": "1.3.0",
|
"ng2-alfresco-search": "1.3.0",
|
||||||
"ng2-alfresco-tag": "1.3.0",
|
"ng2-alfresco-tag": "1.3.0",
|
||||||
|
"ng2-alfresco-social": "1.3.0",
|
||||||
"ng2-alfresco-upload": "1.3.0",
|
"ng2-alfresco-upload": "1.3.0",
|
||||||
"ng2-alfresco-userinfo": "1.3.0",
|
"ng2-alfresco-userinfo": "1.3.0",
|
||||||
"ng2-alfresco-viewer": "1.3.0",
|
"ng2-alfresco-viewer": "1.3.0",
|
||||||
|
23
ng2-components/ng2-alfresco-social/.editorconfig
Normal file
23
ng2-components/ng2-alfresco-social/.editorconfig
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
# http://editorconfig.org
|
||||||
|
|
||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
charset = utf-8
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 4
|
||||||
|
end_of_line = lf
|
||||||
|
insert_final_newline = true
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
|
||||||
|
[package.json]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
|
||||||
|
[karma.conf.js]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
|
||||||
|
[*.md]
|
||||||
|
insert_final_newline = false
|
||||||
|
trim_trailing_whitespace = false
|
19
ng2-components/ng2-alfresco-social/.gitignore
vendored
Normal file
19
ng2-components/ng2-alfresco-social/.gitignore
vendored
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
npm-debug.log
|
||||||
|
node_modules
|
||||||
|
.idea
|
||||||
|
typings
|
||||||
|
coverage
|
||||||
|
dist
|
||||||
|
src/**/*.js
|
||||||
|
src/**/*.js.map
|
||||||
|
src/**/*.d.ts
|
||||||
|
demo/**/*.js
|
||||||
|
demo/**/*.js.map
|
||||||
|
demo/**/*.d.ts
|
||||||
|
index.js
|
||||||
|
index.js.map
|
||||||
|
!systemjs.config.js
|
||||||
|
*.tgz
|
||||||
|
/package/
|
||||||
|
/bundles/
|
||||||
|
index.d.ts
|
16
ng2-components/ng2-alfresco-social/.npmignore
Normal file
16
ng2-components/ng2-alfresco-social/.npmignore
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
npm-debug.log
|
||||||
|
.idea
|
||||||
|
|
||||||
|
coverage/
|
||||||
|
demo/
|
||||||
|
node_modules
|
||||||
|
typings/
|
||||||
|
fonts/
|
||||||
|
|
||||||
|
/.editorconfig
|
||||||
|
/.travis.yml
|
||||||
|
/*.json
|
||||||
|
/karma-test-shim.js
|
||||||
|
/karma.conf.js
|
||||||
|
/gulpfile.ts
|
||||||
|
/.npmignore
|
13
ng2-components/ng2-alfresco-social/LICENSE
Normal file
13
ng2-components/ng2-alfresco-social/LICENSE
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
Copyright 2016 Alfresco <alfresco@alfresco.com>
|
||||||
|
|
||||||
|
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.
|
291
ng2-components/ng2-alfresco-social/README.md
Normal file
291
ng2-components/ng2-alfresco-social/README.md
Normal file
@@ -0,0 +1,291 @@
|
|||||||
|
# Alfresco Social Component for Angular 2
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<a title='Build Status Travis' href="https://travis-ci.org/Alfresco/alfresco-ng2-components">
|
||||||
|
<img src='https://travis-ci.org/Alfresco/alfresco-ng2-components.svg?branch=master' alt='travis
|
||||||
|
Status' />
|
||||||
|
</a>
|
||||||
|
<a title='Build Status AppVeyor' href="https://ci.appveyor.com/project/alfresco/alfresco-ng2-components">
|
||||||
|
<img src='https://ci.appveyor.com/api/projects/status/github/Alfresco/alfresco-ng2-components' alt='travis
|
||||||
|
Status' />
|
||||||
|
</a>
|
||||||
|
<a href='https://codecov.io/gh/Alfresco/alfresco-ng2-components'>
|
||||||
|
<img src='https://img.shields.io/codecov/c/github/Alfresco/alfresco-ng2-components/master.svg?maxAge=2592000' alt='Coverage Status' />
|
||||||
|
</a>
|
||||||
|
<a href='https://www.npmjs.com/package/ng2-alfresco-social'>
|
||||||
|
<img src='https://img.shields.io/npm/dt/ng2-alfresco-social.svg' alt='npm downloads' />
|
||||||
|
</a>
|
||||||
|
<a href='https://github.com/Alfresco/alfresco-ng2-components/blob/master/LICENSE'>
|
||||||
|
<img src='https://img.shields.io/hexpm/l/plug.svg' alt='license' />
|
||||||
|
</a>
|
||||||
|
<a href='https://www.alfresco.com/'>
|
||||||
|
<img src='https://img.shields.io/badge/style-component-green.svg?label=alfresco' alt='alfresco component' />
|
||||||
|
</a>
|
||||||
|
<a href='https://angular.io/'>
|
||||||
|
<img src='https://img.shields.io/badge/style-2-red.svg?label=angular' alt='angular 2' />
|
||||||
|
</a>
|
||||||
|
<a href='https://www.typescriptlang.org/docs/tutorial.html'>
|
||||||
|
<img src='https://img.shields.io/badge/style-lang-blue.svg?label=typescript' alt='typescript' />
|
||||||
|
</a>
|
||||||
|
<a href='https://www.alfresco.com/'>
|
||||||
|
<img src='https://img.shields.io/badge/style-%3E5.0.0-blue.svg?label=node%20version' alt='node version' />
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
|
||||||
|
## Prerequisites
|
||||||
|
|
||||||
|
Before you start using this development framework, make sure you have installed all required software and done all the
|
||||||
|
necessary configuration [prerequisites](https://github.com/Alfresco/alfresco-ng2-components/blob/master/PREREQUISITES.md).
|
||||||
|
|
||||||
|
## Install
|
||||||
|
|
||||||
|
Follow the 3 steps below:
|
||||||
|
|
||||||
|
1. Npm
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm install ng2-alfresco-social --save
|
||||||
|
```
|
||||||
|
|
||||||
|
2. Html
|
||||||
|
|
||||||
|
Include these dependencies in your index.html page:
|
||||||
|
|
||||||
|
```html
|
||||||
|
|
||||||
|
<!-- Google Material Design Lite -->
|
||||||
|
<link rel="stylesheet" href="node_modules/material-design-lite/material.min.css">
|
||||||
|
<script src="node_modules/material-design-lite/material.min.js"></script>
|
||||||
|
<link rel="stylesheet" href="node_modules/material-design-icons/iconfont/material-icons.css">
|
||||||
|
|
||||||
|
<!-- Load the Angular Material 2 stylesheet -->
|
||||||
|
<link href="node_modules/@angular/material/core/theming/prebuilt/deeppurple-amber.css" rel="stylesheet">
|
||||||
|
|
||||||
|
<!-- Polyfill(s) for Safari (pre-10.x) -->
|
||||||
|
<script src="node_modules/intl/dist/Intl.min.js"></script>
|
||||||
|
<script src="node_modules/intl/locale-data/jsonp/en.js"></script>
|
||||||
|
|
||||||
|
<!-- Polyfill(s) for older browsers -->
|
||||||
|
<script src="node_modules/core-js/client/shim.min.js"></script>
|
||||||
|
<script src="//cdnjs.cloudflare.com/ajax/libs/dom4/1.8.3/dom4.js"></script>
|
||||||
|
<script src="node_modules/element.scrollintoviewifneeded-polyfill/index.js"></script>
|
||||||
|
|
||||||
|
<!-- Polyfill(s) for dialogs -->
|
||||||
|
<script src="node_modules/dialog-polyfill/dialog-polyfill.js"></script>
|
||||||
|
<link rel="stylesheet" type="text/css" href="node_modules/dialog-polyfill/dialog-polyfill.css" />
|
||||||
|
<style>._dialog_overlay { position: static !important; } </style>
|
||||||
|
|
||||||
|
<!-- Modules -->
|
||||||
|
<script src="node_modules/zone.js/dist/zone.js"></script>
|
||||||
|
<script src="node_modules/reflect-metadata/Reflect.js"></script>
|
||||||
|
<script src="node_modules/systemjs/dist/system.src.js"></script>
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
3. SystemJs
|
||||||
|
|
||||||
|
Add the following components to your systemjs.config.js file:
|
||||||
|
|
||||||
|
- ng2-translate
|
||||||
|
- alfresco-js-api
|
||||||
|
- ng2-alfresco-core
|
||||||
|
- ng2-alfresco-social
|
||||||
|
|
||||||
|
Please refer to the following example file: [systemjs.config.js](demo/systemjs.config.js) .
|
||||||
|
|
||||||
|
|
||||||
|
#### Basic usage
|
||||||
|
|
||||||
|
In this component are present two different components :
|
||||||
|
|
||||||
|
* adf-like
|
||||||
|
* adf-rating
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## adf-like
|
||||||
|
|
||||||
|
```html
|
||||||
|
<adf-like [nodeId]="nodeId"></adf-like>
|
||||||
|
```
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import { NgModule, Component } from '@angular/core';
|
||||||
|
import { BrowserModule } from '@angular/platform-browser';
|
||||||
|
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
|
||||||
|
|
||||||
|
import { CoreModule, AlfrescoSettingsService, AlfrescoAuthenticationService } from 'ng2-alfresco-core';
|
||||||
|
import { SocialModule } from 'ng2-alfresco-social';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'alfresco-app-demo',
|
||||||
|
template: `<adf-like [nodeId]="'74cd8a96-8a21-47e5-9b3b-a1b3e296787d'"></adf-like>
|
||||||
|
`
|
||||||
|
})
|
||||||
|
class LikeDemo {
|
||||||
|
|
||||||
|
constructor(private authService: AlfrescoAuthenticationService, private settingsService: AlfrescoSettingsService) {
|
||||||
|
settingsService.ecmHost = 'http://localhost:8080';
|
||||||
|
|
||||||
|
this.authService.login('admin', 'admin').subscribe(
|
||||||
|
ticket => {
|
||||||
|
console.log(ticket);
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
console.log(error);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
imports: [
|
||||||
|
BrowserModule,
|
||||||
|
CoreModule.forRoot(),
|
||||||
|
SocialModule
|
||||||
|
],
|
||||||
|
declarations: [ LikeDemo ],
|
||||||
|
bootstrap: [ LikeDemo ]
|
||||||
|
})
|
||||||
|
export class AppModule { }
|
||||||
|
|
||||||
|
platformBrowserDynamic().bootstrapModule(AppModule);
|
||||||
|
```
|
||||||
|
|
||||||
|
### Options
|
||||||
|
|
||||||
|
Attribute | Options | Default | Description | Mandatory
|
||||||
|
--- | --- | --- | --- | ---
|
||||||
|
`nodeId` | *string* | | The identifier of a node.|
|
||||||
|
|
||||||
|
#### Events
|
||||||
|
|
||||||
|
| Name | Description |
|
||||||
|
| --- | --- |
|
||||||
|
| `changeVote` | The event is emitted when vote change |
|
||||||
|
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## adf-rating
|
||||||
|
|
||||||
|
```html
|
||||||
|
<adf-rating [nodeId]="'74cd8a96-8a21-47e5-9b3b-a1b3e296787d'" ></adf-rating>
|
||||||
|
```
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import { NgModule, Component } from '@angular/core';
|
||||||
|
import { BrowserModule } from '@angular/platform-browser';
|
||||||
|
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
|
||||||
|
|
||||||
|
import { CoreModule, AlfrescoSettingsService, AlfrescoAuthenticationService } from 'ng2-alfresco-core';
|
||||||
|
import { SocialModule } from 'ng2-alfresco-social';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'alfresco-app-demo',
|
||||||
|
template: `<adf-rating [nodeId]="'74cd8a96-8a21-47e5-9b3b-a1b3e296787d'></adf-rating>`
|
||||||
|
})
|
||||||
|
class RatingDemo {
|
||||||
|
|
||||||
|
constructor(private authService: AlfrescoAuthenticationService, private settingsService: AlfrescoSettingsService) {
|
||||||
|
settingsService.ecmHost = 'http://localhost:8080';
|
||||||
|
|
||||||
|
this.authService.login('admin', 'admin').subscribe(
|
||||||
|
ticket => {
|
||||||
|
console.log(ticket);
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
console.log(error);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
imports: [
|
||||||
|
BrowserModule,
|
||||||
|
CoreModule.forRoot(),
|
||||||
|
SocialModule
|
||||||
|
],
|
||||||
|
declarations: [ RatingDemo ],
|
||||||
|
bootstrap: [ RatingDemo ]
|
||||||
|
})
|
||||||
|
export class AppModule { }
|
||||||
|
|
||||||
|
platformBrowserDynamic().bootstrapModule(AppModule);
|
||||||
|
```
|
||||||
|
|
||||||
|
### Options
|
||||||
|
|
||||||
|
Attribute | Options | Default | Description | Mandatory
|
||||||
|
--- | --- | --- | --- | ---
|
||||||
|
`nodeId` | *string* | | The identifier of a node.|
|
||||||
|
|
||||||
|
#### Events
|
||||||
|
|
||||||
|
| Name | Description |
|
||||||
|
| --- | --- |
|
||||||
|
| `changeVote` | The event is emitted when vote change |
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
|
||||||
|
## Build from sources
|
||||||
|
|
||||||
|
Alternatively you can build component from sources with the following commands:
|
||||||
|
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm install
|
||||||
|
npm run build
|
||||||
|
```
|
||||||
|
|
||||||
|
### Build the files and keep watching for changes
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ npm run build:w
|
||||||
|
```
|
||||||
|
|
||||||
|
## Running unit tests
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm test
|
||||||
|
```
|
||||||
|
|
||||||
|
### Running unit tests in browser
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm test-browser
|
||||||
|
```
|
||||||
|
|
||||||
|
This task rebuilds all the code, runs tslint, license checks and other quality check tools
|
||||||
|
before performing unit testing.
|
||||||
|
|
||||||
|
### Code coverage
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm run coverage
|
||||||
|
```
|
||||||
|
|
||||||
|
## Demo
|
||||||
|
|
||||||
|
If you want have a demo of how the component works, please check the demo folder :
|
||||||
|
|
||||||
|
```sh
|
||||||
|
cd demo
|
||||||
|
npm install
|
||||||
|
npm start
|
||||||
|
```
|
||||||
|
|
||||||
|
## NPM scripts
|
||||||
|
|
||||||
|
| Command | Description |
|
||||||
|
| --- | --- |
|
||||||
|
| npm run build | Build component |
|
||||||
|
| npm run build:w | Build component and keep watching the changes |
|
||||||
|
| 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 |
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
[Apache Version 2.0](https://github.com/Alfresco/alfresco-ng2-components/blob/master/LICENSE)
|
16
ng2-components/ng2-alfresco-social/assets/license_header.txt
Normal file
16
ng2-components/ng2-alfresco-social/assets/license_header.txt
Normal file
@@ -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.
|
||||||
|
*/
|
23
ng2-components/ng2-alfresco-social/demo/.editorconfig
Normal file
23
ng2-components/ng2-alfresco-social/demo/.editorconfig
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
# http://editorconfig.org
|
||||||
|
|
||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
charset = utf-8
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 4
|
||||||
|
end_of_line = lf
|
||||||
|
insert_final_newline = true
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
|
||||||
|
[package.json]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
|
||||||
|
[karma.conf.js]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
|
||||||
|
[*.md]
|
||||||
|
insert_final_newline = false
|
||||||
|
trim_trailing_whitespace = false
|
6
ng2-components/ng2-alfresco-social/demo/.gitignore
vendored
Normal file
6
ng2-components/ng2-alfresco-social/demo/.gitignore
vendored
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
typings/
|
||||||
|
node_modules/
|
||||||
|
.idea
|
||||||
|
dist/
|
||||||
|
!systemjs.config.js
|
||||||
|
!browser-sync-config.js
|
19
ng2-components/ng2-alfresco-social/demo/README.md
Normal file
19
ng2-components/ng2-alfresco-social/demo/README.md
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
# ng2-alfresco-social - Demo
|
||||||
|
|
||||||
|
* To install dependencies
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ npm install
|
||||||
|
```
|
||||||
|
|
||||||
|
* To provide a live demo
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ npm run start
|
||||||
|
```
|
||||||
|
|
||||||
|
* To clean npm_modules and typings folder
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ npm run clean
|
||||||
|
```
|
47
ng2-components/ng2-alfresco-social/demo/index.html
Normal file
47
ng2-components/ng2-alfresco-social/demo/index.html
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Alfresco Angular 2 Social - Demo</title>
|
||||||
|
<base href="./">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
|
||||||
|
<!-- Google Material Design Lite -->
|
||||||
|
<link rel="stylesheet" href="node_modules/material-design-lite/material.min.css">
|
||||||
|
<script src="node_modules/material-design-lite/material.min.js"></script>
|
||||||
|
<link rel="stylesheet" href="node_modules/material-design-icons/iconfont/material-icons.css">
|
||||||
|
|
||||||
|
<!-- Polyfill(s) for Safari (pre-10.x) -->
|
||||||
|
<script src="node_modules/intl/dist/Intl.min.js"></script>
|
||||||
|
<script src="node_modules/intl/locale-data/jsonp/en.js"></script>
|
||||||
|
|
||||||
|
<!-- Polyfill(s) for older browsers -->
|
||||||
|
<script src="node_modules/core-js/client/shim.min.js"></script>
|
||||||
|
<script src="//cdnjs.cloudflare.com/ajax/libs/dom4/1.8.3/dom4.js"></script>
|
||||||
|
<script src="node_modules/element.scrollintoviewifneeded-polyfill/index.js"></script>
|
||||||
|
|
||||||
|
<!-- Polyfill(s) for dialogs -->
|
||||||
|
<script src="node_modules/dialog-polyfill/dialog-polyfill.js"></script>
|
||||||
|
<link rel="stylesheet" type="text/css" href="node_modules/dialog-polyfill/dialog-polyfill.css" />
|
||||||
|
<style>._dialog_overlay { position: static !important; } </style>
|
||||||
|
|
||||||
|
<!-- Modules -->
|
||||||
|
<script src="node_modules/zone.js/dist/zone.js"></script>
|
||||||
|
<script src="node_modules/reflect-metadata/Reflect.js"></script>
|
||||||
|
<script src="node_modules/systemjs/dist/system.src.js"></script>
|
||||||
|
|
||||||
|
<script src="systemjs.config.js"></script>
|
||||||
|
<script>
|
||||||
|
System.import('app').catch(
|
||||||
|
function (err) {
|
||||||
|
console.error(err);
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<alfresco-app-demo></alfresco-app-demo>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
68
ng2-components/ng2-alfresco-social/demo/package.json
Normal file
68
ng2-components/ng2-alfresco-social/demo/package.json
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
{
|
||||||
|
"name": "ng2-alfresco-social-demo",
|
||||||
|
"description": "Alfresco Angular2 Rating - Demo",
|
||||||
|
"version": "0.3.0",
|
||||||
|
"author": "Alfresco Software, Ltd.",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"clean": "npm install rimraf && npm run clean-build && rimraf dist node_modules typings dist",
|
||||||
|
"clean-build" : "rimraf 'src/{,**/}**.js' 'src/{,**/}**.js.map' 'src/{,**/}**.d.ts'",
|
||||||
|
"postinstall": "npm run build",
|
||||||
|
"start": "npm run build && concurrently \"npm run tsc:w\" \"npm run server\" ",
|
||||||
|
"server": "wsrv -o -s -l",
|
||||||
|
"build": "npm run tslint && npm run clean-build && npm run tsc",
|
||||||
|
"build:w": "npm run tslint && rimraf dist && npm run tsc:w",
|
||||||
|
"travis": "npm link ng2-alfresco-core",
|
||||||
|
"tsc": "tsc",
|
||||||
|
"tsc:w": "tsc -w",
|
||||||
|
"tslint": "tslint -c tslint.json *.ts && tslint -c tslint.json src/{,**/}**.ts -e '{,**/}**.d.ts'"
|
||||||
|
},
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"dependencies": {
|
||||||
|
"@angular/common": "2.2.2",
|
||||||
|
"@angular/compiler": "2.2.2",
|
||||||
|
"@angular/compiler-cli": "2.2.2",
|
||||||
|
"@angular/core": "2.2.2",
|
||||||
|
"@angular/forms": "2.2.2",
|
||||||
|
"@angular/http": "2.2.2",
|
||||||
|
"@angular/platform-browser": "2.2.2",
|
||||||
|
"@angular/platform-browser-dynamic": "2.2.2",
|
||||||
|
"@angular/material": "2.0.0-beta.1",
|
||||||
|
"@angular/router": "3.2.2",
|
||||||
|
"@angular/upgrade": "2.2.2",
|
||||||
|
"core-js": "2.4.1",
|
||||||
|
"reflect-metadata": "0.1.10",
|
||||||
|
"rxjs": "5.0.0-beta.12",
|
||||||
|
"systemjs": "0.19.27",
|
||||||
|
"zone.js": "0.6.26",
|
||||||
|
"intl": "1.2.4",
|
||||||
|
"dialog-polyfill": "0.4.7",
|
||||||
|
"element.scrollintoviewifneeded-polyfill": "1.0.1",
|
||||||
|
"material-design-icons": "2.2.3",
|
||||||
|
"material-design-lite": "1.2.1",
|
||||||
|
"ng2-translate": "4.0.0",
|
||||||
|
"alfresco-js-api": "~1.3.0",
|
||||||
|
"ng2-alfresco-core": "1.3.0",
|
||||||
|
"ng2-alfresco-social": "1.3.0"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/jasmine": "^2.2.33",
|
||||||
|
"@types/node": "^6.0.42",
|
||||||
|
"concurrently": "^2.2.0",
|
||||||
|
"rimraf": "2.5.2",
|
||||||
|
"tslint": "3.15.1",
|
||||||
|
"typescript": "^2.0.3",
|
||||||
|
"wsrv": "^0.1.5"
|
||||||
|
},
|
||||||
|
"contributors": [
|
||||||
|
{
|
||||||
|
"name": "Eugenio Romano",
|
||||||
|
"email": "eugenio.romano@alfresco.com"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"keywords": [
|
||||||
|
"angular2",
|
||||||
|
"typescript",
|
||||||
|
"alfresco"
|
||||||
|
]
|
||||||
|
}
|
117
ng2-components/ng2-alfresco-social/demo/src/main.ts
Normal file
117
ng2-components/ng2-alfresco-social/demo/src/main.ts
Normal file
@@ -0,0 +1,117 @@
|
|||||||
|
/*!
|
||||||
|
* @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 { NgModule, Component, Input, OnInit } from '@angular/core';
|
||||||
|
import { BrowserModule } from '@angular/platform-browser';
|
||||||
|
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
|
||||||
|
|
||||||
|
import { CoreModule, AlfrescoSettingsService, AlfrescoAuthenticationService, StorageService, LogService } from 'ng2-alfresco-core';
|
||||||
|
import { SocialModule } from 'ng2-alfresco-social';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'alfresco-app-demo',
|
||||||
|
template: `
|
||||||
|
<label for="ticket"><b>Insert a valid access ticket / ticket:</b></label><br>
|
||||||
|
<input id="ticket" type="text" size="48" (change)="updateTicket()" [(ngModel)]="ticket"><br>
|
||||||
|
<label for="host"><b>Insert the ip of your Alfresco instance:</b></label><br>
|
||||||
|
<input id="host" type="text" size="48" (change)="updateHost()" [(ngModel)]="ecmHost"><br><br>
|
||||||
|
<div *ngIf="!authenticated" style="color:#FF2323">
|
||||||
|
Authentication failed to ip {{ ecmHost }} with user: admin, admin, you can still try to add a valid ticket to perform
|
||||||
|
operations.
|
||||||
|
</div>
|
||||||
|
<hr>
|
||||||
|
<label for="nodeId"><b>Insert Node Id</b></label><br>
|
||||||
|
<input id="nodeId" type="text" size="48" [(ngModel)]="nodeId"><br>
|
||||||
|
<div class="container" *ngIf="authenticated">
|
||||||
|
<div class="mdl-grid">
|
||||||
|
<div class="mdl-cell mdl-cell--4-col">
|
||||||
|
Like component
|
||||||
|
<adf-like [nodeId]="nodeId"></adf-like></div>
|
||||||
|
<div class="mdl-cell mdl-cell--4-col">
|
||||||
|
Rating component
|
||||||
|
<adf-rating [nodeId]="nodeId"></adf-rating>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`
|
||||||
|
})
|
||||||
|
class SocialDemo implements OnInit {
|
||||||
|
|
||||||
|
@Input()
|
||||||
|
nodeId: string = '74cd8a96-8a21-47e5-9b3b-a1b3e296787d';
|
||||||
|
|
||||||
|
authenticated: boolean;
|
||||||
|
ecmHost: string = 'http://127.0.0.1:8080';
|
||||||
|
ticket: string;
|
||||||
|
|
||||||
|
constructor(private authService: AlfrescoAuthenticationService,
|
||||||
|
private settingsService: AlfrescoSettingsService,
|
||||||
|
private storage: StorageService,
|
||||||
|
private logService: LogService) {
|
||||||
|
|
||||||
|
settingsService.ecmHost = this.ecmHost;
|
||||||
|
settingsService.setProviders('ECM');
|
||||||
|
|
||||||
|
if (this.authService.getTicketEcm()) {
|
||||||
|
this.ticket = this.authService.getTicketEcm();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
this.login();
|
||||||
|
}
|
||||||
|
|
||||||
|
login() {
|
||||||
|
this.authService.login('admin', 'admin').subscribe(
|
||||||
|
ticket => {
|
||||||
|
this.logService.info(ticket);
|
||||||
|
this.ticket = this.authService.getTicketEcm();
|
||||||
|
this.authenticated = true;
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
this.logService.error(error);
|
||||||
|
this.authenticated = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public updateTicket(): void {
|
||||||
|
this.storage.setItem('ticket-ECM', this.ticket);
|
||||||
|
}
|
||||||
|
|
||||||
|
public updateHost(): void {
|
||||||
|
this.settingsService.ecmHost = this.ecmHost;
|
||||||
|
this.login();
|
||||||
|
}
|
||||||
|
|
||||||
|
logData(data) {
|
||||||
|
this.logService.info(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
imports: [
|
||||||
|
BrowserModule,
|
||||||
|
CoreModule.forRoot(),
|
||||||
|
SocialModule
|
||||||
|
],
|
||||||
|
declarations: [SocialDemo],
|
||||||
|
bootstrap: [SocialDemo]
|
||||||
|
})
|
||||||
|
export class AppModule {
|
||||||
|
}
|
||||||
|
|
||||||
|
platformBrowserDynamic().bootstrapModule(AppModule);
|
48
ng2-components/ng2-alfresco-social/demo/systemjs.config.js
Normal file
48
ng2-components/ng2-alfresco-social/demo/systemjs.config.js
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
/**
|
||||||
|
* System configuration for Angular 2 samples
|
||||||
|
* Adjust as necessary for your application needs.
|
||||||
|
*/
|
||||||
|
(function (global) {
|
||||||
|
System.config({
|
||||||
|
paths: {
|
||||||
|
// paths serve as alias
|
||||||
|
'npm:': 'node_modules/'
|
||||||
|
},
|
||||||
|
// map tells the System loader where to look for things
|
||||||
|
map: {
|
||||||
|
// our app is within the app folder
|
||||||
|
app: 'src',
|
||||||
|
// angular bundles
|
||||||
|
'@angular/core': 'npm:@angular/core/bundles/core.umd.js',
|
||||||
|
'@angular/common': 'npm:@angular/common/bundles/common.umd.js',
|
||||||
|
'@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
|
||||||
|
'@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
|
||||||
|
'@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
|
||||||
|
'@angular/http': 'npm:@angular/http/bundles/http.umd.js',
|
||||||
|
'@angular/router': 'npm:@angular/router/bundles/router.umd.js',
|
||||||
|
'@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',
|
||||||
|
'@angular/material': 'npm:@angular/material/bundles/material.umd.js',
|
||||||
|
|
||||||
|
// other libraries
|
||||||
|
'rxjs': 'npm:rxjs',
|
||||||
|
'ng2-translate': 'npm:ng2-translate',
|
||||||
|
'alfresco-js-api': 'npm:alfresco-js-api/dist',
|
||||||
|
'ng2-alfresco-core': 'npm:ng2-alfresco-core',
|
||||||
|
'ng2-alfresco-social': 'npm:ng2-alfresco-social'
|
||||||
|
},
|
||||||
|
// packages tells the System loader how to load when no filename and/or no extension
|
||||||
|
packages: {
|
||||||
|
app: {
|
||||||
|
main: './main.js',
|
||||||
|
defaultExtension: 'js'
|
||||||
|
},
|
||||||
|
rxjs: {
|
||||||
|
defaultExtension: 'js'
|
||||||
|
},
|
||||||
|
'ng2-translate': { defaultExtension: 'js' },
|
||||||
|
'alfresco-js-api': { main: './alfresco-js-api.js', defaultExtension: 'js'},
|
||||||
|
'ng2-alfresco-core': { main: './index.js', defaultExtension: 'js'},
|
||||||
|
'ng2-alfresco-social': { main: './index.js', defaultExtension: 'js'}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})(this);
|
32
ng2-components/ng2-alfresco-social/demo/tsconfig.json
Normal file
32
ng2-components/ng2-alfresco-social/demo/tsconfig.json
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "es5",
|
||||||
|
"module": "commonjs",
|
||||||
|
"moduleResolution": "node",
|
||||||
|
"sourceMap": true,
|
||||||
|
"emitDecoratorMetadata": true,
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"noLib": false,
|
||||||
|
"allowUnreachableCode": false,
|
||||||
|
"allowUnusedLabels": false,
|
||||||
|
"noImplicitAny": false,
|
||||||
|
"noImplicitReturns": false,
|
||||||
|
"noImplicitUseStrict": false,
|
||||||
|
"noFallthroughCasesInSwitch": true,
|
||||||
|
"removeComments": true,
|
||||||
|
"declaration": true,
|
||||||
|
"lib": [
|
||||||
|
"es2015",
|
||||||
|
"dom"
|
||||||
|
],
|
||||||
|
"suppressImplicitAnyIndexErrors": true
|
||||||
|
},
|
||||||
|
"exclude": [
|
||||||
|
"node_modules"
|
||||||
|
],
|
||||||
|
"angularCompilerOptions": {
|
||||||
|
"strictMetadataEmit": false,
|
||||||
|
"skipTemplateCodegen": true
|
||||||
|
}
|
||||||
|
}
|
124
ng2-components/ng2-alfresco-social/demo/tslint.json
Normal file
124
ng2-components/ng2-alfresco-social/demo/tslint.json
Normal file
@@ -0,0 +1,124 @@
|
|||||||
|
{
|
||||||
|
"rules": {
|
||||||
|
"align": [
|
||||||
|
true,
|
||||||
|
"parameters",
|
||||||
|
"arguments",
|
||||||
|
"statements"
|
||||||
|
],
|
||||||
|
"ban": false,
|
||||||
|
"class-name": true,
|
||||||
|
"comment-format": [
|
||||||
|
true,
|
||||||
|
"check-space",
|
||||||
|
"check-lowercase"
|
||||||
|
],
|
||||||
|
"curly": true,
|
||||||
|
"eofline": true,
|
||||||
|
"forin": true,
|
||||||
|
"indent": [
|
||||||
|
true,
|
||||||
|
"spaces"
|
||||||
|
],
|
||||||
|
"interface-name": false,
|
||||||
|
"jsdoc-format": true,
|
||||||
|
"label-position": true,
|
||||||
|
"label-undefined": true,
|
||||||
|
"max-line-length": [
|
||||||
|
true,
|
||||||
|
180
|
||||||
|
],
|
||||||
|
"member-ordering": [
|
||||||
|
true,
|
||||||
|
"public-before-private",
|
||||||
|
"static-before-instance",
|
||||||
|
"variables-before-functions"
|
||||||
|
],
|
||||||
|
"no-any": false,
|
||||||
|
"no-arg": true,
|
||||||
|
"no-bitwise": true,
|
||||||
|
"no-conditional-assignment": true,
|
||||||
|
"no-consecutive-blank-lines": true,
|
||||||
|
"no-console": [
|
||||||
|
true,
|
||||||
|
"debug",
|
||||||
|
"info",
|
||||||
|
"time",
|
||||||
|
"timeEnd",
|
||||||
|
"trace"
|
||||||
|
],
|
||||||
|
"no-construct": true,
|
||||||
|
"no-constructor-vars": false,
|
||||||
|
"no-debugger": true,
|
||||||
|
"no-duplicate-key": true,
|
||||||
|
"no-duplicate-variable": true,
|
||||||
|
"no-empty": true,
|
||||||
|
"no-eval": true,
|
||||||
|
"no-inferrable-types": false,
|
||||||
|
"no-internal-module": true,
|
||||||
|
"no-require-imports": true,
|
||||||
|
"no-shadowed-variable": true,
|
||||||
|
"no-switch-case-fall-through": true,
|
||||||
|
"no-trailing-whitespace": true,
|
||||||
|
"no-unreachable": true,
|
||||||
|
"no-unused-expression": true,
|
||||||
|
"no-unused-variable": true,
|
||||||
|
"no-use-before-declare": true,
|
||||||
|
"no-var-keyword": true,
|
||||||
|
"no-var-requires": true,
|
||||||
|
"object-literal-sort-keys": false,
|
||||||
|
"one-line": [
|
||||||
|
true,
|
||||||
|
"check-open-brace",
|
||||||
|
"check-catch",
|
||||||
|
"check-else",
|
||||||
|
"check-whitespace"
|
||||||
|
],
|
||||||
|
"quotemark": [
|
||||||
|
true,
|
||||||
|
"single",
|
||||||
|
"avoid-escape"
|
||||||
|
],
|
||||||
|
"radix": true,
|
||||||
|
"semicolon": true,
|
||||||
|
"switch-default": true,
|
||||||
|
"trailing-comma": [
|
||||||
|
true,
|
||||||
|
{
|
||||||
|
"multiline": "never",
|
||||||
|
"singleline": "never"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"triple-equals": [
|
||||||
|
true,
|
||||||
|
"allow-null-check"
|
||||||
|
],
|
||||||
|
"typedef": false,
|
||||||
|
"typedef-whitespace": [
|
||||||
|
true,
|
||||||
|
{
|
||||||
|
"call-signature": "nospace",
|
||||||
|
"index-signature": "nospace",
|
||||||
|
"parameter": "nospace",
|
||||||
|
"property-declaration": "nospace",
|
||||||
|
"variable-declaration": "nospace"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"use-strict": false,
|
||||||
|
"variable-name": [
|
||||||
|
true,
|
||||||
|
"check-format",
|
||||||
|
"allow-leading-underscore",
|
||||||
|
"ban-keywords"
|
||||||
|
],
|
||||||
|
"whitespace": [
|
||||||
|
true,
|
||||||
|
"check-branch",
|
||||||
|
"check-operator",
|
||||||
|
"check-separator",
|
||||||
|
"check-type",
|
||||||
|
"check-module",
|
||||||
|
"check-decl"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
5
ng2-components/ng2-alfresco-social/demo/wsrv-config.json
Normal file
5
ng2-components/ng2-alfresco-social/demo/wsrv-config.json
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"watch": [
|
||||||
|
"node_modules/ng2-alfresco-social/dist/**/*.{html,htm,css,js}"
|
||||||
|
]
|
||||||
|
}
|
BIN
ng2-components/ng2-alfresco-social/docs/assets/social1.png
Normal file
BIN
ng2-components/ng2-alfresco-social/docs/assets/social1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.1 KiB |
BIN
ng2-components/ng2-alfresco-social/docs/assets/social2.png
Normal file
BIN
ng2-components/ng2-alfresco-social/docs/assets/social2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.6 KiB |
307
ng2-components/ng2-alfresco-social/gulpfile.ts
Executable file
307
ng2-components/ng2-alfresco-social/gulpfile.ts
Executable file
@@ -0,0 +1,307 @@
|
|||||||
|
import * as gulp from 'gulp';
|
||||||
|
import * as util from 'gulp-util';
|
||||||
|
import * as runSequence from 'run-sequence';
|
||||||
|
import * as gulpLoadPlugins from 'gulp-load-plugins';
|
||||||
|
import * as merge from 'merge-stream';
|
||||||
|
import * as rimraf from 'rimraf';
|
||||||
|
import { join } from 'path';
|
||||||
|
import * as Builder from 'systemjs-builder';
|
||||||
|
var autoprefixer = require('autoprefixer');
|
||||||
|
import * as cssnano from 'cssnano';
|
||||||
|
import * as filter from 'gulp-filter';
|
||||||
|
import * as sourcemaps from 'gulp-sourcemaps';
|
||||||
|
|
||||||
|
var APP_SRC = `.`;
|
||||||
|
var CSS_PROD_BUNDLE = 'main.css';
|
||||||
|
var JS_PROD_SHIMS_BUNDLE = 'shims.js';
|
||||||
|
var NG_FACTORY_FILE = 'main-prod';
|
||||||
|
|
||||||
|
const BUILD_TYPES = {
|
||||||
|
DEVELOPMENT: 'dev',
|
||||||
|
PRODUCTION: 'prod'
|
||||||
|
};
|
||||||
|
|
||||||
|
function normalizeDependencies(deps) {
|
||||||
|
deps
|
||||||
|
.filter((d) => !/\*/.test(d.src)) // Skip globs
|
||||||
|
.forEach((d) => d.src = require.resolve(d.src));
|
||||||
|
return deps;
|
||||||
|
}
|
||||||
|
|
||||||
|
function filterDependency(type: string, d): boolean {
|
||||||
|
const t = d.buildType || d.env;
|
||||||
|
d.buildType = t;
|
||||||
|
if (!t) {
|
||||||
|
d.buildType = Object.keys(BUILD_TYPES).map(k => BUILD_TYPES[k]);
|
||||||
|
}
|
||||||
|
if (!(d.buildType instanceof Array)) {
|
||||||
|
(<any>d).env = [d.buildType];
|
||||||
|
}
|
||||||
|
return d.buildType.indexOf(type) >= 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getInjectableDependency() {
|
||||||
|
var APP_ASSETS = [
|
||||||
|
{src: `src/css/main.css`, inject: true, vendor: false},
|
||||||
|
];
|
||||||
|
|
||||||
|
var NPM_DEPENDENCIES = [
|
||||||
|
{src: 'zone.js/dist/zone.js', inject: 'libs'},
|
||||||
|
{src: 'core-js/client/shim.min.js', inject: 'shims'},
|
||||||
|
{src: 'systemjs/dist/system.src.js', inject: 'shims', buildType:'dev'}
|
||||||
|
];
|
||||||
|
|
||||||
|
return normalizeDependencies(NPM_DEPENDENCIES.filter(filterDependency.bind(null, 'dev')))
|
||||||
|
.concat(APP_ASSETS.filter(filterDependency.bind(null, 'dev')));
|
||||||
|
}
|
||||||
|
|
||||||
|
const plugins = <any>gulpLoadPlugins();
|
||||||
|
|
||||||
|
let tsProjects: any = {};
|
||||||
|
|
||||||
|
function makeTsProject(options: Object = {}) {
|
||||||
|
let optionsHash = JSON.stringify(options);
|
||||||
|
if (!tsProjects[optionsHash]) {
|
||||||
|
let config = Object.assign({
|
||||||
|
typescript: require('typescript')
|
||||||
|
}, options);
|
||||||
|
tsProjects[optionsHash] =
|
||||||
|
plugins.typescript.createProject('tsconfig.json', config);
|
||||||
|
}
|
||||||
|
return tsProjects[optionsHash];
|
||||||
|
}
|
||||||
|
|
||||||
|
gulp.task('build.html_css', () => {
|
||||||
|
const gulpConcatCssConfig = {
|
||||||
|
targetFile: CSS_PROD_BUNDLE,
|
||||||
|
options: {
|
||||||
|
rebaseUrls: false
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const processors = [
|
||||||
|
autoprefixer({
|
||||||
|
browsers: [
|
||||||
|
'ie >= 10',
|
||||||
|
'ie_mob >= 10',
|
||||||
|
'ff >= 30',
|
||||||
|
'chrome >= 34',
|
||||||
|
'safari >= 7',
|
||||||
|
'opera >= 23',
|
||||||
|
'ios >= 7',
|
||||||
|
'android >= 4.4',
|
||||||
|
'bb >= 10'
|
||||||
|
]
|
||||||
|
})
|
||||||
|
];
|
||||||
|
|
||||||
|
const reportPostCssError = (e: any) => util.log(util.colors.red(e.message));
|
||||||
|
|
||||||
|
processors.push(
|
||||||
|
cssnano({
|
||||||
|
discardComments: {removeAll: true},
|
||||||
|
discardUnused: false, // unsafe, see http://goo.gl/RtrzwF
|
||||||
|
zindex: false, // unsafe, see http://goo.gl/vZ4gbQ
|
||||||
|
reduceIdents: false // unsafe, see http://goo.gl/tNOPv0
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Processes the CSS files within `src/client` excluding those in `src/client/assets` using `postcss` with the
|
||||||
|
* configured processors
|
||||||
|
* Execute the appropriate component-stylesheet processing method based on user stylesheet preference.
|
||||||
|
*/
|
||||||
|
function processComponentStylesheets() {
|
||||||
|
return gulp.src(join('src/**', '*.css'))
|
||||||
|
.pipe(plugins.cached('process-component-css'))
|
||||||
|
.pipe(plugins.postcss(processors))
|
||||||
|
.on('error', reportPostCssError);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a stream of external css files for subsequent processing.
|
||||||
|
*/
|
||||||
|
function getExternalCssStream() {
|
||||||
|
return gulp.src(getExternalCss())
|
||||||
|
.pipe(plugins.cached('process-external-css'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get an array of filenames referring to all external css stylesheets.
|
||||||
|
*/
|
||||||
|
function getExternalCss() {
|
||||||
|
return getInjectableDependency().filter(dep => /\.css$/.test(dep.src)).map(dep => dep.src);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Processes the external CSS files using `postcss` with the configured processors.
|
||||||
|
*/
|
||||||
|
function processExternalCss() {
|
||||||
|
return getExternalCssStream()
|
||||||
|
.pipe(plugins.postcss(processors))
|
||||||
|
.pipe(plugins.concatCss(gulpConcatCssConfig.targetFile, gulpConcatCssConfig.options))
|
||||||
|
.on('error', reportPostCssError);
|
||||||
|
}
|
||||||
|
|
||||||
|
return merge(processComponentStylesheets(), processExternalCss());
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
gulp.task('build.bundles.app', (done) => {
|
||||||
|
var BUNDLER_OPTIONS = {
|
||||||
|
format: 'umd',
|
||||||
|
minify: false,
|
||||||
|
mangle: false,
|
||||||
|
sourceMaps: true
|
||||||
|
};
|
||||||
|
var CONFIG_TYPESCRIPT = {
|
||||||
|
baseURL: '.',
|
||||||
|
transpiler: 'typescript',
|
||||||
|
typescriptOptions: {
|
||||||
|
module: 'cjs'
|
||||||
|
},
|
||||||
|
map: {
|
||||||
|
typescript: 'node_modules/typescript/lib/typescript.js',
|
||||||
|
'@angular': 'node_modules/@angular',
|
||||||
|
rxjs: 'node_modules/rxjs',
|
||||||
|
'ng2-translate': 'node_modules/ng2-translate',
|
||||||
|
'alfresco-js-api': 'node_modules/alfresco-js-api/dist/alfresco-js-api',
|
||||||
|
'ng2-alfresco-core': 'node_modules/ng2-alfresco-core/',
|
||||||
|
'ng2-activiti-diagrams': 'node_modules/ng2-activiti-diagrams/',
|
||||||
|
'ng2-activiti-analytics': 'node_modules/ng2-activiti-analytics/',
|
||||||
|
'ng2-alfresco-datatable': 'node_modules/ng2-alfresco-datatable/',
|
||||||
|
'ng2-alfresco-documentlist': 'node_modules/ng2-alfresco-documentlist/',
|
||||||
|
'ng2-activiti-form': 'node_modules/ng2-activiti-form/',
|
||||||
|
'ng2-alfresco-login': 'node_modules/ng2-alfresco-login/',
|
||||||
|
'ng2-activiti-processlist': 'node_modules/ng2-activiti-processlist/',
|
||||||
|
'ng2-alfresco-search': 'node_modules/ng2-alfresco-search/',
|
||||||
|
'ng2-activiti-tasklist': 'node_modules/ng2-activiti-tasklist/',
|
||||||
|
'ng2-alfresco-social': 'node_modules/ng2-alfresco-social/',
|
||||||
|
'ng2-alfresco-upload': 'node_modules/ng2-alfresco-upload/',
|
||||||
|
'ng2-alfresco-userinfo': 'node_modules/ng2-alfresco-userinfo/',
|
||||||
|
'ng2-alfresco-viewer': 'node_modules/ng2-alfresco-viewer/',
|
||||||
|
'ng2-alfresco-webscript': 'node_modules/ng2-alfresco-webscript/'
|
||||||
|
},
|
||||||
|
paths: {
|
||||||
|
'*': '*.js'
|
||||||
|
},
|
||||||
|
meta: {
|
||||||
|
'node_modules/@angular/*': {build: false},
|
||||||
|
'node_modules/rxjs/*': {build: false},
|
||||||
|
'node_modules/ng2-translate/*': {build: false},
|
||||||
|
'node_modules/ng2-alfresco-core/*': {build: false},
|
||||||
|
'node_modules/ng2-activiti-diagrams/*': {build: false},
|
||||||
|
'node_modules/ng2-activiti-analytics/*': {build: false},
|
||||||
|
'node_modules/ng2-alfresco-datatable/*': {build: false},
|
||||||
|
'node_modules/ng2-alfresco-documentlist/*': {build: false},
|
||||||
|
'node_modules/ng2-activiti-form/*': {build: false},
|
||||||
|
'node_modules/ng2-alfresco-login/*': {build: false},
|
||||||
|
'node_modules/ng2-activiti-processlist/*': {build: false},
|
||||||
|
'node_modules/ng2-alfresco-search/*': {build: false},
|
||||||
|
'node_modules/ng2-activiti-tasklist/*': {build: false},
|
||||||
|
'node_modules/ng2-alfresco-social/*': {build: false},
|
||||||
|
'node_modules/ng2-alfresco-upload/*': {build: false},
|
||||||
|
'node_modules/ng2-alfresco-userinfo/*': {build: false},
|
||||||
|
'node_modules/ng2-alfresco-viewer/*': {build: false},
|
||||||
|
'node_modules/ng2-alfresco-webscript/*': {build: false}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var pkg = require('./package.json');
|
||||||
|
var namePkg = pkg.name;
|
||||||
|
|
||||||
|
var builder = new Builder(CONFIG_TYPESCRIPT);
|
||||||
|
builder
|
||||||
|
.buildStatic(APP_SRC + "/index", 'bundles/' + namePkg + '.js', BUNDLER_OPTIONS)
|
||||||
|
.then(function () {
|
||||||
|
return done();
|
||||||
|
})
|
||||||
|
.catch(function (err) {
|
||||||
|
return done(err);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
gulp.task('build.assets.prod', () => {
|
||||||
|
return gulp.src([
|
||||||
|
join('src/**', '*.ts'),
|
||||||
|
'index.ts',
|
||||||
|
join('src/**', '*.css'),
|
||||||
|
join('src/**', '*.html'),
|
||||||
|
'!'+join('*/**', '*.d.ts'),
|
||||||
|
'!'+join('*/**', '*.spec.ts'),
|
||||||
|
'!gulpfile.ts'])
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
gulp.task('build.bundles', () => {
|
||||||
|
merge(bundleShims());
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the shim files to be injected.
|
||||||
|
*/
|
||||||
|
function getShims() {
|
||||||
|
let libs = getInjectableDependency()
|
||||||
|
.filter(d => /\.js$/.test(d.src));
|
||||||
|
|
||||||
|
return libs.filter(l => l.inject === 'shims')
|
||||||
|
.concat(libs.filter(l => l.inject === 'libs'))
|
||||||
|
.concat(libs.filter(l => l.inject === true))
|
||||||
|
.map(l => l.src);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bundles the shim files.
|
||||||
|
*/
|
||||||
|
function bundleShims() {
|
||||||
|
return gulp.src(getShims())
|
||||||
|
.pipe(plugins.concat(JS_PROD_SHIMS_BUNDLE))
|
||||||
|
// Strip the first (global) 'use strict' added by reflect-metadata, but don't strip any others to avoid unintended scope leaks.
|
||||||
|
.pipe(plugins.replace(/('|")use strict\1;var Reflect;/, 'var Reflect;'))
|
||||||
|
.pipe(gulp.dest('bundles'));
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
gulp.task('build.js.prod', () => {
|
||||||
|
const INLINE_OPTIONS = {
|
||||||
|
base: APP_SRC,
|
||||||
|
target: 'es5',
|
||||||
|
useRelativePaths: true,
|
||||||
|
removeLineBreaks: true
|
||||||
|
};
|
||||||
|
|
||||||
|
let tsProject = makeTsProject();
|
||||||
|
let src = [
|
||||||
|
join('src/**/*.ts'),
|
||||||
|
join('!src/**/*.d.ts'),
|
||||||
|
join('!src/**/*.spec.ts'),
|
||||||
|
`!src/**/${NG_FACTORY_FILE}.ts`
|
||||||
|
];
|
||||||
|
|
||||||
|
let result = gulp.src(src)
|
||||||
|
.pipe(plugins.plumber())
|
||||||
|
.pipe(plugins.inlineNg2Template(INLINE_OPTIONS))
|
||||||
|
.pipe(sourcemaps.init())
|
||||||
|
.pipe(tsProject())
|
||||||
|
.once('error', function (e: any) {
|
||||||
|
this.once('finish', () => process.exit(1));
|
||||||
|
});
|
||||||
|
|
||||||
|
return result.js
|
||||||
|
.pipe(plugins.template())
|
||||||
|
.pipe(sourcemaps.write())
|
||||||
|
.pipe(gulp.dest('src'))
|
||||||
|
.on('error', (e: any) => {
|
||||||
|
console.log(e);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
gulp.task('build.prod', (done: any) =>
|
||||||
|
runSequence(
|
||||||
|
'build.assets.prod',
|
||||||
|
'build.html_css',
|
||||||
|
'build.js.prod',
|
||||||
|
'build.bundles',
|
||||||
|
'build.bundles.app',
|
||||||
|
done));
|
61
ng2-components/ng2-alfresco-social/index.ts
Normal file
61
ng2-components/ng2-alfresco-social/index.ts
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
/*!
|
||||||
|
* @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 { NgModule, ModuleWithProviders } from '@angular/core';
|
||||||
|
import { CoreModule } from 'ng2-alfresco-core';
|
||||||
|
|
||||||
|
import { RatingComponent } from './src/components/rating.component';
|
||||||
|
import { LikeComponent } from './src/components/like.component';
|
||||||
|
import { RatingService } from './src/services/rating.service';
|
||||||
|
|
||||||
|
export * from './src/components/rating.component';
|
||||||
|
export * from './src/components/like.component';
|
||||||
|
export * from './src/services/rating.service';
|
||||||
|
|
||||||
|
export const RATING_DIRECTIVES: any[] = [
|
||||||
|
RatingComponent,
|
||||||
|
LikeComponent
|
||||||
|
];
|
||||||
|
|
||||||
|
export const RATING_PROVIDERS: any[] = [
|
||||||
|
RatingService
|
||||||
|
];
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
imports: [
|
||||||
|
CoreModule
|
||||||
|
],
|
||||||
|
declarations: [
|
||||||
|
...RATING_DIRECTIVES
|
||||||
|
],
|
||||||
|
providers: [
|
||||||
|
...RATING_PROVIDERS
|
||||||
|
],
|
||||||
|
exports: [
|
||||||
|
...RATING_DIRECTIVES
|
||||||
|
]
|
||||||
|
})
|
||||||
|
export class SocialModule {
|
||||||
|
static forRoot(): ModuleWithProviders {
|
||||||
|
return {
|
||||||
|
ngModule: SocialModule,
|
||||||
|
providers: [
|
||||||
|
...RATING_DIRECTIVES
|
||||||
|
]
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
115
ng2-components/ng2-alfresco-social/karma-test-shim.js
Normal file
115
ng2-components/ng2-alfresco-social/karma-test-shim.js
Normal file
@@ -0,0 +1,115 @@
|
|||||||
|
// Tun on full stack traces in errors to help debugging
|
||||||
|
Error.stackTraceLimit = Infinity;
|
||||||
|
|
||||||
|
jasmine.DEFAULT_TIMEOUT_INTERVAL = 100000;
|
||||||
|
|
||||||
|
window.componentHandler = {
|
||||||
|
upgradeAllRegistered: function () {
|
||||||
|
},
|
||||||
|
upgradeElement: function () {
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
__karma__.loaded = function() {};
|
||||||
|
|
||||||
|
var builtPath = '/base/src/';
|
||||||
|
|
||||||
|
function isJsFile(path) {
|
||||||
|
return path.slice(-3) == '.js';
|
||||||
|
}
|
||||||
|
|
||||||
|
function isSpecFile(path) {
|
||||||
|
return /\.spec\.(.*\.)?js$/.test(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
function isBuiltFile(path) {
|
||||||
|
return isJsFile(path) && (path.substr(0, builtPath.length) == builtPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
var allSpecFiles = Object.keys(window.__karma__.files)
|
||||||
|
.filter(isSpecFile)
|
||||||
|
.filter(isBuiltFile);
|
||||||
|
|
||||||
|
var paths = {
|
||||||
|
// paths serve as alias
|
||||||
|
'npm:': 'base/node_modules/'
|
||||||
|
};
|
||||||
|
|
||||||
|
var map = {
|
||||||
|
'app': 'base/src',
|
||||||
|
// angular bundles
|
||||||
|
'@angular/core': 'npm:@angular/core/bundles/core.umd.js',
|
||||||
|
'@angular/common': 'npm:@angular/common/bundles/common.umd.js',
|
||||||
|
'@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
|
||||||
|
'@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
|
||||||
|
'@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
|
||||||
|
'@angular/http': 'npm:@angular/http/bundles/http.umd.js',
|
||||||
|
'@angular/router': 'npm:@angular/router/bundles/router.umd.js',
|
||||||
|
'@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',
|
||||||
|
'@angular/material': 'npm:@angular/material/bundles/material.umd.js',
|
||||||
|
|
||||||
|
// testing
|
||||||
|
'@angular/core/testing': 'npm:@angular/core/bundles/core-testing.umd.js',
|
||||||
|
'@angular/common/testing': 'npm:@angular/common/bundles/common-testing.umd.js',
|
||||||
|
'@angular/compiler/testing': 'npm:@angular/compiler/bundles/compiler-testing.umd.js',
|
||||||
|
'@angular/platform-browser/testing': 'npm:@angular/platform-browser/bundles/platform-browser-testing.umd.js',
|
||||||
|
'@angular/platform-browser-dynamic/testing': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic-testing.umd.js',
|
||||||
|
'@angular/http/testing': 'npm:@angular/http/bundles/http-testing.umd.js',
|
||||||
|
'@angular/router/testing': 'npm:@angular/router/bundles/router-testing.umd.js',
|
||||||
|
'@angular/forms/testing': 'npm:@angular/forms/bundles/forms-testing.umd.js',
|
||||||
|
|
||||||
|
// other libraries
|
||||||
|
'rxjs': 'npm:rxjs',
|
||||||
|
'ng2-translate': 'npm:ng2-translate',
|
||||||
|
'hammerjs': 'npm:hammerjs',
|
||||||
|
|
||||||
|
'alfresco-js-api': 'npm:alfresco-js-api/dist',
|
||||||
|
'ng2-alfresco-core': 'npm:ng2-alfresco-core'
|
||||||
|
};
|
||||||
|
|
||||||
|
var packages = {
|
||||||
|
'app': { main: 'main.js', defaultExtension: 'js' },
|
||||||
|
'rxjs': { defaultExtension: 'js' },
|
||||||
|
'ng2-translate': { defaultExtension: 'js' },
|
||||||
|
'hammerjs': {main: './hammerjs.js', defaultExtension: 'js'},
|
||||||
|
|
||||||
|
'alfresco-js-api': { main: './alfresco-js-api.js', defaultExtension: 'js'},
|
||||||
|
'ng2-alfresco-core': { main: './index.js', defaultExtension: 'js'}
|
||||||
|
};
|
||||||
|
|
||||||
|
var config = {
|
||||||
|
paths: paths,
|
||||||
|
map: map,
|
||||||
|
packages: packages
|
||||||
|
};
|
||||||
|
|
||||||
|
System.config(config);
|
||||||
|
|
||||||
|
System.import('@angular/core/testing')
|
||||||
|
.then(initTestBed)
|
||||||
|
.then(initTesting);
|
||||||
|
|
||||||
|
function initTestBed(){
|
||||||
|
return Promise.all([
|
||||||
|
System.import('@angular/core/testing'),
|
||||||
|
System.import('@angular/platform-browser-dynamic/testing')
|
||||||
|
])
|
||||||
|
.then(function (providers) {
|
||||||
|
var coreTesting = providers[0];
|
||||||
|
var browserTesting = providers[1];
|
||||||
|
|
||||||
|
coreTesting.TestBed.initTestEnvironment(
|
||||||
|
browserTesting.BrowserDynamicTestingModule,
|
||||||
|
browserTesting.platformBrowserDynamicTesting());
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// Import all spec files and start karma
|
||||||
|
function initTesting () {
|
||||||
|
return Promise.all(
|
||||||
|
allSpecFiles.map(function (moduleName) {
|
||||||
|
return System.import(moduleName);
|
||||||
|
})
|
||||||
|
)
|
||||||
|
.then(__karma__.start, __karma__.error);
|
||||||
|
}
|
127
ng2-components/ng2-alfresco-social/karma.conf.js
Normal file
127
ng2-components/ng2-alfresco-social/karma.conf.js
Normal file
@@ -0,0 +1,127 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
module.exports = function (config) {
|
||||||
|
var configuration = {
|
||||||
|
basePath: '.',
|
||||||
|
|
||||||
|
frameworks: ['jasmine-ajax', 'jasmine'],
|
||||||
|
|
||||||
|
files: [
|
||||||
|
// System.js for module loading
|
||||||
|
'node_modules/systemjs/dist/system.src.js',
|
||||||
|
|
||||||
|
// Polyfills
|
||||||
|
'node_modules/core-js/client/shim.js',
|
||||||
|
'node_modules/reflect-metadata/Reflect.js',
|
||||||
|
|
||||||
|
// zone.js
|
||||||
|
'node_modules/zone.js/dist/zone.js',
|
||||||
|
'node_modules/zone.js/dist/long-stack-trace-zone.js',
|
||||||
|
'node_modules/zone.js/dist/proxy.js',
|
||||||
|
'node_modules/zone.js/dist/sync-test.js',
|
||||||
|
'node_modules/zone.js/dist/jasmine-patch.js',
|
||||||
|
'node_modules/zone.js/dist/async-test.js',
|
||||||
|
'node_modules/zone.js/dist/fake-async-test.js',
|
||||||
|
'node_modules/hammerjs/hammer.js',
|
||||||
|
|
||||||
|
// RxJs
|
||||||
|
{ pattern: 'node_modules/rxjs/**/*.js', included: false, watched: false },
|
||||||
|
{ pattern: 'node_modules/rxjs/**/*.js.map', included: false, watched: false },
|
||||||
|
|
||||||
|
// Paths loaded via module imports:
|
||||||
|
// Angular itself
|
||||||
|
{pattern: 'node_modules/@angular/**/*.js', included: false, watched: false},
|
||||||
|
{pattern: 'node_modules/@angular/**/*.js.map', included: false, watched: false},
|
||||||
|
|
||||||
|
'node_modules/alfresco-js-api/dist/alfresco-js-api.js',
|
||||||
|
|
||||||
|
{pattern: 'node_modules/ng2-translate/**/*.js', included: false, watched: false},
|
||||||
|
|
||||||
|
'karma-test-shim.js',
|
||||||
|
|
||||||
|
// paths loaded via module imports
|
||||||
|
{pattern: 'src/**/*.js', included: false, watched: true},
|
||||||
|
{pattern: 'src/**/*.html', included: true, served: true, watched: true},
|
||||||
|
{pattern: 'src/**/*.css', included: true, served: true, watched: true},
|
||||||
|
|
||||||
|
// ng2-components
|
||||||
|
{ pattern: 'node_modules/ng2-alfresco-core/src/**/*.js', included: false, served: true, watched: false },
|
||||||
|
{ pattern: 'node_modules/ng2-alfresco-core/index.js', included: false, served: true, watched: false },
|
||||||
|
|
||||||
|
// paths to support debugging with source maps in dev tools
|
||||||
|
{pattern: 'src/**/*.ts', included: false, watched: false},
|
||||||
|
{pattern: 'src/**/*.js.map', included: false, watched: false}
|
||||||
|
],
|
||||||
|
|
||||||
|
exclude: [
|
||||||
|
'node_modules/**/*spec.js'
|
||||||
|
],
|
||||||
|
|
||||||
|
// proxied base paths
|
||||||
|
proxies: {
|
||||||
|
// required for component assets fetched by Angular's compiler
|
||||||
|
'/src/': '/base/src/'
|
||||||
|
},
|
||||||
|
|
||||||
|
port: 9876,
|
||||||
|
|
||||||
|
// level of logging
|
||||||
|
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
|
||||||
|
logLevel: config.LOG_INFO,
|
||||||
|
|
||||||
|
colors: true,
|
||||||
|
|
||||||
|
autoWatch: true,
|
||||||
|
|
||||||
|
captureTimeout: 180000,
|
||||||
|
browserDisconnectTimeout: 180000,
|
||||||
|
browserDisconnectTolerance: 3,
|
||||||
|
browserNoActivityTimeout: 300000,
|
||||||
|
|
||||||
|
browsers: ['Chrome'],
|
||||||
|
|
||||||
|
customLaunchers: {
|
||||||
|
Chrome_travis_ci: {
|
||||||
|
base: 'Chrome',
|
||||||
|
flags: ['--no-sandbox']
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// Karma plugins loaded
|
||||||
|
plugins: [
|
||||||
|
'karma-jasmine',
|
||||||
|
'karma-coverage',
|
||||||
|
'karma-jasmine-ajax',
|
||||||
|
'karma-chrome-launcher',
|
||||||
|
'karma-mocha-reporter',
|
||||||
|
'karma-jasmine-html-reporter'
|
||||||
|
],
|
||||||
|
|
||||||
|
// Coverage reporter generates the coverage
|
||||||
|
reporters: ['mocha', 'coverage', 'kjhtml'],
|
||||||
|
|
||||||
|
// Source files that you wanna generate coverage for.
|
||||||
|
// Do not include tests or libraries (these files will be instrumented by Istanbul)
|
||||||
|
preprocessors: {
|
||||||
|
'src/**/!(*spec|index|*mock|*model|*event).js': 'coverage'
|
||||||
|
},
|
||||||
|
|
||||||
|
coverageReporter: {
|
||||||
|
includeAllSources: true,
|
||||||
|
dir: 'coverage/',
|
||||||
|
subdir: 'report',
|
||||||
|
reporters: [
|
||||||
|
{type: 'text'},
|
||||||
|
{type: 'json', file: 'coverage-final.json'},
|
||||||
|
{type: 'html'},
|
||||||
|
{type: 'lcov'}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (process.env.TRAVIS) {
|
||||||
|
configuration.browsers = ['Chrome_travis_ci'];
|
||||||
|
}
|
||||||
|
|
||||||
|
config.set(configuration)
|
||||||
|
};
|
114
ng2-components/ng2-alfresco-social/package.json
Normal file
114
ng2-components/ng2-alfresco-social/package.json
Normal file
@@ -0,0 +1,114 @@
|
|||||||
|
{
|
||||||
|
"name": "ng2-alfresco-social",
|
||||||
|
"description": "Alfresco rating component",
|
||||||
|
"version": "1.3.0",
|
||||||
|
"author": "Alfresco Software, Ltd.",
|
||||||
|
"scripts": {
|
||||||
|
"clean": "npm install rimraf && npm run clean-build && rimraf dist node_modules typings",
|
||||||
|
"clean-build": "rimraf index.js index.js.map index.d.ts 'src/{,**/}**.js' 'src/{,**/}**.js.map' 'src/{,**/}**.d.ts' bundles",
|
||||||
|
"build": "npm run clean-build && npm run tslint && tsc && license-check && npm run build.umd",
|
||||||
|
"build:w": "npm run clean-build && npm run tslint && npm run tsc:w && license-check && npm run build.umd",
|
||||||
|
"tslint": "tslint -c tslint.json 'src/{,**/}**.ts' 'index.ts' -e '{,**/}**.d.ts' -e './gulpfile.ts'",
|
||||||
|
"tsc": "tsc",
|
||||||
|
"tsc:w": "tsc -w",
|
||||||
|
"pretest": "npm run build",
|
||||||
|
"test": "karma start karma.conf.js --reporters mocha,coverage --single-run",
|
||||||
|
"test-browser": "npm run build && concurrently \"karma start karma.conf.js --reporters kjhtml\" \"npm run watch-task\"",
|
||||||
|
"posttest": "remap-istanbul -i coverage/report/coverage-final.json -o coverage/report -t html && remap-istanbul -i coverage/report/coverage-final.json -o coverage/report/coverage-final.json",
|
||||||
|
"coverage": "npm run test && wsrv -o -p 9875 ./coverage/report",
|
||||||
|
"publish:prod": "npm run test && npm publish",
|
||||||
|
"travis": "npm link ng2-alfresco-core",
|
||||||
|
"gulp": "gulp",
|
||||||
|
"build.umd": "gulp build.prod --color --env-config prod --build-type prod",
|
||||||
|
"reinstall": "npm cache clean && npm install"
|
||||||
|
},
|
||||||
|
"main": "./index.js",
|
||||||
|
"module": "./index.js",
|
||||||
|
"typings": "./index.d.ts",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/Alfresco/alfresco-ng2-components.git"
|
||||||
|
},
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/Alfresco/alfresco-ng2-components/issues"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@angular/common": "2.2.2",
|
||||||
|
"@angular/compiler": "2.2.2",
|
||||||
|
"@angular/core": "2.2.2",
|
||||||
|
"@angular/forms": "2.2.2",
|
||||||
|
"@angular/http": "2.2.2",
|
||||||
|
"@angular/material": "2.0.0-beta.1",
|
||||||
|
"@angular/platform-browser": "2.2.2",
|
||||||
|
"@angular/platform-browser-dynamic": "2.2.2",
|
||||||
|
"@angular/router": "3.2.2",
|
||||||
|
"alfresco-js-api": "~1.3.0",
|
||||||
|
"core-js": "2.4.1",
|
||||||
|
"hammerjs": "2.0.8",
|
||||||
|
"ng2-alfresco-core": "1.3.0",
|
||||||
|
"ng2-translate": "2.5.0",
|
||||||
|
"reflect-metadata": "0.1.10",
|
||||||
|
"rxjs": "5.0.0-beta.12",
|
||||||
|
"systemjs": "0.19.27",
|
||||||
|
"zone.js": "0.6.26"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/hammerjs": "^2.0.34",
|
||||||
|
"@types/jasmine": "2.5.35",
|
||||||
|
"@types/node": "6.0.45",
|
||||||
|
"autoprefixer": "^6.5.4",
|
||||||
|
"concurrently": "^2.2.0",
|
||||||
|
"cpx": "^1.3.1",
|
||||||
|
"cssnano": "^3.8.1",
|
||||||
|
"gulp": "^3.9.1",
|
||||||
|
"gulp-autoprefixer": "^3.1.1",
|
||||||
|
"gulp-cached": "^1.1.1",
|
||||||
|
"gulp-concat": "^2.6.1",
|
||||||
|
"gulp-concat-css": "^2.3.0",
|
||||||
|
"gulp-filter": "^4.0.0",
|
||||||
|
"gulp-inline-ng2-template": "^4.0.0",
|
||||||
|
"gulp-load-plugins": "^1.4.0",
|
||||||
|
"gulp-plumber": "^1.1.0",
|
||||||
|
"gulp-postcss": "^6.2.0",
|
||||||
|
"gulp-replace": "^0.5.4",
|
||||||
|
"gulp-sourcemaps": "^1.9.1",
|
||||||
|
"gulp-template": "^4.0.0",
|
||||||
|
"gulp-typescript": "^3.1.3",
|
||||||
|
"gulp-uglify": "^2.0.0",
|
||||||
|
"gulp-util": "^3.0.7",
|
||||||
|
"jasmine-ajax": "^3.2.0",
|
||||||
|
"jasmine-core": "2.4.1",
|
||||||
|
"karma": "~0.13.22",
|
||||||
|
"karma-chrome-launcher": "~1.0.1",
|
||||||
|
"karma-coverage": "^1.0.0",
|
||||||
|
"karma-jasmine": "~1.0.2",
|
||||||
|
"karma-jasmine-ajax": "^0.1.13",
|
||||||
|
"karma-jasmine-html-reporter": "^0.2.0",
|
||||||
|
"karma-mocha-reporter": "^2.0.3",
|
||||||
|
"license-check": "^1.0.4",
|
||||||
|
"merge-stream": "^1.0.1",
|
||||||
|
"remap-istanbul": "^0.6.3",
|
||||||
|
"rimraf": "2.5.2",
|
||||||
|
"run-sequence": "^1.2.2",
|
||||||
|
"systemjs-builder": "^0.15.34",
|
||||||
|
"traceur": "^0.0.91",
|
||||||
|
"ts-node": "^1.7.0",
|
||||||
|
"tslint": "^3.8.1",
|
||||||
|
"typescript": "^2.0.3",
|
||||||
|
"wsrv": "^0.1.5"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"rating",
|
||||||
|
"alfresco-component"
|
||||||
|
],
|
||||||
|
"license-check-config": {
|
||||||
|
"src": [
|
||||||
|
"./src/**/*.js"
|
||||||
|
],
|
||||||
|
"path": "assets/license_header.txt",
|
||||||
|
"blocking": true,
|
||||||
|
"logInfo": false,
|
||||||
|
"logError": true
|
||||||
|
},
|
||||||
|
"license": "Apache-2.0"
|
||||||
|
}
|
@@ -0,0 +1,41 @@
|
|||||||
|
.adf-like-container {
|
||||||
|
overflow: hidden;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.adf-like {
|
||||||
|
padding: 5px;
|
||||||
|
cursor: pointer;
|
||||||
|
float: left;
|
||||||
|
margin: 5px 0px 5px 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.adf-like-select {
|
||||||
|
cursor: pointer;
|
||||||
|
color: #2196f3;
|
||||||
|
}
|
||||||
|
|
||||||
|
.adf-like-select:hover {
|
||||||
|
cursor: pointer;
|
||||||
|
color: #808080;
|
||||||
|
}
|
||||||
|
|
||||||
|
.adf-like-grey {
|
||||||
|
cursor: pointer;
|
||||||
|
color: #808080;
|
||||||
|
}
|
||||||
|
|
||||||
|
.adf-like-grey:hover {
|
||||||
|
cursor: pointer;
|
||||||
|
color: #2196f3;
|
||||||
|
}
|
||||||
|
|
||||||
|
.adf-like-counter {
|
||||||
|
float: left;
|
||||||
|
padding: 13px 0 0 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.adf-left{
|
||||||
|
float: left;
|
||||||
|
padding: 13px 0 0 4px;
|
||||||
|
}
|
@@ -0,0 +1,11 @@
|
|||||||
|
<div id="adf-like-container" class="adf-like-container">
|
||||||
|
<div class="material-icons adf-like">
|
||||||
|
<span id="adf-like-{{nodeId}}" [ngClass]="{'adf-like-select': isLike ,'adf-like-grey': !isLike }"
|
||||||
|
(click)="likeClick()">
|
||||||
|
<i class="material-icons">thumb_up</i>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div id="adf-like-counter" class="adf-like-counter">{{likesCounter}}</div>
|
||||||
|
<div class="adf-left" *ngIf="likesCounter<=1">Like</div>
|
||||||
|
<div class="adf-left" *ngIf="likesCounter>1">Likes</div>
|
||||||
|
</div>
|
@@ -0,0 +1,208 @@
|
|||||||
|
/*!
|
||||||
|
* @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 { ComponentFixture, TestBed, async } from '@angular/core/testing';
|
||||||
|
import { LikeComponent } from '../components/like.component';
|
||||||
|
import { DebugElement } from '@angular/core';
|
||||||
|
import { CoreModule } from 'ng2-alfresco-core';
|
||||||
|
import { RatingService } from '../services/rating.service';
|
||||||
|
|
||||||
|
declare let jasmine: any;
|
||||||
|
|
||||||
|
describe('Like component', () => {
|
||||||
|
|
||||||
|
let component: any;
|
||||||
|
let fixture: ComponentFixture<LikeComponent>;
|
||||||
|
let debug: DebugElement;
|
||||||
|
let element: HTMLElement;
|
||||||
|
|
||||||
|
beforeEach(async(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
imports: [
|
||||||
|
CoreModule.forRoot()
|
||||||
|
],
|
||||||
|
declarations: [
|
||||||
|
LikeComponent
|
||||||
|
],
|
||||||
|
providers: [
|
||||||
|
RatingService
|
||||||
|
]
|
||||||
|
}).compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(LikeComponent);
|
||||||
|
|
||||||
|
debug = fixture.debugElement;
|
||||||
|
element = fixture.nativeElement;
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
component.nodeId = 'test-id';
|
||||||
|
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Rendering tests', () => {
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
jasmine.Ajax.install();
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
jasmine.Ajax.uninstall();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should like component should be present', (done) => {
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
component.ngOnChanges().subscribe(() => {
|
||||||
|
expect(element.querySelector('#adf-like-test-id')).not.toBe(null);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
|
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||||
|
status: 200,
|
||||||
|
contentType: 'json',
|
||||||
|
responseText: {
|
||||||
|
entry: {
|
||||||
|
id: 'likes',
|
||||||
|
aggregate: {
|
||||||
|
numberOfRatings: 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should like component show the number of likes', (done) => {
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
component.ngOnChanges().subscribe(() => {
|
||||||
|
expect(element.querySelector('#adf-like-counter').innerHTML).not.toBe(1);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
|
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||||
|
status: 200,
|
||||||
|
contentType: 'json',
|
||||||
|
responseText: {
|
||||||
|
entry: {
|
||||||
|
id: 'likes',
|
||||||
|
aggregate: {
|
||||||
|
numberOfRatings: 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('User actions', () => {
|
||||||
|
|
||||||
|
it('should like component update the number of likes when clicked', (done) => {
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
expect(element.querySelector('#adf-like-counter').innerHTML).toBe('0');
|
||||||
|
|
||||||
|
component.ngOnChanges().subscribe(() => {
|
||||||
|
component.changeVote.subscribe(() => {
|
||||||
|
fixture.detectChanges();
|
||||||
|
expect(element.querySelector('#adf-like-counter').innerHTML).toBe('1');
|
||||||
|
});
|
||||||
|
|
||||||
|
let likeButton: any = element.querySelector('#adf-like-test-id');
|
||||||
|
likeButton.click();
|
||||||
|
|
||||||
|
component.changeVote.subscribe(() => {
|
||||||
|
fixture.detectChanges();
|
||||||
|
expect(element.querySelector('#adf-like-counter').innerHTML).toBe('2');
|
||||||
|
});
|
||||||
|
|
||||||
|
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||||
|
status: 200,
|
||||||
|
contentType: 'json',
|
||||||
|
responseText: {
|
||||||
|
'entry': {
|
||||||
|
'myRating': true,
|
||||||
|
'ratedAt': '2017-04-06T15:25:50.305+0000',
|
||||||
|
'id': 'likes',
|
||||||
|
'aggregate': {'numberOfRatings': 2}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
|
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||||
|
status: 200,
|
||||||
|
contentType: 'json',
|
||||||
|
responseText: {
|
||||||
|
entry: {
|
||||||
|
id: 'likes',
|
||||||
|
aggregate: {
|
||||||
|
numberOfRatings: 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should like component decrease the number of likes when clicked and is already liked', (done) => {
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
expect(element.querySelector('#adf-like-counter').innerHTML).toBe('0');
|
||||||
|
|
||||||
|
component.ngOnChanges().subscribe(() => {
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
let likeButton: any = element.querySelector('#adf-like-test-id');
|
||||||
|
likeButton.click();
|
||||||
|
|
||||||
|
component.changeVote.subscribe(() => {
|
||||||
|
fixture.detectChanges();
|
||||||
|
expect(element.querySelector('#adf-like-counter').innerHTML).toBe('0');
|
||||||
|
});
|
||||||
|
|
||||||
|
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||||
|
status: 204,
|
||||||
|
contentType: 'json'
|
||||||
|
});
|
||||||
|
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
|
component.changeVote.subscribe(() => {
|
||||||
|
fixture.detectChanges();
|
||||||
|
expect(element.querySelector('#adf-like-counter').innerHTML).toBe('1');
|
||||||
|
});
|
||||||
|
|
||||||
|
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||||
|
status: 200,
|
||||||
|
contentType: 'json',
|
||||||
|
responseText: {
|
||||||
|
'entry': {
|
||||||
|
'myRating': true,
|
||||||
|
'ratedAt': '2017-04-06T15:41:01.851+0000',
|
||||||
|
'id': 'likes',
|
||||||
|
'aggregate': {'numberOfRatings': 1}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
@@ -0,0 +1,80 @@
|
|||||||
|
/*!
|
||||||
|
* @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, Input, Output, EventEmitter } from '@angular/core';
|
||||||
|
import { RatingService } from './../services/rating.service';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'adf-like',
|
||||||
|
styleUrls: ['./like.component.css'],
|
||||||
|
templateUrl: './like.component.html',
|
||||||
|
providers: [RatingService]
|
||||||
|
})
|
||||||
|
export class LikeComponent {
|
||||||
|
|
||||||
|
@Input()
|
||||||
|
nodeId: string;
|
||||||
|
|
||||||
|
likesCounter: number = 0;
|
||||||
|
|
||||||
|
ratingType: string = 'likes';
|
||||||
|
|
||||||
|
isLike: boolean = false;
|
||||||
|
|
||||||
|
@Output()
|
||||||
|
changeVote = new EventEmitter();
|
||||||
|
|
||||||
|
constructor(private ratingService: RatingService) {
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnChanges() {
|
||||||
|
let ratingObserver = this.ratingService.getRating(this.nodeId, this.ratingType);
|
||||||
|
|
||||||
|
ratingObserver.subscribe(
|
||||||
|
(data) => {
|
||||||
|
if (data.entry.aggregate) {
|
||||||
|
this.likesCounter = data.entry.aggregate.numberOfRatings;
|
||||||
|
if (data.entry.ratedAt) {
|
||||||
|
this.isLike = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
return ratingObserver;
|
||||||
|
}
|
||||||
|
|
||||||
|
likeClick() {
|
||||||
|
if (this.isLike) {
|
||||||
|
this.ratingService.deleteRating(this.nodeId, this.ratingType).subscribe(
|
||||||
|
() => {
|
||||||
|
this.likesCounter -= 1;
|
||||||
|
this.isLike = false;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
this.ratingService.postRating(this.nodeId, this.ratingType, true).subscribe(
|
||||||
|
(data) => {
|
||||||
|
this.likesCounter = data.entry.aggregate.numberOfRatings;
|
||||||
|
this.isLike = true;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.changeVote.emit(this.likesCounter);
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,30 @@
|
|||||||
|
.adf-rating-container {
|
||||||
|
overflow: hidden;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.adf-rating-star {
|
||||||
|
float: left;
|
||||||
|
transition: all .3s;
|
||||||
|
padding: 1px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.adf-colored-star {
|
||||||
|
color: #ffe944;
|
||||||
|
}
|
||||||
|
|
||||||
|
.adf-grey-star {
|
||||||
|
color: #808080;
|
||||||
|
}
|
||||||
|
|
||||||
|
.adf-stars-container {
|
||||||
|
padding: 0!important;
|
||||||
|
margin: 0!important;
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.adf-rating-star:hover {
|
||||||
|
transform: rotate(13deg) scale(1.2);
|
||||||
|
}
|
||||||
|
|
@@ -0,0 +1,10 @@
|
|||||||
|
<div id="adf-rating-container" class="adf-rating-container">
|
||||||
|
<ul class="mdl-list adf-stars-container">
|
||||||
|
<li class="mdl-list__item adf-rating-star" *ngFor="let currentRate of stars; let idx = index">
|
||||||
|
<span id="adf-rate-{{idx}}" class="mdl-list__item-primary-content">
|
||||||
|
<i id="adf-grey-star-{{idx}}" *ngIf="currentRate.fill" class="material-icons adf-colored-star" (click)="updateVote(idx + 1)" >star_rate</i>
|
||||||
|
<i id="adf-colored-star-{{idx}}" *ngIf="!currentRate.fill" class="material-icons adf-grey-star" (click)="updateVote(idx + 1)" >star_border</i>
|
||||||
|
</span>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
@@ -0,0 +1,165 @@
|
|||||||
|
/*!
|
||||||
|
* @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 { ComponentFixture, TestBed, async } from '@angular/core/testing';
|
||||||
|
import { RatingComponent } from '../components/rating.component';
|
||||||
|
import { DebugElement } from '@angular/core';
|
||||||
|
import { CoreModule } from 'ng2-alfresco-core';
|
||||||
|
import { RatingService } from '../services/rating.service';
|
||||||
|
|
||||||
|
declare let jasmine: any;
|
||||||
|
|
||||||
|
describe('Rating component', () => {
|
||||||
|
|
||||||
|
let component: any;
|
||||||
|
let fixture: ComponentFixture<RatingComponent>;
|
||||||
|
let debug: DebugElement;
|
||||||
|
let element: HTMLElement;
|
||||||
|
|
||||||
|
beforeEach(async(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
imports: [
|
||||||
|
CoreModule.forRoot()
|
||||||
|
],
|
||||||
|
declarations: [
|
||||||
|
RatingComponent
|
||||||
|
],
|
||||||
|
providers: [
|
||||||
|
RatingService
|
||||||
|
]
|
||||||
|
}).compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(RatingComponent);
|
||||||
|
|
||||||
|
debug = fixture.debugElement;
|
||||||
|
element = fixture.nativeElement;
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
component.nodeId = 'test-id';
|
||||||
|
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Rendering tests', () => {
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
jasmine.Ajax.install();
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
jasmine.Ajax.uninstall();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should rating component should be present', (done) => {
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
component.ngOnChanges().subscribe(() => {
|
||||||
|
expect(element.querySelector('#adf-rating-container')).not.toBe(null);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
|
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||||
|
status: 200,
|
||||||
|
contentType: 'json',
|
||||||
|
responseText: {
|
||||||
|
entry: {
|
||||||
|
id: 'fiveStar',
|
||||||
|
aggregate: {
|
||||||
|
numberOfRatings: 1,
|
||||||
|
average: 4
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should the star rating filled with the right grey/colored star', (done) => {
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
component.ngOnChanges().subscribe(() => {
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
expect(element.querySelectorAll('.adf-colored-star').length).toBe(3);
|
||||||
|
expect(element.querySelectorAll('.adf-grey-star').length).toBe(2);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
|
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||||
|
status: 200,
|
||||||
|
contentType: 'json',
|
||||||
|
responseText: {
|
||||||
|
entry: {
|
||||||
|
id: 'fiveStar',
|
||||||
|
aggregate: {
|
||||||
|
numberOfRatings: 4,
|
||||||
|
average: 3
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should click on a star change your vote', (done) => {
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
component.ngOnChanges().subscribe(() => {
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
expect(element.querySelectorAll('.adf-colored-star').length).toBe(1);
|
||||||
|
|
||||||
|
component.changeVote.subscribe(() => {
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
expect(element.querySelectorAll('.adf-colored-star').length).toBe(3);
|
||||||
|
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
|
let starThree: any = element.querySelector('#adf-colored-star-3');
|
||||||
|
starThree.click();
|
||||||
|
|
||||||
|
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||||
|
status: 200,
|
||||||
|
contentType: 'json',
|
||||||
|
responseText: {
|
||||||
|
'entry': {
|
||||||
|
'myRating': 3,
|
||||||
|
'ratedAt': '2017-04-06T14:36:40.731+0000',
|
||||||
|
'id': 'fiveStar',
|
||||||
|
'aggregate': {'numberOfRatings': 1, 'average': 3.0}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||||
|
status: 200,
|
||||||
|
contentType: 'json',
|
||||||
|
responseText: {
|
||||||
|
'entry': {
|
||||||
|
myRating: 1,
|
||||||
|
'ratedAt': '2017-04-06T14:34:28.061+0000',
|
||||||
|
'id': 'fiveStar',
|
||||||
|
'aggregate': {'numberOfRatings': 1, 'average': 1.0}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
});
|
@@ -0,0 +1,85 @@
|
|||||||
|
/*!
|
||||||
|
* @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, Input, Output, EventEmitter } from '@angular/core';
|
||||||
|
import { RatingService } from './../services/rating.service';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'adf-rating',
|
||||||
|
styleUrls: ['./rating.component.css'],
|
||||||
|
templateUrl: './rating.component.html',
|
||||||
|
providers: [RatingService]
|
||||||
|
})
|
||||||
|
export class RatingComponent {
|
||||||
|
|
||||||
|
@Input()
|
||||||
|
nodeId: string;
|
||||||
|
|
||||||
|
average: number = 0;
|
||||||
|
|
||||||
|
ratingType: string = 'fiveStar';
|
||||||
|
|
||||||
|
@Output()
|
||||||
|
changeVote = new EventEmitter();
|
||||||
|
|
||||||
|
stars: Array<any> = [];
|
||||||
|
|
||||||
|
constructor(private ratingService: RatingService) {
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnChanges() {
|
||||||
|
let ratingObserver = this.ratingService.getRating(this.nodeId, this.ratingType);
|
||||||
|
|
||||||
|
ratingObserver.subscribe(
|
||||||
|
(data) => {
|
||||||
|
if (data.entry.aggregate) {
|
||||||
|
this.average = data.entry.aggregate.average;
|
||||||
|
this.calculateStars();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
return ratingObserver;
|
||||||
|
}
|
||||||
|
|
||||||
|
calculateStars() {
|
||||||
|
this.stars = [];
|
||||||
|
|
||||||
|
for (let i = 0; i < 5; i++) {
|
||||||
|
if (i < this.average) {
|
||||||
|
this.stars.push({fill: true});
|
||||||
|
} else {
|
||||||
|
this.stars.push({fill: false});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.changeVote.emit(this.average);
|
||||||
|
}
|
||||||
|
|
||||||
|
updateVote(vote: number) {
|
||||||
|
this.ratingService.postRating(this.nodeId, this.ratingType, vote).subscribe(
|
||||||
|
(data) => {
|
||||||
|
if (data.entry.aggregate) {
|
||||||
|
if (this.average !== data.entry.aggregate.average) {
|
||||||
|
this.average = data.entry.aggregate.average;
|
||||||
|
this.calculateStars();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,102 @@
|
|||||||
|
/*!
|
||||||
|
* @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 { ReflectiveInjector } from '@angular/core';
|
||||||
|
import {
|
||||||
|
AlfrescoAuthenticationService,
|
||||||
|
AlfrescoSettingsService,
|
||||||
|
AlfrescoApiService,
|
||||||
|
StorageService,
|
||||||
|
LogService
|
||||||
|
} from 'ng2-alfresco-core';
|
||||||
|
import { RatingService } from '../services/rating.service';
|
||||||
|
|
||||||
|
declare let jasmine: any;
|
||||||
|
|
||||||
|
describe('Rating service', () => {
|
||||||
|
|
||||||
|
let service, injector;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
injector = ReflectiveInjector.resolveAndCreate([
|
||||||
|
AlfrescoSettingsService,
|
||||||
|
AlfrescoApiService,
|
||||||
|
AlfrescoAuthenticationService,
|
||||||
|
RatingService,
|
||||||
|
StorageService,
|
||||||
|
LogService
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
service = injector.get(RatingService);
|
||||||
|
});
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
jasmine.Ajax.install();
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
jasmine.Ajax.uninstall();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Should get rating return an Observable', (done) => {
|
||||||
|
let ratingType: string = 'fiveStar';
|
||||||
|
let nodeId: string = 'fake-node-id';
|
||||||
|
|
||||||
|
service.getRating(nodeId, ratingType).subscribe((data) => {
|
||||||
|
expect(data.entry.myRating).toBe('1');
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
|
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||||
|
status: 200,
|
||||||
|
contentType: 'json',
|
||||||
|
responseText: {
|
||||||
|
'entry': {
|
||||||
|
myRating: 1,
|
||||||
|
'ratedAt': '2017-04-06T14:34:28.061+0000',
|
||||||
|
'id': 'fiveStar',
|
||||||
|
'aggregate': {'numberOfRatings': 1, 'average': 1.0}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Should post rating return an Observable', (done) => {
|
||||||
|
let ratingType: string = 'fiveStar';
|
||||||
|
let nodeId: string = 'fake-node-id';
|
||||||
|
|
||||||
|
service.postRating(nodeId, ratingType, 3).subscribe((data) => {
|
||||||
|
expect(data.entry.myRating).toBe('3');
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
|
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||||
|
status: 200,
|
||||||
|
contentType: 'json',
|
||||||
|
responseText: {
|
||||||
|
'entry': {
|
||||||
|
'myRating': 3,
|
||||||
|
'ratedAt': '2017-04-06T14:36:40.731+0000',
|
||||||
|
'id': 'fiveStar',
|
||||||
|
'aggregate': {'numberOfRatings': 1, 'average': 3.0}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
@@ -0,0 +1,55 @@
|
|||||||
|
/*!
|
||||||
|
* @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 { Response } from '@angular/http';
|
||||||
|
import { Observable } from 'rxjs/Rx';
|
||||||
|
import { AlfrescoApiService } from 'ng2-alfresco-core';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class RatingService {
|
||||||
|
|
||||||
|
constructor(private apiService: AlfrescoApiService) {
|
||||||
|
}
|
||||||
|
|
||||||
|
getRating(nodeId: string, ratingType: any): any {
|
||||||
|
return Observable.fromPromise(this.apiService.getInstance().core.ratingsApi.getRating(nodeId, ratingType))
|
||||||
|
.map(res => res)
|
||||||
|
.catch(this.handleError);
|
||||||
|
}
|
||||||
|
|
||||||
|
postRating(nodeId: string, ratingType: string, vote: any): any {
|
||||||
|
let ratingBody = {
|
||||||
|
'id': ratingType,
|
||||||
|
'myRating': vote
|
||||||
|
};
|
||||||
|
return Observable.fromPromise(this.apiService.getInstance().core.ratingsApi.rate(nodeId, ratingBody))
|
||||||
|
.map(res => res)
|
||||||
|
.catch(this.handleError);
|
||||||
|
}
|
||||||
|
|
||||||
|
deleteRating(nodeId: string, ratingId: string): any {
|
||||||
|
return Observable.fromPromise(this.apiService.getInstance().core.ratingsApi.removeRating(nodeId, ratingId))
|
||||||
|
.map(res => res)
|
||||||
|
.catch(this.handleError);
|
||||||
|
}
|
||||||
|
|
||||||
|
private handleError(error: Response): any {
|
||||||
|
console.error(error);
|
||||||
|
return Observable.throw(error || 'Server error');
|
||||||
|
}
|
||||||
|
}
|
40
ng2-components/ng2-alfresco-social/tsconfig.json
Normal file
40
ng2-components/ng2-alfresco-social/tsconfig.json
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "es5",
|
||||||
|
"module": "commonjs",
|
||||||
|
"moduleResolution": "node",
|
||||||
|
"sourceMap": true,
|
||||||
|
"emitDecoratorMetadata": true,
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"noLib": false,
|
||||||
|
"allowUnreachableCode": false,
|
||||||
|
"allowUnusedLabels": false,
|
||||||
|
"noImplicitAny": false,
|
||||||
|
"noImplicitReturns": false,
|
||||||
|
"noImplicitUseStrict": false,
|
||||||
|
"noFallthroughCasesInSwitch": true,
|
||||||
|
"removeComments": true,
|
||||||
|
"declaration": true,
|
||||||
|
"lib": [
|
||||||
|
"es2015",
|
||||||
|
"dom"
|
||||||
|
],
|
||||||
|
"typeRoots": [
|
||||||
|
"node_modules/@types"
|
||||||
|
],
|
||||||
|
"suppressImplicitAnyIndexErrors": true
|
||||||
|
},
|
||||||
|
"exclude": [
|
||||||
|
"demo",
|
||||||
|
"node_modules",
|
||||||
|
"dist",
|
||||||
|
"tools",
|
||||||
|
"gulpfile.ts",
|
||||||
|
"gulpfile.d.ts"
|
||||||
|
],
|
||||||
|
"angularCompilerOptions": {
|
||||||
|
"strictMetadataEmit": false,
|
||||||
|
"skipTemplateCodegen": true
|
||||||
|
}
|
||||||
|
}
|
121
ng2-components/ng2-alfresco-social/tslint.json
Normal file
121
ng2-components/ng2-alfresco-social/tslint.json
Normal file
@@ -0,0 +1,121 @@
|
|||||||
|
{
|
||||||
|
"rules": {
|
||||||
|
"align": [
|
||||||
|
true,
|
||||||
|
"parameters",
|
||||||
|
"statements"
|
||||||
|
],
|
||||||
|
"ban": false,
|
||||||
|
"class-name": true,
|
||||||
|
"comment-format": [
|
||||||
|
true,
|
||||||
|
"check-space"
|
||||||
|
],
|
||||||
|
"curly": true,
|
||||||
|
"eofline": true,
|
||||||
|
"forin": true,
|
||||||
|
"indent": [
|
||||||
|
true,
|
||||||
|
"spaces"
|
||||||
|
],
|
||||||
|
"interface-name": false,
|
||||||
|
"jsdoc-format": true,
|
||||||
|
"label-position": true,
|
||||||
|
"label-undefined": true,
|
||||||
|
"max-line-length": [
|
||||||
|
true,
|
||||||
|
180
|
||||||
|
],
|
||||||
|
"member-ordering": [
|
||||||
|
true,
|
||||||
|
"static-before-instance",
|
||||||
|
"variables-before-functions"
|
||||||
|
],
|
||||||
|
"no-any": false,
|
||||||
|
"no-arg": true,
|
||||||
|
"no-bitwise": false,
|
||||||
|
"no-conditional-assignment": true,
|
||||||
|
"no-consecutive-blank-lines": true,
|
||||||
|
"no-console": [
|
||||||
|
true,
|
||||||
|
"debug",
|
||||||
|
"info",
|
||||||
|
"time",
|
||||||
|
"timeEnd",
|
||||||
|
"trace"
|
||||||
|
],
|
||||||
|
"no-construct": true,
|
||||||
|
"no-constructor-vars": false,
|
||||||
|
"no-debugger": true,
|
||||||
|
"no-duplicate-key": true,
|
||||||
|
"no-duplicate-variable": true,
|
||||||
|
"no-empty": false,
|
||||||
|
"no-eval": true,
|
||||||
|
"no-inferrable-types": false,
|
||||||
|
"no-internal-module": true,
|
||||||
|
"no-require-imports": false,
|
||||||
|
"no-shadowed-variable": true,
|
||||||
|
"no-switch-case-fall-through": true,
|
||||||
|
"no-trailing-whitespace": true,
|
||||||
|
"no-unreachable": true,
|
||||||
|
"no-unused-expression": true,
|
||||||
|
"no-unused-variable": true,
|
||||||
|
"no-use-before-declare": true,
|
||||||
|
"no-var-keyword": true,
|
||||||
|
"no-var-requires": true,
|
||||||
|
"object-literal-sort-keys": false,
|
||||||
|
"one-line": [
|
||||||
|
true,
|
||||||
|
"check-open-brace",
|
||||||
|
"check-catch",
|
||||||
|
"check-else",
|
||||||
|
"check-whitespace"
|
||||||
|
],
|
||||||
|
"quotemark": [
|
||||||
|
true,
|
||||||
|
"single",
|
||||||
|
"avoid-escape"
|
||||||
|
],
|
||||||
|
"radix": true,
|
||||||
|
"semicolon": true,
|
||||||
|
"switch-default": true,
|
||||||
|
"trailing-comma": [
|
||||||
|
true,
|
||||||
|
{
|
||||||
|
"multiline": "never",
|
||||||
|
"singleline": "never"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"triple-equals": [
|
||||||
|
true,
|
||||||
|
"allow-null-check"
|
||||||
|
],
|
||||||
|
"typedef": false,
|
||||||
|
"typedef-whitespace": [
|
||||||
|
true,
|
||||||
|
{
|
||||||
|
"call-signature": "nospace",
|
||||||
|
"index-signature": "nospace",
|
||||||
|
"parameter": "nospace",
|
||||||
|
"property-declaration": "nospace",
|
||||||
|
"variable-declaration": "nospace"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"use-strict": false,
|
||||||
|
"variable-name": [
|
||||||
|
true,
|
||||||
|
"check-format",
|
||||||
|
"allow-leading-underscore",
|
||||||
|
"ban-keywords"
|
||||||
|
],
|
||||||
|
"whitespace": [
|
||||||
|
true,
|
||||||
|
"check-branch",
|
||||||
|
"check-operator",
|
||||||
|
"check-separator",
|
||||||
|
"check-type",
|
||||||
|
"check-module",
|
||||||
|
"check-decl"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
@@ -15,6 +15,7 @@ eval projects=( "ng2-alfresco-core"
|
|||||||
"ng2-alfresco-login"
|
"ng2-alfresco-login"
|
||||||
"ng2-alfresco-search"
|
"ng2-alfresco-search"
|
||||||
"ng2-alfresco-tag"
|
"ng2-alfresco-tag"
|
||||||
|
"ng2-alfresco-social"
|
||||||
"ng2-alfresco-upload"
|
"ng2-alfresco-upload"
|
||||||
"ng2-alfresco-viewer"
|
"ng2-alfresco-viewer"
|
||||||
"ng2-alfresco-webscript"
|
"ng2-alfresco-webscript"
|
||||||
|
@@ -13,6 +13,7 @@ eval projects=( "ng2-activiti-diagrams"
|
|||||||
"ng2-alfresco-login"
|
"ng2-alfresco-login"
|
||||||
"ng2-alfresco-search"
|
"ng2-alfresco-search"
|
||||||
"ng2-alfresco-tag"
|
"ng2-alfresco-tag"
|
||||||
|
"ng2-alfresco-social"
|
||||||
"ng2-alfresco-upload"
|
"ng2-alfresco-upload"
|
||||||
"ng2-alfresco-viewer"
|
"ng2-alfresco-viewer"
|
||||||
"ng2-alfresco-webscript"
|
"ng2-alfresco-webscript"
|
||||||
|
@@ -21,6 +21,7 @@ for PACKAGE in \
|
|||||||
ng2-alfresco-tag \
|
ng2-alfresco-tag \
|
||||||
ng2-alfresco-upload \
|
ng2-alfresco-upload \
|
||||||
ng2-alfresco-viewer \
|
ng2-alfresco-viewer \
|
||||||
|
ng2-alfresco-social \
|
||||||
ng2-alfresco-webscript \
|
ng2-alfresco-webscript \
|
||||||
ng2-alfresco-userinfo
|
ng2-alfresco-userinfo
|
||||||
do
|
do
|
||||||
|
@@ -15,6 +15,7 @@ for PACKAGE in \
|
|||||||
ng2-alfresco-login \
|
ng2-alfresco-login \
|
||||||
ng2-alfresco-search \
|
ng2-alfresco-search \
|
||||||
ng2-alfresco-tag \
|
ng2-alfresco-tag \
|
||||||
|
ng2-alfresco-social \
|
||||||
ng2-alfresco-upload \
|
ng2-alfresco-upload \
|
||||||
ng2-alfresco-viewer \
|
ng2-alfresco-viewer \
|
||||||
ng2-alfresco-webscript \
|
ng2-alfresco-webscript \
|
||||||
@@ -41,6 +42,7 @@ for PACKAGE in \
|
|||||||
ng2-alfresco-login \
|
ng2-alfresco-login \
|
||||||
ng2-alfresco-search \
|
ng2-alfresco-search \
|
||||||
ng2-alfresco-tag \
|
ng2-alfresco-tag \
|
||||||
|
ng2-alfresco-social \
|
||||||
ng2-alfresco-upload \
|
ng2-alfresco-upload \
|
||||||
ng2-alfresco-viewer \
|
ng2-alfresco-viewer \
|
||||||
ng2-alfresco-webscript \
|
ng2-alfresco-webscript \
|
||||||
|
@@ -16,6 +16,7 @@ for PACKAGE in \
|
|||||||
ng2-alfresco-login \
|
ng2-alfresco-login \
|
||||||
ng2-alfresco-search \
|
ng2-alfresco-search \
|
||||||
ng2-alfresco-tag \
|
ng2-alfresco-tag \
|
||||||
|
ng2-alfresco-social \
|
||||||
ng2-alfresco-upload \
|
ng2-alfresco-upload \
|
||||||
ng2-alfresco-viewer \
|
ng2-alfresco-viewer \
|
||||||
ng2-alfresco-webscript \
|
ng2-alfresco-webscript \
|
||||||
|
@@ -14,45 +14,32 @@ then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for PACKAGE in \
|
eval projects=( "ng2-alfresco-core"
|
||||||
ng2-activiti-diagrams \
|
"ng2-alfresco-datatable"
|
||||||
ng2-activiti-analytics \
|
"ng2-activiti-diagrams"
|
||||||
ng2-activiti-form \
|
"ng2-activiti-analytics"
|
||||||
ng2-activiti-processlist \
|
"ng2-activiti-form"
|
||||||
ng2-activiti-tasklist \
|
"ng2-activiti-tasklist"
|
||||||
ng2-alfresco-core \
|
"ng2-activiti-processlist"
|
||||||
ng2-alfresco-datatable \
|
"ng2-alfresco-documentlist"
|
||||||
ng2-alfresco-documentlist \
|
"ng2-alfresco-login"
|
||||||
ng2-alfresco-login \
|
"ng2-alfresco-search"
|
||||||
ng2-alfresco-search \
|
"ng2-alfresco-tag"
|
||||||
ng2-alfresco-tag \
|
"ng2-alfresco-social"
|
||||||
ng2-alfresco-upload \
|
"ng2-alfresco-upload"
|
||||||
ng2-alfresco-viewer \
|
"ng2-alfresco-viewer"
|
||||||
ng2-alfresco-webscript \
|
"ng2-alfresco-webscript"
|
||||||
ng2-alfresco-userinfo \
|
"ng2-alfresco-userinfo"
|
||||||
alfresco-js-api
|
"alfresco-js-api" )
|
||||||
|
|
||||||
|
for PACKAGE in ${projects[@]}
|
||||||
do
|
do
|
||||||
DESTDIR="$DIR/../ng2-components/${PACKAGE}"
|
DESTDIR="$DIR/../ng2-components/${PACKAGE}"
|
||||||
echo "====== UPDATE PACKAGE VERSION of ${PACKAGE} to ${VERSION} version in all the package.json ======"
|
echo "====== UPDATE PACKAGE VERSION of ${PACKAGE} to ${VERSION} version in all the package.json ======"
|
||||||
find ././../ -type f -maxdepth 4 -name package.json -print0 | xargs -0 sed -i '' "s/\"${PACKAGE}\": \"[0-9]\\.[0-9]\\.[0-9]\"/\"${PACKAGE}\": \"${VERSION}\"/g"
|
find ././../ -type f -maxdepth 4 -name package.json -print0 | xargs -0 sed -i '' "s/\"${PACKAGE}\": \"[0-9]\\.[0-9]\\.[0-9]\"/\"${PACKAGE}\": \"${VERSION}\"/g"
|
||||||
done
|
done
|
||||||
|
|
||||||
for PACKAGE in \
|
for PACKAGE in ${projects[@]}
|
||||||
ng2-activiti-diagrams \
|
|
||||||
ng2-activiti-analytics \
|
|
||||||
ng2-activiti-form \
|
|
||||||
ng2-activiti-processlist \
|
|
||||||
ng2-activiti-tasklist \
|
|
||||||
ng2-alfresco-core \
|
|
||||||
ng2-alfresco-datatable \
|
|
||||||
ng2-alfresco-documentlist \
|
|
||||||
ng2-alfresco-login \
|
|
||||||
ng2-alfresco-search \
|
|
||||||
ng2-alfresco-tag \
|
|
||||||
ng2-alfresco-upload \
|
|
||||||
ng2-alfresco-viewer \
|
|
||||||
ng2-alfresco-webscript \
|
|
||||||
ng2-alfresco-userinfo
|
|
||||||
do
|
do
|
||||||
DESTDIR="$DIR/../ng2-components/${PACKAGE}"
|
DESTDIR="$DIR/../ng2-components/${PACKAGE}"
|
||||||
echo "====== UPDATE VERSION OF ${PACKAGE} to ${VERSION} version ======"
|
echo "====== UPDATE VERSION OF ${PACKAGE} to ${VERSION} version ======"
|
||||||
@@ -63,45 +50,14 @@ echo "====== UPDATE VERSION OF DEMO-SHELL to ${VERSION} version ======"
|
|||||||
|
|
||||||
sed -i '' "s/\"version\": \"[0-9]\\.[0-9]\\.[0-9]\"/\"version\": \"${VERSION}\"/g" ${DIR}/../demo-shell-ng2/package.json
|
sed -i '' "s/\"version\": \"[0-9]\\.[0-9]\\.[0-9]\"/\"version\": \"${VERSION}\"/g" ${DIR}/../demo-shell-ng2/package.json
|
||||||
|
|
||||||
for PACKAGE in \
|
for PACKAGE in ${projects[@]}
|
||||||
ng2-activiti-diagrams \
|
|
||||||
ng2-activiti-analytics \
|
|
||||||
ng2-activiti-form \
|
|
||||||
ng2-activiti-processlist \
|
|
||||||
ng2-activiti-tasklist \
|
|
||||||
ng2-alfresco-core \
|
|
||||||
ng2-alfresco-datatable \
|
|
||||||
ng2-alfresco-documentlist \
|
|
||||||
ng2-alfresco-login \
|
|
||||||
ng2-alfresco-search \
|
|
||||||
ng2-alfresco-tag \
|
|
||||||
ng2-alfresco-upload \
|
|
||||||
ng2-alfresco-viewer \
|
|
||||||
ng2-alfresco-webscript \
|
|
||||||
ng2-alfresco-userinfo \
|
|
||||||
alfresco-js-api
|
|
||||||
do
|
do
|
||||||
DESTDIR="$DIR/../ng2-components/${PACKAGE}"
|
DESTDIR="$DIR/../ng2-components/${PACKAGE}"
|
||||||
echo "====== UPDATE PACKAGE VERSION of ${PACKAGE} to ~${VERSION} version in all the package.json ======"
|
echo "====== UPDATE PACKAGE VERSION of ${PACKAGE} to ~${VERSION} version in all the package.json ======"
|
||||||
find ././../ -type f -maxdepth 4 -name package.json -print0 | xargs -0 sed -i '' "s/\"${PACKAGE}\": \"~[0-9]\\.[0-9]\\.[0-9]\"/\"${PACKAGE}\": \"~${VERSION}\"/g"
|
find ././../ -type f -maxdepth 4 -name package.json -print0 | xargs -0 sed -i '' "s/\"${PACKAGE}\": \"~[0-9]\\.[0-9]\\.[0-9]\"/\"${PACKAGE}\": \"~${VERSION}\"/g"
|
||||||
done
|
done
|
||||||
|
|
||||||
for PACKAGE in \
|
for PACKAGE in ${projects[@]}
|
||||||
ng2-activiti-diagrams \
|
|
||||||
ng2-activiti-analytics \
|
|
||||||
ng2-activiti-form \
|
|
||||||
ng2-activiti-processlist \
|
|
||||||
ng2-activiti-tasklist \
|
|
||||||
ng2-alfresco-core \
|
|
||||||
ng2-alfresco-datatable \
|
|
||||||
ng2-alfresco-documentlist \
|
|
||||||
ng2-alfresco-login \
|
|
||||||
ng2-alfresco-search \
|
|
||||||
ng2-alfresco-tag \
|
|
||||||
ng2-alfresco-upload \
|
|
||||||
ng2-alfresco-viewer \
|
|
||||||
ng2-alfresco-webscript \
|
|
||||||
ng2-alfresco-userinfo
|
|
||||||
do
|
do
|
||||||
DESTDIR="$DIR/../ng2-components/${PACKAGE}"
|
DESTDIR="$DIR/../ng2-components/${PACKAGE}"
|
||||||
echo "====== UPDATE VERSION OF ${PACKAGE} to ~${VERSION} version ======"
|
echo "====== UPDATE VERSION OF ${PACKAGE} to ~${VERSION} version ======"
|
||||||
|
Reference in New Issue
Block a user