KEYCLOAK-8420: Create Hello React

This commit is contained in:
Stan Silvert 2018-10-08 15:35:40 -04:00
parent 8e57cee30f
commit a8ab1fea58
73 changed files with 654 additions and 7966 deletions

View file

@ -41,7 +41,7 @@
var l18n_msg = {};
</#if>
</script>
<base href="${baseUrl}/">
<link rel="icon" href="${resourceUrl}/app/assets/img/favicon.ico" type="image/x-icon"/>
@ -72,7 +72,6 @@
media="screen, print">
<link href="${resourceUrl}/node_modules/patternfly/dist/css/patternfly-additions.min.css" rel="stylesheet"
media="screen, print">
<link rel="stylesheet" href="${resourceUrl}/node_modules/patternfly-ng/dist/css/patternfly-ng.min.css" media="screen, print">
<script src="${resourceUrl}/node_modules/jquery/dist/jquery.min.js"></script>
<script src="${resourceUrl}/node_modules/bootstrap/dist/js/bootstrap.min.js"></script>
@ -107,11 +106,11 @@
document.head.appendChild(script);
};
keycloak.init({onLoad: 'check-sso'}).success(function(authenticated) {
loadjs("/node_modules/core-js/client/shim.min.js", function() {
loadjs("/node_modules/zone.js/dist/zone.min.js", function() {
loadjs("/node_modules/react/umd/react.development.js", function() {
loadjs("/node_modules/react-dom/umd/react-dom.development.js", function() {
loadjs("/node_modules/systemjs/dist/system.src.js", function() {
loadjs("/systemjs.config.js", function() {
System.import('${resourceUrl}/main.js').catch(function (err) {
System.import('${resourceUrl}/Main.js').catch(function (err) {
console.error(err);
});
if (!keycloak.authenticated) document.getElementById("signInButton").style.visibility='visible';
@ -124,7 +123,9 @@
});
</script>
<div id="main_react_container"></div>
<div id="welcomeScreen">
<!-- Top Navigation -->
<nav class="navbar navbar-pf-alt">
@ -166,7 +167,7 @@
<!-- Home Page -->
<div class="cards-pf" id="welcomeScreen">
<div class="cards-pf">
<div class="text-center" id="welcomeMsg">
<h1>${msg("accountManagementWelcomeMessage")}</h1>
</div>
@ -181,7 +182,7 @@
<div class="card-pf-content col-xs-10 col-sm-12 col-md-12 col-lg-12">
<h2>${msg("personalInfoHtmlTitle")}</h2>
<p class="card-pf-content-intro">${msg("personalInfoIntroMessage")}</p>
<h3 id="personalInfoLink"><a href="${baseUrl}/#/account">${msg("personalInfoHtmlTitle")}</a></h3>
<h3 id="personalInfoLink"><a href="${baseUrl}/#/app/account">${msg("personalInfoHtmlTitle")}</a></h3>
</div>
</div>
</div>
@ -195,10 +196,10 @@
<div class="card-pf-content col-xs-10 col-sm-12 col-md-12 col-lg-12">
<h2>${msg("accountSecurityTitle")}</h2>
<p class="card-pf-content-intro">${msg("accountSecurityIntroMessage")}</p>
<h3 id="changePasswordLink"><a href="${baseUrl}/#/password">${msg("changePasswordHtmlTitle")}</a></h3>
<h3 id="authenticatorLink"><a href="${baseUrl}/#/authenticator">${msg("authenticatorTitle")}</a></h3>
<h3 id="deviceActivityLink"><a href="${baseUrl}/#/device-activity">${msg("deviceActivityHtmlTitle")}</a></h3>
<h3 id="linkedAccountsLink"><a href="${baseUrl}/#/linked-accounts">${msg("linkedAccountsHtmlTitle")}</a></h3>
<h3 id="changePasswordLink"><a href="${baseUrl}/#/app/password">${msg("changePasswordHtmlTitle")}</a></h3>
<h3 id="authenticatorLink"><a href="${baseUrl}/#/app/authenticator">${msg("authenticatorTitle")}</a></h3>
<h3 id="deviceActivityLink"><a href="${baseUrl}/#/app/device-activity">${msg("deviceActivityHtmlTitle")}</a></h3>
<h3 id="linkedAccountsLink"><a href="${baseUrl}/#/app/linked-accounts">${msg("linkedAccountsHtmlTitle")}</a></h3>
</div>
</div>
</div>
@ -212,7 +213,7 @@
<div class="card-pf-content col-xs-10 col-sm-12 col-md-12 col-lg-12">
<h2>${msg("applicationsHtmlTitle")}</h2>
<p class="card-pf-content-intro">${msg("applicationsIntroMessage")}</p>
<h3 id="applicationsLink"><a href="${baseUrl}/#/applications">${msg("applicationsHtmlTitle")}</a></h3>
<h3 id="applicationsLink"><a href="${baseUrl}/#/app/applications">${msg("applicationsHtmlTitle")}</a></h3>
</div>
</div>
</div>
@ -226,7 +227,7 @@
<div class="card-pf-content col-xs-10 col-sm-12 col-md-12 col-lg-12">
<h2>${msg("myResources")}</h2>
<p class="card-pf-content-intro">${msg("resourceIntroMessage")}</p>
<h3 id="myResourcesLink"><a href="${baseUrl}/#/my-resources">${msg("myResources")}</a></h3>
<h3 id="myResourcesLink"><a href="${baseUrl}/#/app/my-resources">${msg("myResources")}</a></h3>
</div>
</div>
</div>
@ -235,22 +236,35 @@
</div>
</div>
</div>
</div>
<script>
var isWelcomePage = function() {
var winHash = window.location.hash;
return winHash.indexOf('#/app') !== 0;
}
var toggleReact = function() {
if (!isWelcomePage()) {
document.getElementById("welcomeScreen").style.display='none';
document.getElementById("main_react_container").style.display='block';
} else {
document.getElementById("welcomeScreen").style.display='block';
document.getElementById("main_react_container").style.display='none';
}
};
</script>
<script>
if (!features.isLinkedAccountsEnabled) {
document.getElementById("linkedAccountsLink").style.display='none';
}
};
if (!features.isMyResourcesEnabled) {
document.getElementById("myResourcesCard").style.display='none';
}
};
var winHash = window.location.hash;
if ((winHash.indexOf('#/') == 0) && (!winHash.indexOf('#/&state') == 0)) {
document.getElementById("welcomeScreen").style.display='none';
}
toggleReact();
</script>
<app-root></app-root>
</body>
</html>

View file

@ -15,22 +15,22 @@
* the License.
*/
import {Injectable} from '@angular/core';
/*import {Injectable} from '@angular/core';
import {Http, Response, RequestOptionsArgs} from '@angular/http';
import {KeycloakNotificationService} from '../notification/keycloak-notification.service';
import {KeycloakService} from '../keycloak-service/keycloak.service';
import {NotificationType} from 'patternfly-ng/notification';
import {NotificationType} from 'patternfly-ng/notification';*/
/**
*
* @author Stan Silvert ssilvert@redhat.com (C) 2017 Red Hat Inc.
*/
@Injectable()
//@Injectable()
export class AccountServiceClient {
private accountUrl: string;
/* private accountUrl: string;
constructor(protected http: Http,
protected kcSvc: KeycloakService,
@ -106,7 +106,7 @@ export class AccountServiceClient {
}
this.kcNotifySvc.notify(message, NotificationType.DANGER, response.json().params);
}
} */
}

View file

@ -1,47 +0,0 @@
/*
* Copyright 2018 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import {KeycloakGuard} from './keycloak-service/keycloak.guard';
import { HomePageComponent } from './content/home-page/home-page.component';
declare const resourceUrl: string;
export const routes: Routes = [
{path: '', canActivateChild:[KeycloakGuard], children: [
{ path: 'account', loadChildren: resourceUrl + '/app/content/account-page/account.module.js#AccountModule' },
{ path: 'password', loadChildren: resourceUrl + '/app/content/password-page/password.module.js#PasswordModule' },
{ path: 'authenticator', loadChildren: resourceUrl + '/app/content/authenticator-page/authenticator.module.js#AuthenticatorModule' },
{ path: 'device-activity', loadChildren: resourceUrl + '/app/content/device-activity-page/device-activity.module.js#DeviceActivityModule' },
{ path: 'sessions', loadChildren: resourceUrl + '/app/content/sessions-page/sessions.module.js#SessionsModule' },
{ path: 'applications', loadChildren: resourceUrl + '/app/content/applications-page/applications.module.js#ApplicationsModule' },
{ path: 'linked-accounts', loadChildren: resourceUrl + '/app/content/linked-accounts-page/linked-accounts.module.js#LinkedAccountsModule' },
{ path: 'my-resources', loadChildren: resourceUrl + '/app/content/my-resources-page/my-resources.module.js#MyResourcesModule' },
{ path: ':**', loadChildren: resourceUrl + '/app/content/page-not-found/page-not-found.module.js#PageNotFoundModule' },
]
}
];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule],
declarations: [HomePageComponent]
})
export class AppRoutingModule {}

View file

@ -1,74 +0,0 @@
/*
* Copyright 2017 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {Component, HostListener} from '@angular/core';
import {Router, NavigationEnd} from '@angular/router';
import 'rxjs/add/observable/of'; // needed for ngx-translate
import {TranslateService} from '@ngx-translate/core';
import {ResponsivenessService, ContentWidthClass, MenuClickListener} from "./responsiveness-service/responsiveness.service";
import {KeycloakService} from "./keycloak-service/keycloak.service";
declare const locale: string;
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent implements MenuClickListener {
private contentWidthClass: ContentWidthClass = this.respSvc.calcSideContentWidthClass();
private showSideNav: boolean = false;
constructor(translate: TranslateService,
private respSvc: ResponsivenessService,
private router: Router,
private kcService: KeycloakService) {
// this language will be used as a fallback when a translation isn't found in the current language
translate.setDefaultLang('en');
// the lang to use, if the lang isn't available, it will use the current loader to get them
translate.use(locale);
this.respSvc.addMenuClickListener(this);
// show side nav if we are past the welcome screen
this.router.events.subscribe(value => {
if (value instanceof NavigationEnd) {
const navEnd = value as NavigationEnd;
console.log(navEnd.url);
if (navEnd.url !== '/') {
this.showSideNav = true;
var welcomeScreen = document.getElementById('welcomeScreen')
// must use removeChild() -- remove() not available on IE 11
if (welcomeScreen) welcomeScreen.parentNode.removeChild(welcomeScreen);
}
}
});
}
public menuClicked() : void {
this.contentWidthClass = this.respSvc.calcSideContentWidthClass();
}
@HostListener('window:resize', ['$event'])
private onResize(event: any) {
this.contentWidthClass = this.respSvc.calcSideContentWidthClass();
}
}

View file

@ -1,82 +0,0 @@
/*
* Copyright 2017 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { RouterModule, Routes } from '@angular/router';
import { LocationStrategy, HashLocationStrategy } from '@angular/common';
import { TranslateLoader } from '@ngx-translate/core';
import { TranslateModule } from '@ngx-translate/core';
import { KeycloakService } from './keycloak-service/keycloak.service';
import { KEYCLOAK_HTTP_PROVIDER } from './keycloak-service/keycloak.http';
import {KeycloakGuard} from './keycloak-service/keycloak.guard';
import {ResponsivenessService} from './responsiveness-service/responsiveness.service';
import {KeycloakNotificationService} from './notification/keycloak-notification.service';
import { AccountServiceClient } from './account-service/account.service';
import {TranslateUtil} from './ngx-translate/translate.util';
import { DeclaredVarTranslateLoader } from './ngx-translate/declared.var.translate.loader';
import { AppComponent } from './app.component';
import {VerticalNavComponent} from './vertical-nav/vertical-nav.component';
import {InlineNotification} from './notification/inline-notification-component';
import { VerticalNavigationModule } from 'patternfly-ng/navigation';
import {InlineNotificationModule} from 'patternfly-ng/notification/inline-notification';
/* Routing Module */
import { AppRoutingModule } from './app-routing.module';
const decs = [
AppComponent,
VerticalNavComponent,
InlineNotification,
];
export const ORIGINAL_INCOMING_URL: Location = window.location;
@NgModule({
declarations: decs,
imports: [
BrowserModule,
FormsModule,
HttpModule,
VerticalNavigationModule,
InlineNotificationModule,
TranslateModule.forRoot({
loader: {provide: TranslateLoader, useClass: DeclaredVarTranslateLoader}
}),
AppRoutingModule,
],
providers: [
KeycloakService,
KeycloakGuard,
KEYCLOAK_HTTP_PROVIDER,
ResponsivenessService,
KeycloakNotificationService,
AccountServiceClient,
TranslateUtil,
{ provide: LocationStrategy, useClass: HashLocationStrategy }
],
bootstrap: [AppComponent]
})
export class AppModule { }

View file

@ -1,71 +0,0 @@
/*
* Copyright 2017 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {Component, OnInit, ViewChild} from '@angular/core';
import {Response} from '@angular/http';
import {FormGroup} from '@angular/forms';
import {Features} from '../../page/features';
import {AccountServiceClient} from '../../account-service/account.service';
declare const features: Features;
@Component({
selector: 'app-account-page',
templateUrl: './account-page.component.html',
styleUrls: ['./account-page.component.css']
})
export class AccountPageComponent implements OnInit {
private isRegistrationEmailAsUsername: boolean = features.isRegistrationEmailAsUsername;
private isEditUserNameAllowed: boolean = features.isEditUserNameAllowed;
@ViewChild('formGroup') private formGroup: FormGroup;
// using ordinary variable here for case where username
// is not editable and not controlled by formGroup
private username: string;
constructor(private accountSvc: AccountServiceClient ) {
accountSvc.doGetRequest("/", (res: Response) => this.handleGetResponse(res));
}
public saveAccount() {
console.log("posting: " + JSON.stringify(this.formGroup.value));
this.accountSvc.doPostRequest("/", (res: Response) => this.handlePostResponse(res), this.formGroup.value);
this.formGroup.reset(this.formGroup.value);
}
protected handleGetResponse(res: Response) {
const response: any = res.json();
this.username = response.username;
this.formGroup.reset(response);
console.log('**** response from account REST API ***');
console.log(JSON.stringify(res));
console.log('*** formGroup ***');
console.log(JSON.stringify(this.formGroup.value));
console.log('***************************************');
}
protected handlePostResponse(res: Response) {
console.log('**** response from account POST ***');
console.log(JSON.stringify(res));
console.log('***************************************');
}
ngOnInit() {
}
}

View file

@ -1,31 +0,0 @@
/*
* Copyright 2018 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { AccountPageComponent } from './account-page.component';
const routes: Routes = [
{ path: '**', component: AccountPageComponent },
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class AccountRoutingModule {}

View file

@ -1,34 +0,0 @@
/*
* Copyright 2018 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { TranslateModule } from '@ngx-translate/core';
import { AccountPageComponent } from './account-page.component';
import { AccountRoutingModule } from './account-routing.module';
@NgModule({
imports: [ CommonModule, FormsModule, TranslateModule, AccountRoutingModule ],
declarations: [ AccountPageComponent ],
providers: [ ]
})
export class AccountModule {}

View file

@ -1,61 +0,0 @@
/*
* Copyright 2017 Red Hat Inc. and/or its affiliates and other contributors
* as indicated by the @author tags. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
import {Application} from './application';
/**
*
* @author Stan Silvert ssilvert@redhat.com (C) 2017 Red Hat Inc.
*/
export abstract class AppCard {
abstract app: Application;
abstract sessions: any[];
/*
protected getName(): string {
if (this.app.hasOwnProperty('name')) {
return this.translateUtil.translate(this.app.name);
}
return this.app.clientId;
}
protected getDescription (): string {
if (!this.app.hasOwnProperty('description')) return null;
let desc: string = this.app.description;
if (desc.indexOf("//icon") > -1) {
desc = desc.substring(0, desc.indexOf("//icon"));
}
return desc;
}*/
protected isSessionActive() : boolean {
for (let session of this.sessions) {
for (let client of session.clients) {
if (this.app.clientId === client.clientId) return true;
}
}
return false;
}
}

View file

@ -1,77 +0,0 @@
/*
* Copyright 2017 Red Hat Inc. and/or its affiliates and other contributors
* as indicated by the @author tags. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
import {TranslateUtil} from '../../ngx-translate/translate.util';
/**
*
* @author Stan Silvert ssilvert@redhat.com (C) 2017 Red Hat Inc.
*/
export class Application {
constructor(private app: any, private translateUtil: TranslateUtil ) {
this.setIcon();
}
private setIcon(): void {
this.app.icon = "pficon-key";
if (!this.app.hasOwnProperty('description')) {
return;
}
let desc: string = this.app.description;
const iconIndex: number = desc.indexOf("//icon=");
if (iconIndex > -1) {
this.app.icon = desc.substring(iconIndex + 7, desc.length);
}
}
public get clientId():string {
return this.app.name;
}
public get name():string {
if (this.app.hasOwnProperty('name')) {
return this.translateUtil.translate(this.app.name);
}
return this.app.clientId;
}
public get description(): string {
if (!this.app.hasOwnProperty('description')) return null;
let desc: string = this.app.description;
if (desc.indexOf("//icon") > -1) {
desc = desc.substring(0, desc.indexOf("//icon"));
}
return desc;
}
public get icon(): string {
return this.app.icon;
}
public get effectiveUrl(): string {
return this.app.effectiveUrl;
}
}

View file

@ -1,95 +0,0 @@
/*
* Copyright 2017 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {Component, OnInit} from '@angular/core';
import {Response} from '@angular/http';
import {TranslateUtil} from '../../ngx-translate/translate.util';
import {AccountServiceClient} from '../../account-service/account.service';
import {Application} from './application';
import {View} from '../widgets/toolbar.component';
import {PropertyLabel} from '../widgets/property.label';
import {ActionButton} from '../widgets/action.button';
import {RefreshButton, Refreshable} from '../widgets/refresh.button';
declare const resourceUrl: string;
type SelectableProperty = "name" | "description";
@Component({
moduleId: module.id, // need this for styleUrls path to work properly with Systemjs
selector: 'app-applications-page',
templateUrl: 'applications-page.component.html',
styleUrls: ['applications-page.component.css']
})
export class ApplicationsPageComponent implements Refreshable, OnInit {
private activeView: View = "LargeCards";
private resourceUrl: string = resourceUrl;
private applications: Application[] = [];
private isSortAscending: boolean = true;
private sortBy: SelectableProperty = "name";
private filterBy: SelectableProperty = "name";
private filterText: string = "";
private propLabels: PropertyLabel[] = [];
private actionButtons: ActionButton[] = [];
private sessions: any[] = [];
constructor(accountSvc: AccountServiceClient, private translateUtil: TranslateUtil) {
this.initPropLabels();
this.actionButtons.push(new RefreshButton(accountSvc,"/applications", this));
accountSvc.doGetRequest("/applications", (res: Response) => this.refresh(res));
accountSvc.doGetRequest("/sessions", (res: Response) => this.handleGetSessionsResponse(res));
}
private initPropLabels(): void {
this.propLabels.push({prop: "name", label: "Name"});
this.propLabels.push({prop: "description", label: "Description"});
}
public refresh(res: Response) {
console.log('**** response from apps REST API ***');
console.log(JSON.stringify(res));
console.log('*** apps res.json() ***');
console.log(JSON.stringify(res.json().applications));
console.log('*************************************');
const newApps: Application[] = [];
for (let app of res.json().applications) {
newApps.push(new Application(app, this.translateUtil));
}
// reference must change to trigger pipes
this.applications = newApps;
}
private handleGetSessionsResponse(res: Response) {
console.log('**** response from sessions REST API ***');
console.log(JSON.stringify(res));
console.log('*** sessions res.json() ***');
console.log(JSON.stringify(res.json()));
console.log('***************************************');
this.sessions = res.json();
}
ngOnInit() {
}
}

View file

@ -1,31 +0,0 @@
/*
* Copyright 2018 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { ApplicationsPageComponent } from './applications-page.component';
const routes: Routes = [
{ path: '**', component: ApplicationsPageComponent },
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class ApplicationsRoutingModule {}

View file

@ -1,44 +0,0 @@
/*
* Copyright 2018 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { TranslateModule } from '@ngx-translate/core';
import {WidgetsModule} from '../widgets/widgets.module';
import { ApplicationsPageComponent } from './applications-page.component';
import { ApplicationsRoutingModule } from './applications-routing.module';
import { LargeAppCardComponent } from './large-app-card.component';
import { SmallAppCardComponent } from './small-app-card.component';
import { RowAppCardComponent } from './row-app-card.component';
@NgModule({
imports: [ CommonModule,
TranslateModule,
ApplicationsRoutingModule,
WidgetsModule ],
declarations: [ ApplicationsPageComponent,
LargeAppCardComponent,
SmallAppCardComponent,
RowAppCardComponent ],
providers: [ ]
})
export class ApplicationsModule {}

View file

@ -1,36 +0,0 @@
/*
* Copyright 2017 Red Hat Inc. and/or its affiliates and other contributors
* as indicated by the @author tags. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
import {Component, Input} from '@angular/core';
import {AppCard} from './app-card';
import {Application} from './application';
/**
*
* @author Stan Silvert ssilvert@redhat.com (C) 2017 Red Hat Inc.
*/
@Component({
moduleId: module.id, // need this for styleUrls path to work properly with Systemjs
selector: 'large-app-card',
templateUrl: 'large-app-card.component.html',
styleUrls: ['large-app-card.component.css']
})
export class LargeAppCardComponent extends AppCard {
@Input() app: Application;
@Input() sessions: any[];
}

View file

@ -1,36 +0,0 @@
/*
* Copyright 2017 Red Hat Inc. and/or its affiliates and other contributors
* as indicated by the @author tags. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
import {Component, Input} from '@angular/core';
import {AppCard} from './app-card';
import {Application} from './application';
/**
*
* @author Stan Silvert ssilvert@redhat.com (C) 2017 Red Hat Inc.
*/
@Component({
moduleId: module.id, // need this for styleUrls path to work properly with Systemjs
selector: 'row-app-card',
templateUrl: 'row-app-card.component.html',
styleUrls: ['row-app-card.component.css']
})
export class RowAppCardComponent extends AppCard {
@Input() app: Application;
@Input() sessions: any[];
}

View file

@ -1,36 +0,0 @@
/*
* Copyright 2017 Red Hat Inc. and/or its affiliates and other contributors
* as indicated by the @author tags. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
import {Component, Input} from '@angular/core';
import {AppCard} from './app-card';
import {Application} from './application';
/**
*
* @author Stan Silvert ssilvert@redhat.com (C) 2017 Red Hat Inc.
*/
@Component({
moduleId: module.id, // need this for styleUrls path to work properly with Systemjs
selector: 'small-app-card',
templateUrl: 'small-app-card.component.html',
styleUrls: ['small-app-card.component.css']
})
export class SmallAppCardComponent extends AppCard {
@Input() app: Application;
@Input() sessions: any[];
}

View file

@ -1,32 +0,0 @@
/*
* Copyright 2017 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {Component, OnInit} from '@angular/core';
@Component({
selector: 'app-authenticator-page',
templateUrl: './authenticator-page.component.html',
styleUrls: ['./authenticator-page.component.css']
})
export class AuthenticatorPageComponent implements OnInit {
constructor() {
}
ngOnInit() {
}
}

View file

@ -1,38 +0,0 @@
/*
* Copyright 2018 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { AuthenticatorPageComponent } from './authenticator-page.component';
import { MobileAuthenticatorSetupPageComponent } from './mobile-authenticator-setup-page.component';
import { BackupCodeSetupPageComponent } from './backup-code-setup-page.component';
import { SMSCodeSetupPageComponent } from './sms-code-setup-page.component';
const routes: Routes = [
{ path: 'authenticator', component: AuthenticatorPageComponent },
{ path: 'mobile-authenticator-setup', component: MobileAuthenticatorSetupPageComponent },
{ path: 'backup-code-setup', component: BackupCodeSetupPageComponent },
{ path: 'sms-code-setup', component: SMSCodeSetupPageComponent },
{ path: '**', component: AuthenticatorPageComponent },
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class AuthenticatorRoutingModule {}

View file

@ -1,39 +0,0 @@
/*
* Copyright 2018 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { TranslateModule } from '@ngx-translate/core';
import { AuthenticatorPageComponent } from './authenticator-page.component';
import { AuthenticatorRoutingModule } from './authenticator-routing.module';
import { MobileAuthenticatorSetupPageComponent } from './mobile-authenticator-setup-page.component';
import { BackupCodeSetupPageComponent } from './backup-code-setup-page.component';
import { SMSCodeSetupPageComponent } from './sms-code-setup-page.component';
@NgModule({
imports: [ CommonModule, TranslateModule, AuthenticatorRoutingModule ],
declarations: [ AuthenticatorPageComponent,
MobileAuthenticatorSetupPageComponent,
BackupCodeSetupPageComponent,
SMSCodeSetupPageComponent ],
providers: [ ]
})
export class AuthenticatorModule {}

View file

@ -1,32 +0,0 @@
/*
* Copyright 2018 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {Component, OnInit} from '@angular/core';
@Component({
selector: 'app-backup-code-setup-page',
templateUrl: './backup-code-setup-page.component.html',
styleUrls: ['./backup-code-setup-page.component.css']
})
export class BackupCodeSetupPageComponent implements OnInit {
constructor() {
}
ngOnInit() {
}
}

View file

@ -1,36 +0,0 @@
/*
* Copyright 2018 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {Component, OnInit} from '@angular/core';
declare const resourceUrl: string;
@Component({
selector: 'app-mobile-authenticator-setup-page',
templateUrl: './mobile-authenticator-setup-page.component.html',
styleUrls: ['./mobile-authenticator-setup-page.component.css']
})
export class MobileAuthenticatorSetupPageComponent implements OnInit {
private resourceUrl: string = resourceUrl;
constructor() {
}
ngOnInit() {
}
}

View file

@ -1,32 +0,0 @@
/*
* Copyright 2018 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {Component, OnInit} from '@angular/core';
@Component({
selector: 'app-sms-code-setup-page',
templateUrl: './sms-code-setup-page.component.html',
styleUrls: ['./sms-code-setup-page.component.css']
})
export class SMSCodeSetupPageComponent implements OnInit {
constructor() {
}
ngOnInit() {
}
}

View file

@ -1,48 +0,0 @@
/*
* Copyright 2017 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {Component, OnInit, ViewChild} from '@angular/core';
import {Response} from '@angular/http';
import {FormGroup} from '@angular/forms';
import {AccountServiceClient} from '../../account-service/account.service';
@Component({
selector: 'app-device-activity-page',
templateUrl: './device-activity-page.component.html',
styleUrls: ['./device-activity-page.component.css']
})
export class DeviceActivityPageComponent implements OnInit {
@ViewChild('formGroup') private formGroup: FormGroup;
constructor(private accountSvc: AccountServiceClient) {
}
public deviceActivity() {
console.log("posting: " + JSON.stringify(this.formGroup.value));
this.accountSvc.doPostRequest("/device-activity", (res: Response) => this.handlePostResponse(res), this.formGroup.value);
}
protected handlePostResponse(res: Response) {
console.log('**** response from account POST ***');
console.log(JSON.stringify(res));
console.log('***************************************');
}
ngOnInit() {
}
}

View file

@ -1,31 +0,0 @@
/*
* Copyright 2018 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { DeviceActivityPageComponent } from './device-activity-page.component';
const routes: Routes = [
{ path: '**', component: DeviceActivityPageComponent },
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class DeviceActivityRoutingModule {}

View file

@ -1,34 +0,0 @@
/*
* Copyright 2018 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { TranslateModule } from '@ngx-translate/core';
import { DeviceActivityPageComponent } from './device-activity-page.component';
import { DeviceActivityRoutingModule } from './device-activity-routing.module';
@NgModule({
imports: [ CommonModule, FormsModule, TranslateModule, DeviceActivityRoutingModule ],
declarations: [ DeviceActivityPageComponent ],
providers: [ ]
})
export class DeviceActivityModule {}

View file

@ -1,28 +0,0 @@
/*
* Copyright 2017 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {Component} from '@angular/core';
@Component({
selector: 'home-page',
templateUrl: './home-page.component.html',
styleUrls: ['./home-page.component.css']
})
export class HomePageComponent {
constructor() {}
}

View file

@ -1,32 +0,0 @@
/*
* Copyright 2018 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {Component, OnInit} from '@angular/core';
@Component({
selector: 'app-linked-accounts-page',
templateUrl: './linked-accounts-page.component.html',
styleUrls: ['./linked-accounts-page.component.css']
})
export class LinkedAccountsPageComponent implements OnInit {
constructor() {
}
ngOnInit() {
}
}

View file

@ -1,31 +0,0 @@
/*
* Copyright 2018 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { LinkedAccountsPageComponent } from './linked-accounts-page.component';
const routes: Routes = [
{ path: '**', component: LinkedAccountsPageComponent },
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class LinkedAccountsRoutingModule {}

View file

@ -1,34 +0,0 @@
/*
* Copyright 2018 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { TranslateModule } from '@ngx-translate/core';
import { LinkedAccountsPageComponent } from './linked-accounts-page.component';
import { LinkedAccountsRoutingModule } from './linked-accounts-routing.module';
@NgModule({
imports: [ CommonModule, FormsModule, TranslateModule, LinkedAccountsRoutingModule ],
declarations: [ LinkedAccountsPageComponent ],
providers: [ ]
})
export class LinkedAccountsModule {}

View file

@ -1,32 +0,0 @@
/*
* Copyright 2018 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {Component, OnInit} from '@angular/core';
@Component({
selector: 'app-my-resources-detail-page',
templateUrl: './my-resources-detail-page.component.html',
styleUrls: ['./my-resources-detail-page.component.css']
})
export class MyResourcesDetailPageComponent implements OnInit {
constructor() {
}
ngOnInit() {
}
}

View file

@ -1,32 +0,0 @@
/*
* Copyright 2018 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {Component, OnInit} from '@angular/core';
@Component({
selector: 'app-my-resources-page',
templateUrl: './my-resources-page.component.html',
styleUrls: ['./my-resources-page.component.css']
})
export class MyResourcesPageComponent implements OnInit {
constructor() {
}
ngOnInit() {
}
}

View file

@ -1,38 +0,0 @@
/*
* Copyright 2018 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { MyResourcesPageComponent } from './my-resources-page.component';
import { MyResourcesDetailPageComponent } from './my-resources-detail-page.component';
import { SharedWithMePageComponent } from './shared-with-me-page.component';
import { SharedWithMeDetailPageComponent } from './shared-with-me-detail-page.component';
const routes: Routes = [
{ path: 'my-resources', component: MyResourcesPageComponent },
{ path: 'my-resources-detail', component: MyResourcesDetailPageComponent },
{ path: 'shared-with-me', component: SharedWithMePageComponent },
{ path: 'shared-with-me-detail', component: SharedWithMeDetailPageComponent },
{ path: '**', component: MyResourcesPageComponent },
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class MyResourcesRoutingModule {}

View file

@ -1,41 +0,0 @@
/*
* Copyright 2018 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { TranslateModule } from '@ngx-translate/core';
import { MyResourcesRoutingModule } from './my-resources-routing.module';
import { MyResourcesPageComponent } from './my-resources-page.component';
import { MyResourcesDetailPageComponent } from './my-resources-detail-page.component';
import { SharedWithMePageComponent } from './shared-with-me-page.component';
import { SharedWithMeDetailPageComponent } from './shared-with-me-detail-page.component';
@NgModule({
imports: [ CommonModule, FormsModule, TranslateModule, MyResourcesRoutingModule ],
declarations: [ MyResourcesPageComponent,
MyResourcesDetailPageComponent,
SharedWithMePageComponent,
SharedWithMeDetailPageComponent ],
providers: [ ]
})
export class MyResourcesModule {}

View file

@ -1,32 +0,0 @@
/*
* Copyright 2018 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {Component, OnInit} from '@angular/core';
@Component({
selector: 'app-shared-with-me-detail-page',
templateUrl: './shared-with-me-detail-page.component.html',
styleUrls: ['./shared-with-me-detail-page.component.css']
})
export class SharedWithMeDetailPageComponent implements OnInit {
constructor() {
}
ngOnInit() {
}
}

View file

@ -1,32 +0,0 @@
/*
* Copyright 2018 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {Component, OnInit} from '@angular/core';
@Component({
selector: 'app-shared-with-me-page',
templateUrl: './shared-with-me-page.component.html',
styleUrls: ['./shared-with-me-page.component.css']
})
export class SharedWithMePageComponent implements OnInit {
constructor() {
}
ngOnInit() {
}
}

View file

@ -1,31 +0,0 @@
/*
* Copyright 2018 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { PageNotFoundComponent } from './page-not-found.component';
const routes: Routes = [
{ path: '**', component: PageNotFoundComponent}
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class PageNotFoundRoutingModule {}

View file

@ -1,32 +0,0 @@
/*
* Copyright 2017 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {Component, OnInit} from '@angular/core';
@Component({
selector: 'app-page-not-found',
templateUrl: './page-not-found.component.html',
styleUrls: ['./page-not-found.component.css']
})
export class PageNotFoundComponent implements OnInit {
constructor() {
}
ngOnInit() {
}
}

View file

@ -1,34 +0,0 @@
/*
* Copyright 2018 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { TranslateModule } from '@ngx-translate/core';
import { PageNotFoundComponent } from './page-not-found.component';
import { PageNotFoundRoutingModule } from './page-not-found-routing.module';
@NgModule({
imports: [ CommonModule, FormsModule, TranslateModule, PageNotFoundRoutingModule ],
declarations: [ PageNotFoundComponent ],
providers: [ ]
})
export class PageNotFoundModule {}

View file

@ -1,79 +0,0 @@
/*
* Copyright 2017 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {Component, OnInit, ViewChild, Renderer2} from '@angular/core';
import {Response} from '@angular/http';
import {FormGroup} from '@angular/forms';
import {NotificationType} from 'patternfly-ng/notification';
import {AccountServiceClient} from '../../account-service/account.service';
import {KeycloakNotificationService} from '../../notification/keycloak-notification.service';
@Component({
selector: 'app-password-page',
templateUrl: './password-page.component.html',
styleUrls: ['./password-page.component.css']
})
export class PasswordPageComponent implements OnInit {
@ViewChild('formGroup') private formGroup: FormGroup;
private lastPasswordUpdate: number;
constructor(private accountSvc: AccountServiceClient,
private renderer: Renderer2,
protected kcNotifySvc: KeycloakNotificationService,) {
this.accountSvc.doGetRequest("/credentials/password", (res: Response) => this.handleGetResponse(res));
}
public changePassword() {
console.log("posting: " + JSON.stringify(this.formGroup.value));
if (!this.confirmationMatches()) return;
this.accountSvc.doPostRequest("/credentials/password", (res: Response) => this.handlePostResponse(res), this.formGroup.value);
this.renderer.selectRootElement('#password').focus();
}
private confirmationMatches(): boolean {
const newPassword: string = this.formGroup.value['newPassword'];
const confirmation: string = this.formGroup.value['confirmation'];
const matches: boolean = newPassword === confirmation;
if (!matches) {
this.kcNotifySvc.notify('notMatchPasswordMessage', NotificationType.DANGER)
}
return matches;
}
protected handlePostResponse(res: Response) {
console.log('**** response from password POST ***');
console.log(JSON.stringify(res));
console.log('***************************************');
this.formGroup.reset();
this.accountSvc.doGetRequest("/credentials/password", (res: Response) => this.handleGetResponse(res));
}
protected handleGetResponse(res: Response) {
console.log('**** response from password GET ***');
console.log(JSON.stringify(res));
console.log('***************************************');
this.lastPasswordUpdate = res.json()['lastUpdate'];
}
ngOnInit() {
}
}

View file

@ -1,31 +0,0 @@
/*
* Copyright 2018 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { PasswordPageComponent } from './password-page.component';
const routes: Routes = [
{ path: '**', component: PasswordPageComponent },
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class PasswordRoutingModule {}

View file

@ -1,34 +0,0 @@
/*
* Copyright 2018 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { TranslateModule } from '@ngx-translate/core';
import { PasswordPageComponent } from './password-page.component';
import { PasswordRoutingModule } from './password-routing.module';
@NgModule({
imports: [ CommonModule, FormsModule, TranslateModule, PasswordRoutingModule ],
declarations: [ PasswordPageComponent ],
providers: [ ]
})
export class PasswordModule {}

View file

@ -1,34 +0,0 @@
/*
* Copyright 2017 Red Hat Inc. and/or its affiliates and other contributors
* as indicated by the @author tags. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
import {Component, Input} from '@angular/core';
import {Session} from './session';
/**
*
* @author Stan Silvert ssilvert@redhat.com (C) 2017 Red Hat Inc.
*/
@Component({
moduleId: module.id, // need this for styleUrls path to work properly with Systemjs
selector: 'large-session-card',
templateUrl: 'large-session-card.component.html',
styleUrls: ['large-session-card.component.css']
})
export class LargeSessionCardComponent {
@Input() session: Session;
}

View file

@ -1,35 +0,0 @@
/*
* Copyright 2017 Red Hat Inc. and/or its affiliates and other contributors
* as indicated by the @author tags. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
import {Component, Input} from '@angular/core';
import {Session} from './session';
/**
*
* @author Stan Silvert ssilvert@redhat.com (C) 2017 Red Hat Inc.
*/
@Component({
moduleId: module.id, // need this for styleUrls path to work properly with Systemjs
selector: 'row-session-card',
templateUrl: 'row-session-card.component.html',
styleUrls: ['row-session-card.component.css']
})
export class RowSessionCardComponent {
@Input() sessions: Session[];
}

View file

@ -1,47 +0,0 @@
/*
* Copyright 2017 Red Hat Inc. and/or its affiliates and other contributors
* as indicated by the @author tags. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
/**
*
* @author Stan Silvert ssilvert@redhat.com (C) 2017 Red Hat Inc.
*/
export class Session {
constructor(private session: any) {}
get ipAddress(): string {
return this.session.ipAddress;
}
get started(): number {
return this.session.started;
}
get lastAccess(): number {
return this.session.lastAccess;
}
get expires(): number {
return this.session.expires;
}
get clients(): string[] {
return this.session.clients;
}
}

View file

@ -1,115 +0,0 @@
/*
* Copyright 2017 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {Component, OnInit} from '@angular/core';
import {Response} from '@angular/http';
import {AccountServiceClient} from '../../account-service/account.service';
import {TranslateUtil} from '../../ngx-translate/translate.util';
import {View} from '../widgets/toolbar.component';
import {PropertyLabel} from '../widgets/property.label';
import {ActionButton} from '../widgets/action.button';
import {RefreshButton, Refreshable} from '../widgets/refresh.button';
import {Session} from './session';
@Component({
selector: 'app-sessions-page',
templateUrl: './sessions-page.component.html',
styleUrls: ['./sessions-page.component.css']
})
export class SessionsPageComponent implements Refreshable, OnInit {
private filterLabels: PropertyLabel[] = [];
private sortLabels: PropertyLabel[] = [];
private response: any[] = [];
private sessions: Session[] = [];
private actionButtons: ActionButton[] = [];
constructor(private accountSvc: AccountServiceClient, private translateUtil: TranslateUtil ) {
this.initPropLabels();
this.actionButtons.push(new LogoutAllButton(accountSvc, translateUtil));
this.actionButtons.push(new RefreshButton(accountSvc,"/sessions", this));
accountSvc.doGetRequest("/sessions", (res: Response) => this.refresh(res));
}
private initPropLabels(): void {
this.filterLabels.push({prop: "ipAddress", label: "IP"});
this.sortLabels.push({prop: "ipAddress", label: "IP"});
this.sortLabels.push({prop: "started", label: "Started"});
this.sortLabels.push({prop: "lastAccess", label: "Last Access"});
this.sortLabels.push({prop: "expires", label: "Expires"});
}
public refresh(res: Response) {
console.log('**** response from account REST API ***');
console.log(JSON.stringify(res));
console.log('*** res.json() ***');
console.log(JSON.stringify(res.json()));
console.log('***************************************');
this.response = res.json();
const newSessions: Session[] = [];
for (let session of res.json()) {
newSessions.push(new Session(session));
}
// reference must change to trigger pipes
this.sessions = newSessions;
}
private logoutAllSessions() {
this.accountSvc.doDelete("/sessions",
(res: Response) => this.handleLogoutResponse(res),
{params: {current: true}},
"Logging out all sessions.");
}
private handleLogoutResponse(res: Response) {
console.log('**** response from account DELETE ***');
console.log(JSON.stringify(res));
console.log('***************************************');
}
ngOnInit() {
}
}
class LogoutAllButton implements ActionButton {
public readonly label: string = "Logout All"; //TODO: localize in constructor
public readonly tooltip: string;
constructor(private accountSvc: AccountServiceClient, translateUtil: TranslateUtil ) {
this.tooltip = translateUtil.translate('doLogOutAllSessions');
}
performAction(): void {
this.accountSvc.doDelete("/sessions",
(res: Response) => this.handleLogoutResponse(res),
{params: {current: true}},
"Logging out all sessions.");
}
private handleLogoutResponse(res: Response) {
console.log('**** response from account DELETE ***');
console.log(JSON.stringify(res));
console.log('***************************************');
}
}

View file

@ -1,31 +0,0 @@
/*
* Copyright 2018 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { SessionsPageComponent } from './sessions-page.component';
const routes: Routes = [
{ path: '**', component: SessionsPageComponent },
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class SessionsRoutingModule {}

View file

@ -1,43 +0,0 @@
/*
* Copyright 2018 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { TranslateModule } from '@ngx-translate/core';
import {WidgetsModule} from '../widgets/widgets.module';
import { SessionsRoutingModule } from './sessions-routing.module';
import { SessionsPageComponent } from './sessions-page.component';
import { LargeSessionCardComponent } from './large-session-card.component';
import { SmallSessionCardComponent } from './small-session-card.component';
@NgModule({
imports: [ CommonModule,
TranslateModule,
SessionsRoutingModule,
WidgetsModule ],
declarations: [ SessionsPageComponent,
LargeSessionCardComponent,
SmallSessionCardComponent ],
providers: [ ]
})
export class SessionsModule {}

View file

@ -1,34 +0,0 @@
/*
* Copyright 2017 Red Hat Inc. and/or its affiliates and other contributors
* as indicated by the @author tags. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
import {Component, Input} from '@angular/core';
import {Session} from './session';
/**
*
* @author Stan Silvert ssilvert@redhat.com (C) 2017 Red Hat Inc.
*/
@Component({
moduleId: module.id, // need this for styleUrls path to work properly with Systemjs
selector: 'small-session-card',
templateUrl: 'small-session-card.component.html',
styleUrls: ['small-session-card.component.css']
})
export class SmallSessionCardComponent {
@Input() session: Session;
}

View file

@ -1,32 +0,0 @@
/*
* Copyright 2017 Red Hat Inc. and/or its affiliates and other contributors
* as indicated by the @author tags. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
import {Icon} from '../../page/icon';
/**
*
* @author Stan Silvert ssilvert@redhat.com (C) 2017 Red Hat Inc.
*/
export interface ActionButton {
readonly label: string | Icon;
readonly tooptip?: string;
performAction(): void;
}

View file

@ -1,52 +0,0 @@
/*
* Copyright 2017 Red Hat Inc. and/or its affiliates and other contributors
* as indicated by the @author tags. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
import { Pipe, PipeTransform } from '@angular/core';
/**
* Case insensitive filtering.
*
* @author Stan Silvert ssilvert@redhat.com (C) 2017 Red Hat Inc.
*/
@Pipe({name: 'filterby'})
export class FilterbyPipe implements PipeTransform {
transform(objects: any[], property: string, text: string) {
if (!property) return objects;
if (!text) return objects;
const transformed: any[] = [];
for (let obj of objects) {
let propVal:any = obj[property];
if (!this.isString(propVal)) {
console.error("Can't filter property " + property + ". Its value is not a string.");
break;
}
let strPropVal:string = propVal as string;
if (strPropVal.toLowerCase().indexOf(text.toLowerCase()) != -1) {
transformed.push(obj);
}
}
return transformed;
}
private isString(value: any): boolean {
return (typeof value == 'string') || (value instanceof String);
}
}

View file

@ -1,42 +0,0 @@
/*
* Copyright 2017 Red Hat Inc. and/or its affiliates and other contributors
* as indicated by the @author tags. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
import { Pipe, PipeTransform } from '@angular/core';
/**
*
* @author Stan Silvert ssilvert@redhat.com (C) 2017 Red Hat Inc.
*/
@Pipe({name: 'orderby'})
export class OrderbyPipe implements PipeTransform {
transform(objects: any[], property: string, descending: boolean = true) {
if (!property) return objects;
let sorted: any[] = objects.sort((obj1, obj2) => {
if (obj1[property] > obj2[property]) return 1;
if (obj1[property] < obj2[property]) return -1;
return 0;
})
if (descending) {
return sorted;
} else {
return sorted.reverse();
}
}
}

View file

@ -1,28 +0,0 @@
/*
* Copyright 2017 Red Hat Inc. and/or its affiliates and other contributors
* as indicated by the @author tags. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
/**
* Property name and its human-readable, localized display text.
*
* @author Stan Silvert ssilvert@redhat.com (C) 2017 Red Hat Inc.
*/
export interface PropertyLabel {
readonly prop: string;
readonly label: string;
}

View file

@ -1,49 +0,0 @@
/*
* Copyright 2017 Red Hat Inc. and/or its affiliates and other contributors
* as indicated by the @author tags. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
import {Response} from '@angular/http';
import {ActionButton} from './action.button';
import {Icon} from '../../page/icon';
import {AccountServiceClient} from '../../account-service/account.service';
/**
*
* @author Stan Silvert ssilvert@redhat.com (C) 2017 Red Hat Inc.
*/
export class RefreshButton implements ActionButton {
readonly label:Icon = new Icon('fa', 'refresh');
readonly tooltip:string = 'Refresh'; //TODO: localize in constructor
constructor(private accountSvc: AccountServiceClient,
private request: string,
private refreshable:Refreshable) {}
public performAction(): void {
this.accountSvc.doGetRequest(this.request, (res: Response) => {
this.refreshable.refresh(res);
});
}
}
export interface Refreshable {
refresh(response:Response): void;
}

View file

@ -1,100 +0,0 @@
/*
* Copyright 2017 Red Hat Inc. and/or its affiliates and other contributors
* as indicated by the @author tags. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
import {Component, Input, OnInit} from '@angular/core';
import {PropertyLabel} from './property.label';
import {ActionButton} from './action.button';
import {Icon} from '../../page/icon';
export type View = "LargeCards" | "SmallCards" | "List";
/**
*
* @author Stan Silvert ssilvert@redhat.com (C) 2017 Red Hat Inc.
*/
@Component({
moduleId: module.id, // need this for styleUrls path to work properly with Systemjs
selector: 'toolbar',
templateUrl: 'toolbar.html',
styleUrls: ['toolbar.css']
})
export class ToolbarComponent implements OnInit {
@Input() filterProps: PropertyLabel[];
@Input() sortProps: PropertyLabel[];
@Input() actionButtons: ActionButton[];
// TODO: localize in constructor
readonly sortByTooltip: string = "Sort by...";
readonly sortAscendingTooltip: string = "Sort Ascending";
readonly sortDescendingTooltip: string = "Sort Descending";
private isSortAscending: boolean = true;
private sortBy: PropertyLabel;
private filterBy: PropertyLabel;
private filterText: string = "";
public activeView: View = "LargeCards";
ngOnInit() {
if (this.filterProps && this.filterProps.length > 0) {
this.filterBy = this.filterProps[0];
}
if (this.sortProps && this.sortProps.length > 0) {
this.sortBy = this.sortProps[0];
}
}
private changeView(activeView: View) {
this.activeView = activeView;
}
private toggleSort() {
this.isSortAscending = !this.isSortAscending;
}
private changeSortByProp(prop: PropertyLabel) {
this.sortBy = prop;
}
private changeFilterByProp(prop: PropertyLabel) {
this.filterBy = prop;
this.filterText = "";
}
private selectedFilterClass(prop: PropertyLabel): string {
if (this.filterBy === prop) {
return "selected";
} else {
return "";
}
}
private selectedSortByClass(prop: PropertyLabel): string {
if (this.sortBy === prop) {
return "selected";
} else {
return "";
}
}
isIconButton(button: ActionButton): boolean {
return button.label instanceof Icon;
}
}

View file

@ -1,36 +0,0 @@
/*
* Copyright 2018 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { ToolbarComponent } from './toolbar.component';
import {OrderbyPipe} from './orderby.pipe';
import {FilterbyPipe} from './filterby.pipe';
@NgModule({
imports: [ CommonModule, FormsModule ],
declarations: [ ToolbarComponent, OrderbyPipe, FilterbyPipe ],
exports: [ ToolbarComponent,
OrderbyPipe,
FilterbyPipe ],
providers: [ ]
})
export class WidgetsModule {}

View file

@ -1,36 +0,0 @@
/*
* Copyright 2018 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {Injectable} from '@angular/core';
import {CanActivateChild, ActivatedRouteSnapshot, RouterStateSnapshot} from '@angular/router';
import {KeycloakService} from './keycloak.service';
@Injectable()
export class KeycloakGuard implements CanActivateChild {
constructor(private keycloakService: KeycloakService) {}
canActivateChild(route: ActivatedRouteSnapshot,
state: RouterStateSnapshot): boolean {
if (this.keycloakService.authenticated()) {
return true;
}
this.keycloakService.login();
return false;
}
}

View file

@ -1,65 +0,0 @@
/*
* Copyright 2017 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {Injectable} from '@angular/core';
import {Http, Request, XHRBackend, ConnectionBackend, RequestOptions, RequestOptionsArgs, Response, Headers} from '@angular/http';
import {KeycloakService} from './keycloak.service';
import {Observable} from 'rxjs/Observable';
import 'rxjs/add/observable/fromPromise';
import 'rxjs/add/operator/concatMap';
import 'rxjs/add/operator/map';
/**
* This provides a wrapper over the ng2 Http class that insures tokens are refreshed on each request.
*/
@Injectable()
export class KeycloakHttp extends Http {
constructor(_backend: ConnectionBackend, _defaultOptions: RequestOptions, private _keycloakService: KeycloakService) {
super(_backend, _defaultOptions);
}
request(url: string | Request, options?: RequestOptionsArgs): Observable<Response> {
if (!this._keycloakService.authenticated()) return super.request(url, options);
const tokenPromise: Promise<string> = this._keycloakService.getToken();
const tokenObservable: Observable<string> = Observable.fromPromise(tokenPromise);
if (typeof url === 'string') {
return tokenObservable.map(token => {
const authOptions = new RequestOptions({headers: new Headers({'Authorization': 'Bearer ' + token})});
return new RequestOptions().merge(options).merge(authOptions);
}).concatMap(opts => super.request(url, opts));
} else if (url instanceof Request) {
return tokenObservable.map(token => {
url.headers.set('Authorization', 'Bearer ' + token);
return url;
}).concatMap(request => super.request(request));
}
}
}
export function keycloakHttpFactory(backend: XHRBackend, defaultOptions: RequestOptions, keycloakService: KeycloakService) {
return new KeycloakHttp(backend, defaultOptions, keycloakService);
}
export const KEYCLOAK_HTTP_PROVIDER = {
provide: Http,
useFactory: keycloakHttpFactory,
deps: [XHRBackend, RequestOptions, KeycloakService]
};

View file

@ -14,7 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {Injectable} from '@angular/core';
import {KeycloakLoginOptions} from './keycloak.d';
// If using a local keycloak.js, uncomment this import. With keycloak.js fetched
@ -27,10 +26,20 @@ import * as Keycloak from './keycloak';
export type KeycloakClient = Keycloak.KeycloakInstance;
type InitOptions = Keycloak.KeycloakInitOptions;
@Injectable()
export class KeycloakService {
static keycloakAuth: KeycloakClient;
declare const keycloak: KeycloakClient;
export class KeycloakService {
private static keycloakAuth: KeycloakClient = keycloak;
private static instance: KeycloakService = new KeycloakService();
private constructor() {
}
public static get Instance(): KeycloakService {
return this.instance;
}
/**
* Configure and initialize the Keycloak adapter.
*
@ -54,10 +63,6 @@ export class KeycloakService {
});
}
static setKeycloakAuth(kc:KeycloakClient) {
this.keycloakAuth = kc;
}
authenticated(): boolean {
return KeycloakService.keycloakAuth.authenticated;
}

View file

@ -1,34 +0,0 @@
/*
* Copyright 2017 Red Hat Inc. and/or its affiliates and other contributors
* as indicated by the @author tags. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
import {Observable} from 'rxjs/Observable';
import {TranslateLoader} from '@ngx-translate/core';
declare const l18n_msg: any;
/**
*
* @author Stan Silvert ssilvert@redhat.com (C) 2017 Red Hat Inc.
*/
export class DeclaredVarTranslateLoader implements TranslateLoader {
getTranslation(lang: string): Observable<any> {
return Observable.of(l18n_msg);
}
}

View file

@ -1,46 +0,0 @@
/*
* Copyright 2017 Red Hat Inc. and/or its affiliates and other contributors
* as indicated by the @author tags. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
import {Injectable} from '@angular/core';
import {TranslateService} from '@ngx-translate/core';
/**
*
* @author Stan Silvert ssilvert@redhat.com (C) 2017 Red Hat Inc.
*/
@Injectable()
export class TranslateUtil {
constructor(private translator: TranslateService) {
}
public translate(key: string, params?: Array<any>): string {
// remove Freemarker syntax
if (key.startsWith('${') && key.endsWith('}')) {
key = key.substring(2, key.length - 1);
}
const ngTranslateParams = {};
for (let i in params) {
let paramName: string = 'param_' + i;
ngTranslateParams[paramName] = params[i];
}
return this.translator.instant(key, ngTranslateParams);
}
}

View file

@ -1,61 +0,0 @@
/*
* Copyright 2018 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {Component, OnInit} from '@angular/core';
import {Router, NavigationEnd} from '@angular/router';
import {KeycloakNotificationService} from '../notification/keycloak-notification.service';
@Component({
selector: 'inline-notification',
templateUrl: './inline-notification.component.html',
styleUrls: ['./inline-notification.component.css']
})
export class InlineNotification implements OnInit {
dismissable: boolean = true;
message: string = '';
type: string = 'success';
hidden: boolean = true;
constructor(private notificationSvc: KeycloakNotificationService,
private router: Router) {
this.router.events.subscribe(value => {
if (value instanceof NavigationEnd) {
this.hidden = true;
}
});
}
ngOnInit(): void {
// Track Notifications
this.notificationSvc.getNotificationsObserver
.subscribe((notification) => {
console.log('>> notification=' + JSON.stringify(notification));
if (notification.length === 0) {
this.hidden = true;
return;
}
console.log('>> updating message...');
// always display the latest message
this.message = notification[notification.length-1].message;
this.type = notification[notification.length-1].type;
this.hidden = false;
});
}
}

View file

@ -1,29 +0,0 @@
.faux-layout {
position: fixed;
top: 37px;
bottom: 0;
left: 0;
right: 0;
background-color: #f5f5f5;
padding-top: 15px;
z-index: 1100;
}
.example-page-container.container-fluid {
position: fixed;
top: 37px;
bottom: 0;
left: 0;
right: 0;
background-color: #f5f5f5;
padding-top: 15px;
}
.hide-vertical-nav {
margin-top: 15px;
margin-left: 30px;
}
.navbar-brand-txt {
line-height: 34px;
}

View file

@ -1,6 +0,0 @@
<pfng-inline-notification
[message]="message"
[dismissable]="dismissable"
[type]="type"
[(hidden)]="hidden">
</pfng-inline-notification>

View file

@ -1,57 +0,0 @@
/*
* Copyright 2018 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {Injectable} from '@angular/core';
import {Router, NavigationEnd} from '@angular/router';
import {NotificationService} from 'patternfly-ng/notification/notification-service';
import {TranslateUtil} from '../ngx-translate/translate.util';
@Injectable()
export class KeycloakNotificationService extends NotificationService {
constructor(router: Router,
private translateUtil: TranslateUtil) {
super();
router.events.subscribe(value => {
if (value instanceof NavigationEnd) {
this.removeAll();
};
});
}
public notify(message: string, notificationType: string, params?: Array<any>) : void {
let translatedMessage: string = this.translateUtil.translate(message, params);
translatedMessage = translatedMessage.replace("%27", "'");
this.message(
notificationType, // type
null, // header
translatedMessage, // message
false, // isPersistent
null, // Action primaryAction
null // Action[] more actions
);
this.setVerbose(true);
}
private removeAll(): void {
for (let notification of this.getNotifications()) {
this.remove(notification);
}
}
}

View file

@ -1,46 +0,0 @@
/*
* Copyright 2017 Red Hat Inc. and/or its affiliates and other contributors
* as indicated by the @author tags. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
import {TranslateUtil} from '../ngx-translate/translate.util';
declare const referrer: string;
declare const referrer_uri: string;
/**
* Encapsulate referrer logic.
*
* @author Stan Silvert ssilvert@redhat.com (C) 2017 Red Hat Inc.
*/
export class Referrer {
constructor(private translateUtil: TranslateUtil) {}
public exists(): boolean {
return typeof referrer !== "undefined";
}
// return a value suitable for parameterized use with ngx-translate
// example {{'backTo' | translate:referrer.getName()}}
public getName(): { param_0: string } {
return {param_0: this.translateUtil.translate(referrer) };
}
public getUri(): string {
return referrer_uri;
}
}

View file

@ -1,47 +0,0 @@
/*
* Copyright 2017 Red Hat Inc. and/or its affiliates and other contributors
* as indicated by the @author tags. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
/**
* For this application, we are responsive to three sizes: large, medium, and
* small. Note that these do not perfectly correspond to bootstrap device
* sizes but are more in line with patternfly.
*
* When making decisions based on screen size, you should create a single
* instance of this class and then test for each size. Do not use several
* instances because the screen size could change at any time and you may
* get inconsistent results.
*
* @author Stan Silvert ssilvert@redhat.com (C) 2017 Red Hat Inc.
*/
export class Media {
private screenWidth: number = window.innerWidth;
public isLarge(): boolean {
return this.screenWidth > 1023;
}
public isMedium(): boolean {
return (this.screenWidth < 1023) && (this.screenWidth > 768);
}
public isSmall(): boolean {
return this.screenWidth < 769;
}
}

View file

@ -1,105 +0,0 @@
/*
* Copyright 2017 Red Hat Inc. and/or its affiliates and other contributors
* as indicated by the @author tags. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
import { Injectable } from "@angular/core";
import { Media } from "./media";
export type SideNavClasses = "" | "collapsed" | "hidden" | "hidden show-mobile-nav";
export type ContentWidthClass = "" | "collapsed-nav" | "hidden-nav";
export interface MenuClickListener {
menuClicked(): void;
}
/**
*
* @author Stan Silvert ssilvert@redhat.com (C) 2017 Red Hat Inc.
*/
@Injectable()
export class ResponsivenessService {
private menuOn: boolean = false;
private menuListeners: MenuClickListener[] = Array<MenuClickListener>();
public addMenuClickListener(listener: MenuClickListener) {
this.menuListeners.push(listener);
}
public menuClicked() : void {
this.menuOn = !this.menuOn;
for (let listener of this.menuListeners) {
listener.menuClicked();
}
}
public calcSideNavWidthClasses() : SideNavClasses {
const media: Media = new Media();
if (media.isLarge() && !this.menuOn) {
return "";
}
if (media.isLarge() && this.menuOn) {
return "collapsed";
}
if (media.isMedium() && !this.menuOn) {
return "collapsed";
}
if (media.isMedium() && this.menuOn) {
return "";
}
// media must be small
if (!this.menuOn) {
return "hidden"
}
return "hidden show-mobile-nav";
}
public calcSideContentWidthClass() : ContentWidthClass {
const media: Media = new Media();
if (media.isLarge() && !this.menuOn) {
return "";
}
if (media.isLarge() && this.menuOn) {
return "collapsed-nav";
}
if (media.isMedium() && !this.menuOn) {
return "collapsed-nav";
}
if (media.isMedium() && this.menuOn) {
return "";
}
// media must be small
if (!this.menuOn) {
return "hidden-nav"
}
return "hidden-nav";
}
}

View file

@ -1,107 +0,0 @@
import {Component, OnInit, ViewEncapsulation, ViewChild} from '@angular/core';
import {NavigationItemConfig, VerticalNavigationComponent} from 'patternfly-ng/navigation';
import {TranslateUtil} from '../ngx-translate/translate.util';
import {KeycloakService} from '../keycloak-service/keycloak.service';
import {Features} from '../page/features';
import {Referrer} from "../page/referrer";
declare const baseUrl: string;
declare const resourceUrl: string;
declare const features: Features;
declare const availableLocales: Array<Object>;
@Component({
encapsulation: ViewEncapsulation.None,
selector: 'vertical-nav',
styleUrls: ['./vertical-nav.component.css'],
templateUrl: './vertical-nav.component.html'
})
export class VerticalNavComponent implements OnInit {
@ViewChild('pfVerticalNav') pfVerticalNav: VerticalNavigationComponent;
public resourceUrl: string = resourceUrl;
public availableLocales: Array<Object> = availableLocales;
private referrer: Referrer;
navigationItems: NavigationItemConfig[];
constructor(private keycloakService: KeycloakService,
private translateUtil: TranslateUtil ) {
this.referrer = new Referrer(translateUtil);
}
ngOnInit(): void {
this.navigationItems = [
{
title: this.translateUtil.translate('personalInfoHtmlTitle'),
iconStyleClass: 'fa fa-user-circle',
url: 'account',
mobileItem: false
},
{
title: this.translateUtil.translate('accountSecurityTitle'),
iconStyleClass: 'fa fa-shield',
children: this.makeSecurityChildren(),
},
{
title: this.translateUtil.translate('applicationsHtmlTitle'),
iconStyleClass: 'fa fa-th',
url: 'applications',
}
];
if (features.isMyResourcesEnabled) {
this.navigationItems.push(
{
title: this.translateUtil.translate('myResources'),
iconStyleClass: 'fa fa-file-o',
url: 'my-resources',
}
);
}
}
private makeSecurityChildren(): Array<NavigationItemConfig> {
const children: Array<NavigationItemConfig> = [
{
title: this.translateUtil.translate('changePasswordHtmlTitle'),
iconStyleClass: 'fa fa-shield',
url: 'password',
},
{
title: this.translateUtil.translate('authenticatorTitle'),
iconStyleClass: 'fa fa-shield',
url: 'authenticator',
},
{
title: this.translateUtil.translate('device-activity'),
iconStyleClass: 'fa fa-shield',
url: 'device-activity',
}
];
if (features.isLinkedAccountsEnabled) {
children.push({
title: this.translateUtil.translate('linkedAccountsHtmlTitle'),
iconStyleClass: 'fa fa-shield',
url: 'linked-accounts',
});
};
return children;
}
private logout() {
this.keycloakService.logout(baseUrl);
}
private isShowLocales(): boolean {
return features.isInternationalizationEnabled && (this.availableLocales.length > 1);
}
private changeLocale(newLocale: string) {
this.keycloakService.login({kcLocale: newLocale});
}
}

View file

@ -0,0 +1,42 @@
/*
* Copyright 2018 Red Hat, Inc. and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import * as React from 'react';
import {Link} from 'react-router-dom';
import {KeycloakService} from '../keycloak-service/keycloak.service';
export interface LogoutProps {
}
export class Logout extends React.Component<LogoutProps> {
constructor(props: LogoutProps) {
super(props);
}
handleLogout = () => {
KeycloakService.Instance.logout();
}
render() {
return (
<div>
<Link to="/" type="button" onClick={this.handleLogout}>Logout</Link>
</div>
);
}
}

View file

@ -1,47 +0,0 @@
/*
* Copyright 2017 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { platformBrowser } from '@angular/platform-browser';
import { AppModule } from './app/app.module';
//import { environment } from './environments/environment';
import { KeycloakService, KeycloakClient } from './app/keycloak-service/keycloak.service';
//if (environment.production) {
// enableProdMode();
//}
declare const authUrl: string;
declare const resourceUrl: string;
declare const realm: string;
declare const keycloak: KeycloakClient;
KeycloakService.setKeycloakAuth(keycloak);
loadCss('/styles.css');
platformBrowserDynamic().bootstrapModule(AppModule);
function loadCss(url:string) {
const link = document.createElement("link");
link.href = resourceUrl + url;
link.rel = "stylesheet";
link.media = "screen, print";
document.head.appendChild(link);
}

View file

@ -1,69 +1,27 @@
{
"name": "keycloak-preview",
"version": "1.0.0",
"description": "keycloak-preview account management written in Angular 2",
"description": "keycloak-preview account management written in React",
"scripts": {
"build": "tsc -p ./",
"build:watch": "tsc -p ./ -w",
"build:e2e": "tsc -p e2e/",
"serve": "lite-server -c=bs-config.json",
"serve:e2e": "lite-server -c=bs-config.e2e.json",
"prestart": "npm run build",
"start": "concurrently \"npm run build:watch\" \"npm run serve\"",
"pree2e": "npm run build:e2e",
"e2e": "concurrently \"npm run serve:e2e\" \"npm run protractor\" --kill-others --success first",
"preprotractor": "webdriver-manager update",
"protractor": "protractor protractor.config.js",
"pretest": "npm run build",
"test": "concurrently \"npm run build:watch\" \"karma start karma.conf.js\"",
"pretest:once": "npm run build",
"test:once": "karma start karma.conf.js --single-run",
"lint": "tslint ./**/*.ts --exclude ./node_modules/** -t verbose"
"build": "tsc --jsx react -p ./",
"build:watch": "tsc --jsx react -p ./ -w"
},
"keywords": [],
"author": "Stan Silvert",
"license": "Apache 2.0",
"dependencies": {
"@angular/animations": "5.0.0",
"@angular/common": "5.0.0",
"@angular/compiler": "5.0.0",
"@angular/compiler-cli": "5.0.0",
"@angular/core": "5.0.0",
"@angular/forms": "5.0.0",
"@angular/http": "5.0.0",
"@angular/platform-browser": "5.0.0",
"@angular/platform-browser-dynamic": "5.0.0",
"@angular/platform-server": "5.0.0",
"@angular/router": "5.0.0",
"@ngx-translate/core": "^9.1.1",
"bootstrap": "^4.1.0",
"core-js": "^2.4.1",
"jquery": "^3.3.1",
"patternfly": "^3.23.2",
"patternfly-ng": "^3.13.1",
"rxjs": "5.5.2",
"rxjs-system-bundle": "^5.5.6",
"react": "^16.5.2",
"react-dom": "^16.5.2",
"react-router-dom": "^4.3.1",
"systemjs": "^0.20.17",
"systemjs-plugin-babel": "0.0.25",
"zone.js": "^0.8.4"
"systemjs-plugin-babel": "0.0.25"
},
"devDependencies": {
"@types/jasmine": "2.5.36",
"@types/node": "^6.0.46",
"canonical-path": "0.0.2",
"concurrently": "^3.2.0",
"jasmine-core": "~2.4.1",
"karma": "^1.3.0",
"karma-chrome-launcher": "^2.0.0",
"karma-cli": "^1.0.1",
"karma-jasmine": "^1.0.2",
"karma-jasmine-html-reporter": "^0.2.2",
"lite-server": "^2.2.2",
"lodash": "^4.16.4",
"protractor": "~4.0.14",
"rimraf": "^2.5.4",
"tslint": "^3.15.1",
"typescript": "2.4.2"
"@types/react": "^16.4.14",
"@types/react-dom": "^16.0.8",
"typescript": "^3.1.1"
},
"repository": {}
}

View file

@ -12,41 +12,12 @@
map: {
// our app is within the app folder
'app': resourceUrl + '/app',
'resources': resourceUrl,
// angular bundles
'@angular/core': 'npm:@angular/core/bundles/core.umd.min.js',
'@angular/common': 'npm:@angular/common/bundles/common.umd.min.js',
'@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.min.js',
'@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.min.js',
'@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.min.js',
'@angular/http': 'npm:@angular/http/bundles/http.umd.min.js',
'@angular/router': 'npm:@angular/router/bundles/router.umd.min.js',
'@angular/forms': 'npm:@angular/forms/bundles/forms.umd.min.js',
'react': 'npm:react/umd/react.development.js',
'react-dom': 'npm:react-dom/umd/react-dom.development.js',
'react-router-dom': 'npm:react-router-dom/umd/react-router-dom.js',
// other libraries
'@ngx-translate/core': 'npm:@ngx-translate/core/bundles/core.umd.min.js',
'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js',
'lodash': 'npm:lodash/lodash.js',
// patternfly-ng
'patternfly-ng/navigation': 'npm:patternfly-ng/bundles/patternfly-ng.umd.min.js',
'patternfly-ng/utilities': 'npm:patternfly-ng/bundles/patternfly-ng.umd.min.js',
'patternfly-ng/notification': 'npm:patternfly-ng/bundles/patternfly-ng.umd.min.js',
'patternfly-ng/notification/inline-notification': 'npm:patternfly-ng/bundles/patternfly-ng.umd.min.js',
'patternfly-ng/notification/notification-service': 'npm:patternfly-ng/bundles/patternfly-ng.umd.min.js',
// unused patternfly-ng dependencies
'angular-tree-component': '@empty',
'ng2-dragula': '@empty',
'@swimlane/ngx-datatable': '@empty',
'd3': '@empty',
'c3': '@empty',
// ngx-bootstrap
'ngx-bootstrap': 'npm:ngx-bootstrap/bundles/ngx-bootstrap.umd.min.js',
'ngx-bootstrap/dropdown': 'npm:ngx-bootstrap/bundles/ngx-bootstrap.umd.min.js',
'ngx-bootstrap/popover': 'npm:ngx-bootstrap/bundles/ngx-bootstrap.umd.min.js',
'ngx-bootstrap/tooltip': 'npm:ngx-bootstrap/bundles/ngx-bootstrap.umd.min.js',
},
bundles: {
@ -69,18 +40,14 @@
defaultExtension: 'js',
meta: {
'./*.js': {
loader: resourceUrl + '/systemjs-angular-loader.js'
}
}
},
'@ngx-translate/core': {
defaultExtension: 'js'
},
rxjs: {
defaultExtension: false
},
'lodash': { defaultExtension: 'js' },
}
});
})(this);