summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastien Douheret <sebastien.douheret@iot.bzh>2017-11-29 21:43:37 +0100
committerSebastien Douheret <sebastien.douheret@iot.bzh>2017-11-29 22:38:14 +0100
commit0f2773364006751bb5a59cf53caea3b62146cc8d (patch)
treee7e0c1858ddbb861a6a82a9f3a996ab6af3cb5ef
parentfce0932dba3ca1b2c436400774821ef14fe32fe5 (diff)
Fixed webapp build in production mode
Signed-off-by: Sebastien Douheret <sebastien.douheret@iot.bzh>
-rw-r--r--Makefile16
-rwxr-xr-xscripts/install.sh12
-rw-r--r--webapp/src/app/@theme/components/tiny-mce/tiny-mce.component.ts2
-rw-r--r--webapp/src/app/pages/build/settings-modal/build-settings-modal.component.ts143
-rw-r--r--webapp/src/app/pages/config/config-xds/config-xds.component.html2
-rw-r--r--webapp/src/app/pages/config/config-xds/downloadXdsAgent.component.ts38
6 files changed, 19 insertions, 194 deletions
diff --git a/Makefile b/Makefile
index 99eee7c..e84775a 100644
--- a/Makefile
+++ b/Makefile
@@ -61,11 +61,13 @@ ifeq ($(filter 1,$(RELEASE) $(REL)),)
# disable compiler optimizations and inlining
GO_GCFLAGS=-N -l
BUILD_MODE="Debug mode"
+ WEBAPP_BUILD_RULE=build
else
# optimized code without debug info
GO_LDFLAGS=-s -w
GO_GCFLAGS=
BUILD_MODE="Release mode"
+ WEBAPP_BUILD_RULE=build:prod
endif
ifeq ($(SUB_VERSION), )
@@ -108,10 +110,10 @@ distclean: clean
cd $(ROOT_SRCDIR) && rm -rf $(LOCAL_BINDIR) ./tools ./glide.lock ./vendor ./*.zip ./webapp/node_modules ./webapp/dist
webapp: webapp/install
- (cd webapp && npm run build)
+ cd webapp && npm run $(WEBAPP_BUILD_RULE)
webapp/debug:
- (cd webapp && npm run watch)
+ cd webapp && npm run watch
webapp/install:
(cd webapp && npm install)
@@ -128,10 +130,12 @@ uninstall:
export DESTDIR=$(DESTDIR) && export DESTDIR_WWW=$(DESTDIR_WWW) && $(ROOT_SRCDIR)/scripts/install.sh uninstall
package: clean tools/syncthing vendor build
- @mkdir -p $(PACKAGE_DIR)/xds-agent $(PACKAGE_DIR)/scripts
- @cp -a $(LOCAL_BINDIR)/* $(PACKAGE_DIR)/xds-agent
- @cp -r $(ROOT_SRCDIR)/conf.d $(ROOT_SRCDIR)/scripts $(PACKAGE_DIR)/xds-agent
- cd $(PACKAGE_DIR) && zip -r $(ROOT_SRCDIR)/$(PACKAGE_ZIPFILE) ./xds-agent
+ @mkdir -p $(PACKAGE_DIR)/xds-agent/www $(PACKAGE_DIR)/scripts
+ @cp -a $(LOCAL_BINDIR)/* $(PACKAGE_DIR)/xds-agent/
+ @cp -a webapp/dist/* $(PACKAGE_DIR)/xds-agent/www/
+ @cp -r $(ROOT_SRCDIR)/conf.d $(ROOT_SRCDIR)/scripts $(PACKAGE_DIR)/xds-agent/
+ @cd $(PACKAGE_DIR) && zip -r $(ROOT_SRCDIR)/$(PACKAGE_ZIPFILE) ./xds-agent
+ @echo "### Package $(PACKAGE_ZIPFILE) has been successfuly built - $(BUILD_MODE)"
.PHONY: package-all
package-all:
diff --git a/scripts/install.sh b/scripts/install.sh
index 357c5e8..6432e73 100755
--- a/scripts/install.sh
+++ b/scripts/install.sh
@@ -8,17 +8,17 @@ DESTDIR_WWW=${DESTDIR_WWW:-${DESTDIR}/www}
ROOT_SRCDIR=$(cd $(dirname "$0")/.. && pwd)
install() {
- mkdir -p ${DESTDIR} && cp ${ROOT_SRCDIR}/bin/* ${DESTDIR} || exit 1
- mkdir -p ${DESTDIR_WWW} && cp -a ${ROOT_SRCDIR}/webapp/dist/* ${DESTDIR_WWW} || exit 1
+ mkdir -p "${DESTDIR}" && cp "${ROOT_SRCDIR}/bin/*" "${DESTDIR}" || exit 1
+ mkdir -p "${DESTDIR_WWW}" && cp -a "${ROOT_SRCDIR}/webapp/dist/*" "${DESTDIR_WWW}" || exit 1
- cp ${ROOT_SRCDIR}/conf.d/etc/xds-agent /etc/ || exit 1
- cp ${ROOT_SRCDIR}/conf.d/etc/default/xds-agent /etc/default/ || exit 1
+ cp "${ROOT_SRCDIR}/conf.d/etc/xds-agent" /etc/ || exit 1
+ cp "${ROOT_SRCDIR}/conf.d/etc/default/xds-agent" /etc/default/ || exit 1
FILE=/etc/profile.d/xds-agent.sh
- sed -e "s;%%XDS_INSTALL_BIN_DIR%%;${DESTDIR};g" ${ROOT_SRCDIR}/conf.d/${FILE} > ${FILE} || exit 1
+ sed -e "s;%%XDS_INSTALL_BIN_DIR%%;${DESTDIR};g" "${ROOT_SRCDIR}/conf.d/${FILE}" > ${FILE} || exit 1
FILE=/usr/lib/systemd/user/xds-agent.service
- sed -e "s;/opt/AGL/xds/agent;${DESTDIR};g" ${ROOT_SRCDIR}/conf.d/${FILE} > ${FILE} || exit 1
+ sed -e "s;/opt/AGL/xds/agent;${DESTDIR};g" "${ROOT_SRCDIR}/conf.d/${FILE}" > ${FILE} || exit 1
echo ""
echo "To enable xds-agent service, execute: systemctl --user enable xds-agent"
diff --git a/webapp/src/app/@theme/components/tiny-mce/tiny-mce.component.ts b/webapp/src/app/@theme/components/tiny-mce/tiny-mce.component.ts
index c54685b..5b391ae 100644
--- a/webapp/src/app/@theme/components/tiny-mce/tiny-mce.component.ts
+++ b/webapp/src/app/@theme/components/tiny-mce/tiny-mce.component.ts
@@ -1,3 +1,4 @@
+/* MODS_XDS: not used for now
import { Component, OnDestroy, AfterViewInit, Output, EventEmitter, ElementRef } from '@angular/core';
@Component({
@@ -31,3 +32,4 @@ export class TinyMCEComponent implements OnDestroy, AfterViewInit {
tinymce.remove(this.editor);
}
}
+*/
diff --git a/webapp/src/app/pages/build/settings-modal/build-settings-modal.component.ts b/webapp/src/app/pages/build/settings-modal/build-settings-modal.component.ts
deleted file mode 100644
index fd1b904..0000000
--- a/webapp/src/app/pages/build/settings-modal/build-settings-modal.component.ts
+++ /dev/null
@@ -1,143 +0,0 @@
-import { Component, Input, ViewChild, OnInit } from '@angular/core';
-import { Observable } from 'rxjs/Observable';
-import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
-import { FormControl, FormGroup, Validators, ValidationErrors, FormBuilder, ValidatorFn, AbstractControl } from '@angular/forms';
-
-// Import RxJs required methods
-import 'rxjs/add/operator/map';
-import 'rxjs/add/operator/filter';
-import 'rxjs/add/operator/debounceTime';
-
-import { AlertService, IAlert } from '../../../@core-xds/services/alert.service';
-import { ProjectService, IProject, ProjectType, ProjectTypes } from '../../../@core-xds/services/project.service';
-import { XDSConfigService } from '../../../@core-xds/services/xds-config.service';
-
-
-@Component({
- selector: 'xds-build-settings-modal',
- templateUrl: 'build-settings-modal.component.html',
- styleUrls: ['build-settings-modal.component.scss'],
-})
-export class BuildSettingsModalComponent implements OnInit {
- // @Input('server-id') serverID: string;
- private serverID: string;
-
- cancelAction = false;
- userEditedLabel = false;
- projectTypes = ProjectTypes;
-
- addProjectForm: FormGroup;
- typeCtrl: FormControl;
- pathCliCtrl: FormControl;
- pathSvrCtrl: FormControl;
-
- constructor(
- private alert: AlertService,
- private projectSvr: ProjectService,
- private XdsConfigSvr: XDSConfigService,
- private fb: FormBuilder,
- private activeModal: NgbActiveModal,
- ) {
- // Define types (first one is special/placeholder)
- this.projectTypes.unshift({ value: ProjectType.UNSET, display: '--Select a type--' });
-
- this.typeCtrl = new FormControl(this.projectTypes[0].value, this.validatorProjType);
- this.pathCliCtrl = new FormControl('', this.validatorProjPath);
- this.pathSvrCtrl = new FormControl({ value: '', disabled: true }, this.validatorProjPath);
-
- this.addProjectForm = fb.group({
- type: this.typeCtrl,
- pathCli: this.pathCliCtrl,
- pathSvr: this.pathSvrCtrl,
- label: ['', Validators.nullValidator],
- });
- }
-
-
- ngOnInit() {
- // Update server ID
- this.serverID = this.XdsConfigSvr.getCurServer().id;
- this.XdsConfigSvr.onCurServer().subscribe(svr => this.serverID = svr.id);
-
- // Auto create label name
- this.pathCliCtrl.valueChanges
- .debounceTime(100)
- .filter(n => n)
- .map(n => {
- const last = n.split('/');
- let nm = n;
- if (last.length > 0) {
- nm = last.pop();
- if (nm === '' && last.length > 0) {
- nm = last.pop();
- }
- }
- return 'Project_' + nm;
- })
- .subscribe(value => {
- if (value && !this.userEditedLabel) {
- this.addProjectForm.patchValue({ label: value });
- }
- });
-
- // Handle disabling of Server path
- this.typeCtrl.valueChanges
- .debounceTime(500)
- .subscribe(valType => {
- const dis = (valType === String(ProjectType.SYNCTHING));
- this.pathSvrCtrl.reset({ value: '', disabled: dis });
- });
- }
-
- closeModal() {
- this.activeModal.close();
- }
-
- onKeyLabel(event: any) {
- this.userEditedLabel = (this.addProjectForm.value.label !== '');
- }
-
- onChangeLocalProject(e) {
- }
-
- onSubmit() {
- if (this.cancelAction) {
- return;
- }
-
- const formVal = this.addProjectForm.value;
-
- const type = formVal['type'].value;
- this.projectSvr.add({
- serverId: this.serverID,
- label: formVal['label'],
- pathClient: formVal['pathCli'],
- pathServer: formVal['pathSvr'],
- type: formVal['type'],
- // FIXME: allow to set defaultSdkID from New Project config panel
- })
- .subscribe(prj => {
- this.alert.info('Project ' + prj.label + ' successfully created.');
- this.closeModal();
-
- // Reset Value for the next creation
- this.addProjectForm.reset();
- const selectedType = this.projectTypes[0].value;
- this.addProjectForm.patchValue({ type: selectedType });
-
- },
- err => {
- this.alert.error(err, 60);
- this.closeModal();
- });
- }
-
- private validatorProjType(g: FormGroup): ValidationErrors | null {
- return (g.value !== ProjectType.UNSET) ? null : { validatorProjType: { valid: false } };
- }
-
- private validatorProjPath(g: FormGroup): ValidationErrors | null {
- return (g.disabled || g.value !== '') ? null : { validatorProjPath: { valid: false } };
- }
-
-}
diff --git a/webapp/src/app/pages/config/config-xds/config-xds.component.html b/webapp/src/app/pages/config/config-xds/config-xds.component.html
index e4bd0d5..a2506ce 100644
--- a/webapp/src/app/pages/config/config-xds/config-xds.component.html
+++ b/webapp/src/app/pages/config/config-xds/config-xds.component.html
@@ -10,7 +10,7 @@
<input type="url" class="form-control" [ngClass]="{ 'form-control-danger': !server?.connected }" id="inputServerUrl" [(ngModel)]="xdsServerUrl" name="serverUrl" (ngModelChange)="configFormChanged=true" [disabled]="applying">
</div>
<div class="col-sm-1">
- <span class="fa fa-fw fa-exchange faa-burst fa-size-x2 vcenter" [ngClass]="{'animated': applying}" [style.color]="(server?.connected && !animated)?'green':'red'" ></span>
+ <span class="fa fa-fw fa-exchange faa-burst fa-size-x2 vcenter" [ngClass]="{'animated': applying}" [style.color]="(server?.connected && !applying)?'green':'red'" ></span>
</div>
</div>
<div class="form-group row">
diff --git a/webapp/src/app/pages/config/config-xds/downloadXdsAgent.component.ts b/webapp/src/app/pages/config/config-xds/downloadXdsAgent.component.ts
deleted file mode 100644
index 556316c..0000000
--- a/webapp/src/app/pages/config/config-xds/downloadXdsAgent.component.ts
+++ /dev/null
@@ -1,38 +0,0 @@
-import { Component } from '@angular/core';
-
-@Component({
- selector: 'xds-dwnl-agent',
- template: ``,
- /* FIXME SEB: to be reworked
- template: `
- <template #popTemplate>
- <h3>Install xds-agent:</h3>
- <ul>
- <li>On Linux machine <a href="{{url_OS_Linux}}" target="_blank">
- <span class="fa fa-external-link"></span></a></li>
-
- <li>On Windows machine <a href="{{url_OS_Other}}" target="_blank"><span class="fa fa-external-link"></span></a></li>
-
- <li>On MacOS machine <a href="{{url_OS_Other}}" target="_blank"><span class="fa fa-external-link"></span></a></li>
- </ul>
- <button type="button" class="btn btn-sm" (click)="pop.hide()"> Cancel </button>
- </template>
- <button type="button" class="btn btn-link fa fa-download fa-size-x2"
- [popover]="popTemplate"
- #pop="bs-popover"
- placement="left">
- </button>
- `,
- styles: [`
- .fa-size-x2 {
- font-size: 20px;
- }
- `],
- */
-})
-
-export class DwnlAgentComponent {
-
- public url_OS_Linux = 'https://en.opensuse.org/LinuxAutomotive#Installation_AGL_XDS';
- public url_OS_Other = 'https://github.com/iotbzh/xds-agent#how-to-install-on-other-platform';
-}