npm package: @robertomygo/common-modules
Description: npm install @robertomygo/common-modules
Latest version: 0.0.10

# Common modules

npm install @robertomygo/common-modules

## NPM dependences

"@robertomygo/table"
"@robertomygo/upload"
"@mat-datetimepicker/core"
"@mat-datetimepicker/moment"
"google-libphonenumber"
"intl-tel-input"
"bootstrap":
"bootstrap-select"
"@ng-bootstrap/ng-bootstrap"
"material-design-icons"
"moment"
"ng2-file-upload"
"ngx-daterangepicker-material"
"ngx-intl-tel-input": "~2.2.1"
"ngx-toastr"
"sweetalert2"

## User module

// Add Injection in app.modules providers  

providers: [  
    ...  
    {  
        provide: 'PRODUCT_ID',  
        useValue: 'Your product ID'  
    }  
    ...  
]  

// Add this in themes/default/pages-routing.module.ts

import {UserModule, addressBookRoutes} '@robertomygo/common-modules';

@NgModule({
	imports: [UserModule],  
	exports: [UserModule]  
})
export class CommonUserModule{}

const routes: Routes = [  
    ...  
    {  
        path: addressBookRoutes.USER_ROOT,  
        loadChildren: './pages-routing.module#CommonUserModule'  
    }  
    ...  
]

// And should change all references of UserService as this

import { UserService } from '@robertomygo/common-modules';

class UserGuard implements CanActivate {
    isAllowedManagement(permissionType);
}
class UserService {

    public companyID = null;

    public permissions = [];

    retrieveUser();

    public getUserInMemory():

    public saveUserInMemory(user)

    resetUserInMemory()

    getSelectedCompany()

    public logoutUser()

    public getUsers(payload = null): Promise<any>
    
    public getAdminUsers(payload: any = null): Promise<any>

    public getUserById(userID: string): Promise<UserMessage>

    public delete(userID, notify = 0)

    public deleteFromCompany(userID, notify = 0)

    public add(payload)

    public update(userID, payload)

    getUserByEmail(companyId, productId, email): Promise<any>

    addUserToCompany(companyID, userID): Promise<any>

    addPermission(userID, permission): Promise<any>

    removePermission(userID, permission): Promise<any> {

    updateAllPermission(data): Promise<any>

    setNetState(netState): Promise<any>

    uploadProfileImage(file: File)

    setDefaultLanguage(lang)
}


## Admin Module

// Add this in themes/default/pages-routing.module.ts  

import { AdminModule } from '@robertomygo/common-modules';

@NgModule({  
	imports: [AdminModule],  
	exports: [AdminModule]  
})  
export class CommonAdminModule{}  

const routes: Routes = [  
    ...  
    {  
        path: 'admin',  
        loadChildren: './pages-routing.module#CommonAdminModule'  
    }  
    ...  
]  

// And should change all references of AdminService as this 

import {AdminService} from '@robertomygo/common-modules';

export class AdminService {  

  getPermissionsList(productID = this.productID): Promise<any>

  addPermission(userID, permission)

  removePermission(userID, permission) 

} 


## Group Module

// Add this in themes/default/pages-routing.module.ts  

import { GroupModule } from '@robertomygo/common-modules';

@NgModule({  
	imports: [GroupModule],  
	exports: [GroupModule]  
})  
export class CommonGroupModule{}  

const routes: Routes = [  
    ...  
    {  
        path: 'group',  
        loadChildren: './pages-routing.module#CommonGroupModule'  
    }  
    ...  
]  

// And should change all references of GroupService as this 

import {GroupService} from '@robertomygo/common-modules';

export class GroupService {  

  getAllGroup(payload = null): Promise<any> 

  create(payload): Promise<any>

  delete(groupID): Promise<any>

  getGroupByID(groupID)

  update(groupID, payload)

  addUserToGroup(groupID, userID)

  removeUserFromGroup(groupID, userID)

}