{% block field %}
{% if object.isDbSet %}
<select class="deploy_version_version" data-id="{{ object.id }}" id="deploy_version_version_{{ object.id }}">
<option value="-" readonly selected>Válassz verziót!</option>
<optgroup label="Project images">
{% for deployTag in object.getProject.getDeployTags %}
<option title="{{ deployTag.name }}" value="{{ deployTag.name }}">
{{ deployTag.name }}
{% if deployTag.environment != "" %}
(#{{ deployTag.environment.id }}: {{ deployTag.environment.project.name }}/{{ deployTag.environment.type.name }})
{% endif %}
{% if deployTag.labels is not empty %}
[{% for label in deployTag.getLabels %}
[color={{ label.GetParamsDecoded()["color"] }}]{{ label.value }}[/color]
{% endfor %}]
{% endif %}
{% if deployTag.note != "" %}
({{ deployTag.note }})
{% endif %}
</option>
{% endfor %}
</optgroup>
{% if admin.sharedDeployTags is not empty %}
{% for projectType,deployTags in admin.sharedDeployTags %}
{% if object.project.type.value == projectType %}
{% for projectTypeName,sharedDeployTag in deployTags %}
<optgroup label="{{ projectTypeName }} shared images">
{% for deployTag in sharedDeployTag %}
<option title="{{ deployTag.project.botname }}:{{ deployTag.name }}" value="{{ deployTag.project.botname }}:{{ deployTag.name }}">
{{ deployTag.project.botname }}:{{ deployTag.name }}
{% if deployTag.environment != "" %}
(#{{ deployTag.environment.id }}: {{ deployTag.environment.project.name }}/{{ deployTag.environment.type.name }})
{% endif %}
{% if deployTag.labels is not empty %}
[{% for label in deployTag.getLabels %}
[color={{ label.GetParamsDecoded()["color"] }}]{{ label.value }}[/color]
{% endfor %}]
{% endif %}
{% if deployTag.note != "" %}
({{ deployTag.note }})
{% endif %}
</option>
{% endfor %}
</optgroup>
{% endfor %}
{% endif %}
{% endfor %}
{% endif %}
</select>
{% if object.project.type.value != "phoenix" %}
<a class="btn btn-sm btn-default bg-success" id="deploy_version_button_{{ object.id }}" data-url="{{ admin.generateObjectUrl('deploy', object, {"version":""}) }}" href="#" disabled><i class="fa fa-magic" aria-hidden="true"> </i>Deploy</a>
{% else %}
<a class="btn btn-sm btn-default bg-success" href="https://jenkins.talkabot.net" target="_blank"><i class="fa fa-magic" aria-hidden="true"> </i>Deploy</a>
<a class="btn btn-sm btn-default bg-success" href="#" onclick="copyToClipboard(document.getElementById('deploy_version_version_{{ object.id }}').value)"><i class="fa fa-copy" aria-hidden="true"> </i> Copy Tag</a>
{% endif %}
<a class="btn btn-sm btn-default bg-danger" href="{{ admin.generateObjectUrl('stop', object) }}"><i class="fa fa-stop" aria-hidden="true"> </i>Stop</a>
<a class="btn btn-sm btn-default bg-info" href="{{ admin.generateObjectUrl('idp_generate', object) }}" title="If you would like to make an existing project to use IDP, use this button."><i class="fa fa-sign-in" aria-hidden="true"> </i>IDPfy</a>
<a class="btn btn-sm btn-default bg-info" href="{{ admin.generateObjectUrl('create_resourceproxy_user', object) }}" title="Create a new resourceproxy user" data-toggle="modal"><i class="fa fa-user-plus" aria-hidden="true"> </i>Create Resourceproxy User</a>
{% if object.project.type.value == "cheq" %}
<a class="btn btn-sm btn-default bg-info" href="#" title="Register Viber Auth token (DB update and webhoor registration)!" data-toggle="modal" data-target="#viberTokenModal_{{ object.id }}"><i class="fa fa-user-plus" aria-hidden="true"> </i>vibertoken</a>
{% endif %}
{% if object.project.type.value == "cheq" %}
<a class="btn btn-sm btn-default bg-info" href="#" title="Create this user to permauser and create new inviteToken for it!" data-toggle="modal" data-target="#permaUserCreateModal_{{ object.id }}"><i class="fa fa-user-plus" aria-hidden="true"> </i>PermaUser</a>
{% endif %}
{% if object.type.name == "prod" %}
<a class="btn btn-sm btn-default" href="{{ admin.generateObjectUrl('debug', object) }}" title="Give deploy access to Developers for 1 hour"><i class="fa fa-bug" aria-hidden="true"> </i>Debug</a>
{% endif %}
<!-- Modal -->
<div class="modal fade" id="botidpUserCreateModal_{{ object.id }}" tabindex="-1" role="dialog" aria-labelledby="botidpUserCreateModalLabel_{{ object.id }}" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="botidpUserCreateModalLabel_{{ object.id }}">Create new user in {{ object.getProject }} / {{ object.getType.getName }}</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<form>
<div class="form-group">
<label for="botidpUserCreateEmail_{{ object.id }}">Email address</label>
<input type="email" name='botidpUserCreateEmail_{{ object.id }}' class="form-control" id="botidpUserCreateEmail_{{ object.id }}" aria-describedby="botidpUserCreateEmailHelp" placeholder="Enter email" style="border: solid 2px red;">
<small id="botidpUserCreateEmailHelp" class="form-text text-muted">The password will be sent to this e-mail address. You can add max 10 e-mail-addresses, separated by comma.</small>
</div>
<div class="form-group">
<label for="botidpUserCreateLanguage_{{ object.id }}">Language of email</label>
<select name='botidpUserCreateLanguage_{{ object.id }}' class="form-control" id="botidpUserCreateLanguage_{{ object.id }}" aria-describedby="botidpUserCreateEmailHelp">
<option value='hu_HU' selected>hu_HU</option>
<option value='en_US'>en_US</option>
<option value='nl_NL'>nl_NL</option>
<option value='pl_PL'>pl_PL</option>
</select>
</div>
<div class="form-group">
<label for="botidpUserCreateGroup_{{ object.id }}">Group of user</label>
<select name='botidpUserCreateGroup_{{ object.id }}' class="form-control" id="botidpUserCreateGroup_{{ object.id }}" aria-describedby="botidpUserCreateGroupHelp" multiple>
<option value='admin' selected>admin</option>
<option value='superuser'>superuser</option>
<option value='operator'>operator</option>
<option value='hr admin'>hr admin</option>
<option value='trainer'>trainer</option>
<option value='statistics'>statistics</option>
<option value='user'>user</option>
</select>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<a class="btn btn-sm btn-default bg-info" id="button_create_botdip_user_{{ object.id }}" href="#" data-baseurl="{{ admin.generateObjectUrl('create_botdip_user', object, {'email': "none", 'language': "en_US", 'group': "defaultgroup"}) }}"><i class="fa fa-user-plus" aria-hidden="true"> </i>Create User</a>
</div>
</div>
</div>
</div>
<!-- Modal Permauser -->
<div class="modal fade" id="permaUserCreateModal_{{ object.id }}" tabindex="-1" role="dialog" aria-labelledby="permaUserCreateModalLabel_{{ object.id }}" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="permaUserCreateModalLabel_{{ object.id }}">Create PermaUser user in {{ object.getProject }} / {{ object.getType.getName }}</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<form>
<div class="form-group">
<label for="altusername_{{ object.id }}">Username</label>
<input type="text" name='altusername_{{ object.id }}' class="form-control" id="altusername_{{ object.id }}" aria-describedby="permaUserCreateHelp" placeholder="Leave empty for your user or enter another user!" style="border: solid 2px red;">
<label for="token1_{{ object.id }}">Invite Token 1</label>
<input type="text" name='token1_{{ object.id }}' class="form-control" id="token1_{{ object.id }}" aria-describedby="permaUserCreateHelp" placeholder="Enter Invite token 1!" style="border: solid 2px red;">
<label for="token2_{{ object.id }}">Invite Token 2</label>
<input type="text" name='token2_{{ object.id }}' class="form-control" id="token2_{{ object.id }}" aria-describedby="permaUserCreateHelp" placeholder="Enter Invite token 2!" style="border: solid 2px red;">
<small id="permaUserCreateHelp" class="form-text text-muted">Please redeploy to be a permauser. Invite Tokens are available immediately!</small>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<a class="btn btn-sm btn-default bg-info" id="button_create_perma_user_{{ object.id }}" href="#" data-baseurl="{{ admin.generateObjectUrl('create_perma_user', object, {'token1': "none",'token2': "none",'altusername': "none"}) }}"><i class="fa fa-user-plus" aria-hidden="true"> </i>Create Permauser</a>
</div>
</div>
</div>
</div>
<!-- Modal viber -->
<div class="modal fade" id="viberTokenModal_{{ object.id }}" tabindex="-1" role="dialog" aria-labelledby="viberTokenModalLabel_{{ object.id }}" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="viberTokenModalLabel_{{ object.id }}">Adding viber auth token to {{ object.getProject }} / {{ object.getType.getName }}</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<form>
<div class="form-group">
<label for="vibertoken_{{ object.id }}">Viber auth token</label>
<input type="text" name='vibertoken_{{ object.id }}' class="form-control" id="vibertoken_{{ object.id }}" aria-describedby="viberTokenHelp" placeholder="Enter Viber auth token!" style="border: solid 2px green;">
<small id="viberTokenHelp" class="form-text text-muted">Enter viber auth token or leave empty, if you want to remove auth token from this CHEQ project</small>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<a class="btn btn-sm btn-default bg-info" id="button_add_viber_token_{{ object.id }}" href="#" data-baseurl="{{ admin.generateObjectUrl('viber_token', object, {'vibertoken': "none"}) }}"><i class="fa fa-user-plus" aria-hidden="true"> </i>add Viber auth token</a>
</div>
</div>
</div>
</div>
{% else %}
<p class='font-italic'>Missing DB config!</p>
<select class="init_shared_db_dbserver" data-id="{{ object.id }}" id="init_shared_db_dbserver_{{ object.id }}">
<option value="-" readonly selected>Válassz Szervert!</option>
{% for value in admin.sharedDBServers %}
<option value="{{ value.id }}">
{{ value.name }}
</option>
{% endfor %}
</select>
<a class="btn btn-sm btn-default bg-info" href="{{ admin.generateObjectUrl('init_rds_db', object) }}" title="Init new RDS (AWS SaaS Postgres) Database!"><i class="fa fa-database" aria-hidden="true"> </i>Init RDS DB</a>
<a class="btn btn-sm btn-default bg-info" href="{{ admin.generateObjectUrl('init_adp_db', object) }}" title="Init new ADP (Azure Database for PostgreSQL) Database!"><i class="fa fa-database" aria-hidden="true"> </i>Init ADP DB</a>
<a class="btn btn-sm btn-default bg-success" id="init_shared_db_button_{{ object.id }}" data-url="{{ admin.generateObjectUrl('init_shared_db', object, {"dbserver":""}) }}" href="#" disabled title="Init new PostgreSQL database on shared server"><i class="fa fa-database" aria-hidden="true"> </i>Init shared db</a>
<a class="btn btn-sm btn-default bg-success" id="init_shared_db_admin_button_{{ object.id }}" data-url="{{ admin.generateObjectUrl('init_shared_db', object, {"prefix":"admin", "dbserver":"", }) }}" href="#" disabled title="Init new PostgreSQL database for ADMIN on shared server"><i class="fa fa-database" aria-hidden="true"><i class="fa fa-user" aria-hidden="true"> </i></i>Init ADMIN shared db</a>
{% endif %}
{% endblock %}
{% block javascripts %}
{% if object.isDbSet %}
<script type="text/javascript">
function copyToClipboard(text) {
var dummy = document.createElement("textarea");
document.body.appendChild(dummy);
dummy.value = text;
dummy.select();
document.execCommand("copy");
document.body.removeChild(dummy);
}
$( document ).ready(function() {
$('#botidpUserCreateEmail_{{ object.id }}').keypress(function (e) {
if (e.which == 13) {
return false; //<---- Add this line
}
});
$("#botidpUserCreateLanguage_{{ object.id }}").on("change", function (e) {
checkCreateUser(e);
});
$("#botidpUserCreateGroup_{{ object.id }}").on("change", function (e) {
checkCreateUser(e);
});
$("#botidpUserCreateEmail_{{ object.id }}").keyup(function (e) {
checkCreateUser(e);
});
$('#token1_{{ object.id }}').keypress(function (e) {
if (e.which == 13) {
return false; //<---- Add this line
}
});
$('#token2_{{ object.id }}').keypress(function (e) {
if (e.which == 13) {
return false; //<---- Add this line
}
});
$("#token1_{{ object.id }}").keyup(function (e) {
checkCreatePermaUser(e);
});
$("#token2_{{ object.id }}").keyup(function (e) {
checkCreatePermaUser(e);
});
$('#vibertoken_{{ object.id }}').keypress(function (e) {
if (e.which == 13) {
return false; //<---- Add this line
}
});
$("#vibertoken_{{ object.id }}").keyup(function (e) {
addViberToken();
});
function checkCreateUser(e) {
if($("#botidpUserCreateEmail_{{ object.id }}").val() == "") {
$("#botidpUserCreateEmail_{{ object.id }}").css("border", "solid 2px red");
$("#button_create_botdip_user_{{ object.id }}").attr("href", "#");
} else {
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,}))$/;
var validEmails = true;
var emailSplit = $("#botidpUserCreateEmail_{{ object.id }}").val().split(",");
$.each( emailSplit, function( index, value ) {
console.log(value);
if(re.test(value.trim())) {
return;
} else {
validEmails = false;
}
});
if(!validEmails) {
$("#botidpUserCreateEmail_{{ object.id }}").css("border", "solid 2px red");
$("#button_create_botdip_user_{{ object.id }}").attr("href", "#");
} else {
$("#botidpUserCreateEmail_{{ object.id }}").css("border", "solid 2px green");
baseurl = $("#button_create_botdip_user_{{ object.id }}").attr("data-baseurl");
baseurl = baseurl.replace("none", $("#botidpUserCr7eateEmail_{{ object.id }}").val());
baseurl = baseurl.replace("en_US", $("#botidpUserCreateLanguage_{{ object.id }}").val());
baseurl = baseurl.replace("defaultgroup", $("#botidpUserCreateGroup_{{ object.id }}").val());
$("#button_create_botdip_user_{{ object.id }}").attr("href", baseurl);
}
}
};
function checkCreatePermaUser(e) {
if($("#token1_{{ object.id }}").val() == "" || $("#token2_{{ object.id }}").val() == "" ) {
$("#token1_{{ object.id }}").css("border", "solid 2px red");
$("#token2_{{ object.id }}").css("border", "solid 2px red");
$("#button_create_perma_user_{{ object.id }}").attr("href", "#");
} else {
if($("#token1_{{ object.id }}").val().length >4 && $("#token2_{{ object.id }}").val().length >4 ) {
$("#token1_{{ object.id }}").css("border", "solid 2px green");
$("#token2_{{ object.id }}").css("border", "solid 2px green");
$("#altusername_{{ object.id }}").css("border", "solid 2px green");
baseurl = $("#button_create_perma_user_{{ object.id }}").attr("data-baseurl");
baseurl = baseurl.replace("none", $("#token1_{{ object.id }}").val());
baseurl = baseurl.replace("none", $("#token2_{{ object.id }}").val());
baseurl = baseurl.replace("none", $("#altusername_{{ object.id }}").val());
$("#button_create_perma_user_{{ object.id }}").attr("href", baseurl);
} else {
$("#token1_{{ object.id }}").css("border", "solid 2px red");
$("#token2_{{ object.id }}").css("border", "solid 2px red");
$("#altusername_{{ object.id }}").css("border", "solid 2px red");
$("#button_create_perma_user_{{ object.id }}").attr("href", "#");
}
}
};
function addViberToken(e) {
$("#vibertoken_{{ object.id }}").css("border", "solid 2px green");
$("#button_add_viber_token_{{ object.id }}").attr("href", "#");
console.log("Viberbuli");
baseurl = $("#button_add_viber_token_{{ object.id }}").attr("data-baseurl");
baseurl = baseurl.replace("none", $("#vibertoken_{{ object.id }}").val());
$("#button_add_viber_token_{{ object.id }}").attr("href", baseurl);
};
$("#deploy_version_version_{{ object.id }}").change(function() {
if($(this).val() != "-") {
button = $("#deploy_version_button_"+$(this).attr("data-id"));
url = button.attr("data-url");
button.attr("href", url+$(this).val());
button.removeAttr("disabled");
} else {
button = $("#deploy_version_button_"+$(this).attr("data-id"));
button.attr("href", "#");
button.attr("disabled", true);
}
});
if($("#deploy_version_version_{{ object.id }}").val() != "-") {
$("#deploy_version_version_{{ object.id }}").trigger("change");
}
$(".deploy_version_version").select2({
escapeMarkup: function(m) {
return m.replace(/\[color\=([a-z\-]+)\](.*)\[\/color\]/gi, '<span style=\'color:$1;\'>$2</span>');
}
});
});
</script>
{% else %}
<script type="text/javascript">
$( document ).ready(function() {
$("#init_shared_db_dbserver_{{ object.id }}").change(function() {
if($(this).val() != "-") {
button = $("#init_shared_db_button_"+$(this).attr("data-id"));
url = button.attr("data-url");
button.attr("href", url+$(this).val());
button.removeAttr("disabled");
button = $("#init_shared_db_admin_button_"+$(this).attr("data-id"));
url = button.attr("data-url");
button.attr("href", url+$(this).val());
button.removeAttr("disabled");
} else {
button = $("#init_shared_db_button_"+$(this).attr("data-id"));
button.attr("href", "#");
button.attr("disabled", true);
button = $("#init_shared_db_admin_button_"+$(this).attr("data-id"));
button.attr("href", "#");
button.attr("disabled", true);
}
});
if($("#init_shared_db_dbserver_{{ object.id }}").val() != "-") {
$("#init_shared_db_dbserver_{{ object.id }}").trigger("change");
}
});
</script>
{% endif %}
{% endblock %}