Skip to content
This repository has been archived by the owner on Mar 25, 2023. It is now read-only.

Commit

Permalink
#216 update to master
Browse files Browse the repository at this point in the history
  • Loading branch information
Vladimir Shakhov committed Jul 11, 2017
2 parents 380b30c + 4713f7e commit c980703
Show file tree
Hide file tree
Showing 38 changed files with 607 additions and 382 deletions.
18 changes: 15 additions & 3 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import { AuthService, ErrorService, LanguageService, LayoutService, Notification
import { RouterUtilsService } from './shared/services/router-utils.service';
import { StyleService } from './shared/services/style.service';
import { ZoneService } from './shared/services/zone.service';
import { StorageService } from './shared/services/storage.service';
import { AsyncJobService } from './shared/services/async-job.service';
import { CacheService } from './shared/services/cache.service';


@Component({
Expand All @@ -35,6 +38,9 @@ export class AppComponent implements OnInit, AfterViewInit {
private router: Router,
private error: ErrorService,
private languageService: LanguageService,
private asyncJobService: AsyncJobService,
private cacheService: CacheService,
private storage: StorageService,
private layoutService: LayoutService,
private mdlDialogService: MdlDialogService,
private notification: NotificationService,
Expand All @@ -58,13 +64,19 @@ export class AppComponent implements OnInit, AfterViewInit {
this.loadSettings();

this.error.subscribe(e => this.handleError(e));
this.auth.loggedIn.subscribe(loggedIn => {
this.loggedIn = loggedIn;
this.auth.loggedIn.subscribe(isLoggedIn => {
this.loggedIn = isLoggedIn;
this.updateAccount(this.loggedIn);
if (loggedIn) {
if (isLoggedIn) {
this.auth.startInactivityCounter();
this.loadSettings();
this.zoneService.areAllZonesBasic().subscribe(basic => this.disableSecurityGroups = basic);
} else {
this.auth.clearInactivityTimer();
}
this.asyncJobService.completeAllJobs();
this.cacheService.invalidateAll();
this.storage.resetInMemoryStorage();
});

this.layoutService.drawerToggled.subscribe(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/app/dialog/dialog-module/dialog.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export class DialogService {

this.translateService.get(translationParams.translationTokens, translationParams.interpolateParams)
.subscribe(translations => {
let newConfig = this.getMergedConfig(config);
const newConfig = this.getMergedConfig(config);

newConfig.message = translations[translationParams.message];
newConfig.actions = newConfig.actions.map(action => ({
Expand Down
20 changes: 16 additions & 4 deletions src/app/events/event-list.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,12 @@ export class EventListComponent implements OnInit {
}

public getEvents(params = { reload: false }): void {
if (params.reload) { this.loading = true; }
if (params.reload) {
this.loading = true;
}
this.getEventsObservable(params)
.subscribe(() => this.loading = false);
.finally(() => this.loading = false)
.subscribe();
}

public getEventsObservable(params: { reload: boolean }): Observable<Array<Event>> {
Expand Down Expand Up @@ -109,7 +112,9 @@ export class EventListComponent implements OnInit {
}

private filterBySearch(events: Array<Event>): Array<Event> {
if (!this.query) { return events; }
if (!this.query) {
return events;
}

const queryLower = this.query.toLowerCase();
return events.filter((event: Event) => {
Expand Down Expand Up @@ -169,12 +174,19 @@ export class EventListComponent implements OnInit {
}

private getEventTypes(events: Array<Event>): Array<string> {
return events.reduce((acc, event) => {
const types = events.reduce((acc, event) => {
if (!acc.includes(event.type)) {
acc.push(event.type);
}
return acc;
}, []);

return this.selectedTypes.reduce((acc, type) => {
if (!acc.includes(type)) {
acc.push(type);
}
return acc;
}, types);
}

private initTableModel(translations: any): void {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
<div class="color-preview-container" (click)="popover.toggle($event)">
<div
class="color-preview-container"
[class.disabled]="disabled"
(click)="toggle($event)"
>
<div
class="color-preview"
[style.background-color]="selectedColor?.value"
></div>
</div>
<mdl-textfield
[value]="selectedColor?.value"
(click)="popover.toggle($event)"
[disabled]="disabled"
(click)="toggle($event)"
readonly
></mdl-textfield>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ $input-margin: 10px;
width: 100%;
height: 100%;
}

&.disabled {
cursor: not-allowed;
}
}

:host mdl-textfield {
Expand All @@ -32,6 +36,10 @@ $input-margin: 10px;
/deep/ input {
cursor: pointer;
}

/deep/ input:disabled {
cursor: not-allowed;
}
}

.popover-container {
Expand Down
16 changes: 16 additions & 0 deletions src/app/shared/components/color-picker/color-picker.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
import { MdlPopoverComponent } from '@angular-mdl/popover';
import { Color } from '../../models';
import { toBoolean } from '@angular-mdl/core/components/common/boolean-property';


@Component({
Expand All @@ -35,6 +36,15 @@ export class ColorPickerComponent implements OnChanges, ControlValueAccessor {
public colorWidth: number;

private _selectedColor: Color;
private _disabled: boolean;

@Input() public get disabled(): boolean {
return this._disabled;
};

public set disabled(value) {
this._disabled = toBoolean(value);
}

public ngOnChanges(changes: SimpleChanges): void {
if ('colors' in changes) {
Expand All @@ -52,6 +62,12 @@ export class ColorPickerComponent implements OnChanges, ControlValueAccessor {
this.propagateChange(this._selectedColor);
}

public toggle(event: Event): void {
if (!this._disabled) {
this.popover.toggle(event);
}
}

public selectColor(color: Color): void {
this.selectedColor = color;
this.popover.hide();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
<h3
*ngIf="title"
class="mdl-dialog__title"
>
{{ title | translate }}
</h3>

<form
(ngSubmit)="submit()"
#form="ngForm"
novalidate
>
<div class="mdl-dialog__content">
<mdl-radio
*ngIf="enableAssign"
name="assignExistingRadio"
[value]="modes.assign"
[ngModel]="mode"
(ngModelChange)="setMode($event)"
mdl-ripple
>
{{ assignLabel | translate }}
</mdl-radio>

<mdl-radio
*ngIf="enableCreate"
name="createNewRadio"
[value]="modes.create"
[ngModel]="mode"
(ngModelChange)="setMode($event)"
mdl-ripple
>
{{ createLabel | translate }}
</mdl-radio>

<mdl-radio
*ngIf="defaultValue && enableRemove"
name="removeRadio"
mdl-ripple
[value]="modes.remove"
[ngModel]="mode"
(ngModelChange)="setMode($event)"
>
<div>
{{ removeLabel | translate:{ value: defaultValue } }}
</div>
</mdl-radio>

<mdl-textfield
*ngIf="mode === modes.create"
type="text"
name="textValue"
floating-label
autofocus
required
[(ngModel)]="newValue"
#textField
#textFieldModel="ngModel"
[class.is-invalid]="textFieldModel.invalid && !textFieldModel.pristine"
[style.width]="'100%'"
[placeholder]="textFieldPlaceholder | translate"
[maxlength]="maxLength"
></mdl-textfield>

<mdl-select
name="selectValue"
*ngIf="mode === modes.assign"
[(ngModel)]="newValue"
[placeholder]="selectPlaceholder | translate"
>
<mdl-option
*ngFor="let option of options"
[value]="option"
>
{{ option }}
</mdl-option>
</mdl-select>
</div>

<div class="mdl-dialog__actions">
<button
*ngIf="mode !== modes.remove"
mdl-colored="primary"
mdl-button
mdl-ripple
type="submit"
[disabled]="!valueChanged || !form.valid"
>
{{ 'ASSIGN' | translate }}
</button>
<button
*ngIf="mode === modes.remove"
mdl-colored="primary"
mdl-button
mdl-ripple
type="submit"
>
{{ 'REMOVE' | translate }}
</button>
<button
mdl-colored="primary"
mdl-button
mdl-ripple
type="button"
(click)="cancel()"
>
{{ 'CANCEL' | translate }}
</button>
</div>
</form>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
mdl-radio {
width: 100%;
}

/deep/ mdl-radio div {
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
}

.mdl-dialog__content {
padding-bottom: 0;
}
Loading

0 comments on commit c980703

Please sign in to comment.