Commit f9ce47df authored by Marceau's avatar Marceau

Implement #71 - Open articles in Popup of project in the showcase

parent be584f84
Pipeline #36858 passed with stage
in 50 seconds
This diff is collapsed.
'use strict';
/* Controllers */
root.controller('ProjectShowcaseCtrl', ['$scope', '$state','$http','$stateParams','$rightFactory','$languageFactory', '$projectFactory', '$userFactory', '$portfolioManagerFactory', '$deliverableFactory', '$fileFactory', function($scope, $state, $http,$stateParams,$rightFactory,$languageFactory, $projectFactory, $userFactory, $portfolioManagerFactory, $deliverableFactory, $fileFactory) {
var showcaseCtrl=this;
showcaseCtrl.session = null;
showcaseCtrl.shortName = $stateParams.projectName;
showcaseCtrl.section = "showcase";
showcaseCtrl.projectReady = false;
showcaseCtrl.currentProject = {fullName:"",thumbnail:"",description:"",parent:null,parentName:""};
showcaseCtrl.parentProject = null;
showcaseCtrl.news = [];
showcaseCtrl.members = [];
showcaseCtrl.badges = [];
showcaseCtrl.rawDeliverables = [];
showcaseCtrl.deliverables = [];
showcaseCtrl.plots = {};
showcaseCtrl.plots.labels = [];
showcaseCtrl.plots.charJsOptions = {scaleOverride: true, scaleSteps: 5, scaleStepWidth: 20, scaleStartValue: 0};
showcaseCtrl.plots.data = [[]];
showcaseCtrl.plots.count = [];
showcaseCtrl.isTutor = $userFactory.isTutor();
showcaseCtrl.getProjectPublic = function(refresh,projectId){
if(!projectId) projectId = $scope._getProject()
if(!refresh && showcaseCtrl.projectReady) return;
showcaseCtrl.projectReady = true;
var session = $scope._getSession();
if(session.session && session.session != ""){
showcaseCtrl.session = session.session;
}
var parameters={projectId:projectId};
$projectFactory.get_projectPublic(session, parameters).success(function(data, status, headers, config) {
if(data.status == "success"){
showcaseCtrl.currentProject =data.details[0];
showcaseCtrl.getProjectDetails(true,$scope._getProject());
showcaseCtrl.getMembers();
showcaseCtrl.getDelivrables();
}
});
};
showcaseCtrl.getProjectDetails = function(refresh,projectId){
if(!projectId) projectId = $scope._getProject();
if(!refresh && showcaseCtrl.projectReady) return;
var session = $scope._getSession();
var parameters={projectId:projectId, full:true};
$projectFactory.get_projectDetails(projectId,true,function(data){
if(data.status == "success"){
showcaseCtrl.currentProject =data.details[0];
showcaseCtrl.mainUniversity=data.details["mainUniversity"];
showcaseCtrl.formatProject(showcaseCtrl.currentProject);
}
})
}
showcaseCtrl.newProject = function(){
showcaseCtrl.groupProjects=true;
$portfolioManagerFactory.newModalPrompt({}, null, false, showcaseCtrl.currentProject);
}
showcaseCtrl.getMembers= function (){
$projectFactory.get_project_projectMembers($scope._getProject(),function(data){
if(data.status == "success"){
showcaseCtrl.members = data.details;
showcaseCtrl.projectReady = true;
}},function(data){
$scope._showAlert({status:3,message:$languageFactory._labels.alerts_getProjectMembersFailure});
})
}
showcaseCtrl.getDelivrables = function() {
$deliverableFactory.get_deliverable_getDeliverableRequestsByProject({projectId : $scope._getProject(), userId : $scope._getUser().id}).success(function(data, status, headers, config) {
if(data.status == "success"){
showcaseCtrl.deliverables=data.details;
console.log("DELIV",showcaseCtrl.deliverables);
}
});
}
showcaseCtrl.downloadDeliverable = function(id, projectId) {
$fileFactory.downloadFile(id, projectId);
}
showcaseCtrl.onReady = function(){
var session = $scope._getSession();
var projectName = window.location.href.substring(window.location.href.lastIndexOf("showcase/")+9);
var parameters={projectName:projectName};
var project = $projectFactory.get_projectId(session,parameters).success(function(data, status, headers, config) {
if(data.status == "success" && data.details){
$scope._setProject(data.details.id,data.details.fullName,data.details.parent);
showcaseCtrl.parentProject = data.details.parent;
showcaseCtrl.getProjectPublic(true,data.details.id);
$scope._initMainMenu();
}
});
}
showcaseCtrl.formatProject = function(project){
if(project.thumbnailUrl) project.mainThumbnail = project.thumbnailUrl
else project.mainThumbnail = $scope._urls.defaultImg;
project.beginDate = project.meta.BEGINDATE.toString().substring(2,11);
if(project.meta.ENDDATE)
project.endDate = project.meta.ENDDATE.toString().substring(2,11);
project.fav = project.fav && project.fav.length>0;
// if($languageFactory.isNotifReady) showcaseCtrl.formatProjectNotifications(showcaseCtrl.currentProject);
// else {
// $languageFactory.onInitNotifications(showcaseCtrl,function(file){
// showcaseCtrl.formatProjectNotifications(showcaseCtrl.currentProject);
// })
// }
showcaseCtrl.currentProject = project;
console.log(showcaseCtrl.currentProject);
}
showcaseCtrl.formatProjectNotifications = function(project){
//alert("formatProject")
for (var i=0;i<project.notifications.length;i++){
var notif =project.notifications[i];
var str = $languageFactory._labels.notifications[notif.section][notif.type];
if(notif.owner && notif.project){
console.log('owner',$scope._formatUser(notif.owner).shortName);
str = str.replace("{{user}}",$scope._formatUser(notif.owner).shortName)
str = str.replace("{{project}}",notif.project.fullName)
for(var attr in notif.details ){
var val = notif.details[attr];
if(val=="root") val=$languageFactory._labels[val]
str = str.replace("{{"+attr+"}}",val)
}
var res = str.replace(/{{(\w*)}}/g, "");
notif.body = str;
}
else{
notif.hide = true;
}
}
return project;
}
showcaseCtrl.setProjectFavourite = function(value){
$scope._showAlert({status:2,message:""});
$projectFactory.setProjectFavourite($scope._getProject(),value, function(data){
if(data.status == "success"){
$scope._showAlert({status:1,message:""});
showcaseCtrl.getProjectDetails(true);
}
})
}
showcaseCtrl.requestInviteProject = function(){
$scope._showAlert({status:2,message:""});
$projectFactory.requestInviteProject($scope._getProject(),function(data){
if(data.status == "success"){
$scope._showAlert({status:1,message:""});
}
else{
if(data.details.hasOwnProperty("301"))$scope._showAlert({status:3,message:$languageFactory._labels.alertMsgs.error301});
else $scope._showAlert({status:3,message:""});
}
})
}
showcaseCtrl.startDiscussion = function(){
var projectId = $scope._getProject();
console.log(projectId);
}
showcaseCtrl.onReady();
$portfolioManagerFactory.onCloseModalPrompt($scope, function(param){
showcaseCtrl.groupMembers=false;
showcaseCtrl.groupProjects=false;
console.log("close",param);
if(param.result.success==true){
$state.reload();
}
})
}])
<div modal-scroll class="dialog" style="height: auto;margin-top: 100px;margin-bottom:100px;position:relative;">
<i class="fa fa-times closePopup" ng-click="showcaseCtrl.cancelArticle()" aria-hidden="true"></i>
<h4 style="text-align: center">{{showcaseCtrl.currentArticle.title}}</h4>
<div class="sepator" style="background: #f08317; height: 2px; width: 200px; margin: 0 auto 20px auto;">
</div>
<section ng-if="!showcaseCtrl.isReady"
style="background:none;border:none;width: 100px;margin: auto;margin-top:100px;display: block;padding:10px">
<i class="fa fa-circle-o-notch fa-spin fa-3x fa-fw"></i>
</section>
<div ng-if="showcaseCtrl.isReady">
<div>
<p class="text-small margin-none">
<span><i class="fa fa-fw fa-clock-o"></i> {{showcaseCtrl.currentArticle.date | formatDate}}</span>
<span>{{::_labels.by}}
<strong>{{_formatUser(showcaseCtrl.currentArticle.owner).shortName}}</strong></span>
</p>
<div style="text-align: center;padding: 10px;" ng-if="showcaseCtrl.currentArticle.thumbUrl">
<img ng-src="{{showcaseCtrl.currentArticle.thumbUrl}}"
style="height: 150px; object-fit: none; object-position: center center; width: 100%;" />
</div>
<div class="clearfix separator"></div>
<div id="articleContent" ng-bind-html="showcaseCtrl.currentArticle.content"
style="margin: auto; padding:10px 20px;"></div>
</div>
<div class="clearfix separator"></div>
<div>
<div class="widget" style="padding: 10px;">
<div class="" style="">
<h6>{{::_labels.articleCommentsTitle}}</h6>
<div ng-repeat="comment in showcaseCtrl.currentArticle.comments" style="margin: 10px;"
class="well row border-bottom ">
<div class="pull-left" style="display: inline-block;margin: 5px;">
<img ng-src="{{_formatUser(comment).avatar}}" alt="" class="innerR innerB" width="50">
</div>
<strong>{{_formatUser(comment).shortName}}</strong>
<br />
{{comment.date | formatDate}}:
<div class="separator"></div>
<p style="margin-left: 50px;">{{comment.content}}</p>
</div>
</div>
</div>
</div>
<button class="pull-right cancel" ng-click="showcaseCtrl.cancelArticle()">{{::_labels.closeBtn}}</button>
<div class="clearfix"></div>
</div>
</div>
\ No newline at end of file
<div class="clearfix group-overview">
<div>
<div class="ajouters">
<div class="widget border-top-none " ng-if="showcaseCtrl.articleId==''" ng-include
src="__root+'components/projects/showcase/showcase.project.html'" style="padding:5px;"
onLoad="showcaseCtrl.onReady()"></div>
<div class="chatPopupManager" ng-if="showcaseCtrl.articleId!=''" ng-include
src="__root+'components/projects/showcase/showcase.article.html'" onLoad="showcaseCtrl.initArticle()"
style="padding:5px;"></div>
</div>
</div>
</div>
\ No newline at end of file
'use strict';
/* Controllers */
root.controller('ProjectShowcaseCtrl', ['$scope', '$state', "$http", '$stateParams', '$rightFactory', '$languageFactory', '$projectFactory', '$userFactory', '$portfolioManagerFactory', '$deliverableFactory', '$fileFactory', "$blogFactory", function ($scope, $state, $http, $stateParams, $rightFactory, $languageFactory, $projectFactory, $userFactory, $portfolioManagerFactory, $deliverableFactory, $fileFactory, $blogFactory) {
var showcaseCtrl = this;
showcaseCtrl.session = null;
showcaseCtrl.shortName = $stateParams.projectName;
showcaseCtrl.articleId = $stateParams.articleId;
showcaseCtrl.section = "showcase";
showcaseCtrl.projectReady = false;
showcaseCtrl.currentProject = {
fullName: "",
thumbnail: "",
description: "",
parent: null,
parentName: ""
};
showcaseCtrl.parentProject = null;
showcaseCtrl.news = [];
showcaseCtrl.members = [];
showcaseCtrl.badges = [];
showcaseCtrl.rawDeliverables = [];
showcaseCtrl.deliverables = [];
showcaseCtrl.plots = {};
showcaseCtrl.plots.labels = [];
showcaseCtrl.plots.charJsOptions = {
scaleOverride: true,
scaleSteps: 5,
scaleStepWidth: 20,
scaleStartValue: 0
};
showcaseCtrl.plots.data = [
[]
];
showcaseCtrl.plots.count = [];
showcaseCtrl.isTutor = $userFactory.isTutor();
showcaseCtrl.articleReady = false;
showcaseCtrl.currentArticle = {};
showcaseCtrl.getProjectPublic = function (refresh, projectId) {
if (!projectId) projectId = $scope._getProject()
if (!refresh && showcaseCtrl.projectReady) return;
showcaseCtrl.projectReady = true;
var session = $scope._getSession();
if (session.session && session.session != "") {
showcaseCtrl.session = session.session;
}
var parameters = {
projectId: projectId
};
$projectFactory.get_projectPublic(session, parameters).success(function (data, status, headers, config) {
if (data.status == "success") {
showcaseCtrl.currentProject = data.details[0];
showcaseCtrl.getProjectDetails(true, $scope._getProject());
showcaseCtrl.getMembers();
showcaseCtrl.getDelivrables();
}
});
};
showcaseCtrl.getProjectDetails = function (refresh, projectId) {
if (!projectId) projectId = $scope._getProject();
if (!refresh && showcaseCtrl.projectReady) return;
var session = $scope._getSession();
var parameters = {
projectId: projectId,
full: true
};
$projectFactory.get_projectDetails(projectId, true, function (data) {
if (data.status == "success") {
showcaseCtrl.currentProject = data.details[0];
showcaseCtrl.mainUniversity = data.details["mainUniversity"];
showcaseCtrl.formatProject(showcaseCtrl.currentProject);
}
})
}
showcaseCtrl.newProject = function () {
showcaseCtrl.groupProjects = true;
$portfolioManagerFactory.newModalPrompt({}, null, false, showcaseCtrl.currentProject);
}
showcaseCtrl.getMembers = function () {
$projectFactory.get_project_projectMembers($scope._getProject(), function (data) {
if (data.status == "success") {
showcaseCtrl.members = data.details;
showcaseCtrl.projectReady = true;
}
}, function (data) {
$scope._showAlert({
status: 3,
message: $languageFactory._labels.alerts_getProjectMembersFailure
});
})
}
showcaseCtrl.getDelivrables = function () {
$deliverableFactory.get_deliverable_getDeliverableRequestsByProject({
projectId: $scope._getProject(),
userId: $scope._getUser().id
}).success(function (data, status, headers, config) {
if (data.status == "success") {
showcaseCtrl.deliverables = data.details;
console.log("DELIV", showcaseCtrl.deliverables);
}
});
}
showcaseCtrl.downloadDeliverable = function (id, projectId) {
$fileFactory.downloadFile(id, projectId);
}
showcaseCtrl.onReady = function () {
var session = $scope._getSession();
var parameters = {
projectName: showcaseCtrl.shortName
};
var project = $projectFactory.get_projectId(session, parameters).success(function (data, status, headers, config) {
if (data.status == "success" && data.details) {
$scope._setProject(data.details.id, data.details.fullName, data.details.parent);
showcaseCtrl.parentProject = data.details.parent;
showcaseCtrl.getProjectPublic(true, data.details.id);
$scope._initMainMenu();
}
});
}
showcaseCtrl.formatProject = function (project) {
if (project.thumbnailUrl) project.mainThumbnail = project.thumbnailUrl
else project.mainThumbnail = $scope._urls.defaultImg;
project.beginDate = project.meta.BEGINDATE.toString().substring(2, 11);
if (project.meta.ENDDATE)
project.endDate = project.meta.ENDDATE.toString().substring(2, 11);
project.fav = project.fav && project.fav.length > 0;
showcaseCtrl.currentProject = project;
console.log(showcaseCtrl.currentProject);
}
showcaseCtrl.formatProjectNotifications = function (project) {
//alert("formatProject")
for (var i = 0; i < project.notifications.length; i++) {
var notif = project.notifications[i];
var str = $languageFactory._labels.notifications[notif.section][notif.type];
if (notif.owner && notif.project) {
console.log('owner', $scope._formatUser(notif.owner).shortName);
str = str.replace("{{user}}", $scope._formatUser(notif.owner).shortName)
str = str.replace("{{project}}", notif.project.fullName)
for (var attr in notif.details) {
var val = notif.details[attr];
if (val == "root") val = $languageFactory._labels[val]
str = str.replace("{{" + attr + "}}", val)
}
var res = str.replace(/{{(\w*)}}/g, "");
notif.body = str;
} else {
notif.hide = true;
}
}
return project;
}
showcaseCtrl.setProjectFavourite = function (value) {
$scope._showAlert({
status: 2,
message: ""
});
$projectFactory.setProjectFavourite($scope._getProject(), value, function (data) {
if (data.status == "success") {
$scope._showAlert({
status: 1,
message: ""
});
showcaseCtrl.getProjectDetails(true);
}
})
}
showcaseCtrl.requestInviteProject = function () {
$scope._showAlert({
status: 2,
message: ""
});
$projectFactory.requestInviteProject($scope._getProject(), function (data) {
if (data.status == "success") {
$scope._showAlert({
status: 1,
message: ""
});
} else {
if (data.details.hasOwnProperty("301")) $scope._showAlert({
status: 3,
message: $languageFactory._labels.alertMsgs.error301
});
else $scope._showAlert({
status: 3,
message: ""
});
}
})
}
showcaseCtrl.startDiscussion = function () {
var projectId = $scope._getProject();
console.log(projectId);
}
$portfolioManagerFactory.onCloseModalPrompt($scope, function (param) {
showcaseCtrl.groupMembers = false;
showcaseCtrl.groupProjects = false;
console.log("close", param);
if (param.result.success == true) {
$state.reload();
}
})
// ---------- SECTION POPUP ARTICLE ----------
showcaseCtrl.initArticle = function () {
$blogFactory.getDetailedArticle($scope._getProject(), showcaseCtrl.articleId, function (data) {
if (data.status == "success") {
// load the article
showcaseCtrl.currentArticle = data.details[0];
showcaseCtrl.currentArticle.visibility = parseInt(showcaseCtrl.currentArticle.visibility)
// parse the content
var content = $("<div/>").html(showcaseCtrl.currentArticle.content).text();
content = content.replace(/\\n/g, '');
showcaseCtrl.currentArticle.content = content;
// load the picture
showcaseCtrl.thumbUrl = showcaseCtrl.currentArticle.thumbUrl;
showcaseCtrl.isReady = true;
}
})
}
showcaseCtrl.cancelArticle = function () {
$state.go('showcase', {
articleId: ''
});
}
showcaseCtrl.init = function () {
if (showcaseCtrl.articleId == undefined) {
showcaseCtrl.articleId = "";
}
}
showcaseCtrl.init();
}])
\ No newline at end of file
......@@ -149,7 +149,7 @@ angular.module('myApp', [
value: null
}
}})
$stateProvider.state('showcase',{url:'/showcase/:projectName', templateUrl: __root+'components/projects/showcase.html', controller: 'ProjectShowcaseCtrl',controllerAs:"showcaseCtrl",params: {
$stateProvider.state('showcase',{url:'/showcase/:projectName/:articleId?', templateUrl: __root+'components/projects/showcase/showcase.html', controller: 'ProjectShowcaseCtrl',controllerAs:"showcaseCtrl",params: {
action: {
squash: true,
value:null
......
......@@ -1432,5 +1432,8 @@ controller('CommonCtrl', ['$scope','$sce','$serverFactory','$routeParams','$root
$scope.accessNewTab = function(url) {
var newTab = window.open(url);
}
$scope.accessCurrentTab = function(url) {
var newTab = window.open(url,"_top");
}
}])
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment