diff --git a/app/assets/javascripts/admin/components/ip-lookup.js.es6 b/app/assets/javascripts/admin/components/ip-lookup.js.es6 index 3f06ba38d67..f376007af00 100644 --- a/app/assets/javascripts/admin/components/ip-lookup.js.es6 +++ b/app/assets/javascripts/admin/components/ip-lookup.js.es6 @@ -1,5 +1,6 @@ import { ajax } from "discourse/lib/ajax"; import AdminUser from "admin/models/admin-user"; +import copyText from "discourse/lib/copy-text"; export default Ember.Component.extend({ classNames: ["ip-lookup"], @@ -62,6 +63,38 @@ export default Ember.Component.extend({ this.set("show", false); }, + copy: function() { + let text = `IP: ${this.get("ip")}\n`; + const location = this.get("location"); + if (location) { + if (location.hostname) { + text += `${I18n.t("ip_lookup.hostname")}: ${location.hostname}\n`; + } + + text += I18n.t("ip_lookup.location"); + if (location.loc) { + text += `: ${location.loc} ${this.get("city")}\n`; + } else { + text += `: ${I18n.t("ip_lookup.location_not_found")}\n`; + } + + if (location.org) { + text += I18n.t("ip_lookup.organisation"); + text += `: ${location.org}\n`; + } + + if (location.phone) { + text += I18n.t("ip_lookup.phone"); + text += `: ${location.phone}\n`; + } + } + const copyRange = $(``); + copyRange.text(text); + $(document.body).append(copyRange); + copyText(text, copyRange[0]); + copyRange.remove(); + }, + deleteOtherAccounts: function() { var self = this; bootbox.confirm( diff --git a/app/assets/javascripts/discourse/templates/components/ip-lookup.hbs b/app/assets/javascripts/discourse/templates/components/ip-lookup.hbs index 7fc97aeb052..d63f71375c4 100644 --- a/app/assets/javascripts/discourse/templates/components/ip-lookup.hbs +++ b/app/assets/javascripts/discourse/templates/components/ip-lookup.hbs @@ -6,6 +6,7 @@ {{#if show}}
{{d-icon "times"}} + {{d-icon "copy"}}

{{i18n 'ip_lookup.title'}}

{{{i18n 'ip_lookup.powered_by'}}}