[ADF-1769] Added JSDocs for services (#2949)

This commit is contained in:
Andy Stark
2018-02-14 14:20:10 +00:00
committed by Eugenio Romano
parent 8bfac2f9f8
commit 9887d8bca4
16 changed files with 182 additions and 54 deletions

View File

@@ -4,6 +4,18 @@ Shows a notification message with optional feedback.
![Notification Service screenshot](docassets/images/NotiService.png) ![Notification Service screenshot](docassets/images/NotiService.png)
## Methods
- `openSnackMessage(message: string, millisecondsDuration?: number): MatSnackBarRef<any>`
Opens a snackbar notification to show a message.
- `message` - The message to show
- `millisecondsDuration` - (Optional) Time before notification disappears after being shown
- `openSnackMessageAction(message: string, action: string, millisecondsDuration?: number): MatSnackBarRef<any>`
Opens a snackbar notification with a message and a response button.
- `message` - The message to show
- `action` - Caption for the response button
- `millisecondsDuration` - (Optional) Time before the notification disappears (unless the button is clicked)
## Details ## Details
The Notification Service is implemented on top of the Angular Material Design snackbar. The Notification Service is implemented on top of the Angular Material Design snackbar.

View File

@@ -4,8 +4,9 @@ Sets the page title.
## Methods ## Methods
`setTitle(value: string = '')`<br/> - `setTitle(value: string = '')`
Sets the page title. Sets the page title.
- `value` - The new title
## Details ## Details

View File

@@ -4,11 +4,12 @@ Gets information about a Content Services user.
## Methods ## Methods
`getPerson(personId: string): Observable<any>`<br/> - `getPerson(personId: string): Observable<any>`
Gets information about a user identified by their username. Gets information about a user identified by their username.
- `personId` - ID of the target user
- `getCurrentPerson(): Observable<any>`
Gets information about the user who is currently logged-in.
`getCurrentPerson(): Observable<any>`<br/>
Gets information about the user who is currently logged-in.
## Details ## Details

View File

@@ -4,17 +4,21 @@ Gets information about Process Services users.
## Methods ## Methods
`getWorkflowUsers(taskId?: string, searchWord?: string): Observable<UserProcessModel[]>`<br/> - `getWorkflowUsers(taskId?: string, searchWord?: string): Observable<UserProcessModel[]>`
Gets information about users across all tasks. Gets information about users across all tasks.
- `taskId` - (Optional) ID of the task
`getUserImage(user: UserProcessModel): string`<br/> - `searchWord` - (Optional) Filter text to search for
Gets the profile picture URL for the specified user. - `getUserImage(user: UserProcessModel): string`
Gets the profile picture URL for the specified user.
`involveUserWithTask(taskId: string, idToInvolve: string): Observable<UserProcessModel[]>`<br/> - `user` - The target user
Sets a user to be involved with a task. - `involveUserWithTask(taskId: string, idToInvolve: string): Observable<UserProcessModel[]>`
Sets a user to be involved with a task.
`removeInvolvedUser(taskId: string, idToRemove: string): Observable<UserProcessModel[]>`<br/> - `taskId` - ID of the target task
Removes a user who is currently involved with a task. - `idToInvolve` - ID of the user to involve
- `removeInvolvedUser(taskId: string, idToRemove: string): Observable<UserProcessModel[]>`
Removes a user who is currently involved with a task.
- `taskId` - ID of the target task
- `idToRemove` - ID of the user to remove
## Details ## Details

View File

@@ -4,14 +4,19 @@ Manages ratings for items in Content Services.
## Methods ## Methods
`getRating(nodeId: string, ratingType: any): any`<br/> - `getRating(nodeId: string, ratingType: any): any`
Gets the current user's rating for a node. Gets the current user's rating for a node.
- `nodeId` - Node to get the rating from
`postRating(nodeId: string, ratingType: any, vote: any): any`<br/> - `ratingType` - Type of rating (can be "likes" or "fiveStar")
Adds the current user's rating for a node. - `postRating(nodeId: string, ratingType: any, vote: any): any`
Adds the current user's rating for a node.
`deleteRating(nodeId: string, ratingType: any): any`<br/> - `nodeId` - Target node for the rating
Removes the current user's rating for a node. - `ratingType` - Type of rating (can be "likes" or "fiveStar")
- `vote` - Rating value (boolean for "likes", numeric 0..5 for "fiveStar")
- `deleteRating(nodeId: string, ratingType: any): any`
Removes the current user's rating for a node.
- `nodeId` - Target node
- `ratingType` - Type of rating to remove (can be "likes" or "fiveStar")
## Details ## Details

View File

@@ -4,8 +4,9 @@ Finds shared links to Content Services items.
## Methods ## Methods
`getSharedLinks(options: any = {}): Observable<NodePaging>`<br/> - `getSharedLinks(options: any = {}): Observable<NodePaging>`
Gets shared links available to the current user. Gets shared links available to the current user.
- `options` - Options supported by JSAPI
## Details ## Details

View File

@@ -4,20 +4,23 @@ Accesses and manipulates sites from a Content Services repository.
## Methods ## Methods
`getSites(opts: any = {}): any`<br/> - `getSites(opts: any = {}): Observable<SitePaging>`
Gets a list of all sites in the repository. Gets a list of all sites in the repository.
- `opts` - Options supported by JSAPI
`getSite(siteId: string, opts?: any): any`<br/> - `getSite(siteId: string, opts?: any): Observable<SiteEntry>`
Gets the details for a site. Gets the details for a site.
- `siteId` - ID of the target site
`deleteSite(siteId: string, permanentFlag: boolean = true): any`<br/> - `opts` - (Optional) Options supported by JSAPI
Deletes a site. - `deleteSite(siteId: string, permanentFlag: boolean = true): Observable<any>`
Deletes a site.
`getSiteContent(siteId: string): Observable<any>`<br/> - `siteId` - Site to delete
Gets a site's content. - `permanentFlag` - True: deletion is permanent; False: site is moved to the trash
- `getSiteContent(siteId: string): Observable<SiteEntry>`
`getSiteMembers(siteId: string): Observable<any>`<br/> Gets a site's content.
Gets a list of all a site's members. - `siteId` - ID of the target site
- `getSiteMembers(siteId: string): Observable<SiteEntry>`
Gets a list of all a site's members.
- `siteId` - ID of the target site
## Details ## Details

View File

@@ -4,20 +4,22 @@ Stores items in the form of key-value pairs.
## Methods ## Methods
`getItem(key: string): string | null` <br/> - `getItem(key: string): string`
Gets an item identified by `key`. Gets an item.
- `key` - Key to identify the item
- `setItem(key: string, data: string)`
Stores an item
- `key` - Key to identify the item
- `data` - Data to store
- `clear()`
Removes all currently stored items.
`setItem(key: string, data: string)` <br/> - `removeItem(key: string)`
Stores an item under `key`. Removes a single item.
- `key` - Key to identify the item
`clear()` <br/> - `hasItem(key: string): boolean`
Removes all currently stored items. Is any item currently stored under `key`?
- `key` - Key identifying item to check
`removeItem(key: string)` <br/>
Removes the item identified by `key`.
`hasItem(key: string): boolean` <br/>
Is any item currently stored under `key`?
## Details ## Details

View File

@@ -28,12 +28,23 @@ export class RatingService {
constructor(private apiService: AlfrescoApiService) { constructor(private apiService: AlfrescoApiService) {
} }
/**
* Gets the current user's rating for a node.
* @param nodeId Node to get the rating from
* @param ratingType Type of rating (can be "likes" or "fiveStar")
*/
getRating(nodeId: string, ratingType: any): any { getRating(nodeId: string, ratingType: any): any {
return Observable.fromPromise(this.apiService.getInstance().core.ratingsApi.getRating(nodeId, ratingType)) return Observable.fromPromise(this.apiService.getInstance().core.ratingsApi.getRating(nodeId, ratingType))
.map(res => res) .map(res => res)
.catch(this.handleError); .catch(this.handleError);
} }
/**
* Adds the current user's rating for a node.
* @param nodeId Target node for the rating
* @param ratingType Type of rating (can be "likes" or "fiveStar")
* @param vote Rating value (boolean for "likes", numeric 0..5 for "fiveStar")
*/
postRating(nodeId: string, ratingType: any, vote: any): any { postRating(nodeId: string, ratingType: any, vote: any): any {
let ratingBody: RatingBody = { let ratingBody: RatingBody = {
'id': ratingType, 'id': ratingType,
@@ -44,6 +55,11 @@ export class RatingService {
.catch(this.handleError); .catch(this.handleError);
} }
/**
* Removes the current user's rating for a node.
* @param nodeId Target node
* @param ratingType Type of rating to remove (can be "likes" or "fiveStar")
*/
deleteRating(nodeId: string, ratingType: any): any { deleteRating(nodeId: string, ratingType: any): any {
return Observable.fromPromise(this.apiService.getInstance().core.ratingsApi.removeRating(nodeId, ratingType)) return Observable.fromPromise(this.apiService.getInstance().core.ratingsApi.removeRating(nodeId, ratingType))
.map(res => res) .map(res => res)

View File

@@ -26,12 +26,23 @@ export class NotificationService {
constructor(public snackbar: MatSnackBar) { constructor(public snackbar: MatSnackBar) {
} }
/**
* Opens a snackbar notification to show a message.
* @param message The message to show
* @param millisecondsDuration Time before notification disappears after being shown
*/
public openSnackMessage(message: string, millisecondsDuration?: number): MatSnackBarRef<any> { public openSnackMessage(message: string, millisecondsDuration?: number): MatSnackBarRef<any> {
return this.snackbar.open(message, null, { return this.snackbar.open(message, null, {
duration: millisecondsDuration || NotificationService.DEFAULT_DURATION_MESSAGE duration: millisecondsDuration || NotificationService.DEFAULT_DURATION_MESSAGE
}); });
} }
/**
* Opens a snackbar notification with a message and a response button.
* @param message The message to show
* @param action Caption for the response button
* @param millisecondsDuration Time before the notification disappears (unless the button is clicked)
*/
public openSnackMessageAction(message: string, action: string, millisecondsDuration?: number): MatSnackBarRef<any> { public openSnackMessageAction(message: string, action: string, millisecondsDuration?: number): MatSnackBarRef<any> {
return this.snackbar.open(message, action, { return this.snackbar.open(message, action, {
duration: millisecondsDuration || NotificationService.DEFAULT_DURATION_MESSAGE duration: millisecondsDuration || NotificationService.DEFAULT_DURATION_MESSAGE

View File

@@ -26,6 +26,10 @@ export class PageTitleService {
private titleService: Title, private titleService: Title,
private appConfig: AppConfigService) {} private appConfig: AppConfigService) {}
/**
* Sets the page title.
* @param value The new title
*/
setTitle(value: string = '') { setTitle(value: string = '') {
const name = this.appConfig.get('application.name') || 'Alfresco ADF Application'; const name = this.appConfig.get('application.name') || 'Alfresco ADF Application';
const title = value ? `${value} - ${name}` : `${name}`; const title = value ? `${value} - ${name}` : `${name}`;

View File

@@ -29,6 +29,10 @@ export class PeopleContentService {
return this.apiService.getInstance().core.peopleApi; return this.apiService.getInstance().core.peopleApi;
} }
/**
* Gets information about a user identified by their username.
* @param personId ID of the target user
*/
getPerson(personId: string): Observable<any> { getPerson(personId: string): Observable<any> {
const { peopleApi, handleError } = this; const { peopleApi, handleError } = this;
const promise = peopleApi.getPerson(personId); const promise = peopleApi.getPerson(personId);
@@ -38,6 +42,7 @@ export class PeopleContentService {
.catch(handleError); .catch(handleError);
} }
/** Gets information about the user who is currently logged-in. */
getCurrentPerson(): Observable<any> { getCurrentPerson(): Observable<any> {
return this.getPerson('-me-'); return this.getPerson('-me-');
} }

View File

@@ -31,6 +31,11 @@ export class PeopleProcessService {
private logService: LogService) { private logService: LogService) {
} }
/**
* Gets information about users across all tasks.
* @param taskId ID of the task
* @param searchWord Filter text to search for
*/
getWorkflowUsers(taskId?: string, searchWord?: string): Observable<UserProcessModel[]> { getWorkflowUsers(taskId?: string, searchWord?: string): Observable<UserProcessModel[]> {
let option = { excludeTaskId: taskId, filter: searchWord }; let option = { excludeTaskId: taskId, filter: searchWord };
return Observable.fromPromise(this.getWorkflowUserApi(option)) return Observable.fromPromise(this.getWorkflowUserApi(option))
@@ -38,16 +43,30 @@ export class PeopleProcessService {
.catch(err => this.handleError(err)); .catch(err => this.handleError(err));
} }
/**
* Gets the profile picture URL for the specified user.
* @param user The target user
*/
getUserImage(user: UserProcessModel): string { getUserImage(user: UserProcessModel): string {
return this.getUserProfileImageApi(user.id); return this.getUserProfileImageApi(user.id);
} }
/**
* Sets a user to be involved with a task.
* @param taskId ID of the target task
* @param idToInvolve ID of the user to involve
*/
involveUserWithTask(taskId: string, idToInvolve: string): Observable<UserProcessModel[]> { involveUserWithTask(taskId: string, idToInvolve: string): Observable<UserProcessModel[]> {
let node = {userId: idToInvolve}; let node = {userId: idToInvolve};
return Observable.fromPromise(this.involveUserToTaskApi(taskId, node)) return Observable.fromPromise(this.involveUserToTaskApi(taskId, node))
.catch(err => this.handleError(err)); .catch(err => this.handleError(err));
} }
/**
* Removes a user who is currently involved with a task.
* @param taskId ID of the target task
* @param idToRemove ID of the user to remove
*/
removeInvolvedUser(taskId: string, idToRemove: string): Observable<UserProcessModel[]> { removeInvolvedUser(taskId: string, idToRemove: string): Observable<UserProcessModel[]> {
let node = {userId: idToRemove}; let node = {userId: idToRemove};
return Observable.fromPromise(this.removeInvolvedUserFromTaskApi(taskId, node)) return Observable.fromPromise(this.removeInvolvedUserFromTaskApi(taskId, node))

View File

@@ -33,6 +33,10 @@ export class SharedLinksApiService {
return this.apiService.getInstance().core.sharedlinksApi; return this.apiService.getInstance().core.sharedlinksApi;
} }
/**
* Gets shared links available to the current user.
* @param options Options supported by JSAPI
*/
getSharedLinks(options: any = {}): Observable<NodePaging> { getSharedLinks(options: any = {}): Observable<NodePaging> {
const { sharedLinksApi, handleError } = this; const { sharedLinksApi, handleError } = this;
const defaultOptions = { const defaultOptions = {

View File

@@ -29,6 +29,10 @@ export class SitesService {
constructor( constructor(
private apiService: AlfrescoApiService) { } private apiService: AlfrescoApiService) { }
/**
* Gets a list of all sites in the repository.
* @param opts Options supported by JSAPI
*/
getSites(opts: any = {}): Observable<SitePaging> { getSites(opts: any = {}): Observable<SitePaging> {
const defaultOptions = { const defaultOptions = {
skipCount: 0, skipCount: 0,
@@ -39,11 +43,21 @@ export class SitesService {
.catch(this.handleError); .catch(this.handleError);
} }
/**
* Gets the details for a site.
* @param siteId ID of the target site
* @param opts Options supported by JSAPI
*/
getSite(siteId: string, opts?: any): Observable<SiteEntry> { getSite(siteId: string, opts?: any): Observable<SiteEntry> {
return Observable.fromPromise(this.apiService.getInstance().core.sitesApi.getSite(siteId, opts)) return Observable.fromPromise(this.apiService.getInstance().core.sitesApi.getSite(siteId, opts))
.catch(this.handleError); .catch(this.handleError);
} }
/**
* Deletes a site.
* @param siteId Site to delete
* @param permanentFlag True: deletion is permanent; False: site is moved to the trash
*/
deleteSite(siteId: string, permanentFlag: boolean = true): Observable<any> { deleteSite(siteId: string, permanentFlag: boolean = true): Observable<any> {
let options: any = {}; let options: any = {};
options.permanent = permanentFlag; options.permanent = permanentFlag;
@@ -51,10 +65,18 @@ export class SitesService {
.catch(this.handleError)); .catch(this.handleError));
} }
/**
* Gets a site's content.
* @param siteId ID of the target site
*/
getSiteContent(siteId: string): Observable<SiteEntry> { getSiteContent(siteId: string): Observable<SiteEntry> {
return this.getSite(siteId, { relations: ['containers'] }); return this.getSite(siteId, { relations: ['containers'] });
} }
/**
* Gets a list of all a site's members.
* @param siteId ID of the target site
*/
getSiteMembers(siteId: string): Observable<SiteEntry> { getSiteMembers(siteId: string): Observable<SiteEntry> {
return this.getSite(siteId, { relations: ['members'] }); return this.getSite(siteId, { relations: ['members'] });
} }

View File

@@ -27,6 +27,10 @@ export class StorageService {
this.useLocalStorage = this.storageAvailable('localStorage'); this.useLocalStorage = this.storageAvailable('localStorage');
} }
/**
* Gets an item.
* @param key Key to identify the item
*/
getItem(key: string): string | null { getItem(key: string): string | null {
if (this.useLocalStorage) { if (this.useLocalStorage) {
return localStorage.getItem(key); return localStorage.getItem(key);
@@ -35,6 +39,11 @@ export class StorageService {
} }
} }
/**
* Stores an item
* @param key Key to identify the item
* @param data Data to store
*/
setItem(key: string, data: string) { setItem(key: string, data: string) {
if (this.useLocalStorage) { if (this.useLocalStorage) {
localStorage.setItem(key, data); localStorage.setItem(key, data);
@@ -43,6 +52,7 @@ export class StorageService {
} }
} }
/** Removes all currently stored items. */
clear() { clear() {
if (this.useLocalStorage) { if (this.useLocalStorage) {
localStorage.clear(); localStorage.clear();
@@ -51,6 +61,10 @@ export class StorageService {
} }
} }
/**
* Removes a single item.
* @param key Key to identify the item
*/
removeItem(key: string) { removeItem(key: string) {
if (this.useLocalStorage) { if (this.useLocalStorage) {
localStorage.removeItem(key); localStorage.removeItem(key);
@@ -59,6 +73,10 @@ export class StorageService {
} }
} }
/**
* Is any item currently stored under `key`?
* @param key Key identifying item to check
*/
hasItem(key: string): boolean { hasItem(key: string): boolean {
if (this.useLocalStorage) { if (this.useLocalStorage) {
return localStorage.getItem(key) ? true : false; return localStorage.getItem(key) ? true : false;