2019-08-12 19:34:23 +03:00
|
|
|
///
|
2021-01-11 13:42:16 +02:00
|
|
|
/// Copyright © 2016-2021 The Thingsboard Authors
|
2019-08-12 19:34:23 +03:00
|
|
|
///
|
|
|
|
|
/// 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.
|
|
|
|
|
///
|
|
|
|
|
|
2020-10-14 16:43:07 +03:00
|
|
|
import { Injectable, NgModule } from '@angular/core';
|
|
|
|
|
import { Resolve, RouterModule, Routes } from '@angular/router';
|
2019-08-12 19:34:23 +03:00
|
|
|
|
|
|
|
|
import { MailServerComponent } from '@modules/home/pages/admin/mail-server.component';
|
|
|
|
|
import { ConfirmOnExitGuard } from '@core/guards/confirm-on-exit.guard';
|
|
|
|
|
import { Authority } from '@shared/models/authority.enum';
|
2020-04-02 11:01:13 +03:00
|
|
|
import { GeneralSettingsComponent } from '@modules/home/pages/admin/general-settings.component';
|
|
|
|
|
import { SecuritySettingsComponent } from '@modules/home/pages/admin/security-settings.component';
|
2020-07-09 13:47:35 +03:00
|
|
|
import { OAuth2SettingsComponent } from '@home/pages/admin/oauth2-settings.component';
|
2020-10-14 16:43:07 +03:00
|
|
|
import { User } from '@shared/models/user.model';
|
|
|
|
|
import { Store } from '@ngrx/store';
|
|
|
|
|
import { AppState } from '@core/core.state';
|
|
|
|
|
import { UserService } from '@core/http/user.service';
|
|
|
|
|
import { Observable } from 'rxjs';
|
|
|
|
|
import { getCurrentAuthUser } from '@core/auth/auth.selectors';
|
|
|
|
|
import { OAuth2Service } from '@core/http/oauth2.service';
|
|
|
|
|
import { UserProfileResolver } from '@home/pages/profile/profile-routing.module';
|
2020-11-20 13:08:20 +02:00
|
|
|
import { SmsProviderComponent } from '@home/pages/admin/sms-provider.component';
|
2020-10-14 16:43:07 +03:00
|
|
|
|
|
|
|
|
@Injectable()
|
|
|
|
|
export class OAuth2LoginProcessingUrlResolver implements Resolve<string> {
|
|
|
|
|
|
|
|
|
|
constructor(private oauth2Service: OAuth2Service) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
resolve(): Observable<string> {
|
|
|
|
|
return this.oauth2Service.getLoginProcessingUrl();
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-08-12 19:34:23 +03:00
|
|
|
|
|
|
|
|
const routes: Routes = [
|
|
|
|
|
{
|
|
|
|
|
path: 'settings',
|
|
|
|
|
data: {
|
2020-10-12 10:58:28 +03:00
|
|
|
auth: [Authority.SYS_ADMIN],
|
2019-08-12 19:34:23 +03:00
|
|
|
breadcrumb: {
|
|
|
|
|
label: 'admin.system-settings',
|
|
|
|
|
icon: 'settings'
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
children: [
|
|
|
|
|
{
|
|
|
|
|
path: '',
|
2020-09-21 16:10:00 +03:00
|
|
|
redirectTo: 'general',
|
2019-08-12 19:34:23 +03:00
|
|
|
pathMatch: 'full'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
path: 'general',
|
|
|
|
|
component: GeneralSettingsComponent,
|
|
|
|
|
canDeactivate: [ConfirmOnExitGuard],
|
|
|
|
|
data: {
|
|
|
|
|
auth: [Authority.SYS_ADMIN],
|
|
|
|
|
title: 'admin.general-settings',
|
|
|
|
|
breadcrumb: {
|
|
|
|
|
label: 'admin.general',
|
|
|
|
|
icon: 'settings_applications'
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
path: 'outgoing-mail',
|
|
|
|
|
component: MailServerComponent,
|
|
|
|
|
canDeactivate: [ConfirmOnExitGuard],
|
|
|
|
|
data: {
|
|
|
|
|
auth: [Authority.SYS_ADMIN],
|
|
|
|
|
title: 'admin.outgoing-mail-settings',
|
|
|
|
|
breadcrumb: {
|
|
|
|
|
label: 'admin.outgoing-mail',
|
|
|
|
|
icon: 'mail'
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
2020-11-20 13:08:20 +02:00
|
|
|
{
|
|
|
|
|
path: 'sms-provider',
|
|
|
|
|
component: SmsProviderComponent,
|
|
|
|
|
canDeactivate: [ConfirmOnExitGuard],
|
|
|
|
|
data: {
|
|
|
|
|
auth: [Authority.SYS_ADMIN],
|
|
|
|
|
title: 'admin.sms-provider-settings',
|
|
|
|
|
breadcrumb: {
|
|
|
|
|
label: 'admin.sms-provider',
|
|
|
|
|
icon: 'sms'
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
2019-08-12 19:34:23 +03:00
|
|
|
{
|
|
|
|
|
path: 'security-settings',
|
|
|
|
|
component: SecuritySettingsComponent,
|
|
|
|
|
canDeactivate: [ConfirmOnExitGuard],
|
|
|
|
|
data: {
|
|
|
|
|
auth: [Authority.SYS_ADMIN],
|
|
|
|
|
title: 'admin.security-settings',
|
|
|
|
|
breadcrumb: {
|
|
|
|
|
label: 'admin.security-settings',
|
|
|
|
|
icon: 'security'
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-07-09 13:47:35 +03:00
|
|
|
},
|
|
|
|
|
{
|
2020-09-08 17:05:13 +03:00
|
|
|
path: 'oauth2',
|
2020-07-09 13:47:35 +03:00
|
|
|
component: OAuth2SettingsComponent,
|
|
|
|
|
canDeactivate: [ConfirmOnExitGuard],
|
|
|
|
|
data: {
|
2020-09-21 16:10:00 +03:00
|
|
|
auth: [Authority.SYS_ADMIN],
|
2020-09-08 17:05:13 +03:00
|
|
|
title: 'admin.oauth2.oauth2',
|
2020-07-09 13:47:35 +03:00
|
|
|
breadcrumb: {
|
2020-09-08 17:05:13 +03:00
|
|
|
label: 'admin.oauth2.oauth2',
|
2020-07-09 13:47:35 +03:00
|
|
|
icon: 'security'
|
|
|
|
|
}
|
2020-10-14 16:43:07 +03:00
|
|
|
},
|
|
|
|
|
resolve: {
|
|
|
|
|
loginProcessingUrl: OAuth2LoginProcessingUrlResolver
|
2020-07-09 13:47:35 +03:00
|
|
|
}
|
2019-08-12 19:34:23 +03:00
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
@NgModule({
|
|
|
|
|
imports: [RouterModule.forChild(routes)],
|
2020-10-14 16:43:07 +03:00
|
|
|
exports: [RouterModule],
|
|
|
|
|
providers: [
|
|
|
|
|
OAuth2LoginProcessingUrlResolver
|
|
|
|
|
]
|
2019-08-12 19:34:23 +03:00
|
|
|
})
|
|
|
|
|
export class AdminRoutingModule { }
|