mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
[ADF-847] upgrade to use application configuration service (#1986)
* migrate core lib to use server-side app config * fix unit tests * update Search tests - update tests - upgrade tests to use TestBed * update UserInfo tests * update Social tests * update tests * update unit tests * cleanup old code * update about page * update demo shell readme * dev and prod configurations
This commit is contained in:
committed by
Eugenio Romano
parent
f5b94e1bb4
commit
d5f64fa9fc
@@ -1,14 +1,7 @@
|
||||
|
||||
<h1 align="center">Alfresco Angular 2 Components</h1>
|
||||
<p align="center">
|
||||
<img title="alfresco" alt='alfresco' src='../assets/alfresco.png' width="280px" height="150px" ></img>
|
||||
<img title="angular2" alt='angular2' src='../assets/angular2.png' width="150px" height="150px" ></img>
|
||||
</p>
|
||||
<p align="center">
|
||||
<a href='https://github.com/mgechev/angular2-style-guide'>
|
||||
<img src='https://mgechev.github.io/angular2-style-guide/images/badge.svg' alt='style' />
|
||||
</a>
|
||||
</p>
|
||||
# ADF Demo Application
|
||||
|
||||
Please note that this application is not an official product, but a testing and demo application to showcase complex interactions for ADF components.
|
||||
|
||||
## Installing
|
||||
|
||||
@@ -20,6 +13,53 @@ cd alfresco-ng2-components/demo-shell-ng2/
|
||||
npm install
|
||||
```
|
||||
|
||||
## Proxy settings and CORS
|
||||
|
||||
To simplify development and reduce the time to get started the application features the following Proxy settings:
|
||||
|
||||
- **http://localhost:3000/ecm** is mapped to **http://localhost:8080**
|
||||
- **http://localhost:3000/bpm** is mapped to **http://localhost:9999**
|
||||
|
||||
The settings above address most common scenarios for running ACS on port 8080 and APS on port 9999 and allow you to skip the CORS configuration.
|
||||
|
||||
If you would like to change default proxy settings, please edit the `config/webpack.common.js` file.
|
||||
|
||||
## Application settings (server-side)
|
||||
|
||||
All server-side application settings are stored in the `app.config-dev.json` and `app.config-prod.json` files.
|
||||
By default the configuration files have the content similar to the following one:
|
||||
|
||||
```json
|
||||
{
|
||||
"ecmHost": "http://localhost:3000/ecm",
|
||||
"bpmHost": "http://localhost:3000/bpm",
|
||||
"application": {
|
||||
"name": "Alfresco"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
You can add any additional settings to the application configuration file if needed.
|
||||
|
||||
Configuration files are picked based on environment settings (see `app.module.ts` for more details).
|
||||
|
||||
```ts
|
||||
let appConfigFile = 'app.config-dev.json';
|
||||
if (process.env.ENV === 'production') {
|
||||
appConfigFile = 'app.config-prod.json';
|
||||
}
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
...
|
||||
CoreModule.forRoot({
|
||||
appConfigFile: appConfigFile
|
||||
}),
|
||||
...
|
||||
]
|
||||
})
|
||||
```
|
||||
|
||||
## Development build
|
||||
|
||||
```sh
|
||||
@@ -59,42 +99,3 @@ If you want to run the demo shell with the latest change from the development br
|
||||
./npm-clean.sh
|
||||
./start-linked.sh -install
|
||||
```
|
||||
|
||||
## Multi-language
|
||||
To support a new language you need to create your language file (.json) and add it to `i18n/` folder.
|
||||
|
||||
```json
|
||||
{
|
||||
"username" : "Username",
|
||||
"input-required-message": "Required",
|
||||
"input-min-message": "Your username needs to be at least 4 characters.",
|
||||
"login-button": "Login"
|
||||
}
|
||||
```
|
||||
|
||||
Directory structure:
|
||||
```
|
||||
.
|
||||
├── i18n/
|
||||
│ ├── en.json
|
||||
│ ├── it.json
|
||||
│ └── fr.json
|
||||
```
|
||||
|
||||
## Custom-files
|
||||
|
||||
If you need to add custom files on your project you can add this files in the folders public
|
||||
|
||||
```
|
||||
.
|
||||
├── public/
|
||||
│ ├── images/
|
||||
│ ├── css/
|
||||
│ └── js/
|
||||
```
|
||||
|
||||
the public folder above wil be copied in the root of your project and you can refer to them for example as
|
||||
|
||||
* './images/custom_image.png'
|
||||
* './js/custom_script.js'
|
||||
* './css/custom_style.css'
|
||||
|
7
demo-shell-ng2/app.config-prod.json
Normal file
7
demo-shell-ng2/app.config-prod.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"ecmHost": "http://localhost:3000/ecm",
|
||||
"bpmHost": "http://localhost:3000/bpm",
|
||||
"application": {
|
||||
"name": "Alfresco"
|
||||
}
|
||||
}
|
@@ -21,7 +21,6 @@
|
||||
<a class="mdl-navigation__link" data-automation-id="files" href="" routerLink="/files">DocumentList</a>
|
||||
<a class="mdl-navigation__link" data-automation-id="activiti" href="" routerLink="/activiti">Process Services</a>
|
||||
<a class="mdl-navigation__link" data-automation-id="login" href="" routerLink="/login">Login</a>
|
||||
<a class="mdl-navigation__link" data-automation-id="settings" href="" routerLink="/settings">Settings</a>
|
||||
</nav>
|
||||
|
||||
</div>
|
||||
@@ -60,7 +59,6 @@
|
||||
<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="/settings" (click)="hideDrawer()">Settings</a>
|
||||
</nav>
|
||||
</div>
|
||||
<main class="mdl-layout__content" (dragover)="onDragOverMainPage($event)"
|
||||
|
@@ -35,17 +35,12 @@ declare var document: any;
|
||||
export class AppComponent {
|
||||
searchTerm: string = '';
|
||||
|
||||
ecmHost: string = `http://${window.location.hostname}` + (window.location.port ? `:${window.location.port}` : '') + `/ecm`;
|
||||
bpmHost: string = `http://${window.location.hostname}` + (window.location.port ? `:${window.location.port}` : '') + `/bpm`;
|
||||
|
||||
constructor(private authService: AlfrescoAuthenticationService,
|
||||
private router: Router,
|
||||
private settingsService: AlfrescoSettingsService,
|
||||
private translateService: AlfrescoTranslationService,
|
||||
private storage: StorageService,
|
||||
private logService: LogService) {
|
||||
this.setEcmHost();
|
||||
this.setBpmHost();
|
||||
this.setProvider();
|
||||
|
||||
if (translateService) {
|
||||
@@ -100,24 +95,6 @@ export class AppComponent {
|
||||
document.querySelector('.mdl-layout').MaterialLayout.toggleDrawer();
|
||||
}
|
||||
|
||||
private setEcmHost() {
|
||||
if (this.storage.hasItem(`ecmHost`)) {
|
||||
this.settingsService.ecmHost = this.storage.getItem(`ecmHost`);
|
||||
this.ecmHost = this.storage.getItem(`ecmHost`);
|
||||
} else {
|
||||
this.settingsService.ecmHost = this.ecmHost;
|
||||
}
|
||||
}
|
||||
|
||||
private setBpmHost() {
|
||||
if (this.storage.hasItem(`bpmHost`)) {
|
||||
this.settingsService.bpmHost = this.storage.getItem(`bpmHost`);
|
||||
this.bpmHost = this.storage.getItem(`bpmHost`);
|
||||
} else {
|
||||
this.settingsService.bpmHost = this.bpmHost;
|
||||
}
|
||||
}
|
||||
|
||||
private setProvider() {
|
||||
if (this.storage.hasItem(`providers`)) {
|
||||
this.settingsService.setProviders(this.storage.getItem(`providers`));
|
||||
|
@@ -58,15 +58,21 @@ import {
|
||||
SocialComponent,
|
||||
AboutComponent,
|
||||
FilesComponent,
|
||||
FormNodeViewer,
|
||||
SettingComponent
|
||||
FormNodeViewer
|
||||
} from './components/index';
|
||||
|
||||
let appConfigFile = 'app.config-dev.json';
|
||||
if (process.env.ENV === 'production') {
|
||||
appConfigFile = 'app.config-prod.json';
|
||||
}
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
BrowserModule,
|
||||
routing,
|
||||
CoreModule.forRoot(),
|
||||
CoreModule.forRoot({
|
||||
appConfigFile: appConfigFile
|
||||
}),
|
||||
MaterialModule,
|
||||
LoginModule.forRoot(),
|
||||
SearchModule.forRoot(),
|
||||
@@ -104,7 +110,6 @@ import {
|
||||
AboutComponent,
|
||||
FilesComponent,
|
||||
FormNodeViewer,
|
||||
SettingComponent,
|
||||
CreateFolderDialog
|
||||
],
|
||||
providers: [],
|
||||
|
@@ -33,8 +33,7 @@ import {
|
||||
SocialComponent,
|
||||
AboutComponent,
|
||||
FormViewer,
|
||||
FormNodeViewer,
|
||||
SettingComponent
|
||||
FormNodeViewer
|
||||
} from './components/index';
|
||||
|
||||
import { UploadButtonComponent } from 'ng2-alfresco-upload';
|
||||
@@ -129,8 +128,7 @@ export const appRoutes: Routes = [
|
||||
component: SocialComponent,
|
||||
canActivate: [AuthGuardEcm]
|
||||
},
|
||||
{ path: 'about', component: AboutComponent },
|
||||
{ path: 'settings', component: SettingComponent }
|
||||
{ path: 'about', component: AboutComponent }
|
||||
];
|
||||
|
||||
export const routing: ModuleWithProviders = RouterModule.forRoot(appRoutes);
|
||||
|
@@ -1,10 +1,25 @@
|
||||
<div class="about-container">
|
||||
|
||||
<h3>Server settings</h3>
|
||||
<small>The values below are taken from the AppConfigService and loaded from the '{{ configFile }}' file.</small>
|
||||
<div>
|
||||
Alfresco Process Services URL: <strong>{{ bpmHost }}</strong>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
Alfresco Content Services URL: <strong>{{ ecmHost }}</strong>
|
||||
</div>
|
||||
|
||||
<div *ngIf="githubUrlCommitAlpha">
|
||||
<h3>Current Commit position</h3>
|
||||
<h3>Source code</h3>
|
||||
<small>You are running the project based on the following commit:</small>
|
||||
<div>
|
||||
<a [href]="githubUrlCommitAlpha">{{githubUrlCommitAlpha}}</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<h3>Packages</h3>
|
||||
<small>Current project is using the following ADF libraries:</small>
|
||||
<alfresco-datatable [data]="data"></alfresco-datatable>
|
||||
</div>
|
||||
|
@@ -18,7 +18,7 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Http } from '@angular/http';
|
||||
import { ObjectDataTableAdapter } from 'ng2-alfresco-datatable';
|
||||
import { LogService } from 'ng2-alfresco-core';
|
||||
import { LogService, AppConfigService } from 'ng2-alfresco-core';
|
||||
|
||||
@Component({
|
||||
selector: 'about-page',
|
||||
@@ -28,10 +28,14 @@ import { LogService } from 'ng2-alfresco-core';
|
||||
export class AboutComponent implements OnInit {
|
||||
|
||||
data: ObjectDataTableAdapter;
|
||||
|
||||
githubUrlCommitAlpha: string = 'https://github.com/Alfresco/alfresco-ng2-components/commits/';
|
||||
|
||||
configFile: string = '';
|
||||
ecmHost: string = '';
|
||||
bpmHost: string = '';
|
||||
|
||||
constructor(private http: Http,
|
||||
private appConfig: AppConfigService,
|
||||
private logService: LogService) {
|
||||
}
|
||||
|
||||
@@ -62,6 +66,10 @@ export class AboutComponent implements OnInit {
|
||||
{type: 'text', key: 'version', title: 'Version', sortable: true}
|
||||
]);
|
||||
});
|
||||
|
||||
this.configFile = this.appConfig.configFile;
|
||||
this.ecmHost = this.appConfig.get<string>('ecmHost');
|
||||
this.bpmHost = this.appConfig.get<string>('bpmHost');
|
||||
}
|
||||
|
||||
private gitHubLinkCreation(alfrescoPackagesTableRepresentation): void {
|
||||
|
@@ -29,5 +29,4 @@ export { SocialComponent } from './social/social.component';
|
||||
export { AboutComponent } from './about/about.component';
|
||||
export { FilesComponent } from './files/files.component';
|
||||
export { FormNodeViewer } from './activiti/form-node-viewer.component';
|
||||
export { SettingComponent } from './setting/setting.component';
|
||||
export { ActivitiAppsView } from './activiti/apps.view';
|
||||
|
@@ -23,16 +23,6 @@
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<!--SETTING BUTTON-->
|
||||
|
||||
<a class="mdl-navigation__link setting-button" data-automation-id="settings" href="" routerLink="/settings">
|
||||
<button class="mdl-button mdl-js-button mdl-button--fab mdl-button--colored">
|
||||
<i class="material-icons">settings</i>
|
||||
</button>
|
||||
</a>
|
||||
|
||||
<!--LOGIN-->
|
||||
|
||||
<alfresco-login #alfrescologin
|
||||
[providers]="providers"
|
||||
[fieldsValidation]="customValidation"
|
||||
|
@@ -1,35 +0,0 @@
|
||||
.setting-card.mdl-card {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.setting-card > .mdl-card__title {
|
||||
color: #fff;
|
||||
background: bottom right 15% no-repeat #1fbcd2;
|
||||
}
|
||||
|
||||
.setting-card-padding {
|
||||
width: 50%;
|
||||
display: table-cell;
|
||||
vertical-align: middle;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.setting-container {
|
||||
display: table;
|
||||
border-collapse: collapse;
|
||||
border-spacing: 0;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.icon-margin {
|
||||
margin-right: 9px;
|
||||
}
|
||||
|
||||
.table-row {
|
||||
display: table-row;
|
||||
}
|
||||
|
||||
.adf-setting-input-padding {
|
||||
padding-top: 0px !important;
|
||||
}
|
@@ -1,48 +0,0 @@
|
||||
<div class="setting-container">
|
||||
<div class="table-row">
|
||||
<div class="setting-card-padding"></div>
|
||||
<div class="setting-card mdl-card mdl-shadow--2dp">
|
||||
<div class="mdl-card__title mdl-card--expand">
|
||||
<h2 class="mdl-card__title-text">SETTINGS</h2>
|
||||
</div>
|
||||
<div class="mdl-card__actions mdl-card--border">
|
||||
<div class="mdl-card__supporting-text">
|
||||
Content Services host URL configuration
|
||||
</div>
|
||||
<nav class="mdl-navigation">
|
||||
<i class="icon material-icons icon-margin">link</i>
|
||||
<div class="mdl-textfield mdl-js-textfield adf-setting-input-padding">
|
||||
<input data-automation-id="ecmHost"
|
||||
class="mdl-textfield__input" tabindex="1"
|
||||
type="text" tabindex="1"
|
||||
(change)="onChangeECMHost($event)"
|
||||
pattern="^(http|https):\/\/.*" id="ecmHost" value="{{ecmHost}}">
|
||||
<label class="mdl-textfield__label" for="ecmHost">ECM Host</label>
|
||||
<span class="mdl-textfield__error">ECM host is not valid!</span>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<div class="mdl-card__supporting-text">
|
||||
Process Services host URL configuration
|
||||
</div>
|
||||
<nav class="mdl-navigation">
|
||||
<i class="icon material-icons icon-margin">link</i>
|
||||
<div class="mdl-textfield mdl-js-textfield adf-setting-input-padding">
|
||||
<input class="mdl-textfield__input"
|
||||
type="text"
|
||||
(change)="onChangeBPMHost($event)"
|
||||
tabindex="2" pattern="^(http|https):\/\/.*" id="bpmHost" value="{{bpmHost}}">
|
||||
<label class="mdl-textfield__label" for="bpmHost">BPM Host</label>
|
||||
<span class="mdl-textfield__error">BPM host is not valid!</span>
|
||||
</div>
|
||||
</nav>
|
||||
</div>
|
||||
<div class="mdl-card__actions mdl-card--border">
|
||||
<a class="mdl-button mdl-button--colored mdl-js-button mdl-js-ripple-effect" onclick="window.history.back()" >
|
||||
Back
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="setting-card-padding"></div>
|
||||
</div>
|
||||
</div>
|
@@ -1,75 +0,0 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright 2016 Alfresco Software, Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Component, AfterViewChecked } from '@angular/core';
|
||||
import { AlfrescoSettingsService, StorageService, LogService } from 'ng2-alfresco-core';
|
||||
|
||||
declare var componentHandler: any;
|
||||
|
||||
@Component({
|
||||
selector: 'alfresco-setting-demo',
|
||||
templateUrl: './setting.component.html',
|
||||
styleUrls: ['./setting.component.css']
|
||||
})
|
||||
export class SettingComponent implements AfterViewChecked {
|
||||
|
||||
ecmHost: string;
|
||||
bpmHost: string;
|
||||
|
||||
constructor(private settingsService: AlfrescoSettingsService,
|
||||
private storage: StorageService,
|
||||
private logService: LogService) {
|
||||
this.ecmHost = this.settingsService.ecmHost;
|
||||
this.bpmHost = this.settingsService.bpmHost;
|
||||
}
|
||||
|
||||
ngAfterViewChecked() {
|
||||
// workaround for MDL issues with dynamic components
|
||||
if (componentHandler) {
|
||||
componentHandler.upgradeAllRegistered();
|
||||
}
|
||||
}
|
||||
|
||||
public onChangeECMHost(event: KeyboardEvent): void {
|
||||
let value = (<HTMLInputElement>event.target).value.trim();
|
||||
if (value && this.isValidUrl(value)) {
|
||||
this.logService.info(`ECM host: ${value}`);
|
||||
this.ecmHost = value;
|
||||
this.settingsService.ecmHost = value;
|
||||
this.storage.setItem(`ecmHost`, value);
|
||||
} else {
|
||||
console.error('Ecm address does not match the pattern');
|
||||
}
|
||||
}
|
||||
|
||||
public onChangeBPMHost(event: KeyboardEvent): void {
|
||||
let value = (<HTMLInputElement>event.target).value.trim();
|
||||
if (value && this.isValidUrl(value)) {
|
||||
this.logService.info(`BPM host: ${value}`);
|
||||
this.bpmHost = value;
|
||||
this.settingsService.bpmHost = value;
|
||||
this.storage.setItem(`bpmHost`, value);
|
||||
} else {
|
||||
console.error('Bpm address does not match the pattern');
|
||||
}
|
||||
}
|
||||
|
||||
isValidUrl(url: string) {
|
||||
return /^(http|https):\/\/.*/.test(url);
|
||||
}
|
||||
|
||||
}
|
@@ -102,7 +102,10 @@ module.exports = {
|
||||
to: 'resources/i18n'
|
||||
},
|
||||
{
|
||||
from: 'app.config.json'
|
||||
from: 'app.config-dev.json'
|
||||
},
|
||||
{
|
||||
from: 'app.config-prod.json'
|
||||
},
|
||||
{
|
||||
from: 'favicon-96x96.png'
|
||||
|
@@ -90,7 +90,7 @@ describe('AnalyticsReportListComponent', () => {
|
||||
});
|
||||
|
||||
it('should return the default reports when the report list is empty', (done) => {
|
||||
jasmine.Ajax.stubRequest('http://localhost:9999/activiti-app/app/rest/reporting/reports').andReturn({
|
||||
jasmine.Ajax.stubRequest('http://localhost:3000/bpm/activiti-app/app/rest/reporting/reports').andReturn({
|
||||
status: 200,
|
||||
contentType: 'json',
|
||||
responseText: []
|
||||
@@ -98,13 +98,13 @@ describe('AnalyticsReportListComponent', () => {
|
||||
|
||||
fixture.detectChanges();
|
||||
|
||||
jasmine.Ajax.stubRequest('http://localhost:9999/activiti-app/app/rest/reporting/default-reports').andReturn({
|
||||
jasmine.Ajax.stubRequest('http://localhost:3000/bpm/activiti-app/app/rest/reporting/default-reports').andReturn({
|
||||
status: 200,
|
||||
contentType: 'json',
|
||||
responseText: []
|
||||
});
|
||||
|
||||
jasmine.Ajax.stubRequest('http://localhost:9999/activiti-app/app/rest/reporting/reports').andReturn({
|
||||
jasmine.Ajax.stubRequest('http://localhost:3000/bpm/activiti-app/app/rest/reporting/reports').andReturn({
|
||||
status: 200,
|
||||
contentType: 'json',
|
||||
responseText: reportList
|
||||
|
@@ -295,13 +295,13 @@ describe('AnalyticsReportParametersComponent', () => {
|
||||
done();
|
||||
});
|
||||
|
||||
jasmine.Ajax.stubRequest('http://localhost:9999/activiti-app/app/rest/reporting/report-params/1').andReturn({
|
||||
jasmine.Ajax.stubRequest('http://localhost:3000/bpm/activiti-app/app/rest/reporting/report-params/1').andReturn({
|
||||
status: 200,
|
||||
contentType: 'json',
|
||||
responseText: analyticParamsMock.reportDefParamProcessDef
|
||||
});
|
||||
|
||||
jasmine.Ajax.stubRequest('http://localhost:9999/activiti-app/app/rest/reporting/process-definitions').andReturn({
|
||||
jasmine.Ajax.stubRequest('http://localhost:3000/bpm/activiti-app/app/rest/reporting/process-definitions').andReturn({
|
||||
status: 200,
|
||||
contentType: 'json',
|
||||
responseText: analyticParamsMock.reportDefParamProcessDefOptionsNoApp
|
||||
@@ -326,7 +326,7 @@ describe('AnalyticsReportParametersComponent', () => {
|
||||
done();
|
||||
});
|
||||
|
||||
jasmine.Ajax.stubRequest('http://localhost:9999/activiti-app/app/rest/reporting/report-params/1').andReturn({
|
||||
jasmine.Ajax.stubRequest('http://localhost:3000/bpm/activiti-app/app/rest/reporting/report-params/1').andReturn({
|
||||
status: 200,
|
||||
contentType: 'json',
|
||||
responseText: analyticParamsMock.reportDefParamProcessDef
|
||||
@@ -334,7 +334,7 @@ describe('AnalyticsReportParametersComponent', () => {
|
||||
|
||||
let appId = '1';
|
||||
|
||||
jasmine.Ajax.stubRequest('http://localhost:9999/activiti-app/api/enterprise/process-definitions?appDefinitionId=' + appId).andReturn({
|
||||
jasmine.Ajax.stubRequest('http://localhost:3000/bpm/activiti-app/api/enterprise/process-definitions?appDefinitionId=' + appId).andReturn({
|
||||
status: 200,
|
||||
contentType: 'json',
|
||||
responseText: analyticParamsMock.reportDefParamProcessDefOptionsApp
|
||||
@@ -392,13 +392,13 @@ describe('AnalyticsReportParametersComponent', () => {
|
||||
done();
|
||||
});
|
||||
|
||||
jasmine.Ajax.stubRequest('http://localhost:9999/activiti-app/app/rest/reporting/report-params/1').andReturn({
|
||||
jasmine.Ajax.stubRequest('http://localhost:3000/bpm/activiti-app/app/rest/reporting/report-params/1').andReturn({
|
||||
status: 200,
|
||||
contentType: 'json',
|
||||
responseText: analyticParamsMock.reportDefParamProcessDef
|
||||
});
|
||||
|
||||
jasmine.Ajax.stubRequest('http://localhost:9999/activiti-app/app/rest/reporting/process-definitions').andReturn({
|
||||
jasmine.Ajax.stubRequest('http://localhost:3000/bpm/activiti-app/app/rest/reporting/process-definitions').andReturn({
|
||||
status: 404,
|
||||
contentType: 'json',
|
||||
responseText: []
|
||||
|
@@ -30,7 +30,7 @@ export class DiagramsService {
|
||||
}
|
||||
|
||||
getProcessDefinitionModel(processDefinitionId: string): Observable<any> {
|
||||
let url = `${this.settingsService.getBPMApiBaseUrl()}/app/rest/process-definitions/${processDefinitionId}/model-json`;
|
||||
let url = `${this.settingsService.bpmHost}/activiti-app/app/rest/process-definitions/${processDefinitionId}/model-json`;
|
||||
let options = this.getRequestOptions();
|
||||
return this.http
|
||||
.get(url, options)
|
||||
@@ -41,7 +41,7 @@ export class DiagramsService {
|
||||
}
|
||||
|
||||
getRunningProcessDefinitionModel(processInstanceId: string): Observable<any> {
|
||||
let url = `${this.settingsService.getBPMApiBaseUrl()}/app/rest/process-instances/${processInstanceId}/model-json`;
|
||||
let url = `${this.settingsService.bpmHost}/activiti-app/app/rest/process-instances/${processInstanceId}/model-json`;
|
||||
let options = this.getRequestOptions();
|
||||
return this.http
|
||||
.get(url, options)
|
||||
|
@@ -15,14 +15,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { ReflectiveInjector } from '@angular/core';
|
||||
import {
|
||||
AlfrescoAuthenticationService,
|
||||
AlfrescoSettingsService,
|
||||
AlfrescoApiService,
|
||||
StorageService,
|
||||
LogService
|
||||
} from 'ng2-alfresco-core';
|
||||
import { TestBed, async } from '@angular/core/testing';
|
||||
import { CoreModule, AlfrescoApiService, LogService } from 'ng2-alfresco-core';
|
||||
import { Observable } from 'rxjs/Rx';
|
||||
import { FormService } from './form.service';
|
||||
import { Response, ResponseOptions } from '@angular/http';
|
||||
@@ -69,24 +63,26 @@ function createFakeBlob() {
|
||||
|
||||
describe('Form service', () => {
|
||||
|
||||
let service, injector, apiService, logService;
|
||||
let service: FormService;
|
||||
let apiService: AlfrescoApiService;
|
||||
let logService: LogService;
|
||||
|
||||
beforeEach(() => {
|
||||
injector = ReflectiveInjector.resolveAndCreate([
|
||||
AlfrescoSettingsService,
|
||||
AlfrescoApiService,
|
||||
AlfrescoAuthenticationService,
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
CoreModule
|
||||
],
|
||||
providers: [
|
||||
EcmModelService,
|
||||
StorageService,
|
||||
FormService,
|
||||
LogService
|
||||
]);
|
||||
});
|
||||
FormService
|
||||
]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
service = injector.get(FormService);
|
||||
apiService = injector.get(AlfrescoApiService);
|
||||
logService = injector.get(LogService);
|
||||
service = TestBed.get(FormService);
|
||||
apiService = TestBed.get(AlfrescoApiService);
|
||||
logService = TestBed.get(LogService);
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
@@ -530,7 +526,7 @@ describe('Form service', () => {
|
||||
|
||||
function stubCreateForm() {
|
||||
jasmine.Ajax.stubRequest(
|
||||
'http://localhost:9999/activiti-app/api/enterprise/models'
|
||||
'http://localhost:3000/bpm/activiti-app/api/enterprise/models'
|
||||
).andReturn({
|
||||
status: 200,
|
||||
statusText: 'HTTP/1.1 200 OK',
|
||||
@@ -541,7 +537,7 @@ describe('Form service', () => {
|
||||
|
||||
function stubGetEcmModel() {
|
||||
jasmine.Ajax.stubRequest(
|
||||
'http://localhost:8080/alfresco/api/-default-/private/alfresco/versions/1/cmm/activitiFormsModel/types'
|
||||
'http://localhost:3000/ecm/alfresco/api/-default-/private/alfresco/versions/1/cmm/activitiFormsModel/types'
|
||||
).andReturn({
|
||||
status: 200,
|
||||
statusText: 'HTTP/1.1 200 OK',
|
||||
@@ -562,7 +558,7 @@ describe('Form service', () => {
|
||||
|
||||
function stubAddFieldsToAForm() {
|
||||
jasmine.Ajax.stubRequest(
|
||||
'http://localhost:9999/activiti-app/api/enterprise/editor/form-models/' + formId
|
||||
'http://localhost:3000/bpm/activiti-app/api/enterprise/editor/form-models/' + formId
|
||||
).andReturn({
|
||||
status: 200,
|
||||
statusText: 'HTTP/1.1 200 OK',
|
||||
|
@@ -15,21 +15,11 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { ReflectiveInjector } from '@angular/core';
|
||||
import { async } from '@angular/core/testing';
|
||||
import {
|
||||
AlfrescoAuthenticationService,
|
||||
AlfrescoSettingsService,
|
||||
AlfrescoApiService,
|
||||
StorageService,
|
||||
LogService
|
||||
} from 'ng2-alfresco-core';
|
||||
import { TestBed, async } from '@angular/core/testing';
|
||||
import { CoreModule } from 'ng2-alfresco-core';
|
||||
import { ActivitiTaskListService } from './activiti-tasklist.service';
|
||||
import { TaskDetailsModel } from '../models/task-details.model';
|
||||
import {
|
||||
FilterRepresentationModel,
|
||||
TaskQueryRequestRepresentationModel
|
||||
} from '../models/filter.model';
|
||||
import { FilterRepresentationModel, TaskQueryRequestRepresentationModel } from '../models/filter.model';
|
||||
import { Comment } from '../models/comment.model';
|
||||
import {
|
||||
fakeFilters,
|
||||
@@ -56,21 +46,20 @@ declare let jasmine: any;
|
||||
describe('Activiti TaskList Service', () => {
|
||||
|
||||
let service: ActivitiTaskListService;
|
||||
let injector;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
CoreModule.forRoot()
|
||||
],
|
||||
providers: [
|
||||
ActivitiTaskListService
|
||||
]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
injector = ReflectiveInjector.resolveAndCreate([
|
||||
AlfrescoSettingsService,
|
||||
AlfrescoApiService,
|
||||
AlfrescoAuthenticationService,
|
||||
ActivitiTaskListService,
|
||||
StorageService,
|
||||
LogService
|
||||
]);
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
service = injector.get(ActivitiTaskListService);
|
||||
service = TestBed.get(ActivitiTaskListService);
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
|
@@ -6,7 +6,6 @@
|
||||
|
||||
- [Prerequisites](#prerequisites)
|
||||
- [Install](#install)
|
||||
- [Library content](#library-content)
|
||||
- [Toolbar Component](#toolbar-component)
|
||||
* [Properties](#properties)
|
||||
- [Upload Directive](#upload-directive)
|
||||
@@ -52,24 +51,6 @@ necessary configuration, see this [page](https://github.com/Alfresco/alfresco-ng
|
||||
npm install ng2-alfresco-core
|
||||
```
|
||||
|
||||
## Library content
|
||||
|
||||
- Components
|
||||
- [Toolbar](#toolbar-component)
|
||||
- [Accordion](#accordion-component)
|
||||
- Directives
|
||||
- [Upload](#upload-directive)
|
||||
- [Context Menu](#context-menu-directive)
|
||||
- Services
|
||||
- [AppConfigService](#appconfigservice), application configuration
|
||||
- **LogService**, log service implementation
|
||||
- [NotificationService](#notification-service), Notification service implementation
|
||||
- [AlfrescoApiService](#alfresco-api-service), provides access to Alfresco JS API instance
|
||||
- [AlfrescoAuthenticationService](#authentication-service), main authentication APIs
|
||||
- [AlfrescoTranslationService](#alfrescotranslationservice), various i18n-related APIs
|
||||
- **ContextMenuService**, global context menu APIs
|
||||
- [Renditions Service](#renditions-service)
|
||||
|
||||
## Toolbar Component
|
||||
|
||||
```html
|
||||
@@ -350,6 +331,28 @@ export class AppComponent {
|
||||
You custom components can also benefit from the `AppConfigService`,
|
||||
you can put an unlimited number of settings and optionally a nested JSON hierarchy.
|
||||
|
||||
### Different configurations based on environment settings
|
||||
|
||||
The CoreModule allows you to provide custom application configuration path.
|
||||
That means you can evaluate the final file name based on conditions, for example environment settings:
|
||||
|
||||
```ts
|
||||
let appConfigFile = 'app.config-dev.json';
|
||||
if (process.env.ENV === 'production') {
|
||||
appConfigFile = 'app.config-prod.json';
|
||||
}
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
...
|
||||
CoreModule.forRoot({
|
||||
appConfigFile: appConfigFile
|
||||
}),
|
||||
...
|
||||
]
|
||||
})
|
||||
```
|
||||
|
||||
## Notification Service
|
||||
|
||||
The Notification Service is implemented on top of the Angular 2 Material Design snackbar.
|
||||
|
@@ -19,54 +19,29 @@ import { Injectable } from '@angular/core';
|
||||
import { AlfrescoApi } from 'alfresco-js-api';
|
||||
import * as alfrescoApi from 'alfresco-js-api';
|
||||
import { AlfrescoSettingsService } from './alfresco-settings.service';
|
||||
import { AppConfigService } from './app-config.service';
|
||||
import { StorageService } from './storage.service';
|
||||
|
||||
@Injectable()
|
||||
export class AlfrescoApiService {
|
||||
|
||||
private alfrescoApi: AlfrescoApi;
|
||||
|
||||
private provider: string;
|
||||
|
||||
private ticketEcm: string;
|
||||
|
||||
private ticketBpm: string;
|
||||
|
||||
private hostEcm: string;
|
||||
|
||||
private hostBpm: string;
|
||||
|
||||
private contextRoot: string;
|
||||
|
||||
private disableCsrf: boolean;
|
||||
|
||||
public getInstance(): AlfrescoApi {
|
||||
return this.alfrescoApi;
|
||||
}
|
||||
|
||||
constructor(private settingsService: AlfrescoSettingsService,
|
||||
constructor(private appConfig: AppConfigService,
|
||||
private settingsService: AlfrescoSettingsService,
|
||||
private storage: StorageService) {
|
||||
|
||||
this.provider = this.settingsService.getProviders();
|
||||
this.ticketEcm = this.getTicketEcm();
|
||||
this.ticketBpm = this.getTicketBpm();
|
||||
this.hostEcm = this.settingsService.ecmHost;
|
||||
this.hostBpm = this.settingsService.bpmHost;
|
||||
this.contextRoot = 'alfresco';
|
||||
this.disableCsrf = false;
|
||||
|
||||
this.init();
|
||||
|
||||
settingsService.bpmHostSubject.subscribe((hostBpm) => {
|
||||
this.hostBpm = hostBpm;
|
||||
this.init();
|
||||
});
|
||||
|
||||
settingsService.ecmHostSubject.subscribe((hostEcm) => {
|
||||
this.hostEcm = hostEcm;
|
||||
this.init();
|
||||
});
|
||||
|
||||
settingsService.csrfSubject.subscribe((disableCsrf) => {
|
||||
this.disableCsrf = disableCsrf;
|
||||
this.init();
|
||||
@@ -81,29 +56,12 @@ export class AlfrescoApiService {
|
||||
private init() {
|
||||
this.alfrescoApi = <AlfrescoApi>new alfrescoApi({
|
||||
provider: this.provider,
|
||||
ticketEcm: this.ticketEcm,
|
||||
ticketBpm: this.ticketBpm,
|
||||
hostEcm: this.hostEcm,
|
||||
hostBpm: this.hostBpm,
|
||||
contextRoot: this.contextRoot,
|
||||
ticketEcm: this.storage.getItem('ticket-ECM'),
|
||||
ticketBpm: this.storage.getItem('ticket-BPM'),
|
||||
hostEcm: this.appConfig.get<string>('ecmHost'),
|
||||
hostBpm: this.appConfig.get<string>('bpmHost'),
|
||||
contextRoot: 'alfresco',
|
||||
disableCsrf: this.disableCsrf
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* The method return the ECM ticket stored in the Storage
|
||||
* @returns ticket
|
||||
*/
|
||||
private getTicketEcm(): string {
|
||||
return this.storage.getItem('ticket-ECM');
|
||||
}
|
||||
|
||||
/**
|
||||
* The method return the BPM ticket stored in the Storage
|
||||
* @returns ticket
|
||||
*/
|
||||
private getTicketBpm(): string {
|
||||
return this.storage.getItem('ticket-BPM');
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -15,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { ReflectiveInjector } from '@angular/core';
|
||||
import { TestBed, async } from '@angular/core/testing';
|
||||
import { AlfrescoSettingsService } from './alfresco-settings.service';
|
||||
import { AlfrescoAuthenticationService } from './alfresco-authentication.service';
|
||||
import { AlfrescoApiService } from './alfresco-api.service';
|
||||
@@ -23,30 +23,39 @@ import { StorageService } from './storage.service';
|
||||
import { CookieService } from './cookie.service';
|
||||
import { CookieServiceMock } from './../assets/cookie.service.mock';
|
||||
import { LogService } from './log.service';
|
||||
import { AppConfigModule } from './app-config.service';
|
||||
|
||||
declare let jasmine: any;
|
||||
|
||||
describe('AlfrescoAuthenticationService', () => {
|
||||
let injector;
|
||||
let apiService: AlfrescoApiService;
|
||||
let authService: AlfrescoAuthenticationService;
|
||||
let settingsService: AlfrescoSettingsService;
|
||||
let storage: StorageService;
|
||||
let cookie: CookieService;
|
||||
|
||||
beforeEach(() => {
|
||||
injector = ReflectiveInjector.resolveAndCreate([
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
AppConfigModule
|
||||
],
|
||||
providers: [
|
||||
AlfrescoSettingsService,
|
||||
AlfrescoApiService,
|
||||
AlfrescoAuthenticationService,
|
||||
StorageService,
|
||||
{ provide: CookieService, useClass: CookieServiceMock },
|
||||
LogService
|
||||
]);
|
||||
]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
authService = injector.get(AlfrescoAuthenticationService);
|
||||
settingsService = injector.get(AlfrescoSettingsService);
|
||||
cookie = injector.get(CookieService);
|
||||
storage = injector.get(StorageService);
|
||||
beforeEach(() => {
|
||||
apiService = TestBed.get(AlfrescoApiService);
|
||||
authService = TestBed.get(AlfrescoAuthenticationService);
|
||||
settingsService = TestBed.get(AlfrescoSettingsService);
|
||||
cookie = TestBed.get(CookieService);
|
||||
storage = TestBed.get(StorageService);
|
||||
storage.clear();
|
||||
|
||||
jasmine.Ajax.install();
|
||||
@@ -350,32 +359,6 @@ describe('AlfrescoAuthenticationService', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('Setting service change should reflect in the api', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
settingsService.setProviders('ALL');
|
||||
});
|
||||
|
||||
it('should host ecm url change be reflected in the api configuration', () => {
|
||||
settingsService.ecmHost = '127.99.99.99';
|
||||
|
||||
expect(authService.alfrescoApi.getInstance().config.hostEcm).toBe('127.99.99.99');
|
||||
});
|
||||
|
||||
it('should host bpm url change be reflected in the api configuration', () => {
|
||||
settingsService.bpmHost = '127.99.99.99';
|
||||
|
||||
expect(authService.alfrescoApi.getInstance().config.hostBpm).toBe('127.99.99.99');
|
||||
});
|
||||
|
||||
it('should host bpm provider change be reflected in the api configuration', () => {
|
||||
settingsService.setProviders('ECM');
|
||||
|
||||
expect(authService.alfrescoApi.getInstance().config.provider).toBe('ECM');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('when the setting is both ECM and BPM ', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
|
@@ -15,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { ReflectiveInjector } from '@angular/core';
|
||||
import { TestBed, async } from '@angular/core/testing';
|
||||
import { AlfrescoSettingsService } from './alfresco-settings.service';
|
||||
import { AlfrescoAuthenticationService } from './alfresco-authentication.service';
|
||||
import { AlfrescoContentService } from './alfresco-content.service';
|
||||
@@ -24,12 +24,13 @@ import { StorageService } from './storage.service';
|
||||
import { CookieService } from './cookie.service';
|
||||
import { CookieServiceMock } from './../assets/cookie.service.mock';
|
||||
import { LogService } from './log.service';
|
||||
import { AppConfigModule } from './app-config.service';
|
||||
|
||||
declare let jasmine: any;
|
||||
|
||||
describe('AlfrescoContentService', () => {
|
||||
|
||||
let injector, contentService: AlfrescoContentService;
|
||||
let contentService: AlfrescoContentService;
|
||||
let authService: AlfrescoAuthenticationService;
|
||||
let settingsService: AlfrescoSettingsService;
|
||||
let storage: StorageService;
|
||||
@@ -37,8 +38,14 @@ describe('AlfrescoContentService', () => {
|
||||
|
||||
const nodeId = 'fake-node-id';
|
||||
|
||||
beforeEach(() => {
|
||||
injector = ReflectiveInjector.resolveAndCreate([
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
AppConfigModule
|
||||
],
|
||||
declarations: [
|
||||
],
|
||||
providers: [
|
||||
AlfrescoApiService,
|
||||
AlfrescoContentService,
|
||||
AlfrescoAuthenticationService,
|
||||
@@ -46,12 +53,15 @@ describe('AlfrescoContentService', () => {
|
||||
StorageService,
|
||||
{ provide: CookieService, useClass: CookieServiceMock },
|
||||
LogService
|
||||
]);
|
||||
]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
authService = injector.get(AlfrescoAuthenticationService);
|
||||
settingsService = injector.get(AlfrescoSettingsService);
|
||||
contentService = injector.get(AlfrescoContentService);
|
||||
storage = injector.get(StorageService);
|
||||
beforeEach(() => {
|
||||
authService = TestBed.get(AlfrescoAuthenticationService);
|
||||
settingsService = TestBed.get(AlfrescoSettingsService);
|
||||
contentService = TestBed.get(AlfrescoContentService);
|
||||
storage = TestBed.get(StorageService);
|
||||
storage.clear();
|
||||
|
||||
node = {
|
||||
@@ -73,7 +83,7 @@ describe('AlfrescoContentService', () => {
|
||||
|
||||
it('should return a valid content URL', (done) => {
|
||||
authService.login('fake-username', 'fake-password').subscribe(() => {
|
||||
expect(contentService.getContentUrl(node)).toBe('http://localhost:8080/alfresco/api/' +
|
||||
expect(contentService.getContentUrl(node)).toBe('http://localhost:3000/ecm/alfresco/api/' +
|
||||
'-default-/public/alfresco/versions/1/nodes/fake-node-id/content?attachment=false&alf_ticket=fake-post-ticket');
|
||||
done();
|
||||
});
|
||||
@@ -88,7 +98,7 @@ describe('AlfrescoContentService', () => {
|
||||
it('should return a valid thumbnail URL', (done) => {
|
||||
authService.login('fake-username', 'fake-password').subscribe(() => {
|
||||
expect(contentService.getDocumentThumbnailUrl(node))
|
||||
.toBe('http://localhost:8080/alfresco/api/-default-/public/alfresco' +
|
||||
.toBe('http://localhost:3000/ecm/alfresco/api/-default-/public/alfresco' +
|
||||
'/versions/1/nodes/fake-node-id/renditions/doclib/content?attachment=false&alf_ticket=fake-post-ticket');
|
||||
done();
|
||||
});
|
||||
|
@@ -15,35 +15,32 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { TestBed, async } from '@angular/core/testing';
|
||||
import { AppConfigModule } from './app-config.service';
|
||||
import { AlfrescoSettingsService } from './alfresco-settings.service';
|
||||
|
||||
describe('AlfrescoSettingsService', () => {
|
||||
|
||||
let service: AlfrescoSettingsService;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
AppConfigModule
|
||||
],
|
||||
declarations: [
|
||||
],
|
||||
providers: [
|
||||
AlfrescoSettingsService
|
||||
]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
service = new AlfrescoSettingsService();
|
||||
service = TestBed.get(AlfrescoSettingsService);
|
||||
});
|
||||
|
||||
it('should have default ECM host', () => {
|
||||
expect(service.ecmHost).toBe(AlfrescoSettingsService.DEFAULT_ECM_ADDRESS);
|
||||
});
|
||||
|
||||
it('should change host ECM', () => {
|
||||
// this test ensures 'host' getter/setter working properly
|
||||
let address = 'http://192.168.0.1';
|
||||
service.ecmHost = address;
|
||||
expect(service.ecmHost).toBe(address);
|
||||
});
|
||||
|
||||
it('should have default BPM host', () => {
|
||||
expect(service.bpmHost).toBe(AlfrescoSettingsService.DEFAULT_BPM_ADDRESS);
|
||||
});
|
||||
|
||||
it('should change host BPM', () => {
|
||||
// this test ensures 'host' getter/setter working properly
|
||||
let address = 'http://192.168.0.1';
|
||||
service.bpmHost = address;
|
||||
expect(service.bpmHost).toBe(address);
|
||||
it('should be exposed by the module', () => {
|
||||
expect(service).toBeDefined();
|
||||
});
|
||||
});
|
||||
|
@@ -17,31 +17,23 @@
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Subject } from 'rxjs/Subject';
|
||||
import { AppConfigService } from './app-config.service';
|
||||
|
||||
@Injectable()
|
||||
export class AlfrescoSettingsService {
|
||||
|
||||
static DEFAULT_ECM_ADDRESS: string = 'http://' + window.location.hostname + ':8080';
|
||||
static DEFAULT_BPM_ADDRESS: string = 'http://' + window.location.hostname + ':9999';
|
||||
static DEFAULT_CSRF_CONFIG: boolean = false;
|
||||
|
||||
static DEFAULT_BPM_CONTEXT_PATH: string = '/activiti-app';
|
||||
|
||||
private _ecmHost: string = AlfrescoSettingsService.DEFAULT_ECM_ADDRESS;
|
||||
private _bpmHost: string = AlfrescoSettingsService.DEFAULT_BPM_ADDRESS;
|
||||
private _csrfDisabled: boolean = AlfrescoSettingsService.DEFAULT_CSRF_CONFIG;
|
||||
|
||||
private _bpmContextPath = AlfrescoSettingsService.DEFAULT_BPM_CONTEXT_PATH;
|
||||
|
||||
private providers: string = 'ALL'; // ECM, BPM , ALL
|
||||
|
||||
public bpmHostSubject: Subject<string> = new Subject<string>();
|
||||
public ecmHostSubject: Subject<string> = new Subject<string>();
|
||||
public csrfSubject: Subject<boolean> = new Subject<boolean>();
|
||||
public providerSubject: Subject<string> = new Subject<string>();
|
||||
|
||||
constructor(private appConfig: AppConfigService) {}
|
||||
|
||||
public get ecmHost(): string {
|
||||
return this._ecmHost;
|
||||
return this.appConfig.get<string>('ecmHost');
|
||||
}
|
||||
|
||||
public set csrfDisabled(csrfDisabled: boolean) {
|
||||
@@ -49,22 +41,24 @@ export class AlfrescoSettingsService {
|
||||
this._csrfDisabled = csrfDisabled;
|
||||
}
|
||||
|
||||
/* @deprecated in 1.6.0 */
|
||||
public set ecmHost(ecmHostUrl: string) {
|
||||
this.ecmHostSubject.next(ecmHostUrl);
|
||||
this._ecmHost = ecmHostUrl;
|
||||
console.log('AlfrescoSettingsService.ecmHost is deprecated. Use AppConfigService instead.');
|
||||
}
|
||||
|
||||
public get bpmHost(): string {
|
||||
return this._bpmHost;
|
||||
return this.appConfig.get<string>('bpmHost');
|
||||
}
|
||||
|
||||
/* @deprecated in 1.6.0 */
|
||||
public set bpmHost(bpmHostUrl: string) {
|
||||
this.bpmHostSubject.next(bpmHostUrl);
|
||||
this._bpmHost = bpmHostUrl;
|
||||
console.log('AlfrescoSettingsService.bpmHost is deprecated. Use AppConfigService instead.');
|
||||
}
|
||||
|
||||
/* @deprecated in 1.6.0 */
|
||||
public getBPMApiBaseUrl(): string {
|
||||
return this._bpmHost + this._bpmContextPath;
|
||||
console.log('AlfrescoSettingsService.getBPMApiBaseUrl is deprecated.');
|
||||
return this.bpmHost + '/activiti-app';
|
||||
}
|
||||
|
||||
public getProviders(): string {
|
||||
|
@@ -16,7 +16,7 @@
|
||||
*/
|
||||
|
||||
import { Injectable, APP_INITIALIZER, NgModule, ModuleWithProviders } from '@angular/core';
|
||||
import { Http } from '@angular/http';
|
||||
import { HttpModule, Http } from '@angular/http';
|
||||
import { ObjectUtils } from '../utils/object-utils';
|
||||
|
||||
@Injectable()
|
||||
@@ -70,6 +70,9 @@ export function InitAppConfigServiceProvider(resource: string): any {
|
||||
}
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
HttpModule
|
||||
],
|
||||
providers: [
|
||||
AppConfigService
|
||||
]
|
||||
|
@@ -15,6 +15,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { TestBed, async, inject } from '@angular/core/testing';
|
||||
import { Router} from '@angular/router';
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
|
||||
import { AlfrescoSettingsService } from './alfresco-settings.service';
|
||||
import { AlfrescoAuthenticationService } from './alfresco-authentication.service';
|
||||
import { AlfrescoApiService } from './alfresco-api.service';
|
||||
@@ -23,24 +27,29 @@ import { LogService } from './log.service';
|
||||
import { CookieService } from './cookie.service';
|
||||
import { CookieServiceMock } from './../assets/cookie.service.mock';
|
||||
import { AuthGuardBpm } from './auth-guard-bpm.service';
|
||||
import { Router} from '@angular/router';
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
import { TestBed, async, inject } from '@angular/core/testing';
|
||||
import { AppConfigModule } from './app-config.service';
|
||||
|
||||
describe('AuthGuardService BPM', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [AuthGuardBpm,
|
||||
imports: [
|
||||
AppConfigModule,
|
||||
RouterTestingModule
|
||||
],
|
||||
declarations: [
|
||||
],
|
||||
providers: [
|
||||
AuthGuardBpm,
|
||||
AlfrescoSettingsService,
|
||||
AlfrescoApiService,
|
||||
AlfrescoAuthenticationService,
|
||||
StorageService,
|
||||
{ provide: CookieService, useClass: CookieServiceMock },
|
||||
LogService],
|
||||
imports: [RouterTestingModule]
|
||||
});
|
||||
});
|
||||
LogService
|
||||
]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
it('if the alfresco js api is logged in should canActivate be true',
|
||||
async(inject([AuthGuardBpm, Router, AlfrescoSettingsService, StorageService, AlfrescoAuthenticationService], (auth, router, settingsService, storage, authService) => {
|
||||
|
@@ -15,6 +15,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { TestBed, async, inject } from '@angular/core/testing';
|
||||
import { Router} from '@angular/router';
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
|
||||
import { AlfrescoSettingsService } from './alfresco-settings.service';
|
||||
import { AlfrescoAuthenticationService } from './alfresco-authentication.service';
|
||||
import { AlfrescoApiService } from './alfresco-api.service';
|
||||
@@ -23,24 +27,29 @@ import { CookieService } from './cookie.service';
|
||||
import { CookieServiceMock } from './../assets/cookie.service.mock';
|
||||
import { LogService } from './log.service';
|
||||
import { AuthGuardEcm } from './auth-guard-ecm.service';
|
||||
import { Router} from '@angular/router';
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
import { TestBed, async, inject } from '@angular/core/testing';
|
||||
import { AppConfigModule } from './app-config.service';
|
||||
|
||||
describe('AuthGuardService ECM', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [AuthGuardEcm,
|
||||
imports: [
|
||||
AppConfigModule,
|
||||
RouterTestingModule
|
||||
],
|
||||
declarations: [
|
||||
],
|
||||
providers: [
|
||||
AuthGuardEcm,
|
||||
AlfrescoSettingsService,
|
||||
AlfrescoApiService,
|
||||
AlfrescoAuthenticationService,
|
||||
StorageService,
|
||||
{ provide: CookieService, useClass: CookieServiceMock },
|
||||
LogService],
|
||||
imports: [RouterTestingModule]
|
||||
});
|
||||
});
|
||||
LogService
|
||||
]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
it('if the alfresco js api is logged in should canActivate be true',
|
||||
async(inject([AuthGuardEcm, Router, AlfrescoSettingsService, StorageService, AlfrescoAuthenticationService], (auth, router, settingsService, storage, authService) => {
|
||||
|
@@ -15,6 +15,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { TestBed, async, inject } from '@angular/core/testing';
|
||||
import { Router} from '@angular/router';
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
|
||||
import { AlfrescoSettingsService } from './alfresco-settings.service';
|
||||
import { AlfrescoAuthenticationService } from './alfresco-authentication.service';
|
||||
import { AlfrescoApiService } from './alfresco-api.service';
|
||||
@@ -23,24 +27,27 @@ import { CookieService } from './cookie.service';
|
||||
import { CookieServiceMock } from './../assets/cookie.service.mock';
|
||||
import { LogService } from './log.service';
|
||||
import { AuthGuard } from './auth-guard.service';
|
||||
import { Router} from '@angular/router';
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
import { TestBed, async, inject } from '@angular/core/testing';
|
||||
import { AppConfigModule } from './app-config.service';
|
||||
|
||||
describe('AuthGuardService', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [AuthGuard,
|
||||
imports: [
|
||||
AppConfigModule,
|
||||
RouterTestingModule
|
||||
],
|
||||
providers: [
|
||||
AuthGuard,
|
||||
AlfrescoSettingsService,
|
||||
AlfrescoApiService,
|
||||
AlfrescoAuthenticationService,
|
||||
StorageService,
|
||||
{ provide: CookieService, useClass: CookieServiceMock },
|
||||
LogService],
|
||||
imports: [RouterTestingModule]
|
||||
});
|
||||
});
|
||||
LogService
|
||||
]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
it('if the alfresco js api is logged in should canActivate be true',
|
||||
async(inject([AuthGuard, Router, AlfrescoSettingsService, StorageService, AlfrescoAuthenticationService], (auth, router, settingsService, storage, authService) => {
|
||||
|
@@ -15,33 +15,40 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { ReflectiveInjector } from '@angular/core';
|
||||
import { TestBed, async } from '@angular/core/testing';
|
||||
import { AlfrescoApiService } from './alfresco-api.service';
|
||||
import { RenditionsService } from './renditions.service';
|
||||
import { AlfrescoSettingsService } from './alfresco-settings.service';
|
||||
import { StorageService } from './storage.service';
|
||||
import { LogService } from './log.service';
|
||||
import { fakeRedition, fakeReditionCreated, fakeReditionsList } from '../assets/renditionsService.mock';
|
||||
import { AppConfigModule } from './app-config.service';
|
||||
|
||||
declare let jasmine: any;
|
||||
declare let AlfrescoApi: any;
|
||||
|
||||
describe('RenditionsService', () => {
|
||||
let service, injector;
|
||||
let service: RenditionsService;
|
||||
|
||||
beforeEach(() => {
|
||||
injector = ReflectiveInjector.resolveAndCreate([
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
AppConfigModule
|
||||
],
|
||||
declarations: [
|
||||
],
|
||||
providers: [
|
||||
AlfrescoApiService,
|
||||
RenditionsService,
|
||||
AlfrescoSettingsService,
|
||||
StorageService,
|
||||
LogService
|
||||
]);
|
||||
});
|
||||
]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
jasmine.Ajax.install();
|
||||
service = injector.get(RenditionsService);
|
||||
service = TestBed.get(RenditionsService);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
@@ -63,7 +70,7 @@ describe('RenditionsService', () => {
|
||||
|
||||
it('Create redition service should call the server with the ID passed and the asked encoding', (done) => {
|
||||
service.createRendition('fake-node-id', 'pdf').subscribe((res) => {
|
||||
expect(jasmine.Ajax.requests.mostRecent().url).toBe('http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/fake-node-id/renditions');
|
||||
expect(jasmine.Ajax.requests.mostRecent().url).toBe('http://localhost:3000/ecm/alfresco/api/-default-/public/alfresco/versions/1/nodes/fake-node-id/renditions');
|
||||
done();
|
||||
});
|
||||
|
||||
|
@@ -15,30 +15,22 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { TestBed, async } from '@angular/core/testing';
|
||||
import {
|
||||
AlfrescoSettingsService,
|
||||
AlfrescoAuthenticationService,
|
||||
AlfrescoApiService,
|
||||
StorageService,
|
||||
CoreModule,
|
||||
CookieService,
|
||||
AlfrescoContentService,
|
||||
LogService,
|
||||
LogServiceMock
|
||||
} from 'ng2-alfresco-core';
|
||||
import { FileNode } from '../assets/document-library.model.mock';
|
||||
import { CookieServiceMock } from '../../../ng2-alfresco-core/src/assets/cookie.service.mock';
|
||||
import { ReflectiveInjector } from '@angular/core';
|
||||
import { DocumentListService } from './document-list.service';
|
||||
|
||||
declare let jasmine: any;
|
||||
|
||||
describe('DocumentListService', () => {
|
||||
|
||||
let injector;
|
||||
let service: DocumentListService;
|
||||
let settingsService: AlfrescoSettingsService;
|
||||
let authService: AlfrescoAuthenticationService;
|
||||
let alfrescoApiService: AlfrescoApiService;
|
||||
|
||||
let fakeEntryNode = {
|
||||
'entry': {
|
||||
@@ -101,23 +93,21 @@ describe('DocumentListService', () => {
|
||||
}
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
injector = ReflectiveInjector.resolveAndCreate([
|
||||
AlfrescoApiService,
|
||||
AlfrescoAuthenticationService,
|
||||
AlfrescoSettingsService,
|
||||
AlfrescoApiService,
|
||||
AlfrescoContentService,
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
CoreModule
|
||||
],
|
||||
providers: [
|
||||
DocumentListService,
|
||||
StorageService,
|
||||
{ provide: CookieService, useClass: CookieServiceMock },
|
||||
{ provide: LogService, useClass: LogServiceMock }
|
||||
]);
|
||||
]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
settingsService = injector.get(AlfrescoSettingsService);
|
||||
authService = injector.get(AlfrescoAuthenticationService);
|
||||
alfrescoApiService = injector.get(AlfrescoApiService);
|
||||
service = injector.get(DocumentListService);
|
||||
beforeEach(() => {
|
||||
service = TestBed.get(DocumentListService);
|
||||
jasmine.Ajax.install();
|
||||
});
|
||||
|
||||
|
@@ -21,14 +21,7 @@ import { AlfrescoSearchAutocompleteComponent } from './alfresco-search-autocompl
|
||||
import { AlfrescoThumbnailService } from './../services/alfresco-thumbnail.service';
|
||||
import { TranslationMock } from './../assets/translation.service.mock';
|
||||
import { result } from './../assets/alfresco-search.component.mock';
|
||||
import {
|
||||
AlfrescoSettingsService,
|
||||
AlfrescoApiService,
|
||||
AlfrescoAuthenticationService,
|
||||
AlfrescoContentService,
|
||||
AlfrescoTranslationService,
|
||||
CoreModule
|
||||
} from 'ng2-alfresco-core';
|
||||
import { CoreModule, AlfrescoTranslationService } from 'ng2-alfresco-core';
|
||||
import { AlfrescoSearchService } from '../services/alfresco-search.service';
|
||||
|
||||
describe('AlfrescoSearchControlComponent', () => {
|
||||
@@ -42,7 +35,7 @@ describe('AlfrescoSearchControlComponent', () => {
|
||||
window['componentHandler'] = componentHandler;
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
CoreModule
|
||||
CoreModule.forRoot()
|
||||
],
|
||||
declarations: [
|
||||
AlfrescoSearchControlComponent,
|
||||
@@ -51,10 +44,6 @@ describe('AlfrescoSearchControlComponent', () => {
|
||||
providers: [
|
||||
{provide: AlfrescoTranslationService, useClass: TranslationMock},
|
||||
AlfrescoThumbnailService,
|
||||
AlfrescoSettingsService,
|
||||
AlfrescoApiService,
|
||||
AlfrescoAuthenticationService,
|
||||
AlfrescoContentService,
|
||||
AlfrescoSearchService
|
||||
]
|
||||
}).compileComponents().then(() => {
|
||||
@@ -65,7 +54,7 @@ describe('AlfrescoSearchControlComponent', () => {
|
||||
}));
|
||||
|
||||
it('should setup i18n folder', () => {
|
||||
let translationService = fixture.debugElement.injector.get(AlfrescoTranslationService);
|
||||
let translationService = TestBed.get(AlfrescoTranslationService);
|
||||
spyOn(translationService, 'addTranslationFolder');
|
||||
fixture.detectChanges();
|
||||
expect(translationService.addTranslationFolder)
|
||||
@@ -210,7 +199,7 @@ describe('AlfrescoSearchControlComponent', () => {
|
||||
});
|
||||
|
||||
it('should keep find-as-you-type control visible when user tabs into results', (done) => {
|
||||
let searchService = fixture.debugElement.injector.get(AlfrescoSearchService);
|
||||
let searchService = TestBed.get(AlfrescoSearchService);
|
||||
spyOn(searchService, 'getQueryNodesPromise')
|
||||
.and.returnValue(Promise.resolve(result));
|
||||
|
||||
|
@@ -22,17 +22,7 @@ import { Observable } from 'rxjs/Rx';
|
||||
import { AlfrescoSearchComponent } from './alfresco-search.component';
|
||||
import { TranslationMock } from './../assets/translation.service.mock';
|
||||
import { AlfrescoSearchService } from '../services/alfresco-search.service';
|
||||
import {
|
||||
AlfrescoSettingsService,
|
||||
AlfrescoApiService,
|
||||
AlfrescoAuthenticationService,
|
||||
AlfrescoTranslationService,
|
||||
CoreModule,
|
||||
StorageService,
|
||||
CookieService,
|
||||
LogService
|
||||
} from 'ng2-alfresco-core';
|
||||
import { CookieServiceMock } from './../../../ng2-alfresco-core/src/assets/cookie.service.mock';
|
||||
import { AlfrescoTranslationService, CoreModule } from 'ng2-alfresco-core';
|
||||
import { DocumentListModule } from 'ng2-alfresco-documentlist';
|
||||
|
||||
describe('AlfrescoSearchComponent', () => {
|
||||
@@ -114,7 +104,7 @@ describe('AlfrescoSearchComponent', () => {
|
||||
declarations: [AlfrescoSearchComponent], // declare the test component
|
||||
providers: [
|
||||
AlfrescoSearchService,
|
||||
{provide: AlfrescoTranslationService, useClass: TranslationMock}
|
||||
{ provide: AlfrescoTranslationService, useClass: TranslationMock }
|
||||
]
|
||||
}).compileComponents().then(() => {
|
||||
fixture = TestBed.createComponent(AlfrescoSearchComponent);
|
||||
@@ -143,26 +133,8 @@ describe('AlfrescoSearchComponent', () => {
|
||||
expect(search.searchTerm).toBe('exampleTerm692');
|
||||
});
|
||||
|
||||
it('should have a null search term if no query param provided via RouteParams', () => {
|
||||
let injector = ReflectiveInjector.resolveAndCreate([
|
||||
AlfrescoSearchService,
|
||||
AlfrescoAuthenticationService,
|
||||
AlfrescoSettingsService,
|
||||
AlfrescoApiService,
|
||||
StorageService,
|
||||
{ provide: CookieService, useClass: CookieServiceMock },
|
||||
LogService,
|
||||
{provide: ActivatedRoute, useValue: {params: Observable.from([{}])}}
|
||||
]);
|
||||
let search = new AlfrescoSearchComponent(injector.get(AlfrescoSearchService), null, injector.get(ActivatedRoute));
|
||||
|
||||
search.ngOnInit();
|
||||
|
||||
expect(search.searchTerm).toBeNull();
|
||||
});
|
||||
|
||||
it('should setup i18n folder', () => {
|
||||
let translationService = fixture.debugElement.injector.get(AlfrescoTranslationService);
|
||||
let translationService = TestBed.get(AlfrescoTranslationService);
|
||||
spyOn(translationService, 'addTranslationFolder');
|
||||
|
||||
fixture.detectChanges();
|
||||
@@ -198,7 +170,7 @@ describe('AlfrescoSearchComponent', () => {
|
||||
|
||||
it('should display search results when a search term is provided', (done) => {
|
||||
|
||||
let searchService = fixture.debugElement.injector.get(AlfrescoSearchService);
|
||||
let searchService = TestBed.get(AlfrescoSearchService);
|
||||
spyOn(searchService, 'getQueryNodesPromise').and.returnValue(Promise.resolve(result));
|
||||
component.searchTerm = '';
|
||||
|
||||
@@ -219,7 +191,7 @@ describe('AlfrescoSearchComponent', () => {
|
||||
|
||||
it('should display no result if no result are returned', (done) => {
|
||||
|
||||
let searchService = fixture.debugElement.injector.get(AlfrescoSearchService);
|
||||
let searchService = TestBed.get(AlfrescoSearchService);
|
||||
spyOn(searchService, 'getQueryNodesPromise')
|
||||
.and.returnValue(Promise.resolve(noResult));
|
||||
|
||||
@@ -241,7 +213,7 @@ describe('AlfrescoSearchComponent', () => {
|
||||
|
||||
it('should display an error if an error is encountered running the search', (done) => {
|
||||
|
||||
let searchService = fixture.debugElement.injector.get(AlfrescoSearchService);
|
||||
let searchService = TestBed.get(AlfrescoSearchService);
|
||||
spyOn(searchService, 'getQueryNodesPromise')
|
||||
.and.returnValue(Promise.reject(errorJson));
|
||||
|
||||
@@ -266,7 +238,7 @@ describe('AlfrescoSearchComponent', () => {
|
||||
|
||||
it('should update search results when the search term input is changed', (done) => {
|
||||
|
||||
let searchService = fixture.debugElement.injector.get(AlfrescoSearchService);
|
||||
let searchService = TestBed.get(AlfrescoSearchService);
|
||||
spyOn(searchService, 'getQueryNodesPromise')
|
||||
.and.returnValue(Promise.resolve(result));
|
||||
|
||||
@@ -298,7 +270,7 @@ describe('AlfrescoSearchComponent', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
debugElement = fixture.debugElement;
|
||||
searchService = fixture.debugElement.injector.get(AlfrescoSearchService);
|
||||
searchService = TestBed.get(AlfrescoSearchService);
|
||||
querySpy = spyOn(searchService, 'getQueryNodesPromise').and.returnValue(Promise.resolve(result));
|
||||
emitSpy = spyOn(component.preview, 'emit');
|
||||
});
|
||||
|
@@ -15,17 +15,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { ReflectiveInjector } from '@angular/core';
|
||||
import { TestBed, async } from '@angular/core/testing';
|
||||
import { AlfrescoSearchService } from './alfresco-search.service';
|
||||
import {
|
||||
AlfrescoAuthenticationService,
|
||||
AlfrescoSettingsService,
|
||||
AlfrescoApiService,
|
||||
StorageService,
|
||||
CookieService,
|
||||
LogService
|
||||
} from 'ng2-alfresco-core';
|
||||
import { CookieServiceMock } from './../../../ng2-alfresco-core/src/assets/cookie.service.mock';
|
||||
import { CoreModule, AlfrescoApiService } from 'ng2-alfresco-core';
|
||||
import { fakeApi, fakeSearch, fakeError } from '../assets/alfresco-search.service.mock';
|
||||
|
||||
declare let jasmine: any;
|
||||
@@ -34,20 +26,21 @@ describe('AlfrescoSearchService', () => {
|
||||
|
||||
let service: AlfrescoSearchService;
|
||||
let apiService: AlfrescoApiService;
|
||||
let injector: ReflectiveInjector;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
CoreModule
|
||||
],
|
||||
providers: [
|
||||
AlfrescoSearchService
|
||||
]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
injector = ReflectiveInjector.resolveAndCreate([
|
||||
AlfrescoSearchService,
|
||||
AlfrescoSettingsService,
|
||||
AlfrescoApiService,
|
||||
AlfrescoAuthenticationService,
|
||||
StorageService,
|
||||
{ provide: CookieService, useClass: CookieServiceMock },
|
||||
LogService
|
||||
]);
|
||||
service = injector.get(AlfrescoSearchService);
|
||||
apiService = injector.get(AlfrescoApiService);
|
||||
service = TestBed.get(AlfrescoSearchService);
|
||||
apiService = TestBed.get(AlfrescoApiService);
|
||||
spyOn(apiService, 'getInstance').and.returnValue(fakeApi);
|
||||
});
|
||||
|
||||
|
@@ -15,37 +15,27 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { ReflectiveInjector } from '@angular/core';
|
||||
import { TestBed, async } from '@angular/core/testing';
|
||||
import { AlfrescoThumbnailService } from './alfresco-thumbnail.service';
|
||||
import {
|
||||
AlfrescoApiService,
|
||||
AlfrescoAuthenticationService,
|
||||
AlfrescoContentService,
|
||||
AlfrescoSettingsService,
|
||||
StorageService,
|
||||
CookieService,
|
||||
LogService
|
||||
} from 'ng2-alfresco-core';
|
||||
import { CookieServiceMock } from './../../../ng2-alfresco-core/src/assets/cookie.service.mock';
|
||||
import { CoreModule } from 'ng2-alfresco-core';
|
||||
|
||||
describe('AlfrescoThumbnailService', () => {
|
||||
|
||||
let injector: ReflectiveInjector;
|
||||
let service: AlfrescoThumbnailService;
|
||||
|
||||
beforeEach(() => {
|
||||
injector = ReflectiveInjector.resolveAndCreate([
|
||||
AlfrescoApiService,
|
||||
AlfrescoAuthenticationService,
|
||||
AlfrescoContentService,
|
||||
AlfrescoSettingsService,
|
||||
AlfrescoThumbnailService,
|
||||
StorageService,
|
||||
{ provide: CookieService, useClass: CookieServiceMock },
|
||||
LogService
|
||||
]);
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
CoreModule.forRoot()
|
||||
],
|
||||
providers: [
|
||||
AlfrescoThumbnailService
|
||||
]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
service = injector.get(AlfrescoThumbnailService);
|
||||
beforeEach(() => {
|
||||
service = TestBed.get(AlfrescoThumbnailService);
|
||||
});
|
||||
|
||||
it('should return the correct icon for a plain text file', () => {
|
||||
|
@@ -15,35 +15,29 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { ReflectiveInjector } from '@angular/core';
|
||||
import {
|
||||
AlfrescoAuthenticationService,
|
||||
AlfrescoSettingsService,
|
||||
AlfrescoApiService,
|
||||
StorageService,
|
||||
LogService
|
||||
} from 'ng2-alfresco-core';
|
||||
import { TestBed, async } from '@angular/core/testing';
|
||||
import { CoreModule } from 'ng2-alfresco-core';
|
||||
import { RatingService } from '../services/rating.service';
|
||||
|
||||
declare let jasmine: any;
|
||||
|
||||
describe('Rating service', () => {
|
||||
|
||||
let service, injector;
|
||||
let service;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
CoreModule.forRoot()
|
||||
],
|
||||
providers: [
|
||||
RatingService
|
||||
]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
injector = ReflectiveInjector.resolveAndCreate([
|
||||
AlfrescoSettingsService,
|
||||
AlfrescoApiService,
|
||||
AlfrescoAuthenticationService,
|
||||
RatingService,
|
||||
StorageService,
|
||||
LogService
|
||||
]);
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
service = injector.get(RatingService);
|
||||
service = TestBed.get(RatingService);
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
|
@@ -118,7 +118,7 @@ describe('Test ng2-alfresco-tag Tag actions list', () => {
|
||||
deleteButton.click();
|
||||
|
||||
expect(jasmine.Ajax.requests.at(1).url)
|
||||
.toBe('http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/fake-node-id/tags/0ee933fa-57fc-4587-8a77-b787e814f1d2');
|
||||
.toBe('http://localhost:3000/ecm/alfresco/api/-default-/public/alfresco/versions/1/nodes/fake-node-id/tags/0ee933fa-57fc-4587-8a77-b787e814f1d2');
|
||||
expect(jasmine.Ajax.requests.at(1).method).toBe('DELETE');
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
|
@@ -117,7 +117,7 @@ describe('Test ng2-alfresco-tag Tag relative node list', () => {
|
||||
deleteButton.click();
|
||||
|
||||
expect(jasmine.Ajax.requests.mostRecent().url).
|
||||
toBe('http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/fake-node-id/tags/0ee933fa-57fc-4587-8a77-b787e814f1d2');
|
||||
toBe('http://localhost:3000/ecm/alfresco/api/-default-/public/alfresco/versions/1/nodes/fake-node-id/tags/0ee933fa-57fc-4587-8a77-b787e814f1d2');
|
||||
expect(jasmine.Ajax.requests.mostRecent().method).toBe('DELETE');
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
|
@@ -15,35 +15,29 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { ReflectiveInjector } from '@angular/core';
|
||||
import {
|
||||
AlfrescoAuthenticationService,
|
||||
AlfrescoSettingsService,
|
||||
AlfrescoApiService,
|
||||
StorageService,
|
||||
LogService
|
||||
} from 'ng2-alfresco-core';
|
||||
import { TestBed, async } from '@angular/core/testing';
|
||||
import { CoreModule } from 'ng2-alfresco-core';
|
||||
import { TagService } from '../services/tag.service';
|
||||
|
||||
declare let jasmine: any;
|
||||
|
||||
describe('Tag service', () => {
|
||||
|
||||
let service, injector;
|
||||
let service: TagService;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
CoreModule.forRoot()
|
||||
],
|
||||
providers: [
|
||||
TagService
|
||||
]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
injector = ReflectiveInjector.resolveAndCreate([
|
||||
AlfrescoSettingsService,
|
||||
AlfrescoApiService,
|
||||
AlfrescoAuthenticationService,
|
||||
TagService,
|
||||
StorageService,
|
||||
LogService
|
||||
]);
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
service = injector.get(TagService);
|
||||
service = TestBed.get(TagService);
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
@@ -60,7 +54,7 @@ describe('Tag service', () => {
|
||||
service.removeTag('fake-node-id', 'fake-tag').subscribe(() => {
|
||||
expect(jasmine.Ajax.requests.mostRecent().method).toBe('DELETE');
|
||||
expect(jasmine.Ajax.requests.mostRecent().url)
|
||||
.toBe('http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/fake-node-id/tags/fake-tag');
|
||||
.toBe('http://localhost:3000/ecm/alfresco/api/-default-/public/alfresco/versions/1/nodes/fake-node-id/tags/fake-tag');
|
||||
done();
|
||||
});
|
||||
|
||||
@@ -73,7 +67,7 @@ describe('Tag service', () => {
|
||||
service.addTag('fake-node-id', 'fake-tag').subscribe(() => {
|
||||
expect(jasmine.Ajax.requests.mostRecent().method).toBe('POST');
|
||||
expect(jasmine.Ajax.requests.mostRecent().url)
|
||||
.toBe('http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/fake-node-id/tags');
|
||||
.toBe('http://localhost:3000/ecm/alfresco/api/-default-/public/alfresco/versions/1/nodes/fake-node-id/tags');
|
||||
done();
|
||||
});
|
||||
|
||||
@@ -86,7 +80,7 @@ describe('Tag service', () => {
|
||||
service.getAllTheTags().subscribe(() => {
|
||||
expect(jasmine.Ajax.requests.mostRecent().method).toBe('GET');
|
||||
expect(jasmine.Ajax.requests.mostRecent().url)
|
||||
.toBe('http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/tags');
|
||||
.toBe('http://localhost:3000/ecm/alfresco/api/-default-/public/alfresco/versions/1/tags');
|
||||
done();
|
||||
});
|
||||
|
||||
@@ -99,7 +93,7 @@ describe('Tag service', () => {
|
||||
service.getTagsByNodeId('fake-node-id').subscribe(() => {
|
||||
expect(jasmine.Ajax.requests.mostRecent().method).toBe('GET');
|
||||
expect(jasmine.Ajax.requests.mostRecent().url)
|
||||
.toBe('http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/fake-node-id/tags');
|
||||
.toBe('http://localhost:3000/ecm/alfresco/api/-default-/public/alfresco/versions/1/nodes/fake-node-id/tags');
|
||||
done();
|
||||
});
|
||||
|
||||
|
@@ -17,7 +17,7 @@
|
||||
|
||||
import { Component, ElementRef, Input, Output, EventEmitter, OnInit, OnChanges, SimpleChanges } from '@angular/core';
|
||||
import { Observable, Subject } from 'rxjs/Rx';
|
||||
import { AlfrescoApiService, AlfrescoContentService, AlfrescoTranslationService, LogService, NotificationService, AlfrescoSettingsService, FileUtils } from 'ng2-alfresco-core';
|
||||
import { AlfrescoApiService, AlfrescoContentService, AlfrescoTranslationService, LogService, NotificationService, FileUtils } from 'ng2-alfresco-core';
|
||||
import { MinimalNodeEntryEntity } from 'alfresco-js-api';
|
||||
import { UploadService } from '../services/upload.service';
|
||||
import { FileModel } from '../models/file.model';
|
||||
@@ -93,7 +93,6 @@ export class UploadButtonComponent implements OnInit, OnChanges {
|
||||
private translateService: AlfrescoTranslationService,
|
||||
private logService: LogService,
|
||||
private notificationService: NotificationService,
|
||||
private settingsService: AlfrescoSettingsService,
|
||||
private apiService: AlfrescoApiService,
|
||||
private contentService: AlfrescoContentService) {
|
||||
if (translateService) {
|
||||
@@ -102,10 +101,6 @@ export class UploadButtonComponent implements OnInit, OnChanges {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.settingsService.ecmHostSubject.subscribe((hostEcm: string) => {
|
||||
this.checkPermission();
|
||||
});
|
||||
|
||||
this.permissionValue.subscribe((permission: boolean) => {
|
||||
this.hasPermission = permission;
|
||||
});
|
||||
|
@@ -85,7 +85,7 @@ describe('UploadService', () => {
|
||||
service.uploadFilesInTheQueue(emitter);
|
||||
|
||||
let request = jasmine.Ajax.requests.mostRecent();
|
||||
expect(request.url).toBe('http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/-root-/children?autoRename=true');
|
||||
expect(request.url).toBe('http://localhost:3000/ecm/alfresco/api/-default-/public/alfresco/versions/1/nodes/-root-/children?autoRename=true');
|
||||
expect(request.method).toBe('POST');
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
@@ -109,7 +109,7 @@ describe('UploadService', () => {
|
||||
service.addToQueue(fileFake);
|
||||
service.uploadFilesInTheQueue(emitter);
|
||||
expect(jasmine.Ajax.requests.mostRecent().url)
|
||||
.toBe('http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/-root-/children?autoRename=true');
|
||||
.toBe('http://localhost:3000/ecm/alfresco/api/-default-/public/alfresco/versions/1/nodes/-root-/children?autoRename=true');
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
'status': 404,
|
||||
@@ -159,7 +159,7 @@ describe('UploadService', () => {
|
||||
service.uploadFilesInTheQueue(emitter);
|
||||
|
||||
let request = jasmine.Ajax.requests.mostRecent();
|
||||
expect(request.url).toBe('http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/123/children?autoRename=true');
|
||||
expect(request.url).toBe('http://localhost:3000/ecm/alfresco/api/-default-/public/alfresco/versions/1/nodes/123/children?autoRename=true');
|
||||
expect(request.method).toBe('POST');
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
|
@@ -15,35 +15,30 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { ReflectiveInjector } from '@angular/core';
|
||||
import {
|
||||
AlfrescoAuthenticationService,
|
||||
AlfrescoSettingsService,
|
||||
AlfrescoApiService,
|
||||
StorageService,
|
||||
LogService
|
||||
} from 'ng2-alfresco-core';
|
||||
import { TestBed, async } from '@angular/core/testing';
|
||||
import { CoreModule } from 'ng2-alfresco-core';
|
||||
import { BpmUserService } from '../services/bpm-user.service';
|
||||
import { BpmUserModel } from '../models/bpm-user.model';
|
||||
|
||||
declare let jasmine: any;
|
||||
|
||||
describe('Bpm user service', () => {
|
||||
|
||||
let service, injector;
|
||||
let service: BpmUserService;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
CoreModule.forRoot()
|
||||
],
|
||||
providers: [
|
||||
BpmUserService
|
||||
]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
injector = ReflectiveInjector.resolveAndCreate([
|
||||
AlfrescoSettingsService,
|
||||
AlfrescoApiService,
|
||||
AlfrescoAuthenticationService,
|
||||
BpmUserService,
|
||||
StorageService,
|
||||
LogService
|
||||
]);
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
service = injector.get(BpmUserService);
|
||||
service = TestBed.get(BpmUserService);
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
|
@@ -15,19 +15,11 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { TestBed, async } from '@angular/core/testing';
|
||||
import { EcmUserService } from '../services/ecm-user.service';
|
||||
import { fakeEcmUser } from '../assets/fake-ecm-user.service.mock';
|
||||
import { ReflectiveInjector } from '@angular/core';
|
||||
import {
|
||||
AlfrescoAuthenticationService,
|
||||
AlfrescoContentService,
|
||||
AlfrescoSettingsService,
|
||||
AlfrescoApiService,
|
||||
StorageService,
|
||||
CookieService,
|
||||
LogService
|
||||
} from 'ng2-alfresco-core';
|
||||
import { CookieServiceMock } from './../../../ng2-alfresco-core/src/assets/cookie.service.mock';
|
||||
import { CoreModule, AlfrescoAuthenticationService, AlfrescoContentService} from 'ng2-alfresco-core';
|
||||
|
||||
declare let jasmine: any;
|
||||
|
||||
describe('EcmUserService', () => {
|
||||
@@ -35,25 +27,22 @@ describe('EcmUserService', () => {
|
||||
let service: EcmUserService;
|
||||
let authService: AlfrescoAuthenticationService;
|
||||
let contentService: AlfrescoContentService;
|
||||
let injector;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
CoreModule.forRoot()
|
||||
],
|
||||
providers: [
|
||||
EcmUserService
|
||||
]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
injector = ReflectiveInjector.resolveAndCreate([
|
||||
AlfrescoSettingsService,
|
||||
AlfrescoApiService,
|
||||
AlfrescoAuthenticationService,
|
||||
AlfrescoContentService,
|
||||
EcmUserService,
|
||||
StorageService,
|
||||
{ provide: CookieService, useClass: CookieServiceMock },
|
||||
LogService
|
||||
]);
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
service = injector.get(EcmUserService);
|
||||
authService = injector.get(AlfrescoAuthenticationService);
|
||||
contentService = injector.get(AlfrescoContentService);
|
||||
service = TestBed.get(EcmUserService);
|
||||
authService = TestBed.get(AlfrescoAuthenticationService);
|
||||
contentService = TestBed.get(AlfrescoContentService);
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
|
@@ -87,7 +87,7 @@ describe('Test ng2-alfresco-webscript', () => {
|
||||
|
||||
component.ngOnChanges(null).then(() => {
|
||||
fixture.detectChanges();
|
||||
expect(jasmine.Ajax.requests.mostRecent().url).toBe('http://localhost:8080/alfresco/service/sample/folder/Company%20Home');
|
||||
expect(jasmine.Ajax.requests.mostRecent().url).toBe('http://localhost:3000/ecm/alfresco/service/sample/folder/Company%20Home');
|
||||
done();
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user