Is there any sample for #angular-libphonenumber with angular 2 or higher? [closed] - libphonenumber

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 2 months ago.
The community reviewed whether to reopen this question 2 months ago and left it closed:
Original close reason(s) were not resolved
Improve this question
I am trying to create a directive for formatting and validating the phone numbers in my angualr 4 application, was looking for some guidance to getting started.

Edited (15.03.2018) - thanks #Joseph Webber
First, you have to install libphonenumber-js, which is a wrapper of google-libphonenumber ready to be imported on Angular 2+.
You can install it on your app with:
npm install libphonenumber-js --save
or
yarn add libphonenumber-js
depending on the package manager you use.
After install you can use it on your component like:
import { Component, OnInit } from '#angular/core';
import { parse, format, AsYouType } from 'libphonenumber-js';
#Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit {
asYouType: any;
format: any;
parse: any;
ngOnInit() {
this.asYouType = new AsYouType('US').input('2133734');
this.format = format('2133734253', 'US', 'International');
this.parse = parse('(0777) 844 822', 'RO');
}
}
I added the working demo on Github:
libphonenumber-demo-angular2

Related

Suggestions for admin dashboard in golang [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
I am using a gobuffalo framework to create a website with a postgres database, and I am trying to find a good admin dashboard to accompany it. Something like Rail's ActiveAdmin would be awesome. Does anyone have any suggestions?
I ended up using qor/admin to generate the dashboard. It came with views that were already setup. The only code I needed was to tell qor which models I wanted to show. For anyone else trying to implement this in gobuffalo.io, here is how you can generate the routes
func App() *buffalo.App {
if app == nil {
app = buffalo.Automatic(buffalo.Options{
Env: ENV,
SessionName: "_liam_session",
})
app.GET("/", HomeHandler)
app.ANY("/admin/{path:.+}", buffalo.WrapHandler(http.StripPrefix("/admin", Other())))
app.ServeFiles("/assets", packr.NewBox("../public/assets"))
}
return app
}
func Other() http.Handler {
f := func(res http.ResponseWriter, req *http.Request) {
fmt.Fprintln(res, req.URL.String())
fmt.Fprintln(res, req.Method)
}
mux := mux.NewRouter()
mux.HandleFunc("/foo", f).Methods("GET")
mux.HandleFunc("/bar", f).Methods("DELETE")
return mux
}
I use templates for this and it works well. You can generate the views and potentially the handlers and model with basic admin views for CRUD actions very quickly, which is nice. Obviously for each admin view you're going to want to customise it to some extent but as a starting point it works very well.
This is the tool I'm using (if you've used rails it should be familiar), you should also be able to knock something together with go generate (for code), a tool like genny, or just your own solution using text/template to output what you need. I've used this approach on a few projects now, I recommend if you find yourself creating dashboards which then need to be customised later. Most apps have a certain amount of boilerplate for each resource (create, update, delete, index).

How to use REST in web applications? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
Nowadays i am learning REST but i couldn't understand its way of usage. Probably this is perfectly easy question but since i have lack of knowledge about concepts i am totally confused.
Let say i have a simple Spring MVC application and i run localhost:8080/greeting/?id=1 and it shows my greeting.html page and some data from my database. So far so good.
But when i change my #Controller to #RestController and call localhost:8080/greeting/1 i get a json as following {"id":1,"content":"Hello, World!"}. I understand this is normal because this is a response of rest service.
But how to use it in my greeting.html? i mean what is the concept to map this data to my html page?
Thanks in advance
Altan
There are multiple tutorial that explain how to consume RESTful Web Service on Spring.io website :
Consuming a RESTful Web Service with AngularJS : https://spring.io/guides/gs/consuming-rest-angularjs/
Consuming a RESTful Web Service with rest.js : https://spring.io/guides/gs/consuming-rest-restjs/
Consuming a RESTful Web Service with Backbone.js : https://spring.io/guides/gs/consuming-rest-backbone/
Consuming a RESTful Web Service with jQuery : https://spring.io/guides/gs/consuming-rest-jquery/
Consuming a RESTful Web Service with Sencha Touch : https://spring.io/guides/gs/consuming-rest-sencha/
You just have to choose the method with which you are most familiar.
you can use jQuery to parse this json String
var obj = jQuery.parseJSON( '{ "name": "John" }' );
alert( obj.name === "John" );
then your can set value like this
<p>Input field: <input type="text" id="test" value="Mickey Mouse"></p>
$("#test").text(obj.name);

WebAPI - auto generate documentation with all possible responses [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
I have read an article http://www.asp.net/web-api/overview/getting-started-with-aspnet-web-api/creating-api-help-pages and it works fine. But I would prefer to add all possible responses and conditions, when these responses will be sent. Any tool to analyze each WebAPI method, found all places with responses, why it can be happened and create a documentation about it automatically?
I.e. I have the following code:
public HttpResponseMessage GetEditorialRequests()
{
SetUser();
try
{
var r_list = _service.RequestList(user.Id);
if (r_list.Count > 0)
{
var list = mapper.Map<List<SmartphonePhotographerRequestElementApiModel>>(r_list);
return Request.CreateResponse<List<SmartphonePhotographerRequestElementApiModel>>(HttpStatusCode.OK, list);
}
else
return Request.CreateResponse(HttpStatusCode.NoContent);
}
catch (PixlocateBusinessLogic.NoSmartphonePhotographerLocationException)
{
return Request.CreateErrorResponse(HttpStatusCode.BadRequest, new HttpError("User does not have any locations") { { "CustomStatusCode", 466 } });
}
}
I would like to have documentation, which describes that method returns:
StatusCode = 200 and list of elements when method is completed successfully and elements are found
StatusCode = 204 when method is completed successfully and no elements found
StatusCode = 400 when location is not found (condition for getting editorial requests) and detail response with message and CustomStatusCode
Have you tried Swagger (and Swashbuckle)?
Swagger
Swagger is a simple yet powerful representation of your RESTful API. With the largest ecosystem of API tooling on the planet, thousands of developers are supporting Swagger in almost every modern programming language and deployment environment. With a Swagger-enabled API, you get interactive documentation, client SDK generation and discoverability.
Swashbuckle
Seamlessly adds a Swagger to WebApi projects! Combines ApiExplorer and Swagger/swagger-ui to provide a rich discovery, documentation and playground experience to your API consumers. In addition to its Swagger generator, Swashbuckle also contains an embedded version of swagger-ui which it will automatically serve up once Swashbuckle is installed. This means you can complement your API with a slick discovery UI to assist consumers with their integration efforts. Best of all, it requires minimal coding and maintenance, allowing you to focus on building an awesome API!
I use them in many projects, very easy to use and extremely powerful.

Using reCaptcha.MVC always returns false in production [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I am integrating a reCAPTCHA to my site using ReCAPTCHA MVC it is working fine in my development machine but after deploying to production it always send false response. I followed all the steps correctly that are mentioned in the documentation of ReCAPTCHA MVC. and also configure my website url in domain list of Google ReCAPTCHA key settings.
My form is ajax based so that's i written my code as per MVC AJAX.
[HttpPost]
[ValidateAntiForgeryToken]
[AllowAnonymous]
[CaptchaValidator]
public JsonResult SubmitContact(ContactUs contactus, bool captchaValid)
{
if (!captchaValid)
{
return Json("Invalid captcha");
}
if (ModelState.IsValid)
{
//some impl.
return Json("Success");
}
else
{
//some impl.
return Json("Error");
}
}
captchaValid always false in production but works fine in developement.
I am not found any luck.
Could any one please suggest what i am doing wrong.
May be because you registered localhost on registration. So it works on development and when you try to use same keys on your production, it doesn't!
Problem resolved: I am getting always response false due to my requested site's certificate has expired.

Set up S3 bucket as website using ruby SDK [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
I want to set up an Amazon S3 bucket as a website as described here:
http://docs.amazonwebservices.com/AmazonS3/latest/API/RESTBucketPUTwebsite.html?r=5271
but using an ruby API, preferably the aws-sdk for ruby.
Is there a possibility to do that / a library that already supports that? Could not find anything in aws-sdk and right-aws, but maybe I was just blind?
It is possible to configure your bucket as website using an ruby API. I did found a solution, but this uses the aws-s3 gem, not the aws-sdk gem. I found this solution in the ponyhost gem:
body = '<?xml version="1.0" encoding="UTF-8"?>
<WebsiteConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<IndexDocument><Suffix>index.html</Suffix></IndexDocument>
<ErrorDocument><Key>404.html</Key></ErrorDocument>
</WebsiteConfiguration>'
res = AWS::S3::Base.request(:put, "/#{bucketname}?website", {}, body)
EDIT you could also use the fog gem to accomplish this.
storage = Fog::Storage.new({
:provider => 'AWS',
:aws_access_key_id => 'YOUR_KEY',
:aws_secret_access_key => 'YOUR_SECRET',
:region => 'eu-west-1'
})
if storage.kind_of?(Fog::Storage::AWS::Real)
storage.put_bucket_website("YOUR_BUCKET", "index.html", :key => "404.html")
end
Version one of AWS SDK for Ruby has the method #configure_website for bucket objects. So something like this would work:
s3 = AWS::S3.new
b = s3.buckets.create(name, acl: :public_read)
b.configure_website do |cfg|
cfg.options[:index_document] = { suffix: 'index.html' }
end
(the block to configure_website may be omitted if you don't need to set non-default options)
#Aljoscha AWS S3 is just a storage solution, to store all your files. It doesnt provide any kind of run time solution. You need to have a Ec2 instance to host your ruby based application or either to use ruby API. You can just host a static web site on S3 but cant run any kind of app.

Resources