2023-04-14 19:18:35 +03:00
|
|
|
///
|
|
|
|
|
/// Copyright © 2016-2023 The Thingsboard Authors
|
|
|
|
|
///
|
|
|
|
|
/// 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 {
|
|
|
|
|
AfterContentInit,
|
|
|
|
|
AfterViewInit,
|
|
|
|
|
ChangeDetectorRef,
|
|
|
|
|
Component,
|
2023-04-19 13:55:51 +03:00
|
|
|
ContentChildren, EventEmitter,
|
2023-04-14 19:18:35 +03:00
|
|
|
Input,
|
2023-04-19 13:55:51 +03:00
|
|
|
OnInit, Output,
|
2023-04-14 19:18:35 +03:00
|
|
|
QueryList,
|
|
|
|
|
ViewChild
|
|
|
|
|
} from '@angular/core';
|
|
|
|
|
import { PageComponent } from '@shared/components/page.component';
|
|
|
|
|
import { Store } from '@ngrx/store';
|
|
|
|
|
import { AppState } from '@core/core.state';
|
|
|
|
|
import { AdminService } from '@core/http/admin.service';
|
|
|
|
|
import { UpdateMessage } from '@shared/models/settings.models';
|
|
|
|
|
import { getCurrentAuthUser } from '@core/auth/auth.selectors';
|
|
|
|
|
import { Authority } from '@shared/models/authority.enum';
|
2023-04-17 19:09:23 +03:00
|
|
|
import { of, Subscription } from 'rxjs';
|
2023-04-14 19:18:35 +03:00
|
|
|
import { MatStepper } from '@angular/material/stepper';
|
|
|
|
|
import { MatButtonToggle, MatButtonToggleGroup } from '@angular/material/button-toggle';
|
2023-04-17 19:09:23 +03:00
|
|
|
import { BreakpointObserver, BreakpointState } from '@angular/cdk/layout';
|
|
|
|
|
import { MediaBreakpoints } from '@shared/models/constants';
|
2023-05-04 17:46:43 +03:00
|
|
|
import { coerceBoolean } from '@shared/decorators/coercion';
|
2023-05-25 17:03:52 +03:00
|
|
|
import { BreadCrumb } from '@shared/components/breadcrumb';
|
2023-04-17 19:09:23 +03:00
|
|
|
|
|
|
|
|
export interface ToggleHeaderOption {
|
|
|
|
|
name: string;
|
|
|
|
|
value: any;
|
|
|
|
|
}
|
2023-04-14 19:18:35 +03:00
|
|
|
|
2023-05-25 17:03:52 +03:00
|
|
|
export type ToggleHeaderAppearance = 'fill' | 'fill-invert' | 'stroked';
|
2023-05-16 20:00:53 +03:00
|
|
|
|
2023-04-14 19:18:35 +03:00
|
|
|
@Component({
|
|
|
|
|
selector: 'tb-toggle-header',
|
|
|
|
|
templateUrl: './toggle-header.component.html',
|
|
|
|
|
styleUrls: ['./toggle-header.component.scss']
|
|
|
|
|
})
|
2023-04-17 19:09:23 +03:00
|
|
|
export class ToggleHeaderComponent extends PageComponent implements OnInit {
|
2023-04-14 19:18:35 +03:00
|
|
|
|
2023-04-17 19:09:23 +03:00
|
|
|
@Input()
|
|
|
|
|
value: any;
|
2023-04-14 19:18:35 +03:00
|
|
|
|
2023-04-19 13:55:51 +03:00
|
|
|
@Output()
|
|
|
|
|
valueChange = new EventEmitter<any>();
|
|
|
|
|
|
2023-04-17 19:09:23 +03:00
|
|
|
@Input()
|
|
|
|
|
options: ToggleHeaderOption[];
|
2023-04-14 19:18:35 +03:00
|
|
|
|
2023-04-17 19:09:23 +03:00
|
|
|
@Input()
|
|
|
|
|
name: string;
|
2023-04-14 19:18:35 +03:00
|
|
|
|
|
|
|
|
@Input()
|
2023-04-17 19:09:23 +03:00
|
|
|
@coerceBoolean()
|
|
|
|
|
useSelectOnMdLg = true;
|
2023-04-14 19:18:35 +03:00
|
|
|
|
2023-05-16 20:00:53 +03:00
|
|
|
@Input()
|
|
|
|
|
@coerceBoolean()
|
|
|
|
|
ignoreMdLgSize = false;
|
|
|
|
|
|
|
|
|
|
@Input()
|
|
|
|
|
appearance: ToggleHeaderAppearance = 'stroked';
|
|
|
|
|
|
2023-04-17 19:09:23 +03:00
|
|
|
isMdLg: boolean;
|
2023-04-14 19:18:35 +03:00
|
|
|
|
2023-04-17 19:09:23 +03:00
|
|
|
private observeBreakpointSubscription: Subscription;
|
2023-04-14 19:18:35 +03:00
|
|
|
|
2023-04-17 19:09:23 +03:00
|
|
|
constructor(protected store: Store<AppState>,
|
|
|
|
|
private cd: ChangeDetectorRef,
|
|
|
|
|
private breakpointObserver: BreakpointObserver) {
|
2023-04-14 19:18:35 +03:00
|
|
|
super(store);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ngOnInit() {
|
2023-04-17 19:09:23 +03:00
|
|
|
this.isMdLg = this.breakpointObserver.isMatched(MediaBreakpoints['md-lg']);
|
|
|
|
|
this.observeBreakpointSubscription = this.breakpointObserver
|
|
|
|
|
.observe(MediaBreakpoints['md-lg'])
|
|
|
|
|
.subscribe((state: BreakpointState) => {
|
|
|
|
|
this.isMdLg = state.matches;
|
|
|
|
|
this.cd.markForCheck();
|
|
|
|
|
}
|
|
|
|
|
);
|
2023-04-14 19:18:35 +03:00
|
|
|
}
|
2023-05-25 17:03:52 +03:00
|
|
|
|
|
|
|
|
trackByHeaderOption(index: number, option: ToggleHeaderOption){
|
|
|
|
|
return option.value;
|
|
|
|
|
}
|
2023-04-14 19:18:35 +03:00
|
|
|
}
|