frontent refactoring - move account into phraseanet-production-client

This commit is contained in:
Florian BLOUET
2016-03-22 18:34:16 +01:00
parent ffaead9da3
commit 06760d8a79
8 changed files with 14 additions and 261 deletions

View File

@@ -33,6 +33,6 @@
"postinstall": "./node_modules/.bin/gulp install;" "postinstall": "./node_modules/.bin/gulp install;"
}, },
"dependencies": { "dependencies": {
"phraseanet-production-client": "~0.5.0" "phraseanet-production-client": "~0.6.0"
} }
} }

View File

@@ -13,19 +13,6 @@ gulp.task('build-account-css', function(){
], 'account', 'account/css/', debugMode); ], 'account', 'account/css/', debugMode);
}); });
gulp.task('build-account-js', function(){
var accountGroup = [
config.paths.vendors + 'requirejs/require.js',
config.paths.src + 'account/js/account.js'
];
return utils.buildJsGroup(accountGroup, 'account', 'account/js', debugMode);
});
gulp.task('watch-account-js', function() {
debugMode = true;
return gulp.watch(config.paths.src + 'account/**/*.js', ['build-account-js']);
});
gulp.task('watch-account-css', function() { gulp.task('watch-account-css', function() {
debugMode = true; debugMode = true;
gulp.watch(config.paths.src + 'account/**/*.scss', ['build-account-css']); gulp.watch(config.paths.src + 'account/**/*.scss', ['build-account-css']);
@@ -33,5 +20,5 @@ gulp.task('watch-account-css', function() {
gulp.task('build-account', ['copy-account-images', 'build-account-css'], function(){ gulp.task('build-account', ['copy-account-images', 'build-account-css'], function(){
debugMode = false; debugMode = false;
return gulp.start('build-account-js'); return gulp.start('build-account-css');
}); });

View File

@@ -27,7 +27,6 @@ gulp.task('watch-js', function(){
//gulp.start('watch-uploadFlash'); //gulp.start('watch-uploadFlash');
gulp.start('watch-admin-js'); gulp.start('watch-admin-js');
gulp.start('watch-report-js'); gulp.start('watch-report-js');
gulp.start('watch-account-js');
// gulp.start('watch-permaview'); // gulp.start('watch-permaview');
gulp.start('watch-setup-js'); gulp.start('watch-setup-js');
gulp.start('watch-authentication-js'); gulp.start('watch-authentication-js');

View File

@@ -1,171 +0,0 @@
$(document).ready(function () {
// revoke third party application access
$("a.app-btn").bind("click", function (e) {
e.preventDefault();
var $this = $(this);
$.ajax({
type: "GET",
url: $this.attr("href"),
dataType: 'json',
data: {revoke: $this.hasClass("authorize") ? 0 : 1},
success: function (data) {
if (data.success) {
var li = $this.closest('li');
var hidden = $('.app-btn.hidden , .status.hidden', li);
var notHidden = $('.app-btn:not(.hidden), .status:not(.hidden)', li);
hidden.removeClass('hidden');
notHidden.addClass('hidden');
}
}
});
});
// generate new access token
$("a#generate_access").bind("click", function (e) {
e.preventDefault();
var $this = $(this);
$.ajax({
type: "POST",
url: $this.attr("href"),
dataType: 'json',
data: {
usr_id: $this.closest("div").attr("id")
},
success: function (data) {
if (data.success) {
$("#my_access_token").empty().append(data.token);
}
}
});
});
//modify application callback url
$(".modifier_callback").bind("click", function () {
var modifierBtn = $(this);
var saveBtn = $("a.save_callback");
var input = $(".url_callback_input");
var inputVal = input.html();
modifierBtn.hide();
saveBtn.show();
// wrapp current calback in an input
input
.empty()
.wrapInner(''
+ '<input value = "' + inputVal + '"'
+ ' name="oauth_callback" size="50" type="text"/>'
);
$(".url_callback").off();
// save new callback
saveBtn.bind("click", function (e) {
e.preventDefault();
var callback = $("input[name=oauth_callback]").val();
$.ajax({
type: "POST",
url: saveBtn.attr("href"),
dataType: 'json',
data: {callback: callback},
success: function (data) {
if (data.success) {
input.empty().append(callback);
} else {
input.empty().append(inputVal);
}
modifierBtn.show();
saveBtn.hide();
}
});
});
});
//modify application webhook url
$(".webhook-modify-btn").bind("click", function () {
var modifierBtn = $(this);
var saveBtn = $("a.save_webhook");
var input = $(".url_webhook_input");
var inputVal = input.html();
modifierBtn.hide();
saveBtn.show();
// wrapp current calback in an input
input
.empty()
.wrapInner(''
+ '<input value = "' + inputVal + '"'
+ ' name="oauth_webhook" size="50" type="text"/>'
);
$(".url_webhook").off();
// save new callback
saveBtn.bind("click", function (e) {
e.preventDefault();
var webhook = $("input[name=oauth_webhook]").val();
$.ajax({
type: "POST",
url: saveBtn.attr("href"),
dataType: 'json',
data: {webhook: webhook},
success: function (data) {
if (data.success) {
input.empty().append(webhook);
} else {
input.empty().append(inputVal);
}
modifierBtn.show();
saveBtn.hide();
}
});
});
});
// hide or show callback url input whether user choose a web or dektop application
$("#form_create input[name=type]").bind("click", function () {
if ($(this).val() === "desktop") {
$("#form_create .callback-control-group").hide().find("input").val('');
} else {
$("#form_create .callback-control-group").show();
}
});
// authorize password grant type or not
$('.grant-type').bind('click', function () {
var $this = $(this);
$.ajax({
type: "POST",
url: $this.attr("value"),
dataType: 'json',
data: {grant: $this.is(":checked") ? "1" : "0"},
success: function (data) {
}
});
});
// delete an application
$("a.delete-app").bind("click", function (e) {
e.preventDefault();
var $this = $(this);
var li = $this.closest("li");
$.ajax({
type: "DELETE",
url: $this.attr('href'),
dataType: 'json',
data: {},
success: function (data) {
if (data.success) {
li.find('.modal').modal('hide');
li.remove();
}
}
});
});
});

View File

@@ -11,39 +11,9 @@
{% block javascript %} {% block javascript %}
{{ parent() }} {{ parent() }}
<script type="text/javascript"> <script type="text/javascript">
requirejs.config({ accountApp.bootstrap({
baseUrl: "/scripts", state: 'editAccount',
paths: { geonameServerUrl: '{{ app['geonames.server-uri'] }}'
jquery: "../assets/vendors/jquery/jquery.min",
"jquery.ui": "../assets/vendors/jquery-ui/jquery-ui.min",
"jquery.geonames": "../assets/vendors/jquery.geonames/jquery.geonames"
},
shim: {
"jquery.geonames": {
deps: ["jquery", "jquery.ui"],
exports: "$.fn.geocompleter"
},
"common/geonames": {
deps: ["jquery.geonames"]
}
}
});
require([
"jquery",
"common/geonames"
], function ($, geonames) {
$(document).ready(function() {
$('legend').bind('click', function () {
$(".form-info").hide(200);
$($(this).data('target')).show();
});
geonames.init($("#form_geonameid"), {
"server": "{{ app['geonames.server-uri'] }}",
"limit": 40
});
});
}); });
</script> </script>
{% endblock %} {% endblock %}
@@ -130,7 +100,7 @@
<div class="control-group"> <div class="control-group">
<label class="form_label control-label" for="form_city"><strong>{{ "admin::compte-utilisateur ville" | trans }}</strong></label> <label class="form_label control-label" for="form_city"><strong>{{ "admin::compte-utilisateur ville" | trans }}</strong></label>
<div class="controls"> <div class="controls">
<input class="input_element input-xlarge geoname_field" type="text" name="form_geonameid" id="form_geonameid" value="{{ app["authentication"].getUser().getGeonameId() }}" /> <input class="input_element input-xlarge geoname_field" type="text" name="form_geonameid" id="form_geonameid" value="{{ app["authentication"].getUser().getGeonameId() }}" autocomplete="false"/>
<p class="form_alert help-block"></p> <p class="form_alert help-block"></p>
</div> </div>
</div> </div>

View File

@@ -36,8 +36,8 @@
{% endblock %} {% endblock %}
{% block javascript %} {% block javascript %}
<script type="text/javascript" src="/assets/common/js/common{% if not app.debug %}.min{% endif %}.js"></script> <script type="text/javascript" src="/assets/production/commons{% if not app.debug %}.min{% endif %}.js"></script>
<script type="text/javascript" src="/assets/account/js/account{% if not app.debug %}.min{% endif %}.js"></script> <script type="text/javascript" src="/assets/production/account{% if not app.debug %}.min{% endif %}.js"></script>
{% endblock %} {% endblock %}
{% block content %} {% block content %}
@@ -77,13 +77,6 @@
</div> </div>
<div id="DIALOG"></div> <div id="DIALOG"></div>
{% block scripts %} {% block scripts %}
<script type="text/javascript"> <script type="text/javascript"></script>
// close alerts
$(document).on("click", ".alert .alert-block-close a", function(e){
e.preventDefault();
$(this).closest('.alert').alert('close');
return false;
});
</script>
{% endblock %} {% endblock %}
{% endblock %} {% endblock %}

View File

@@ -62,7 +62,6 @@
{% block scripts %} {% block scripts %}
{{ parent() }} {{ parent() }}
<script type="text/javascript" src="/assets/production/commons{% if not app.debug %}.min{% endif %}.js"></script>
<script type="text/javascript" src="/assets/production/authenticate{% if not app.debug %}.min{% endif %}.js"></script> <script type="text/javascript" src="/assets/production/authenticate{% if not app.debug %}.min{% endif %}.js"></script>
<script> <script>
authenticateApp.bootstrap({ authenticateApp.bootstrap({

View File

@@ -78,34 +78,10 @@
</div> </div>
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function() { {{parent()}}
var modal = $("#modal-delete-confirm").modal({ accountApp.bootstrap({
"show" : false state: 'editSession',
}); geonameServerUrl: '{{ app['geonames.server-uri'] }}'
$("a.delete-session").bind("click", function(e) {
e.preventDefault();
modal
.data("delete-url", $(this).prop("href"))
.modal("toggle");
return false;
});
$("a.confirm-delete").on("click", function(e) {
e.preventDefault();
$.ajax({
type: "POST",
url: modal.data("delete-url"),
dataType: "json",
success: function(data){
if (data.success) {
$("#row-" + data.session_id).closest("tr").remove();
}
modal.modal("toggle");
}
});
});
}); });
</script> </script>
{% endblock %} {% endblock %}