3.1.25 • Published 2 years ago

@bcone/neo-app-sdk v3.1.25

Weekly downloads
832
License
-
Repository
-
Last release
2 years ago

NEO App SDK

This NPM package contains Bristlecone NEO® starter kit components which includes User Authentication with Single Sign-On and Aws Cognito, Claims Management and Tableau widget.

It contains inbuilt services like AuthGaurd for authorization, Login Service, Message Service, Neoutil Service, HTTP Interceptor Service.

Dependencies

LibraryVersion
@aws-amplify/auth1.2.24
@aws-amplify/core1.0.28
@ng-bootstrap/ng-bootstrap4.2.2
ngx-alerts3.4.5
angular-oauth2-oidc8.0.4
apollo-angular1.8.0
apollo-cache-inmemory1.6.5
apollo-client2.6.8

Creating an app using the NEO® App SDK Starter Kit

If you are creating an app using the NEO® App SDK repo https://github.com/BconeLabs/neo-app-sdk.git then do the following 1. Register your app using NEO® Developer App (https://developer.<tenant>-neo.bcone.com) 2. Create a empty environment configuration with a name. 3. Update the environment.ts with the values configured in above steps

export const environment = {
    ...
    ...
    application_id: '', // Application id used in Step #1 
    config_fetch_env: '', // Environement name used in Step #2
    graphql_url: '' // https://graphql.<tenant>-neo.bcone.com
    ...
}

To override the default app configurations, login to NEO® Developer App and change the following values.

<i>client_id</i> - client id that has access to the cognito pool    
<i>pool_id</i> - cognito pool id that authenticates the user

Creating/Modifying existing angular application

neo-app-sdk@2.1.x is compataible with Angular version 7.2.x . If in your project is using Angular version below 7.2.x please update Angular & typescript using step 1 and 2.

  1. Update Angular core and Angular cli

    ng update @angular/cli@7.2.11 @angular/core@7.2.11
  2. Update typescript version

    npm install --save-dev typescript@3.1.6

If you are creating or modifying an existing app that has not used this npm package follow the below mentioned steps.

  1. Install neo-app-sdk npm package

    npm install --save @bcone/neo-app-sdk
    npm install --save angular-oauth2-oidc@8.0.4  apollo-angular@1.8.0  apollo-cache-inmemory@1.6.5  apollo-client@2.6.8 
  2. Update app.module.ts

    Import the following in app.module.ts

    import { InitConfigService } from '@bcone/neo-app-sdk';
    import { TokenInterceptor } from '@bcone/neo-app-sdk';
    import { MessageService } from '@bcone/neo-app-sdk';
    import { NeoAppsdkLoginModule } from '@bcone/neo-app-sdk';
    import { AuthGuard } from '@bcone/neo-app-sdk';
    import { NeoUtilService } from '@bcone/neo-app-sdk';

    Add the following code in @NgModule imports section

    imports: [
        ...
        ...
        NeoTableauModule,
        NeoAppsdkLoginModule.forRoot(appEnv)
    ]

    Inject following services in @NgModule Providers of app.module.ts

    providers: [
        ...
        ...
        AuthGuard,
        MessageService,
        InitConfigService,
        NeoUtilService,
        {
            provide: APP_INITIALIZER,
            useFactory: (config: InitConfigService) => () => config.load(),
            deps: [InitConfigService],
            multi: true
        },
        {
            provide: HTTP_INTERCEPTORS,
            useClass: TokenInterceptor,
            multi: true
        }
    ]
  3. Create/Update login component

    Create login (do not change the name) component if it does not exist

    ng g c login

    Add login component as a parent

    const routes: Routes = [
        ...
        ...
        {
            path: 'login',
            component: LoginComponent,
        }
    ]

    In login.component.html replace the content with the following directive/component

    <ngx-neo-appsdk-login [enableCognito]="true" [enableSso]="true"></ngx-neo-appsdk-login>

    enableCognito (Boolean) - To enable/disable cognito login

    enableSso (Boolean) - To enable/disable SSO login

  4. Privacy Policy acceptance

    To enable Privacy Policy acceptance use the following tag in app.component.html file

    <ngx-neo-app-privacy-policy [enablePrivacyPolicy]="true"></ngx-neo-app-privacy-policy>

    enablePrivacyPolicy (Boolean) - To enable/disable privacy policy acceptance

  5. Customize default login screen (Optional)

    To customize Login Page UI use html injection. For Sidebar injection use loginSidebar attribute in div tag. For header injection use loginHeader attribute in div tag.

    <ngx-neo-appsdk-login>
        <div loginSidebar>
        // insert login sidebar HTML content here
        </div>
        <div loginHeader>
            // insert login header text here
        </div>
    </ngx-neo-appsdk-login>
  6. Customize default header (Optional)

    To inject custom UI in header, use the following section

    <ngx-neo-app-header>
        <div headerLogo>
            <div class="d-inline">
            <span class="app-logo">
                <img src="<path-to-the-logo>">
            </span>
            </div>
        </div>
        <div navigationLink>
            <ul class="customNav">
            <li>...</li>
            <li>...</li>
            </ul>
        </div>
    </ngx-neo-app-header>
  7. Implement checkFragmentUrl()

    Invoke checkFragmentUrl() if SSO Login is used to display or hide intermediate screen or navigation based on fragment

    ngOnInit() {
        ......
        ......
        if(this.neoUtilService.checkFragmentUrl()) {
                this.showSideBar = true; // Here We enable sidebar during SSO login
        } else {
            this.showSideBar = false; //Here We disable sidebar during SSO login
        }
    }

Tableau Widget

To use Tableau feature import NeoTableauModule in respective components module.ts file

import {  NeoTableauModule } from '@bcone/neo-app-sdk';

imports: [
    ...
    ...
    NeoTableauModule
]

In components html file add the following section

<div *ngIf="tableauConfig" >
<ngx-neo-tableau  [tableauConfig]="tableauConfig"></ngx-neo-tableau>
</div>

In components ts file define tableauConfig

const tableauConfig ={
    userName="",
    tenantName="",
    dashboardPath="",
    tableauProxyApi="",
    tableauServer=""

}

Services

MessageService

MethodTypeDescription
getEnv(keyName)-Provides option to fetch environment data using keyname.
getClaimObj()-Method to fetch ClaimObject of application that contains details such as userClaims, full configuration of app, userInfo, userRoles, tenantinfo.

NeoUtilService

MethodReturn TypeDescription
fetchMenu(graphqlurl: optional)ObservableMethod is used to fetch app menu items. By default it is invoked.
ssoLogin()-To login in to the app using SSO credentials.
checkFragmentUrl()-To avoid intermediate login or Navigation. It returns true or false based on login state.
cognitoSignIn(email,password,initialRoute)-To login in to the app using Cognito credentials. Default value of intialRoute is '/'
isValidAccessToken()booleanTo check if the token is still valid
getAccessToken()stringTo get the access token
getIdToken()stringTo get the id token
getUserClaim()jsonTo get the claim associated with the logged in user
getUserName()stringTo get the full name of the logged in user
getUserEmail()stringTo get the email of the logged in user
getUserRole()stringTo get the role of the logged in user in the app
isCognito()booleanTo check if the login is with SSO or cognito mode. If true it is cognito mode else it is SSO.
signOut()-To logout of the app

Customize redirection to the landing page

If an app wants to redirect logged in user to a different landing page based on custom logic (Based on role, user profile, etc.) use the following approach.

Define custom logic shown below

dynamicRouteFn(claim: any): string {
    // claim contain roles, userprofiles, etc.
    let redirectUrl = '' // Set default url if is not matched
    if(claim.roles && claim.roles.legth > 0) {
        claim.roles.foreach((role) => {
            if(role === 'Developer') {
                redirectUrl = 'developer-landing-url'
            }
            if(role === 'Data-scientist') {
                redirectUrl = 'data-scientist-landing-page';
            }
        });
    }
    return redirectUrl;
}

Inject defined callback function into ssoreturn() method & cognitosignin() of NeoUtilService Class. this.neoUtilService.ssoReturn(this.dynamicRouteFn); this.neoUtilService.cognitoSignIn(this.dynamicRouteFn);

How to use claim object in component or Html

Claims which are permissions on features can be configured in NEO® App Developer.

For configure please follow product handbook below given link https://docs.bristleconeneo.com/202003/neo_handbook/ProviderDeveloper.html

After configuration claim object is available in the below given format based on the role of the user

claims:{ 
      "page.page-name.view":true,
      "entity.entity-name.edit": true,
      "component.component-name.view": true,
   }

Claim object contains three part, first is compononent type like page/component/entity, second consists name of component and last part of claim object contains CRUD(Create, Read, Update & Delete) operation of component of HTML.

For example, the claim for page aboutUs and has view permission. The claim for that particular page would be

page.aboutUs.view = true;

Component conditioning based on claim object can be implemented as below

<app-aboutUs-component *ngIf="page.aboutUs.view"> </app-aboutUs-component>

TableauJS component

TableauJS component is useful to display Tableau Chart using tableau js api. It provide refresh, revert, extract option.

Use

index.html

........
........
 <script src="https://public.tableau.com/javascripts/api/tableau-2.min.js"></script>

Paste the above script in index.html

To use Tableau feature import NeoTableauModule in respective components module.ts file

import {  NeoTableauJSModule } from '@bcone/neo-app-sdk';

imports: [
    ...
    ...
    NeoTableauJSModule
]

In components ts file define tableauConfig

xyz.component.ts

import { NgOnint } from '@angular/common';
.......................
.......................

const declare tableau : any; 


export class XyzComponent implements OnInit {
    ................
    ................
    tableau = tableau;
    tableauConfig
    tabOption = {
        .....
        height: '500px',
        .....
    }

    constructor() {

    }

    ngOninit() {
        const tableauConfig ={
            userName="",
            tenantName="",
            dashboardPath="",
            tableauProxyApi="",
            tableauServer=""
        }
    }
}

In components html file add the following section

xyz.component.html

<div *ngIf="tableauConfig" >
<neo-tableau-js  [tableauConfig]="tableauConfig"  [tableauInstance]="tableau" [tabOption]="tabOption"></ngx-neo-tableau-js>
</div>

Styling button

Refresh, Revert, the export button has refresh-btn, revert-btn, export-btn class with help of css class button can customize according to requirement.

tabOption

NameTypeDescription
disableUrlActionsPopupsboolIndicates whether to suppress the execution of URL actions. This option does not prevent the URL action event from being raised. You can use this option to change what happens when a URL action occurs. If set to trueand you create an event listener for the URL_ACTION event, you can use an event listener handler to customize the actions. For example, you can direct the URL to appear in an iframeon your web page
hideTabsboolIndicates whether tabs are hidden or shown.
hideToolbarboolIndicates whether the toolbar is hidden or shown.
instanceIdToClonestringSpecifies the ID of an existing instance to make a copy (clone) of. This is useful if the user wants to continue analysis of an existing visualization without losing the state of the original. If the ID does not refer to an existing visualization, the cloned version is derived from the original visualization.
heightstringCan be any valid CSS size specifier. If not specified, defaults to the published height of the view.
widthstringCan be any valid CSS size specifier. If not specified, defaults to the published width of the view.
devicestringSpecifies a device layout for a dashboard, if it exists. Values can be default, desktop, tablet, or phone. If not specified, defaults to loading a layout based on the smallest dimension of the hosting iframe element.

|

3.1.25

2 years ago

3.1.24

2 years ago

3.1.23

3 years ago

3.1.22

3 years ago

3.1.21

3 years ago

3.1.20

3 years ago

3.1.19

3 years ago

3.1.18

3 years ago

3.1.17-beta

3 years ago

3.1.17

3 years ago

3.1.14

3 years ago

3.1.13

3 years ago

3.1.16

3 years ago

3.1.15

3 years ago

3.1.12

3 years ago

3.1.11

3 years ago

3.1.10

3 years ago

3.1.9

3 years ago

3.1.9-alphp

3 years ago

3.1.8

3 years ago

3.1.7-alpha

3 years ago

3.1.7

3 years ago

2.2.3-1

3 years ago

2.2.2-alpha

3 years ago

2.2.3

3 years ago

2.2.2

3 years ago

2.2.2-alpha-1

3 years ago

3.1.6

3 years ago

3.1.5

3 years ago

3.1.4

3 years ago

2.2.1

3 years ago

3.1.3

3 years ago

3.1.2

3 years ago

3.1.1

3 years ago

2.2.0

4 years ago

2.1.86

4 years ago

2.1.85

4 years ago

2.1.85-1-beta

4 years ago

2.1.85-beta

4 years ago

2.1.84

4 years ago

2.1.83

4 years ago

2.1.82

4 years ago

2.1.81

4 years ago

2.1.81-azure

4 years ago

2.1.80

4 years ago

2.1.79

4 years ago

2.1.78

4 years ago

2.1.77

4 years ago

2.1.76

4 years ago

3.0.5

4 years ago

3.0.4

4 years ago

4.1.0

4 years ago

4.0.1

4 years ago

3.0.3

4 years ago

3.0.2

4 years ago

2.1.75

4 years ago

3.0.1

4 years ago

3.0.0

4 years ago

2.1.74

4 years ago

2.1.73

4 years ago

2.1.72

4 years ago

2.1.71

4 years ago

2.1.70

4 years ago

2.1.69-beta

4 years ago

2.1.69

4 years ago

2.1.69-alpha

4 years ago

2.1.68

4 years ago

2.1.66-beta-3

4 years ago

2.1.66-beta-1

4 years ago

2.1.66-alpha

4 years ago

2.1.66-beta

4 years ago

2.1.67

4 years ago

2.1.66

4 years ago

2.1.65

4 years ago

2.1.63

4 years ago

2.1.64

4 years ago

2.1.62

4 years ago

2.1.62-beta-6

4 years ago

2.1.62-beta-5

4 years ago

2.1.62-beta-4

4 years ago

2.1.62-beta-3

4 years ago

2.1.62-beta-2

4 years ago

2.1.62-beta-1

4 years ago

2.1.61-beta-2

4 years ago

2.1.61

4 years ago

2.1.61-beta-1

4 years ago

2.1.60

4 years ago

2.1.60-beta-1

4 years ago

2.1.59-beta-4

4 years ago

2.1.59

4 years ago

2.1.59-beta-3

4 years ago

2.1.59-beta-2

4 years ago

2.1.59-beta-1

4 years ago

2.1.59-beta

4 years ago

2.1.58

4 years ago

2.1.57

4 years ago

2.1.56

4 years ago

2.1.43-beta

4 years ago

2.1.55

4 years ago

0.1.4

4 years ago

0.1.2

4 years ago

2.1.54

4 years ago

2.1.53

4 years ago

2.1.52

4 years ago

0.1.1

4 years ago

2.1.49

4 years ago

2.1.51

4 years ago

2.1.47

4 years ago

2.1.48

4 years ago

2.1.46

4 years ago

2.1.45

4 years ago

2.1.45-beta.1

4 years ago

2.1.45-beta.2

4 years ago

2.1.43

4 years ago

2.1.44

4 years ago

2.1.41

4 years ago

2.1.42

4 years ago

2.1.40

4 years ago

2.1.40-b

4 years ago

2.1.39

4 years ago

2.1.39-beta.4

4 years ago

2.1.39-beta.3

4 years ago

2.1.39-beta.2

4 years ago

2.1.3-9.beta.1

4 years ago

2.1.38

4 years ago

2.1.37

4 years ago

2.1.36

4 years ago

2.1.35-beta

4 years ago

2.1.35

4 years ago

2.1.34

4 years ago

2.1.32

4 years ago

2.1.33

4 years ago

2.1.31

4 years ago

2.1.30

4 years ago

2.1.28

4 years ago

2.1.29

4 years ago

2.1.27

4 years ago

2.1.27-rc

4 years ago

2.1.26

4 years ago

2.1.25

4 years ago

2.1.24

4 years ago

2.1.23

4 years ago

2.1.22

4 years ago

2.1.21

4 years ago

2.1.20

4 years ago

2.1.19

4 years ago

2.1.18

4 years ago

2.1.17

5 years ago

2.1.16

5 years ago

2.1.15

5 years ago

2.1.14

5 years ago

2.1.12

5 years ago

2.1.11

5 years ago

2.1.10

5 years ago

2.1.9

5 years ago

1.0.10

5 years ago

2.1.8

5 years ago

2.1.7

5 years ago

2.1.6

5 years ago

2.1.5

5 years ago

2.1.4

5 years ago

2.1.3

5 years ago

2.1.2

5 years ago

2.1.1

5 years ago

2.0.0

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago

0.0.10

5 years ago

0.0.9

5 years ago

0.0.8

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago