7.3.10 • Published 4 years ago

cockpit-core v7.3.10

Weekly downloads
170
License
-
Repository
-
Last release
4 years ago

cockpit-core

This package provides an Angular library with the core features used by a Cockpit NextGen application. Cockpit NextGen is the name of a set of web applications used by the Scientific Network South Tyrol as intranet portal.

This documentations describes the API of the services that are exposed by the library, if you are interested in developing the library itself, or if you need to understand the content of this code repository, please refer to ./doc/development.md.

The quickest way to get ready to work on a new Cockpit NextGen project is to start from our template project.

Services

It follows an overview of the services available.

Cockpit Service

A general purpose service for app-wide settings and functions.

The service keeps a public reference to three attributes:

  • config: any: Reference to the app config, contained in environment.ts
  • appName: string: Human readable name of the app
  • appIcon: string: The icon of the app - ask Yuval which icons are available, or to add a new one

Note: before being used should be initialized calling init(). This is usually done only once for the app, in app.component in method ngOnInit.

Data Service

DataService is simple way to store any kind of javascript object in the browser's local storage. Stored objects are persisted indefinitely, and can even be accessed by different apps, provided that they reside under the same domain (e.g. cockpit.scientificnet.org). DataService provides two methods:

  • set(key: string, value: any): void: to store any kind of value
  • get<T>(key: string): any: to retrieve a value of a given type T (if nothing is found it returns undefined)
  • remove(key: string): void: to delete an object given its key.

Profile Service

The ProfileService is used to get user-specific data with respect of the current logged or impersonated user. It has two primary purposes:

  • getProfile(): Observable<Profile>: returns an observable to the profile
  • fetchUserPicture(): Observable<any>: returns an observable to a stream of bytes representing the user's picture

Mail Service

The MailService sends email messages. It authenticates against the Microsoft Graph's endpoint with the current logged username (does not support impersonation). It's only interface is send():

send(
  to: string | string[],
  subject: string,
  body: string,
  cc: string | string[] = []
): void

Navigation Service

The navigation in the sidebar can be changed at run-time using NavigationService. You can get the current links in the navigation and you can set new ones. The navigation can also be configured statically, which is preferable if you don't need to change it at run time. See section Configuration in the documentation of the template project.

  • getSidebarLinks(): MenuLink[]
  • setSidebarLinks(links: MenuLink[]): void

Note: in the next release of this template, there will be the possibility to have localized navigation. For the moment just use a default, english, one.

Message Service

The message service allows to dynamically display messages to the end user. Messages are shown in the bottom-right corner of the screen. The Message Service exposes only one method: push().

Messages can be displayed with different severity levels: success, info, warning, danger. The default severity level is "danger".

Messages can optionally have a custom icon. All icons part of Bootstrap's Glyphicons are available. Only the last part of the CSS class has to be taken into account. So, for example, if you use the string "ok", you will get glyphicon glyphicon-ok.

If you pass an error object (e.g. result of a thrown exception), it will be logged in the browser's console, but only if the current user is an administrator.

public push(
  message: string,
  error?: any,
  severity: 'success' | 'info' | 'warning' | 'danger' = 'danger',
  icon: string = 'info-sign'
): void

Automatic handling of error messages

A nice feature offered by ErrorInterceptor, is to automatically push new error messages to the Message Service.
If you add the Error Interceptor to your App module, it will automatically intercept all HTTP traffic that is sent/received using Angular's HttpClient.
By intercepting an HTTP response with an error status (4XX), and containing a header "X-Error-NonBlocking", the interceptor will push a new message to the Message Service.
Therefore, if you can develop your webservice to return a "X-Error-NonBlocking" header in case of error, the response body will automatically shown on the user interface.

Spinner Service

The Spinner Service is used to control the display/hide state of a spinner component: a page-blocking spinning wheel placed in the middle of the page which is used to tell the user that something is loading, and to prevent the user from clicking anything on the page.

The Spinner Service exposes two methods:

  • spin() to start the spinner
  • stop() to stop it

Translation Service

The Translation Service helps you to translate "runtime" translations where the text cannot be captured from the template by the i18n's angular service. An example is when you need to push messages (see Message Service) where the key is passed via typescript. Do not use this service when you can capture the text from the template.

The Translation Service exposes one method:

  • getTranslations() that returns the list of key-values based on your translations.ts of the current language.

Example:

  constructor(private translationSvc: TranslationService) { }

  ngOnInit() {
    const translations = this.translationSvc.getTranslations();
    console.log(translations['hello_world']); // <-- return "Ciao Mondo!" if the current lang is IT
  }

The translations.ts file is located under the folder src/enviroments.

7.3.1-1.beta.6

4 years ago

7.3.11-beta.4

4 years ago

7.3.11-beta.3

4 years ago

7.3.11-beta.2

4 years ago

7.3.10-beta.8

4 years ago

7.3.10-beta.7

4 years ago

7.3.11-beta.1

4 years ago

7.3.11-beta.0

4 years ago

7.3.10

4 years ago

7.3.10-beta.6

4 years ago

7.3.10-beta.5

4 years ago

7.3.10-beta.4

4 years ago

7.3.10-beta.1

4 years ago

7.3.10-beta.0

4 years ago

7.3.10-beta.3

4 years ago

7.3.10-beta.2

4 years ago

7.3.9

4 years ago

7.3.8

4 years ago

7.3.7

4 years ago

7.3.6

4 years ago

7.3.5

4 years ago

7.3.4-beta.0

4 years ago

7.3.4

4 years ago

7.3.3

4 years ago

7.3.2

4 years ago

7.3.1

4 years ago

7.3.1-beta.3

4 years ago

7.3.1-beta.2

4 years ago

7.3.1-beta.1

4 years ago

7.3.1-beta.0

4 years ago

7.3.0-beta.0

4 years ago

7.2.9-beta.3

4 years ago

7.2.9-beta.2

4 years ago

7.2.9-beta.0

4 years ago

7.2.9-beta.1

4 years ago

7.2.8-beta.69

4 years ago

7.2.8-beta.68

4 years ago

7.2.8-beta.67

4 years ago

7.2.8-beta.66

4 years ago

7.2.8-beta.65

4 years ago

7.2.8-beta.64

4 years ago

7.2.8-beta.63

4 years ago

7.2.8-beta.61

4 years ago

7.2.8-beta.6

4 years ago

7.2.8-beta.5

4 years ago

7.2.8-beta.4

4 years ago

7.2.8-beta.3

4 years ago

7.2.8-beta.2

4 years ago

7.2.8-beta.1

4 years ago

7.2.8-beta.0

4 years ago

7.2.7-beta.92

4 years ago

7.2.7-beta.91

4 years ago

7.2.7-beta.9

4 years ago

7.2.7-beta.8

4 years ago

7.2.7-beta.7

4 years ago

7.2.7-beta.6

4 years ago

7.2.7-beta.5

4 years ago

7.2.7-beta.4

4 years ago

7.2.7-beta.3

4 years ago

7.2.7-beta.2

4 years ago

7.2.7-beta.1

4 years ago

7.2.7-beta.0

4 years ago

7.2.6-beta.4

4 years ago

7.2.6-beta.3

4 years ago

7.2.6-beta.2

4 years ago

7.2.6-beta.1

4 years ago

7.2.6-beta.0

4 years ago

7.2.5-beta.9

4 years ago

7.2.5-beta.7

4 years ago

7.2.5-beta.5

4 years ago

7.2.5-beta.4

4 years ago

7.2.5-beta.3

4 years ago

7.2.5-beta.2

4 years ago

7.2.5-beta.1

4 years ago

7.2.5-beta.0

4 years ago

7.2.4

4 years ago

7.2.3-beta.0

4 years ago

7.2.3-beta.1

4 years ago

7.2.3-beta.2

4 years ago

7.2.2

4 years ago

7.2.2-beta.0

4 years ago

7.2.1

4 years ago

7.2.0

4 years ago

7.1.9

5 years ago

7.1.81

5 years ago

7.1.8

5 years ago

7.1.7

5 years ago

7.1.6

5 years ago

7.1.5

5 years ago

7.1.4

5 years ago

7.1.3

5 years ago

7.1.2

5 years ago

0.99.1001

5 years ago

0.99.1000

5 years ago

7.1.1

5 years ago

7.1.0

5 years ago

7.0.9

5 years ago

7.0.8

5 years ago

7.0.7

5 years ago

7.0.6

5 years ago

7.0.5

5 years ago

7.0.4

5 years ago

7.0.3

5 years ago

7.0.1

5 years ago

7.0.0

5 years ago

7.0.0-beta.0

5 years ago

0.99.998

5 years ago

0.99.996

5 years ago

0.99.994

5 years ago

0.99.992

5 years ago

0.99.991

5 years ago

0.99.99

5 years ago

0.99.97

5 years ago

0.99.96

5 years ago

0.99.95

5 years ago

0.99.93

5 years ago

0.99.91

5 years ago

0.99.9

5 years ago

0.99.0

5 years ago

0.10.3

5 years ago

0.10.1

5 years ago

0.10.0

5 years ago

0.9.10

6 years ago

0.9.9

6 years ago

0.2.5

6 years ago

0.2.4

6 years ago

0.2.3

6 years ago

0.2.2

6 years ago

0.2.1

6 years ago

0.2.0

6 years ago

0.1.6

6 years ago

0.1.5

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago

0.0.22

6 years ago

0.0.21

6 years ago

0.0.20

6 years ago

0.0.19

6 years ago

0.0.18

6 years ago

0.0.17

6 years ago

0.0.16

6 years ago

0.0.14

6 years ago

0.0.13

6 years ago

0.0.12

6 years ago

0.0.11

6 years ago

0.0.10

6 years ago

0.0.9

6 years ago

0.0.8

6 years ago

0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago

0.0.0

6 years ago