Skip to content

Commit

Permalink
Fixes #v0.7: Popup changes added
Browse files Browse the repository at this point in the history
  • Loading branch information
saravanan477 committed Jun 1, 2021
1 parent 07d2000 commit 460a899
Show file tree
Hide file tree
Showing 8 changed files with 354 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Gruntfile.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions client/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@
<script src="./js/views/boards_user_view.js"></script>
<script src="./js/views/chat_view.js"></script>
<script src="./js/views/intro_video_view.js"></script>
<script src="./js/views/popup_view.js"></script>
<script src="./js/views/card_view.js"></script>
<script src="./js/views/modal_card_view.js"></script>
<script src="./js/views/modal_list_view.js"></script>
Expand Down
8 changes: 8 additions & 0 deletions client/js/templates/popup.jst.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<div class="row mt5">
<div class="col-xs-12 text-center">
<h3><%- i18next.t("You're using open source Community Edition. Please consider upgrading to the Enterprise Edition and support this open source project") %></h3>
</div>
<div class="col-xs-12 text-center">
<a href="http://restya.com/enterprise?utm_source=Restyaboard - <%- SITE_NAME %>&utm_medium=web&utm_campaign=contact&category=contact" target="_blank" title="<%- i18next.t('Upgrade to Enterprise Edition') %>" class="btn btn-primary navbar-btn"><%- i18next.t('Upgrade') %></a>
</div>
</div>
11 changes: 9 additions & 2 deletions client/js/views/intro_video_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ App.intro_video_view = Backbone.View.extend({
*/
initialize: function() {
var field = $('#content').attr('class');
if (field === "container-fluid") {
if (field.indexOf("container-fluid") !== -1) {
this.render();
}
},
Expand All @@ -25,7 +25,9 @@ App.intro_video_view = Backbone.View.extend({
*
*/
render: function() {
$('#content').addClass('intro_video');
if (!$('#content').hasClass("intro_video")) {
$('#content').addClass("intro_video");
}
if (authuser.user.is_intro_video_skipped === "f" || authuser.user.is_intro_video_skipped === null) {
this.$el.dockmodal({
height: 300,
Expand Down Expand Up @@ -151,9 +153,14 @@ App.intro_video_view = Backbone.View.extend({
}
}
});
/*The popupView has been called here*/
var popupView = new App.popupView();
}
});
this.$el.html(this.template);
} else {
/*The popupView has been called here*/
var popupView = new App.popupView();
}
return this;
}
Expand Down
20 changes: 20 additions & 0 deletions client/js/views/login_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ App.LoginView = Backbone.View.extend({
auth_response.user.is_ldap = response.user.is_ldap;
auth_response.user.is_saml = response.user.is_saml;
auth_response.user.is_intro_video_skipped = response.user.is_intro_video_skipped;
auth_response.user.community_edition_popup = response.user.community_edition_popup;
auth_response.user.is_two_factor_authentication_enabled = response.user.is_two_factor_authentication_enabled;
$.cookie('auth', JSON.stringify(auth_response));
$.removeCookie('push_tokens');
Expand All @@ -146,6 +147,25 @@ App.LoginView = Backbone.View.extend({
}
auth_user_organizations.add(authuser.user.organizations);
self.changeFavicon(response.user.notify_count);
if (_.isUndefined(authuser.user.community_edition_popup) || _.isEmpty(authuser.user.community_edition_popup) || authuser.user.community_edition_popup == null) {
var userdata = {};
userdata.date = moment(new Date()).format('YYYY-MM-DD HH:mm:ss').split(' ').join('T');
userdata.is_skipped = false;
var formdata = {};
formdata.community_edition_popup = JSON.stringify(userdata);
var user = new App.User();
user.url = api_url + 'users/' + authuser.user.id + '.json';
user.save(formdata, {
success: function(response) {
if (!_.isEmpty(response.attributes.success)) {
var Auth = JSON.parse($.cookie('auth'));
Auth.user.community_edition_popup = JSON.stringify(userdata);
$.cookie('auth', JSON.stringify(Auth));
authuser = Auth;
}
}
});
}
this.headerView = new App.HeaderView({
model: model
});
Expand Down
180 changes: 180 additions & 0 deletions client/js/views/popup_view.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
/**
* popup View
* @class popupView
* @constructor
* @extends Backbone.View
*/

App.popupView = Backbone.View.extend({
/**
* Constructor
* initialize default values and actions
*/
initialize: function() {
if (window.location.hash === "#/boards") {
this.render();
}
},
template: JST['templates/popup'],
/**
* render()
* populate the html to the dom
* @param NULL
* @return object
*
*/
render: function() {
var communityEditionPopup = JSON.parse(authuser.user.community_edition_popup);
var expirationDate = communityEditionPopup.date.replace('T', ' ');
expirationDate = new Date(expirationDate);
expirationDate.setDate(expirationDate.getDate() + parseInt(30));
var currentDate = new Date('2021-08-01 16:56:23');
if ((currentDate.getTime() > expirationDate.getTime()) && !communityEditionPopup.is_skipped) {
this.$el.dockmodal({
height: 300,
width: 200,
animationSpeed: ANIMATION_SPEED,
title: "<div class='col-xs-12'><div class='text-center'><strong>" + i18next.t('Upgrade to Enterprise Edition') + "</strong></div></div>",
beforePopout: function(event) {
if ($(window).width() < 1400) {
$('.editor').resizable({
maxWidth: 1000,
minWidth: 500
});
} else {
$('.editor').resizable({
maxWidth: 1050,
minWidth: 500
});
}
$('.editor').each(function() {
var $this = $(this);
var factor1 = '30',
factor2 = '70';
if (!_.isUndefined(authuser.user) && !_.isEmpty(authuser.user)) {
if (!_.isUndefined(authuser.user.persist_card_divider_position) && authuser.user.persist_card_divider_position !== null) {
factor1 = authuser.user.persist_card_divider_position;
factor2 = 100 - factor1;
}
}
$this.resizable({
handles: 'e',
resize: function(event, ui) {
var x = ui.element.outerWidth();
var ele = ui.element;
var factor = x * 100 / $(this).parent().width();
var f1 = factor;
var f2 = 100 - factor;
$.cookie('factor1', f1);
$this.css('width', f1 + '%');
$this.next().css('width', f2 + '%');
},
stop: function(event, ui) {
var x = ui.element.outerWidth();
var factor = x * 100 / $(this).parent().width();
if (!_.isUndefined(authuser.user) && !_.isEmpty(authuser.user)) {
var data = {
persist_card_divider_position: factor
};
var user = new App.User();
user.url = api_url + 'users/' + authuser.user.id + '.json';
user.set('id', parseInt(authuser.user.id));
user.save(data, {
success: function(model, response) {
var Auth = JSON.parse($.cookie('auth'));
Auth.user.persist_card_divider_position = factor;
$.cookie('auth', JSON.stringify(Auth));
authuser = Auth;
}
});
}
},
}).css({
width: factor1 + '%'
}).next().css({
width: factor2 + '%'
});
});
},
beforeRestore: function(event) {
$('.editor').resizable({
maxWidth: 380,
minWidth: 350
});
$('.editor').each(function() {
var $this = $(this);
var factor1 = '60';
var factor2 = '40';
$this.resizable({
handles: 'e',
resize: function(event, ui) {
var x = ui.element.outerWidth();
var ele = ui.element;
var factor = x * 100 / $(this).parent().width();
var f1 = factor;
var f2 = 100 - factor;
$this.css('width', f1 + '%');
$this.next().css('width', f2 + '%');
}
}).css({
width: factor1 + '%'
}).next().css({
width: factor2 + '%'
});
});
},
open: function(event, dialog) {
$('.dockmodal').removeClass('active');
event.parent().parent().addClass('active');
$('.dockmodal').click(function(e) {
$('.dockmodal').removeClass('active');
$(this).addClass('active');
});
$(window).bind('keydown', function(e) {
if (e.keyCode === 27) {
$('.action-close', $('.dockmodal.active')).trigger('click');
}
});
},
close: function(event, dialog) {
var data = {};
data.date = communityEditionPopup.date;
data.is_skipped = true;
var formdata = {};
formdata.community_edition_popup = JSON.stringify(data);
var user = new App.User();
user.url = api_url + 'users/' + authuser.user.id + '.json';
user.save(formdata, {
success: function(response) {
if (!_.isEmpty(response.attributes.success)) {
var Auth = JSON.parse($.cookie('auth'));
Auth.user.community_edition_popup = JSON.stringify(data);
$.cookie('auth', JSON.stringify(Auth));
authuser = Auth;
}
}
});
/* var data = {};
data.is_intro_video_skipped = true;
$('.action-close', ('.dockmodal-header')).trigger('click');
var introvideo = new App.intro_view_model();
introvideo.url = api_url + 'users/' + authuser.user.id + '.json';
introvideo.save(data, {
success: function(response) {
if (!_.isEmpty(response.attributes.success)) {
var Auth = JSON.parse($.cookie('auth'));
Auth.user.is_intro_video_skipped = response.attributes.is_intro_video_skipped;
$.cookie('auth', JSON.stringify(Auth));
authuser = Auth;
}
}
}); */
}
});
this.$el.html(this.template);
}
return this;
}
});
7 changes: 7 additions & 0 deletions server/php/R/r.php
Original file line number Diff line number Diff line change
Expand Up @@ -3286,6 +3286,13 @@ function r_post($r_resource_cmd, $r_resource_vars, $r_resource_filters, $r_post)
);
pg_query_params($db_lnk, 'UPDATE users SET is_intro_video_skipped= $1 WHERE id = $2', $qry_val_arr);
}
if (!empty($r_post['community_edition_popup'])) {
$qry_val_arr = array(
$r_post['community_edition_popup'],
$r_resource_vars['users']
);
pg_query_params($db_lnk, 'UPDATE users SET community_edition_popup= $1 WHERE id = $2', $qry_val_arr);
}
if (!empty($_POST['username'])) {
$qry_val_arr = array(
$r_resource_vars['users']
Expand Down
Loading

0 comments on commit 460a899

Please sign in to comment.