Commit b42f8935 authored by kunw's avatar kunw
Browse files

Fix and update codes for AoT.

parent 012a42a6
......@@ -15,14 +15,17 @@
"@angular/animations": "^4.0.1",
"@angular/common": "^4.0.1",
"@angular/compiler": "^4.0.1",
"@angular/compiler-cli": "^4.0.2",
"@angular/core": "^4.0.1",
"@angular/forms": "^4.0.1",
"@angular/http": "^4.0.1",
"@angular/platform-browser": "^4.0.1",
"@angular/platform-browser-dynamic": "^4.0.1",
"@angular/platform-server": "^4.0.2",
"@angular/router": "^4.0.1",
"@ngx-translate/core": "^6.0.0",
"@ngx-translate/http-loader": "0.0.3",
"@types/jquery": "^2.0.41",
"@webcomponents/custom-elements": "1.0.0-alpha.3",
"angular2-cookie": "^1.2.6",
"clarity-angular": "^0.9.0",
......@@ -30,6 +33,7 @@
"clarity-ui": "^0.9.0",
"core-js": "^2.4.1",
"mutationobserver-shim": "^0.3.2",
"ngx-cookie": "^1.0.0",
"rxjs": "^5.0.1",
"ts-helpers": "^1.1.1",
"web-animations-js": "^2.2.1",
......@@ -53,6 +57,10 @@
"karma-phantomjs-launcher": "^1.0.0",
"karma-remap-istanbul": "^0.2.1",
"protractor": "4.0.9",
"rollup": "^0.41.6",
"rollup-plugin-commonjs": "^8.0.2",
"rollup-plugin-node-resolve": "^3.0.0",
"rollup-plugin-uglify": "^1.0.1",
"ts-node": "1.2.1",
"tslint": "^4.1.1",
"typescript": "~2.2.0",
......
import nodeResolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import uglify from 'rollup-plugin-uglify';
export default {
entry: 'src/main-aot.js',
dest: 'src/build.js', // output a single application bundle
sourceMap: false,
format: 'iife',
onwarn: function(warning) {
// Skip certain warnings
// should intercept ... but doesn't in some rollup versions
if ( warning.code === 'THIS_IS_UNDEFINED' ) { return; }
// intercepts in some rollup versions
if ( typeof warning === 'string' && warning.indexOf("The 'this' keyword is equivalent to 'undefined'") > -1 ) { return; }
// console.warn everything else
console.warn( warning.message );
},
plugins: [
nodeResolve({jsnext: true, module: true, browser: true}),
commonjs({
include: ['node_modules/**']
}),
uglify()
]
}
......@@ -31,21 +31,21 @@ export class AccountSettingsModalComponent implements OnInit, AfterViewChecked {
account: SessionUser;
error: any = null;
originalStaticData: SessionUser;
private emailTooltip: string = 'TOOLTIP.EMAIL';
emailTooltip: string = 'TOOLTIP.EMAIL';
private validationStateMap: any = {
"account_settings_email": true,
"account_settings_full_name": true
};
private mailAlreadyChecked = {};
mailAlreadyChecked = {};
private isOnCalling: boolean = false;
private formValueChanged: boolean = false;
private checkOnGoing: boolean = false;
isOnCalling: boolean = false;
formValueChanged: boolean = false;
checkOnGoing: boolean = false;
accountFormRef: NgForm;
@ViewChild("accountSettingsFrom") accountForm: NgForm;
@ViewChild(InlineAlertComponent)
private inlineAlert: InlineAlertComponent;
inlineAlert: InlineAlertComponent;
constructor(
private session: SessionService,
......@@ -56,11 +56,11 @@ export class AccountSettingsModalComponent implements OnInit, AfterViewChecked {
this.account = Object.assign({}, this.session.getCurrentUser());
}
private getValidationState(key: string): boolean {
getValidationState(key: string): boolean {
return this.validationStateMap[key];
}
private handleValidation(key: string, flag: boolean): void {
handleValidation(key: string, flag: boolean): void {
if (flag) {
//Checking
let cont = this.accountForm.controls[key];
......@@ -104,7 +104,7 @@ export class AccountSettingsModalComponent implements OnInit, AfterViewChecked {
}
}
private isUserDataChange(): boolean {
isUserDataChange(): boolean {
if (!this.originalStaticData || !this.account) {
return false;
}
......@@ -215,7 +215,7 @@ export class AccountSettingsModalComponent implements OnInit, AfterViewChecked {
});
}
confirmCancel(): void {
confirmCancel($event: any): void {
this.inlineAlert.close();
this.opened = false;
}
......
......@@ -25,14 +25,14 @@ import { InlineAlertComponent } from '../../shared/inline-alert/inline-alert.com
})
export class ForgotPasswordComponent {
opened: boolean = false;
private onGoing: boolean = false;
private email: string = "";
private validationState: boolean = true;
private isSuccess: boolean = false;
onGoing: boolean = false;
email: string = "";
validationState: boolean = true;
isSuccess: boolean = false;
@ViewChild("forgotPasswordFrom") forgotPwdForm: NgForm;
@ViewChild(InlineAlertComponent)
private inlineAlert: InlineAlertComponent;
inlineAlert: InlineAlertComponent;
constructor(private pwdService: PasswordSettingService) { }
......
......@@ -33,8 +33,8 @@ export class PasswordSettingComponent implements AfterViewChecked {
reNewPwd: string = "";
error: any = null;
private formValueChanged: boolean = false;
private onCalling: boolean = false;
formValueChanged: boolean = false;
onCalling: boolean = false;
private validationStateMap: any = {
"newPassword": true,
"reNewPassword": true
......@@ -43,7 +43,7 @@ export class PasswordSettingComponent implements AfterViewChecked {
pwdFormRef: NgForm;
@ViewChild("changepwdForm") pwdForm: NgForm;
@ViewChild(InlineAlertComponent)
private inlineAlert: InlineAlertComponent;
inlineAlert: InlineAlertComponent;
constructor(
private passwordService: PasswordSettingService,
......@@ -68,11 +68,11 @@ export class PasswordSettingComponent implements AfterViewChecked {
return this.onCalling;
}
private getValidationState(key: string): boolean {
getValidationState(key: string): boolean {
return this.validationStateMap[key];
}
private handleValidation(key: string, flag: boolean): void {
handleValidation(key: string, flag: boolean): void {
if (flag) {
//Checking
let cont = this.pwdForm.controls[key];
......@@ -139,7 +139,7 @@ export class PasswordSettingComponent implements AfterViewChecked {
}
}
confirmCancel(): void {
confirmCancel($event: any): void {
this.opened = false;
}
......
......@@ -23,11 +23,11 @@ const resetPasswordEndpoint = "/reset";
@Injectable()
export class PasswordSettingService {
private headers: Headers = new Headers({
headers: Headers = new Headers({
"Accept": 'application/json',
"Content-Type": 'application/json'
});
private options: RequestOptions = new RequestOptions({
options: RequestOptions = new RequestOptions({
'headers': this.headers
});
......
......@@ -27,19 +27,19 @@ import { CommonRoutes } from '../../shared/shared.const';
})
export class ResetPasswordComponent implements OnInit {
opened: boolean = true;
private onGoing: boolean = false;
private password: string = "";
onGoing: boolean = false;
password: string = "";
private validationState: any = {
"newPassword": true,
"reNewPassword": true
};
private resetUuid: string = "";
private resetOk: boolean = false;
resetUuid: string = "";
resetOk: boolean = false;
confirmPwd: string = "";
@ViewChild("resetPwdForm") resetPwdForm: NgForm;
@ViewChild(InlineAlertComponent)
private inlineAlert: InlineAlertComponent;
inlineAlert: InlineAlertComponent;
constructor(
private pwdService: PasswordSettingService,
......@@ -131,7 +131,7 @@ export class ResetPasswordComponent implements OnInit {
}
}
private getControlValidationState(key: string): boolean {
getControlValidationState(key: string): boolean {
if (this.resetPwdForm) {
let control = this.resetPwdForm.controls[key];
if (control) {
......@@ -142,7 +142,7 @@ export class ResetPasswordComponent implements OnInit {
return false;
}
private samePassword(): boolean {
samePassword(): boolean {
if (this.resetPwdForm) {
let control1 = this.resetPwdForm.controls["newPassword"];
let control2 = this.resetPwdForm.controls["reNewPassword"];
......
......@@ -27,7 +27,7 @@ import { AppConfigService } from '../../app-config.service';
import { AppConfig } from '../../app-config';
import { User } from '../../user/user';
import { CookieService, CookieOptions } from 'angular2-cookie/core';
import { CookieService, CookieOptions } from 'ngx-cookie';
//Define status flags for signing in states
export const signInStatusNormal = 0;
......@@ -43,11 +43,11 @@ const expireDays = 10;
})
export class SignInComponent implements AfterViewChecked, OnInit {
private redirectUrl: string = "";
private appConfig: AppConfig = new AppConfig();
redirectUrl: string = "";
appConfig: AppConfig = new AppConfig();
//Remeber me indicator
private rememberMe: boolean = false;
private rememberedName: string = "";
rememberMe: boolean = false;
rememberedName: string = "";
//Form reference
signInForm: NgForm;
@ViewChild('signInForm') currentForm: NgForm;
......@@ -126,7 +126,7 @@ export class SignInComponent implements AfterViewChecked, OnInit {
return this.appConfig.auth_mode != 'ldap_auth';
}
private clickRememberMe($event): void {
clickRememberMe($event: any): void {
if ($event && $event.target) {
this.rememberMe = $event.target.checked;
if (!this.rememberMe) {
......@@ -137,23 +137,23 @@ export class SignInComponent implements AfterViewChecked, OnInit {
}
}
private remeberMe(): void {
remeberMe(): void {
if (this.rememberMe) {
if (this.rememberedName != this.signInCredential.principal) {
//Set expire time
let expires: number = expireDays * 3600 * 24 * 1000;
let date = new Date(Date.now() + expires);
let cookieptions = new CookieOptions({
let cookieptions: CookieOptions = {
path: "/",
expires: date
});
};
this.cookie.put(remCookieKey, this.signInCredential.principal, cookieptions);
}
}
}
//General error handler
private handleError(error) {
handleError(error: any) {
//Set error status
this.signInStatus = signInStatusError;
......@@ -162,7 +162,7 @@ export class SignInComponent implements AfterViewChecked, OnInit {
}
//Hande form values changes
private formChanged() {
formChanged() {
if (this.currentForm === this.signInForm) {
return;
}
......@@ -177,7 +177,7 @@ export class SignInComponent implements AfterViewChecked, OnInit {
}
//Fill the new user info into the sign in form
private handleUserCreation(user: User): void {
handleUserCreation(user: User): void {
if (user) {
this.currentForm.setValue({
"login_username": user.username,
......
......@@ -27,14 +27,14 @@ const signInUrl = '/login';
*/
@Injectable()
export class SignInService {
private headers = new Headers({
headers = new Headers({
"Content-Type": 'application/x-www-form-urlencoded'
});
constructor(private http: Http) {}
//Handle the related exceptions
private handleError(error: any): Promise<any>{
handleError(error: any): Promise<any>{
return Promise.reject(error.message || error);
}
......
......@@ -29,9 +29,9 @@ import { MessageService } from '../../global-message/message.service';
templateUrl: "sign-up-page.component.html"
})
export class SignUpPageComponent implements OnInit {
private error: any;
private onGoing: boolean = false;
private formValueChanged: boolean = false;
error: any;
onGoing: boolean = false;
formValueChanged: boolean = false;
constructor(
private userService: UserService,
......@@ -39,9 +39,9 @@ export class SignUpPageComponent implements OnInit {
private router: Router) { }
@ViewChild(NewUserFormComponent)
private newUserForm: NewUserFormComponent;
newUserForm: NewUserFormComponent;
private getNewUser(): User {
getNewUser(): User {
return this.newUserForm.getData();
}
......
......@@ -30,9 +30,9 @@ import { Modal } from 'clarity-angular';
export class SignUpComponent {
opened: boolean = false;
staticBackdrop: boolean = true;
private error: any;
private onGoing: boolean = false;
private formValueChanged: boolean = false;
error: any;
onGoing: boolean = false;
formValueChanged: boolean = false;
@Output() userCreation = new EventEmitter<User>();
......@@ -41,15 +41,15 @@ export class SignUpComponent {
private userService: UserService) { }
@ViewChild(NewUserFormComponent)
private newUserForm: NewUserFormComponent;
newUserForm: NewUserFormComponent;
@ViewChild(InlineAlertComponent)
private inlienAlert: InlineAlertComponent;
inlienAlert: InlineAlertComponent;
@ViewChild(Modal)
private modal: Modal;
modal: Modal;
private getNewUser(): User {
getNewUser(): User {
return this.newUserForm.getData();
}
......@@ -97,7 +97,7 @@ export class SignUpComponent {
}
}
confirmCancel(): void {
confirmCancel($event: any): void {
this.opened = false;
this.modal.close();
}
......
......@@ -16,7 +16,7 @@ import { Headers, Http, RequestOptions } from '@angular/http';
import 'rxjs/add/operator/toPromise';
import { AppConfig } from './app-config';
import { CookieService } from 'angular2-cookie/core';
import { CookieService } from 'ngx-cookie';
import { CookieKeyOfAdmiral, HarborQueryParamKey } from './shared/shared.const';
import { maintainUrlQueryParmas } from './shared/shared.utils';
......@@ -30,15 +30,15 @@ export const systemInfoEndpoint = "/api/systeminfo";
*/
@Injectable()
export class AppConfigService {
private headers = new Headers({
headers = new Headers({
"Content-Type": 'application/json'
});
private options = new RequestOptions({
options = new RequestOptions({
headers: this.headers
});
//Store the application configuration
private configurations: AppConfig = new AppConfig();
configurations: AppConfig = new AppConfig();
constructor(
private http: Http,
......
......@@ -13,7 +13,7 @@
// limitations under the License.
import { Component, ReflectiveInjector, LOCALE_ID } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { CookieService } from 'angular2-cookie/core';
import { CookieService } from 'ngx-cookie';
import { supportedLangs, enLang } from './shared/shared.const';
import { SessionService } from './shared/session.service';
......@@ -56,7 +56,7 @@ export class AppComponent {
});
}
private isLangMatch(browserLang: string, supportedLangs: string[]) {
isLangMatch(browserLang: string, supportedLangs: string[]) {
if (supportedLangs && supportedLangs.length > 0) {
return supportedLangs.find(lang => lang === browserLang);
}
......
......@@ -32,15 +32,15 @@ const deBounceTime = 500; //ms
})
export class GlobalSearchComponent implements OnInit, OnDestroy {
//Keep search term as Subject
private searchTerms = new Subject<string>();
searchTerms = new Subject<string>();
//Keep subscription for future use
private searchSub: Subscription;
private closeSub: Subscription;
searchSub: Subscription;
closeSub: Subscription;
//To indicate if the result panel is opened
private isResPanelOpened: boolean = false;
private searchTerm: string = "";
isResPanelOpened: boolean = false;
searchTerm: string = "";
//Placeholder text
placeholderText: string = "GLOBAL_SEARCH.PLACEHOLDER";
......
......@@ -27,10 +27,10 @@ const searchEndpoint = "/api/search";
*/
@Injectable()
export class GlobalSearchService {
private headers = new Headers({
headers = new Headers({
"Content-Type": 'application/json'
});
private options = new RequestOptions({
options = new RequestOptions({
headers: this.headers
});
......
......@@ -30,22 +30,22 @@ import { MessageHandlerService } from '../../shared/message-handler/message-hand
})
export class SearchResultComponent implements OnInit, OnDestroy {
private searchResults: SearchResults = new SearchResults();
private originalCopy: SearchResults;
searchResults: SearchResults = new SearchResults();
originalCopy: SearchResults;
private currentTerm: string = "";
currentTerm: string = "";
//Open or close
private stateIndicator: boolean = false;
stateIndicator: boolean = false;
//Search in progress
private onGoing: boolean = false;
onGoing: boolean = false;
//Whether or not mouse point is onto the close indicator
private mouseOn: boolean = false;
mouseOn: boolean = false;
//Watch message channel
private searchSub: Subscription;
private closeSearchSub: Subscription;
searchSub: Subscription;
closeSearchSub: Subscription;
constructor(
private search: GlobalSearchService,
......@@ -71,7 +71,7 @@ export class SearchResultComponent implements OnInit, OnDestroy {
}
}
private clone(src: SearchResults): SearchResults {
clone(src: SearchResults): SearchResults {
let res: SearchResults = new SearchResults();
if (src) {
......
......@@ -18,9 +18,9 @@ import { AlertType } from '../../shared/shared.const';
@Injectable()
export class SearchTriggerService {
private searchTriggerSource = new Subject<string>();
private searchCloseSource = new Subject<boolean>();
private searchClearSource = new Subject<boolean>();
searchTriggerSource = new Subject<string>();
searchCloseSource = new Subject<boolean>();
searchClearSource = new Subject<boolean>();
searchTriggerChan$ = this.searchTriggerSource.asObservable();
searchCloseChan$ = this.searchCloseSource.asObservable();
......@@ -37,7 +37,7 @@ export class SearchTriggerService {
}
//Clear search term
clear(event): void {
clear(event: any): void {
this.searchClearSource.next(event);
}
......
......@@ -39,23 +39,23 @@ import { CommonRoutes } from '../../shared/shared.const';
export class HarborShellComponent implements OnInit, OnDestroy {
@ViewChild(AccountSettingsModalComponent)
private accountSettingsModal: AccountSettingsModalComponent;
accountSettingsModal: AccountSettingsModalComponent;
@ViewChild(PasswordSettingComponent)
private pwdSetting: PasswordSettingComponent;
pwdSetting: PasswordSettingComponent;
@ViewChild(NavigatorComponent)
private navigator: NavigatorComponent;
navigator: NavigatorComponent;
@ViewChild(AboutDialogComponent)
private aboutDialog: AboutDialogComponent;
aboutDialog: AboutDialogComponent;
//To indicator whwther or not the search results page is displayed
//We need to use this property to do some overriding work
private isSearchResultsOpened: boolean = false;
isSearchResultsOpened: boolean = false;
private searchSub: Subscription;
private searchCloseSub: Subscription;
searchSub: Subscription;
searchCloseSub: Subscription;
constructor(
private route: ActivatedRoute,
......