|
A better answer would be to set up a state in the NG router that will prompt for credentials (with "Register" and "Forgot Password" buttons) when it receives a 403 error from your site, or if a local authentication object is not hydrated.
|
|
|
|
|
I did, I could able to Route it when the user is trying to login, then I am checking if the User is authenticated, if not then redirect to login else redirect to Query string, but I am getting problem for the new user, since new User doesn't have status, it has just a hyperlink then its landing the user onto OnlineRegistration page, how can I do the same when there is just a HyperLink, Register hyperlink is as below:
<div class="two-up">
<h2 class="divider-heading" id="firstTimeUserHeader">{{'LoginView.FirsttimeUser?' | Translate}}</h2>
<form name="EnrollForm">
<fieldset>
<legend>{{'LoginView.EnrollForm' | Translate}}</legend>
<ol>
<li>
<p id="enrollHeaderText">{{'LoginView.EnrollHeader' | Translate}}</p>
</li>
<li>
<a class="btn" routerLink="/OnlineRegistration" id="enrollButton" (click)="browserBack.Initialize()">{{'LoginView.Register' | Translate}}</a>
</li>
</ol>
</fieldset>
</form>
</div>
Any help how to maintain the Query string when situation like this arises? Thanks a lot my friend.
|
|
|
|
|
Hi Nathan,
Is there any way I can assign dynamic public property of ts file to routeLink attribute of an Anchor tag or hyperlink buddy as below:
<a class="btn" [routerLink]= "{{Login.OnlineRegistrationRoute}}" id="enrollButton" (click)="browserBack.Initialize()">{{'LoginView.Register' | Translate}}</a>
Login.OnlineRegistrationRoute can have values as "AccountInformation" or "OnlineRegistration;r:XYYZ", is there anyway we can assign this variable to routerLink attribute?
When I am trying to use Encoding as below, its giving me some Crazy encoded url my friend:
this.OnlineRegistrationRoute = `${this.OnlineRegistrationRoute};r=${this.Login.ReturnUrl}`;
Its giving me the url as below:
https://localhost:44307/OnlineRegistration%3Br%3DPeakTimeRebate[^]
Even the hyperlink is getting generated this way:
<a class="btn" id="enrollButton" ng-reflect-router-link="/OnlineRegistration;r=PeakTime" href="/OnlineRegistration%3Br%3DPeakTimeRebate">Register</a>
Why is is putting "/OnlineRegistration%3Br%3DPeakTimeRebate" for href I don't know
I am new to the front-end World, I am not understating how to do this encoding, why is it giving me %3Br%3D instead of ;r=, any help would be greatly helpful, how to make it working my friend please.
modified 7-Mar-19 20:17pm.
|
|
|
|
|
simpledeveloper wrote: I am new to the front-end World, I am not understating how to do this encoding, why is it giving me %3Br%3D instead of ;r=, any help would be greatly helpful, how to make it working my friend please.
Yeah, so I'm not terribly up on current NG conventions, but I can tell you that you're trying to build a malformed URL, which might be prompting Angular to URL Encode the whole thing. A semi-colon is not a legal character anywhere in an URL, and an "=" is only valid in the query string. If you're trying to pass paramaters through a URL, it needs to be like this:
https://<url>?r=thing&q=another_thing
The question mark is the delimiter between the location (route, etc) portion of the URL and the query string. The query string is a bunch of key value pairs with an ampersand between each.
"Never attribute to malice that which can be explained by stupidity."
- Hanlon's Razor
|
|
|
|
|
I could able to do it this way, let me know if there is another better way to do it, this one is fulfilling my need, but if there is another better approach it would be great:
<a class="btn" routerLink="/OnlineRegistration" [queryParams]="OnlineRegistrationRoute!=''?{r:OnlineRegistrationRoute}:{}" id="enrollButton" (click)="browserBack.Initialize()">{{'LoginView.Register' | Translate}}</a>
This is appending the Query string when clicked, but if you have better approach please let me know my friend.
And one more question, is there anyway I can put this OnlineRegistrationRoute!=''?{r:OnlineRegistrationRoute}:{} into a function in the ts file and reference it in the [queryParams] value, my lead is not liking it this way, he wants to hide all the login from the html, any help my friend?
modified 12-Mar-19 17:04pm.
|
|
|
|
|
And another way also I have resolved the issue, to store the Query string value into a local storage in the current page and reading that in the end page where we want it.
|
|
|
|
|
Hi, I am new in Angular world, I am struggling for small thing, but I a trying everything to fix it.
I have a ts file as below:
@Component({
templateUrl: 'residentialRegistration.component.html'
})
export class ResidentialRegistrationComponent extends ComponentBase {
private _lsKey: string = 'OnlineRegistration.LS';
public OnlineRegistration: OnlineRegistration = new OnlineRegistration();
public NoOfInvalidAttempts: number = 0;
public RegexValidationType = RegexValidationType;
public EmitEvent: boolean = false;
public RouteName: string = '';
public MaskingResource: MaskingResource = new MaskingResource();
public IdentificationType: IdentificationType = IdentificationType.PhoneNumber;
public VerificationType: VerificationType = VerificationType.Last4DigitsOfSSN;
public IsIdentifiedByAcctNumber: boolean = false;
public IsIdentifiedByPhoneNumber: boolean = false;
public IsVerifiedByLast4DigitsOfDriversLicenseOrStateId: boolean = false;
public IsVerifiedByLast4DigitsOfSSN: boolean = false;
constructor(private _ls: PgeLocalStorage_PROVIDER<OnlineRegistration>,
private _pgeRoute: PgeRoute,
private _activatedRoute: ActivatedRoute
) {
super();
this.initialize();
}
public initialize(): void {
let lsData = this._ls.getEncrypted(this._lsKey);
if (lsData !== null && lsData !== undefined) {
this.OnlineRegistration = lsData;
this.IdentificationType = IdentificationType.PhoneNumber;
this.VerificationType = VerificationType.Last4DigitsOfSSN;
}
else {
debugger;
this._pgeRoute.redirectToError();
}
};
public onAccountVerificationCompleted(verificationValidation: VerificationValidation): void {
if (verificationValidation.FormValid && !verificationValidation.AccountVerificationValid) {
this.NoOfInvalidAttempts += 1;
}
else if (verificationValidation.FormValid && verificationValidation.AccountVerificationValid) {
this._pgeRoute.navigateToSibling('Success', this._activatedRoute);
}
}
public onModelChange(): void {
debugger;
if (this.IdentificationType === IdentificationType.PhoneNumber) {
this.IsIdentifiedByPhoneNumber = true;
this.IsIdentifiedByAcctNumber = false;
}
else if (this.IdentificationType === IdentificationType.AccountNumber) {
this.IsIdentifiedByPhoneNumber = false;
this.IsIdentifiedByAcctNumber = true;
}
if (this.VerificationType === VerificationType.Last4DigitsOfSSN)
this.IsVerifiedByLast4DigitsOfSSN = true;
else if (this.VerificationType === VerificationType.Last4DigitsOfDriversLicenseOrStateId)
this.IsVerifiedByLast4DigitsOfDriversLicenseOrStateId = true;
}
IdentificationType and VerificationType are enum values
export enum IdentificationType {
Unknown,
PhoneNumber,
AccountNumber
}
export enum VerificationType {
Unknown,
Last4DigitsOfSSN,
Last4DigitsOfDriversLicenseOrStateId
}
And my html is as below:
<form name="residentialRegistrationForm" id="residentialRegistrationForm" novalidate #residentialRegistrationForm="ngForm" (submit)="onNext(residentialRegistrationForm.valid)">
<div id="subHeaderText">
{{ 'OnlineRegistration.SignUpToAccess' | Translate }}
<a class="da-click" data-da-event="telephoneClick" href="tel:800-542-8818">
{{ 'Common.CustomerServiceNumber' | Translate }}
</a>.
<br />
<br />
{{ 'OnlineRegistration.BusinessWithMoreAccounts' | Translate }}
<a href="http://www.portlandgeneral.com/~/link.aspx?_id=B31F170826494FC88B776CBA1E49431F&_z=z">
{{ 'OnlineRegistration.WorkWithMultipleAccounts' | Translate }}
</a>.
</div>
<fieldset>
<ol>
<li>
<br />
<ol>
<li>
<div id="IdentifyLabel">Identify the PGE account:</div>
</li>
<li *ngIf="NoOfInvalidAttempts > 2">
<div class="field-validation-error" id="onlineHelpText">
{{ 'ResidentialView.Validator.OnlineHelp1' | Translate}}{{ 'ResidentialView.Validator.OnlineHelp2' | Translate}}{{ 'ResidentialView.Validator.OnlineHelp3' | Translate}}
</div>
</li>
<li>
<div class="two-up">
<input id="byPhoneNumberOption" name="identificationByOption" type="radio" class="ng-untouched ng-pristine ng-valid" [value]="IdentificationType.PhoneNumber"
[checked]="IsIdentifiedByPhoneNumber"
[(ngModel)]="IdentificationType" (ngModelChange)="onModelChange()" />
<label for="byPhoneNumberOption" id="byPhoneNumberLabel" name="byPhoneNumberLabel">{{'AccountVerification.PhoneNumber' | Translate}}</label>
{{IsIdentifiedByPhoneNumber}}
<div id="divPhoneIdentification" *ngIf="IsIdentifiedByPhoneNumber">
<div *ngIf="(residentialRegistrationForm.submitted || phoneNumberInput.touched)">
<div id="phoneNumberInputRequired" name="phoneNumberInputRequired" class="field-validation-error" *ngIf="phoneNumberInput.errors !== null && phoneNumberInput.errors.required">{{'Common.Validator.PhoneNumberRequired' | Translate}}</div>
<div id="phoneNumberInputRequired1" name="phoneNumberInputInvalid" class="field-validation-error" *ngIf="phoneNumberInput.errors !== null && phoneNumberInput.errors.regexValidator">{{'Common.Validator.PhoneNumberInvalid' | Translate}}</div>
</div>
<input id="phoneNumberInput"
name="phoneNumberInput"
type="tel"
#phoneNumberInput="ngModel"
placeholder="(___) ___-____"
requiredValidator
[textMask]="{ mask: MaskingResource.Phone }"
(ngModelChange)="onInputChanged()"
[(ngModel)]="OnlineRegistration.PhoneNumber"
regexValidator="OnlineRegistration.PhoneNumber"
[regexType]="RegexValidationType.Phone"
pgeAutoMaskingCursor
[ngClass]="{ 'ng-blurred' : residentialRegistrationForm.submitted || phoneNumberInput.touched }" />
</div>
</div>
</li>
<li>
<div class="two-up">
<input type="radio" id="byAccountNumberOption" name="identificationByOption" [value]="IdentificationType.AccountNumber"
[checked]="IsIdentifiedByAcctNumber"
[(ngModel)]="IdentificationType" (ngModelChange)="onModelChange()" />
<label id="byAccountNumberLabel" name="byAccountNumberLabel" for="byAccountNumberOption">{{'Common.AccountNumber' | Translate}}</label>
{{IsIdentifiedByAcctNumber}}
<div id="divAccountIdentification" *ngIf="IsIdentifiedByAcctNumber">
<div *ngIf="(residentialRegistrationForm.submitted || accountNumberInput.touched )">
<div id="accountNumberInputRequired" name="accountNumberInputRequired" class="field-validation-error" *ngIf="accountNumberInput.errors !== null && accountNumberInput.errors.required">{{'Common.Validator.EnterValidAccountNumber' | Translate}}</div>
<div id="accountNumberInputInvalid" name="accountNumberInputInvalid" class="field-validation-error" *ngIf="accountNumberInput.errors !== null && accountNumberInput.errors.regexValidator">{{'Common.Validator.EnterValidAccountNumber' | Translate}}</div>
</div>
<input type="tel"
id="accountNumberInput"
name="accountNumberInput"
#accountNumberInput="ngModel"
placeholder="__________"
requiredValidator
regexValidator="OnlineRegistration.AccountNumber"
[regexType]="RegexValidationType.AccountNumber"
[textMask]="{ mask: MaskingResource.AccountNumber }"
pgeAutoMaskingCursor
(ngModelChange)="onInputChanged()"
[(ngModel)]="OnlineRegistration.AccountNumber"
[ngClass]="{ 'ng-blurred' : residentialRegistrationForm.submitted || accountNumberInput.touched }" />
</div>
</div>
</li>
</ol>
</li>
</ol>
</fieldset>
</form>
<browser-back [lastpage]="false" redirecturl="/AccountInformation"></browser-back>
Basically when I click on the Radio button: byPhoneNumberOption, then it should be checked and radio button byAccountNumberOption should be unchecked and div: divPhoneIdentification should be visible and divAccountIdentification should invisible, similar but oppose thing should happen when we click on the byAccountNumberOption radio button.
Here I am trying to compare this with enum, and passing IdentificationType.PhoneNumber when byPhoneNumberOption radio is clicked
and IdentificationType.AccountNumber when byAccountNumberOption radio is clicked, depending upon this value I am trying to change the check status of radio buttons and visibility of the divs, any help would be very very helpful, I have declared the variables and imported the files properly, something else must be the problem.
When I am trying to see the below method:
public onModelChange(): void {
debugger;
if (this.IdentificationType === IdentificationType.PhoneNumber) {
this.IsIdentifiedByPhoneNumber = true;
this.IsIdentifiedByAcctNumber = false;
}
else if (this.IdentificationType === IdentificationType.AccountNumber) {
this.IsIdentifiedByPhoneNumber = false;
this.IsIdentifiedByAcctNumber = true;
}
if (this.VerificationType === VerificationType.Last4DigitsOfSSN)
this.IsVerifiedByLast4DigitsOfSSN = true;
else if (this.VerificationType === VerificationType.Last4DigitsOfDriversLicenseOrStateId)
this.IsVerifiedByLast4DigitsOfDriversLicenseOrStateId = true;
}
this.IdentificationType value is coming as null instead of the value passed from the radios, where as this.VerificationType value is not coming as null, so, is there anything I am missing in the binding?
Any help would be very very helpful, thanks in advance friends.
|
|
|
|
|
Hallo to the comunity,
That ist the problem, Im trying to send two values/variables fron my view (opciones.phtml), to my controller/action through an Ajax function. I get it with only one parameter, but with two I dont get it!!
I`ll thank any help
this is my html:
guardar
<span class="badge btn-success" id="resultado"></span>
this is my javascript function, inside I invoke the ajax function..
<script type="text/javascript">
function saveNombre(){
var nombre=document.getElementById("nombre").value;
var codc=<?=$this->codcli?>;
if(nombre!==""){
$.ajax({
type:"POST",
data:dataString,
dataType:{nombre:nombre,codc:codc},
cache:false,
url:"<?=$this->basePath("alta/areapersonal/updatenombreclienteajax")?>",
success:function(datos){
$("#resultado").html(datos);
}
});
}else{
return null;
}
}
here you find the data recepcion from view/ajax,in the controller/Action
if you send only one parameter, from ajax function, you can easily "clean" the value
with the PHP function trim();
but in this case, I,m try to send two values, customer code and Name, I need to include this
to parameters in a function to update the name of the customer, but I dont´t konw hoe to extract from
$datosCliente,
some Idea?, thanks !!
public function updateNombreClienteAjaxAction(){
if($this->request->isxmlHttpRequest()){
$datosCliente= $this->request->getContent("data");
}else{
var_dump("Error action Ajax");
}
}
|
|
|
|
|
I am calling a third-party API to get customer contact information and it returns a string for each field and my application needs to determine if the string is a phone number or Email or web address
String data=GetCustomerInfoFromAPI()
some examples for the data string I am getting back from the API call
"www.google.com"
"602.123.1778"
"John@gmail.com"
|
|
|
|
|
If the source system does not provide the type then you will need to work it out by trial and error. Assuming that each type will be guaranteed to be in a certain basic form you can use the various JavaScript String Reference[^] methods to parse the strings and check for patterns etc. For example will all telephone numbers contsain only numbers and specific field delimiters? Will all email addresses contain @ characters etc.
|
|
|
|
|
I'm probably to late but here is it anyway. You can make use of Regular expression (Regex) to validation your strings.
Here is an example on how to check if the string is an email address using regex:
function validateEmail(email) {
var re = /^(([^<>()[]\.,;:\s@"]+(.[^<>()[]\.,;:\s@"]+)*)|(".+"))@(([[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}])|(([a-zA-Z-0-9]+.)+[a-zA-Z]{2,}))$/;
return re.test(String(email).toLowerCase());
}
|
|
|
|
|
I am not sure where else to go. I am in a programming class and I have no clue what is going on. My school decided to take it upon themselves to enter me in a class that has required prereqs without me taking the prereqs. I will post the question below. Any help will be greatly appreciated.
1. Write a program that asks the user to enter a String and perform a series of Character, Math and String functions on this input String. Use “printf” to print all your output.
2. Create a zip file that contains your Java programs. Include a screenshot of each program execution. You can either paste the screenshot into a Word document or simply paste it into the Comments field when submitting your homework.
Can anyone help me please?!?!
|
|
|
|
|
Sorry, no. This site provides assistance with code that you have written, it does not provide code to order. If you cannot understand your assignments then you need to discuss the problem with your teacher. It will not help you to hand in work that someone else has written for you.
|
|
|
|
|
Member 14145236 wrote: 1. Write a program that asks the user to enter a String and perform a series of Character, Math and String functions on this input String. Use “printf” to print all your output. Where are you stuck?
Member 14145236 wrote: 2. Create a zip file that contains your Java programs. Include a screenshot of each program execution. You can either paste the screenshot into a Word document or simply paste it into the Comments field when submitting your homework. That's the easy part.
Social Media - A platform that makes it easier for the crazies to find each other.
Everyone is born right handed. Only the strongest overcome it.
Fight for left-handed rights and hand equality.
|
|
|
|
|
Is it appropriate working JavaScript in Microsoft Visual Studio or there is a better environment for that.
Please help me.
thnx.
|
|
|
|
|
|
I have installed Visual Studio Enterprise 2015 but JavaSript package hadn't been installed and i approach:
"Microsoft Visual Studio JavaScript Language Service
Not signature was present in the subject." in the end of installation.
how can i fix it and start JavaScript in Visual Studio.
Thanks.
|
|
|
|
|
|
Hi,
I need a Modal Dialog for a customer to submit their account code and password. I have put the following Java Script together:-
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
<!--
function LoginToAccount() {
window.open("LogIn/LoginForm.html", "","width=350,height=150")
}
</SCRIPT>
It works of sorts, the form appears on the screen, but:-
- it appears at the Top Left Corner rather than Centre Screen
- It contains the Source Bar, and all the windows furniture.
- The Dialog is not Modal.
Is there a way to remedie this, or am I totally on the wrong path.
Kind Regards,
Bram van Kampen
|
|
|
|
|
|
Hi,
I have a Web Api as below:
[Route("api/PeakTimeRebate")]
public class PeakTimeRebateController : Controller
{
[HttpGet("GetTransactionStatus")]
[DecryptoFilter]
public IActionResult GetTransactionStatus(string EncryptedAccountNumber)
{
this.Response.ContentType = "text/html";
int randVal = new Random().Next(0, 10);
if ((randVal == 1) || (randVal == 2) || (randVal == 3) || (randVal == 5) || (randVal == 7))
return new ObjectResult("Prime");
if (randVal % 2 == 0)
{
return new ObjectResult("Even");
}
else
{
return new ObjectResult("Odd");
}
}
}
I am calling this from a Angular Service as below:
@Injectable()
export class PeakTimeRebatesService extends ServiceBase {
private _peaktimerebateTransactionStatusUrl: string = '/api/PeakTimeRebate/GetTransactionStatus';
constructor(public _http: PgeCustomHttp) {
super(_http);
}
public peakTimeRebateTransactionStatus(encryptedAccountNumber: string): Observable<string> {
debugger;
const params: URLSearchParams = new URLSearchParams();
params.set('EncryptedAccountNumber', encryptedAccountNumber);
const options = new RequestOptions({ search: params });
return this._http.get(this._peaktimerebateTransactionStatusUrl, options)
.map(this.extractBoolean)
.catch(this.handleError);
};
};
I already have imported necessary components for the Service that I haven't mentioned here.
Now I have a component as below:
import { PeakTimeRebatesService } from '../peakTimeRebates/peakTimeRebates.service';
@Component({
selector: 'transactionSuccessful-message',
templateUrl: 'transactionSuccessful.component.html'
})
export class TransactionSuccessfulComponent extends ComponentBase {
@Input()
public TransactionMessage: string = '';
public TransactionSuccessStatus = false;
public TransactionExceptionStatus = false;
private max: number = 10; private min: number = 0; private randVal: number; private checkStatMessage: string;
@Input()
public get EncryptedAccountNumber() {
debugger;
return this._encryptedAccountNumber;
}
public set EncryptedAccountNumber(value: string) {
debugger;
if ((value == null) || (value == '')) {
value = 'XYZ'
}
this._encryptedAccountNumber = value;
if (this.EncryptedAccountNumber !== '') {
this.peakTimeRebateTransactionStatus(this.EncryptedAccountNumber);
}
}
private _encryptedAccountNumber: string = '';
public constructor(
private _service: PeakTimeRebatesService
) {
super();
debugger;
}
private peakTimeRebateTransactionStatus(encryptedAccountNumber: string): void {
debugger;
this._service.peakTimeRebateTransactionStatus(encryptedAccountNumber).subscribe((peakTimeRebateTransactionStatus: any) => {
this.TransactionMessage = peakTimeRebateTransactionStatus;
});
}
ngOnInit(): void {
debugger;
this.EncryptedAccountNumber = '';
if (this.TransactionMessage == "Prime")
{
this.TransactionSuccessStatus = true;
}
else if (this.TransactionMessage == "Even")
{
this.TransactionSuccessStatus = false;
}
else
{
this.TransactionExceptionStatus = true;
}
}
}
And finally my html component is:
<div class="layout-two-column">
<section class="layout-primary">
<form #payBillSuccessForm="ngForm" id="payBillSuccessForm" name="payBillSuccessForm" novalidate>
<div *ngIf="TransactionSuccessStatus">
<h2 id="transactionSucessfulText">{{ 'Common.EnrollmentSuccessful' | Translate }}</h2>
</div>
<div *ngIf="!TransactionSuccessStatus">
<h2 id="transactionFailedText">{{ 'PeakTimeRebatesView.EnrollmentSuccessMessage' | Translate }}</h2>
</div>
<div *ngIf="TransactionExceptionStatus">
<h2 id="transactionExceptionText">{{ 'PeakTimeRebatesView.PeakTimeRebatesHeader' | Translate }}</h2>
</div>
<div class="divider-invisible text-right">
<a class="btn" routerLink="/AccountInformation" id="doneButton">{{ 'Common.Done' | Translate }}</a>
</div>
</form>
</section>
</div>
<browser-back [lastpage]="true"></browser-back>
Now I am expecting that I want to show the message depending upon the returned value from web api, (the problem is that, the execution of the ngOnInit is finishing before execution of Web Api, I mean the setting of TransactionMessage is happening before the Web Api returns value, I am not sure why is it happening, I am new to the client side programming World) I found it when I put the break point, from onInit method before Service call is being completed the control is coming back and finishing the onInit then finishing the web api call, trying to understand how to call the web api from the angular controller, is the onInit not a right place to call the web api from the Angular Component. Any suggestions where am I making mistake? Any help would be very very helpful, thanks in advance. I am new to Angular, really need some help - please, thank you.
modified 29-Jan-19 16:17pm.
|
|
|
|
|
Hi all,
Can you help with this query..
How can we execute a next condition if the first condition is false. In the for loop statement in javascript.
|
|
|
|
|
The same way you would do it in code that is outside of a for loop: with an IF statement. Your question is not clear, perhaps if you show the code where the problem is, people will be able to make suggestions.
|
|
|
|
|
Easy.
for (int i = 0; i < 10; i++){
if (something == 1)
{
}
else{
}
}
Everyone is born right handed. Only the strongest overcome it.
Fight for left-handed rights and hand equality.
|
|
|
|
|
You should actually write if else ladder to check for another condition if one fails, like below;
for(var i = 0; i < 10; i++)
{
if(condition1==true)
{
}
else if(condition2==true)
{
}
else if(conditionN==true)
{
}
else
{
}
}
|
|
|
|
|