This will contain examples of how components are used.
the app auth guard is a generic role-checking auth guard than can be used.
The App Auth Guard is applicable on Routes only. you can pass through multiple roles per route as well
{ path: 'feed', component: FeedComponent,
canActivate: [AppAuthGuard], data: {roles: [{ appCode: 500, name: 'Admin' }}
},
{ path: 'manage', component: ManageComponent,
canActivate: [AppAuthGuard], data: {roles: [{ appCode: 500, name: 'Admin' }, { appCode: 3600, name: 'Admin' } }
}
if the users role does not match the provided roles then ueer will be kicked to an unauthorized page.
the default route is /not-authorized
this can be overriden through the config.
The config service based. The ideal place to override config will be from the `app.component.ts' file.
constructor(private wsi: WorldskillsAngularLibService) {
}
ngOnInit() {
const appConfig = this.wsi.appConfigSubject.getValue();
appConfig.notAuthorizedRoute = ['/not-authorized'];
this.wsi.appConfigSubject.next(appConfig);
this.wsi.authConfigSubject.next({
loginUrl: 'http://localhost:50300/oauth/authorize',
clientId: '7221138f6772',
redirectUri: 'http://localhost:4200/home',
userinfoEndpoint: 'http://localhost:8081/users/loggedIn?show_child_roles=false&app_code=500',
oidc: false
});
const httpConfig = this.wsi.httpConfigSubject.getValue();
httpConfig.encoderUriPatterns = [];
httpConfig.authUriPatterns = ['http://localhost:8081'];
this.wsi.httpConfigSubject.next(httpConfig);
const serviceConfig = this.wsi.serviceConfigSubject.getValue();
serviceConfig.appCode = [500];
serviceConfig.apiEndpoint = 'http://localhost:8081';
this.wsi.serviceConfigSubject.next(serviceConfig);
}
The footer component has been made with 6 columns that can be overriden when needed. overriding a column is optional.
<ws-footer
[currentUser]="user"
(loginClick)="login()"
(logoutClick)="logout()"
[isLoggedIn]="isLoggedIn">
</ws-footer>
<!-- Create the template -->
<ng-template #override5>
<h1>Social</h1>
<ul>
<li><a href="https://www.facebook.com/WorldSkills" target="_blank"><i class="fa fa-facebook-official mr-3"></i>Facebook</a></li>
<li><a href="https://twitter.com/WorldSkills" target="_blank"><i class="fa fa-twitter mr-3"></i>Twitter</a></li>
<li><a href="https://www.youtube.com/user/WorldSkillsTV" target="_blank"><i class="fa fa-youtube-play mr-3"></i>YouTube</a></li>
<li><a href="https://www.flickr.com/photos/worldskills/collections/" target="_blank"><i class="fa fa-flickr mr-3"></i>Flickr</a></li>
<li><a href="http://instagram.com/worldskills/" target="_blank"><i class="fa fa-instagram mr-3"></i>Instagram</a></li>
</ul>
</ng-template>
<!-- Inject the custom template into the component -->
<ws-footer
[currentUser]="user"
(loginClick)="login()"
(logoutClick)="logout()"
[isLoggedIn]="isLoggedIn"
[col5Template]="override5">
</ws-footer>
col1Template
col2Template
col3Template
col4Template
col5Template
col6Template
currentUser
: the current logged in user.isLoggedIn
: indicate if the current user is logged in
loginClick
: when the login button is clicked.logoutClick
: when the logout button is clicked
<app-vote-control
[showEditButton]="true"
[showResetButton]="true"
[showDeleteButton]="true"
[poll]="poll"
[results]="results"
[voted]="voted"
(viewChange)="viewChanged($event)"
(voteSelected)="voteSelected($event)"
(edit)="edit($event)"
(reset)="reset($event)"
(delete)="delete($event)">
</app-vote-control>
poll
: an instance off poll-view.results
: an array of result-view instances.voted
: an intance of the voted-view.showEditButton
: weather or not the edit button will show.showResetButton
: weather or not the reset button will show.showDeleteButton
: weather or not the delete button will show.
beforeOptionsTemplate
- appears before the options are dispalyedafterOptionsTemplate
- appears after the options are displayedbeforeResultTemplate
- appears before the results are dispalysafterResultTemplate
- appears after the results are displayedtitleTemplate
- replaces the default title templatefooterTemplate
- replaces the default footer templatequestionTemplate
- replaces the default question template
viewChange
: triggers when the view changes.viewChange(view: string)
- view names:
question
: the question view the lists optionsresult
: the view that shows the results
voteSelected
: trigger when the user votesvoteSelected(optionId: number)
edit
: triggers when the edit button is clickededit(poll: PollView)
reset
: triggers when the reset button is clickedreset(poll: PollView)
delete
: triggers when the delete button is clickeddelete(poll: PollView)
<ws-datetime-picker [(ngModel)]="dateTime" (change)="dateTimeChange($event)"></ws-datetime-picker>
As we touch more parts of the library more documentation would be added.