diff --git a/demo-shell-ng2/app/app.component.html b/demo-shell-ng2/app/app.component.html index 3619ac5ec1..4d860b8bcd 100644 --- a/demo-shell-ng2/app/app.component.html +++ b/demo-shell-ng2/app/app.component.html @@ -21,6 +21,7 @@ DocumentList Process Services Login + Settings @@ -59,6 +60,7 @@ Tag Social About + Settings
+ + + + + .mdl-card__title { + color: #fff; + background: bottom right 15% no-repeat #1fbcd2; +} + +.setting-card-padding { + width: 50%; + display: table-cell; + vertical-align: middle; + margin: 0; +} + +.setting-container { + display: table; + border-collapse: collapse; + border-spacing: 0; + width: 100%; +} + +.icon-margin { + margin-right: 9px; +} + +.table-row { + display: table-row; +} + +.adf-setting-input-padding { + padding-top: 0px !important; +} diff --git a/demo-shell-ng2/app/components/settings/settings.component.html b/demo-shell-ng2/app/components/settings/settings.component.html new file mode 100644 index 0000000000..321dfe1ca2 --- /dev/null +++ b/demo-shell-ng2/app/components/settings/settings.component.html @@ -0,0 +1,46 @@ +
+
+
+
+
+

SETTINGS

+
+
+
+ Content Services host URL configuration +
+ + +
+ Process Services host URL configuration +
+ +
+ +
+
+
+
diff --git a/demo-shell-ng2/app/components/settings/settings.component.ts b/demo-shell-ng2/app/components/settings/settings.component.ts new file mode 100644 index 0000000000..71d99b0638 --- /dev/null +++ b/demo-shell-ng2/app/components/settings/settings.component.ts @@ -0,0 +1,73 @@ +/*! + * @license + * Copyright 2016 Alfresco Software, Ltd. + * + * 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, AfterViewChecked } from '@angular/core'; +import { AlfrescoSettingsService, StorageService, LogService } from 'ng2-alfresco-core'; + +declare var componentHandler: any; + +@Component({ + selector: 'app-settings', + templateUrl: 'settings.component.html', + styleUrls: ['settings.component.css'] +}) +export class SettingsComponent implements AfterViewChecked { + + ecmHost: string; + bpmHost: string; + + constructor(private settingsService: AlfrescoSettingsService, + private storage: StorageService, + private logService: LogService) { + this.ecmHost = storage.getItem('ecmHost') || this.settingsService.ecmHost; + this.bpmHost = storage.getItem('bpmHost') || this.settingsService.bpmHost; + } + + ngAfterViewChecked() { + // workaround for MDL issues with dynamic components + if (componentHandler) { + componentHandler.upgradeAllRegistered(); + } + } + + public onChangeECMHost(event: KeyboardEvent): void { + let value = (event.target).value.trim(); + if (value && this.isValidUrl(value)) { + this.logService.info(`ECM host: ${value}`); + this.ecmHost = value; + this.storage.setItem(`ecmHost`, value); + } else { + console.error('Ecm address does not match the pattern'); + } + } + + public onChangeBPMHost(event: KeyboardEvent): void { + let value = (event.target).value.trim(); + if (value && this.isValidUrl(value)) { + this.logService.info(`BPM host: ${value}`); + this.bpmHost = value; + this.storage.setItem(`bpmHost`, value); + } else { + console.error('Bpm address does not match the pattern'); + } + } + + isValidUrl(url: string) { + return /^(http|https):\/\/.*/.test(url); + } + +} diff --git a/demo-shell-ng2/app/services/debug-app-config.service.ts b/demo-shell-ng2/app/services/debug-app-config.service.ts new file mode 100644 index 0000000000..4c9e4065ee --- /dev/null +++ b/demo-shell-ng2/app/services/debug-app-config.service.ts @@ -0,0 +1,37 @@ +/*! + * @license + * Copyright 2016 Alfresco Software, Ltd. + * + * 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 } from '@angular/http'; +import { AppConfigService, StorageService } from 'ng2-alfresco-core'; + +@Injectable() +export class DebugAppConfigService extends AppConfigService { + + constructor(private storage: StorageService, http: Http) { + super(http); + } + + /** @override */ + get(key: string): T { + if (key === 'ecmHost' || key === 'bpmHost') { + return (this.storage.getItem(key) || super.get(key)); + } + return super.get(key); + }; + +} diff --git a/demo-shell-ng2/tsconfig.json b/demo-shell-ng2/tsconfig.json index ab2146c0a8..2949628c4f 100644 --- a/demo-shell-ng2/tsconfig.json +++ b/demo-shell-ng2/tsconfig.json @@ -38,7 +38,9 @@ "ng2-alfresco-upload": ["../ng2-components/ng2-alfresco-upload/"], "ng2-alfresco-viewer": ["../ng2-components/ng2-alfresco-viewer/"], "ng2-alfresco-webscript": ["../ng2-components/ng2-alfresco-webscript/"], - "ng2-alfresco-userinfo": ["../ng2-components/ng2-alfresco-userinfo/"] + "ng2-alfresco-userinfo": ["../ng2-components/ng2-alfresco-userinfo/"], + "@angular/*": ["../ng2-components/node_modules/@angular/*"], + "rxjs/*": ["../ng2-components/node_modules/rxjs/*"] }, "suppressImplicitAnyIndexErrors": true },