diff options
Diffstat (limited to 'src/app/vnfs')
-rw-r--r-- | src/app/vnfs/LoginGuardService/Login-guard-service.ts | 16 | ||||
-rw-r--r-- | src/app/vnfs/userlogin-form/userlogin-form.component.ts | 16 | ||||
-rw-r--r-- | src/app/vnfs/vnf.routing.ts | 35 |
3 files changed, 35 insertions, 32 deletions
diff --git a/src/app/vnfs/LoginGuardService/Login-guard-service.ts b/src/app/vnfs/LoginGuardService/Login-guard-service.ts index 2c834a8..35640d0 100644 --- a/src/app/vnfs/LoginGuardService/Login-guard-service.ts +++ b/src/app/vnfs/LoginGuardService/Login-guard-service.ts @@ -16,18 +16,14 @@ 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. - -ECOMP is a trademark and service mark of AT&T Intellectual Property. ============LICENSE_END============================================ */ -import {Injectable} from '@angular/core'; import {ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot} from '@angular/router'; - -import {NgbModal} from '@ng-bootstrap/ng-bootstrap'; - +import {Injectable} from '@angular/core'; import {MappingEditorService} from '../../shared/services/mapping-editor.service'; +import {NgbModal} from '@ng-bootstrap/ng-bootstrap'; @Injectable() export class LoginGuardService implements CanActivate { @@ -39,11 +35,11 @@ export class LoginGuardService implements CanActivate { let userId = localStorage['userId']; if (userId != null && userId != undefined && userId != '') { - this.router.navigate(['/vnfs/list']); - return false; - } else { return true; + } else { + this.router.navigate(['/vnfs/login'],{ queryParams: { returnUrl: state.url }}); + return false; } } -}
\ No newline at end of file +} diff --git a/src/app/vnfs/userlogin-form/userlogin-form.component.ts b/src/app/vnfs/userlogin-form/userlogin-form.component.ts index dfb665e..188fe81 100644 --- a/src/app/vnfs/userlogin-form/userlogin-form.component.ts +++ b/src/app/vnfs/userlogin-form/userlogin-form.component.ts @@ -16,36 +16,38 @@ 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. - -ECOMP is a trademark and service mark of AT&T Intellectual Property. ============LICENSE_END============================================ */ import {Component, OnInit} from '@angular/core'; -import {Router} from '@angular/router'; + +import { ActivatedRoute } from '@angular/router'; import {EmitterService} from '../../shared/services/emitter.service'; +import {Router} from '@angular/router'; import {UtilityService} from '../../shared/services/utilityService/utility.service'; @Component({selector: 'app-mvnfs-form', templateUrl: './userlogin-form.component.html', styleUrls: ['./userlogin-form.component.css']}) export class userloginFormComponent implements OnInit { userId: string = ''; + returnUrl:string - constructor(private router: Router, private utiltiy: UtilityService) { + constructor(private router: Router, private utiltiy: UtilityService, private route: ActivatedRoute + ) { } ngOnInit() { + this.returnUrl = this.route.snapshot.queryParams['returnUrl'] || '/home'; } + getData() { localStorage['userId'] = this.userId; localStorage['apiToken'] = this.utiltiy.randomId(); EmitterService .get('userLogin') .emit(this.userId); - this - .router - .navigate(['vnfs', 'list']); + this.router.navigateByUrl(this.returnUrl); } } diff --git a/src/app/vnfs/vnf.routing.ts b/src/app/vnfs/vnf.routing.ts index b12530d..fa4e517 100644 --- a/src/app/vnfs/vnf.routing.ts +++ b/src/app/vnfs/vnf.routing.ts @@ -16,26 +16,24 @@ 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. - -ECOMP is a trademark and service mark of AT&T Intellectual Property. ============LICENSE_END============================================ */ -import { GoldenConfigurationHolderComponent, } from './build-artifacts/template-holder/template-holder.component'; -import { MyvnfsComponent } from './myvnfs/myvnfs.component'; -import { NgModule } from '@angular/core'; import { RouterModule, Routes } from '@angular/router'; -import { ReferenceDataformComponent } from './build-artifacts/reference-dataform/reference-dataform.component'; + +import { BuildDesignComponent } from './build-artifacts/build-artifacts.component'; import { GoldenConfigurationComponent } from './build-artifacts/template-holder/template-configuration/template-configuration.component'; +import { GoldenConfigurationHolderComponent, } from './build-artifacts/template-holder/template-holder.component'; import { GoldenConfigurationMappingComponent } from './build-artifacts/template-holder/param-name-value/param-name-value.component'; +import { LoginGuardService } from './LoginGuardService/Login-guard-service'; +import { MyvnfsComponent } from './myvnfs/myvnfs.component'; +import { NgModule } from '@angular/core'; import { ParameterComponent } from './build-artifacts/parameter-definitions/parameter.component'; import { ParameterHolderComponent } from './build-artifacts/parameter-holder/parameter-holder.component'; +import { ReferenceDataHolderComponent } from './build-artifacts/reference-data-holder/reference-data-holder.component'; +import { ReferenceDataformComponent } from './build-artifacts/reference-dataform/reference-dataform.component'; import { VnfsComponent } from './vnfs/vnfs.component'; -import { BuildDesignComponent } from './build-artifacts/build-artifacts.component'; import { userloginFormComponent } from './userlogin-form/userlogin-form.component'; -import { LoginGuardService } from './LoginGuardService/Login-guard-service'; -import { ReferenceDataHolderComponent } from './build-artifacts/reference-data-holder/reference-data-holder.component'; - const routes: Routes = [ { @@ -43,19 +41,21 @@ const routes: Routes = [ component: VnfsComponent, children: [ { - path: '', + path: 'login', component: userloginFormComponent, - canActivate: [LoginGuardService], + }, { path: 'list', - component: MyvnfsComponent + component: MyvnfsComponent, + canActivate: [LoginGuardService], }, { path: 'design', component: BuildDesignComponent, + children: [ { path: 'references', @@ -117,8 +117,13 @@ const routes: Routes = [ ] - }, + } ] + }, { + path: '', + redirectTo: 'list', + pathMatch: 'full' + } ] } @@ -129,4 +134,4 @@ const routes: Routes = [ exports: [RouterModule] }) export class VnfRoutingModule { -}
\ No newline at end of file +} |