presentations
This commit is contained in:
@@ -228,20 +228,20 @@ angular.module('app.frontend')
|
|||||||
this.editUrlPressed = function() {
|
this.editUrlPressed = function() {
|
||||||
this.showMenu = false;
|
this.showMenu = false;
|
||||||
var url = this.publicUrlForNote(this.note);
|
var url = this.publicUrlForNote(this.note);
|
||||||
url = url.replace(this.note.presentation.root_path, "");
|
url = url.replace(this.note.presentation_name, "");
|
||||||
this.url = {base: url, token : this.note.presentation.root_path};
|
this.url = {base: url, token : this.note.presentation_name};
|
||||||
this.editingUrl = true;
|
this.editingUrl = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.saveUrl = function($event) {
|
this.saveUrl = function($event) {
|
||||||
$event.target.blur();
|
$event.target.blur();
|
||||||
|
|
||||||
var original = this.note.presentation.relative_path;
|
var original = this.note.presentation_name;
|
||||||
this.note.presentation.relative_path = this.url.token;
|
this.note.presentation_name = this.url.token;
|
||||||
|
|
||||||
apiController.updatePresentation(this.note, this.note.presentation, function(response){
|
apiController.saveItems([this.note], function(response){
|
||||||
if(!response) {
|
if(!response) {
|
||||||
this.note.presentation.relative_path = original;
|
this.note.presentation_name = original;
|
||||||
this.url.token = original;
|
this.url.token = original;
|
||||||
alert("This URL is not available.");
|
alert("This URL is not available.");
|
||||||
} else {
|
} else {
|
||||||
@@ -259,14 +259,14 @@ angular.module('app.frontend')
|
|||||||
a.click();
|
a.click();
|
||||||
}
|
}
|
||||||
|
|
||||||
apiController.shareItem(this.user, this.note, function(note){
|
apiController.shareItem(this.note, function(note){
|
||||||
openInNewTab(this.publicUrlForNote(note));
|
openInNewTab(this.publicUrlForNote(note));
|
||||||
}.bind(this))
|
}.bind(this))
|
||||||
this.showMenu = false;
|
this.showMenu = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.unshareNote = function() {
|
this.unshareNote = function() {
|
||||||
apiController.unshareItem(this.user, this.note, function(note){
|
apiController.unshareItem(this.note, function(note){
|
||||||
|
|
||||||
})
|
})
|
||||||
this.showMenu = false;
|
this.showMenu = false;
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ angular.module('app.frontend')
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.controller('NotesCtrl', function (apiController, $timeout, ngDialog, $rootScope) {
|
.controller('NotesCtrl', function (apiController, $timeout, $rootScope) {
|
||||||
|
|
||||||
$rootScope.$on("editorFocused", function(){
|
$rootScope.$on("editorFocused", function(){
|
||||||
this.showMenu = false;
|
this.showMenu = false;
|
||||||
@@ -81,38 +81,16 @@ angular.module('app.frontend')
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var callback = function(username) {
|
apiController.shareItem(this.tag, function(response){})
|
||||||
apiController.shareItem(this.user, this.tag, function(response){
|
|
||||||
})
|
|
||||||
}.bind(this);
|
|
||||||
|
|
||||||
if(!this.user.username) {
|
|
||||||
ngDialog.open({
|
|
||||||
template: 'frontend/modals/username.html',
|
|
||||||
controller: 'UsernameModalCtrl',
|
|
||||||
resolve: {
|
|
||||||
user: function() {return this.user}.bind(this),
|
|
||||||
callback: function() {return callback}
|
|
||||||
},
|
|
||||||
className: 'ngdialog-theme-default',
|
|
||||||
disableAnimation: true
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
callback(this.user.username);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.selectedTagUnshare = function() {
|
this.selectedTagUnshare = function() {
|
||||||
this.showMenu = false;
|
this.showMenu = false;
|
||||||
apiController.unshareItem(this.user, this.tag, function(response){
|
apiController.unshareItem(this.tag, function(response){
|
||||||
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
this.publicUrlForTag = function() {
|
|
||||||
return this.tag.presentation.url;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.selectFirstNote = function(createNew) {
|
this.selectFirstNote = function(createNew) {
|
||||||
var visibleNotes = this.tag.notes.filter(function(note){
|
var visibleNotes = this.tag.notes.filter(function(note){
|
||||||
return note.visible;
|
return note.visible;
|
||||||
|
|||||||
@@ -64,8 +64,13 @@ class Item {
|
|||||||
// should be overriden to manage local properties
|
// should be overriden to manage local properties
|
||||||
}
|
}
|
||||||
|
|
||||||
|
referencesAffectedBySharingChange() {
|
||||||
|
// should be overriden to determine which references should be decrypted/encrypted
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
isPublic() {
|
isPublic() {
|
||||||
return this.presentation;
|
return this.presentation_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
isEncrypted() {
|
isEncrypted() {
|
||||||
@@ -77,7 +82,7 @@ class Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
presentationURL() {
|
presentationURL() {
|
||||||
return this.presentation.url;
|
return this.presentation_url;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,10 @@ class Note extends Item {
|
|||||||
this.tags = this.referencesMatchingContentType("Tag");
|
this.tags = this.referencesMatchingContentType("Tag");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
referencesAffectedBySharingChange() {
|
||||||
|
return super.referencesAffectedBySharingChange();
|
||||||
|
}
|
||||||
|
|
||||||
get hasOnePublicTag() {
|
get hasOnePublicTag() {
|
||||||
var hasPublicTag = false;
|
var hasPublicTag = false;
|
||||||
this.tags.forEach(function(tag){
|
this.tags.forEach(function(tag){
|
||||||
|
|||||||
@@ -20,4 +20,8 @@ class Tag extends Item {
|
|||||||
super.updateReferencesLocalMapping();
|
super.updateReferencesLocalMapping();
|
||||||
this.notes = this.referencesMatchingContentType("Note");
|
this.notes = this.referencesMatchingContentType("Note");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
referencesAffectedBySharingChange() {
|
||||||
|
return this.referencesMatchingContentType("Note");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,34 +18,6 @@ angular.module('app.frontend')
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
.state('presentation', {
|
|
||||||
url: '/:root_path',
|
|
||||||
parent: 'base',
|
|
||||||
views: {
|
|
||||||
'content@' : {
|
|
||||||
templateUrl: 'frontend/presentation.html',
|
|
||||||
controller: "PresentationCtrl"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
resolve: {
|
|
||||||
presentation: getPresentation
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
.state('tag', {
|
|
||||||
url: '/:root_path/:secondary_path',
|
|
||||||
parent: 'base',
|
|
||||||
views: {
|
|
||||||
'content@' : {
|
|
||||||
templateUrl: 'frontend/presentation.html',
|
|
||||||
controller: "PresentationCtrl"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
resolve: {
|
|
||||||
presentation: getPresentation
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
// Auth routes
|
// Auth routes
|
||||||
.state('auth', {
|
.state('auth', {
|
||||||
abstract: true,
|
abstract: true,
|
||||||
@@ -89,20 +61,6 @@ angular.module('app.frontend')
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function getPresentation ($q, $state, $stateParams, Restangular) {
|
|
||||||
var deferred = $q.defer();
|
|
||||||
var restangularQuery = Restangular.one('presentations', 'show_by_path');
|
|
||||||
restangularQuery.get({root_path: $stateParams.root_path, secondary_path: $stateParams.secondary_path})
|
|
||||||
.then(function(response) {
|
|
||||||
deferred.resolve(response);
|
|
||||||
})
|
|
||||||
.catch(function(response) {
|
|
||||||
$state.go('404');
|
|
||||||
});
|
|
||||||
|
|
||||||
return deferred.promise;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Default fall back route
|
// Default fall back route
|
||||||
$urlRouterProvider.otherwise(function($injector, $location){
|
$urlRouterProvider.otherwise(function($injector, $location){
|
||||||
var state = $injector.get('$state');
|
var state = $injector.get('$state');
|
||||||
|
|||||||
@@ -20,11 +20,11 @@ angular.module('app.frontend')
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
this.$get = function(Restangular, modelManager) {
|
this.$get = function(Restangular, modelManager, ngDialog) {
|
||||||
return new ApiController(Restangular, modelManager);
|
return new ApiController(Restangular, modelManager, ngDialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
function ApiController(Restangular, modelManager) {
|
function ApiController(Restangular, modelManager, ngDialog) {
|
||||||
|
|
||||||
this.setUser = function(user) {
|
this.setUser = function(user) {
|
||||||
this.user = user;
|
this.user = user;
|
||||||
@@ -65,6 +65,7 @@ angular.module('app.frontend')
|
|||||||
Restangular.one("users/current").get().then(function(response){
|
Restangular.one("users/current").get().then(function(response){
|
||||||
var plain = response.plain();
|
var plain = response.plain();
|
||||||
var items = plain.items;
|
var items = plain.items;
|
||||||
|
console.log("retreived items", plain);
|
||||||
this.decryptItemsWithLocalKey(items);
|
this.decryptItemsWithLocalKey(items);
|
||||||
callback(plain);
|
callback(plain);
|
||||||
}.bind(this))
|
}.bind(this))
|
||||||
@@ -143,9 +144,9 @@ angular.module('app.frontend')
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
this.setUsername = function(user, username, callback) {
|
this.setUsername = function(user, username, callback) {
|
||||||
var request = Restangular.one("users", user.uuid).one("set_username");
|
var request = Restangular.one("users", user.uuid);
|
||||||
request.username = username;
|
request.username = username;
|
||||||
request.post().then(function(response){
|
request.patch().then(function(response){
|
||||||
callback(response.plain());
|
callback(response.plain());
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -205,9 +206,6 @@ angular.module('app.frontend')
|
|||||||
request.post().then(function(response) {
|
request.post().then(function(response) {
|
||||||
var savedItems = response.items;
|
var savedItems = response.items;
|
||||||
console.log("response items", savedItems);
|
console.log("response items", savedItems);
|
||||||
// items.forEach(function(item) {
|
|
||||||
// _.merge(item, _.find(savedItems, {uuid: item.uuid}));
|
|
||||||
// })
|
|
||||||
callback(response);
|
callback(response);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -215,7 +213,8 @@ angular.module('app.frontend')
|
|||||||
this.createRequestParamsForItem = function(item) {
|
this.createRequestParamsForItem = function(item) {
|
||||||
var itemCopy = _.cloneDeep(item);
|
var itemCopy = _.cloneDeep(item);
|
||||||
|
|
||||||
var params = {uuid: item.uuid, content_type: item.content_type};
|
var params = {uuid: item.uuid, content_type: item.content_type, presentation_name: item.presentation_name};
|
||||||
|
|
||||||
itemCopy.content.references = _.map(itemCopy.content.references, function(reference){
|
itemCopy.content.references = _.map(itemCopy.content.references, function(reference){
|
||||||
return {uuid: reference.uuid, content_type: reference.content_type};
|
return {uuid: reference.uuid, content_type: reference.content_type};
|
||||||
})
|
})
|
||||||
@@ -248,55 +247,43 @@ angular.module('app.frontend')
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.shareItem = function(item, callback) {
|
this.shareItem = function(item, callback) {
|
||||||
|
console.log("sharing item", item);
|
||||||
if(!this.user.uuid) {
|
if(!this.user.uuid) {
|
||||||
alert("You must be signed in to share.");
|
alert("You must be signed in to share.");
|
||||||
} else {
|
return;
|
||||||
Restangular.one("users", this.user.uuid).one("items", item.uuid).one("presentations").post()
|
}
|
||||||
.then(function(response){
|
|
||||||
var presentation = response.plain();
|
|
||||||
_.merge(item, {presentation: presentation});
|
|
||||||
callback(item);
|
|
||||||
|
|
||||||
// decrypt references
|
var shareFn = function() {
|
||||||
if(item.references.length > 0) {
|
item.presentation_name = "_auto_";
|
||||||
this.saveBatchItems(item.references, function(success){})
|
var needsUpdate = [item].concat(item.referencesAffectedBySharingChange() || []);
|
||||||
}
|
this.saveItems(needsUpdate, function(success){})
|
||||||
})
|
}.bind(this)
|
||||||
|
|
||||||
|
if(!this.user.username) {
|
||||||
|
ngDialog.open({
|
||||||
|
template: 'frontend/modals/username.html',
|
||||||
|
controller: 'UsernameModalCtrl',
|
||||||
|
resolve: {
|
||||||
|
user: function() {return this.user}.bind(this),
|
||||||
|
callback: function() {
|
||||||
|
return shareFn;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
className: 'ngdialog-theme-default',
|
||||||
|
disableAnimation: true
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
shareFn();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.unshareItem = function(item, callback) {
|
this.unshareItem = function(item, callback) {
|
||||||
var request = Restangular.one("users", this.user.uuid).one("items", item.uuid).one("presentations", item.presentation.uuid);
|
console.log("unsharing item", item);
|
||||||
request.remove().then(function(response){
|
item.presentation_name = null;
|
||||||
item.presentation = null;
|
var needsUpdate = [item].concat(item.referencesAffectedBySharingChange() || []);
|
||||||
callback(null);
|
this.saveItems(needsUpdate, function(success){})
|
||||||
|
|
||||||
// encrypt references
|
|
||||||
if(item.references.length > 0) {
|
|
||||||
this.saveBatchItems(item.references, function(success){})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
Presentations
|
|
||||||
*/
|
|
||||||
|
|
||||||
this.updatePresentation = function(resource, presentation, callback) {
|
|
||||||
var request = Restangular.one("users", this.user.uuid)
|
|
||||||
.one("items", resource.uuid)
|
|
||||||
.one("presentations", resource.presentation.uuid);
|
|
||||||
_.merge(request, presentation);
|
|
||||||
request.patch().then(function(response){
|
|
||||||
callback(response.plain());
|
|
||||||
})
|
|
||||||
.catch(function(error){
|
|
||||||
callback(nil);
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Import
|
Import
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -17,9 +17,6 @@
|
|||||||
%span.sr-only
|
%span.sr-only
|
||||||
|
|
||||||
%ul.dropdown-menu.dropdown-menu-left.nt-dropdown-menu.dark{"ng-if" => "ctrl.showMenu && !ctrl.note.locked"}
|
%ul.dropdown-menu.dropdown-menu-left.nt-dropdown-menu.dark{"ng-if" => "ctrl.showMenu && !ctrl.note.locked"}
|
||||||
-# %li
|
|
||||||
-# %a.text{"ng-click" => "ctrl.selectedMenuItem(); ctrl.saveNote($event, note)"} Save
|
|
||||||
-# .shortcut Cmd + S
|
|
||||||
%li
|
%li
|
||||||
%a.text{"ng-click" => "ctrl.selectedMenuItem(); ctrl.toggleFullScreen()"} Toggle Fullscreen
|
%a.text{"ng-click" => "ctrl.selectedMenuItem(); ctrl.toggleFullScreen()"} Toggle Fullscreen
|
||||||
.shortcut Cmd + O
|
.shortcut Cmd + O
|
||||||
@@ -40,7 +37,7 @@
|
|||||||
.panel-body{"style" => "text-align: center; color: black;"}
|
.panel-body{"style" => "text-align: center; color: black;"}
|
||||||
This editor is Markdown enabled.
|
This editor is Markdown enabled.
|
||||||
.menu-right-container
|
.menu-right-container
|
||||||
.public-link{"ng-if" => "ctrl.note.presentation"}
|
.public-link{"ng-if" => "ctrl.note.isPublic()"}
|
||||||
%a.url{"ng-if" => "!ctrl.editingUrl", "href" => "{{ctrl.publicUrlForNote(ctrl.note)}}", "target" => "_blank"}
|
%a.url{"ng-if" => "!ctrl.editingUrl", "href" => "{{ctrl.publicUrlForNote(ctrl.note)}}", "target" => "_blank"}
|
||||||
%span.icon-rss.icon
|
%span.icon-rss.icon
|
||||||
{{ctrl.publicUrlForNote(note)}}
|
{{ctrl.publicUrlForNote(note)}}
|
||||||
|
|||||||
@@ -22,9 +22,9 @@
|
|||||||
%a.text{"ng-click" => "ctrl.selectedMenuItem(); ctrl.selectedTagDelete()"} Delete Tag
|
%a.text{"ng-click" => "ctrl.selectedMenuItem(); ctrl.selectedTagDelete()"} Delete Tag
|
||||||
.menu-right-container
|
.menu-right-container
|
||||||
.public-link{"ng-if" => "ctrl.tag.presentation"}
|
.public-link{"ng-if" => "ctrl.tag.presentation"}
|
||||||
%a.url{"ng-if" => "!ctrl.editingUrl", "href" => "{{ctrl.publicUrlForTag(ctrl.tag)}}", "target" => "_blank"}
|
%a.url{"ng-if" => "!ctrl.editingUrl", "href" => "{{ctrl.tag.presentationURL()}}", "target" => "_blank"}
|
||||||
%span.icon-rss.icon
|
%span.icon-rss.icon
|
||||||
{{ctrl.publicUrlForTag()}}
|
{{ctrl.tag.presentationURL()}}
|
||||||
.edit-url{"ng-if" => "ctrl.editingUrl"}
|
.edit-url{"ng-if" => "ctrl.editingUrl"}
|
||||||
{{ctrl.url.base}}
|
{{ctrl.url.base}}
|
||||||
%input.input{"ng-model" => "ctrl.url.token", "ng-keyup" => "$event.keyCode == 13 && ctrl.saveUrl($event)",
|
%input.input{"ng-model" => "ctrl.url.token", "ng-keyup" => "$event.keyCode == 13 && ctrl.saveUrl($event)",
|
||||||
|
|||||||
182
vendor/assets/javascripts/transpiled.js
vendored
182
vendor/assets/javascripts/transpiled.js
vendored
@@ -52,30 +52,6 @@ angular.module('app.frontend', ['ui.router', 'ng-token-auth', 'restangular', 'ip
|
|||||||
controller: 'HomeCtrl'
|
controller: 'HomeCtrl'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).state('presentation', {
|
|
||||||
url: '/:root_path',
|
|
||||||
parent: 'base',
|
|
||||||
views: {
|
|
||||||
'content@': {
|
|
||||||
templateUrl: 'frontend/presentation.html',
|
|
||||||
controller: "PresentationCtrl"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
resolve: {
|
|
||||||
presentation: getPresentation
|
|
||||||
}
|
|
||||||
}).state('tag', {
|
|
||||||
url: '/:root_path/:secondary_path',
|
|
||||||
parent: 'base',
|
|
||||||
views: {
|
|
||||||
'content@': {
|
|
||||||
templateUrl: 'frontend/presentation.html',
|
|
||||||
controller: "PresentationCtrl"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
resolve: {
|
|
||||||
presentation: getPresentation
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
// Auth routes
|
// Auth routes
|
||||||
@@ -117,18 +93,6 @@ angular.module('app.frontend', ['ui.router', 'ng-token-auth', 'restangular', 'ip
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function getPresentation($q, $state, $stateParams, Restangular) {
|
|
||||||
var deferred = $q.defer();
|
|
||||||
var restangularQuery = Restangular.one('presentations', 'show_by_path');
|
|
||||||
restangularQuery.get({ root_path: $stateParams.root_path, secondary_path: $stateParams.secondary_path }).then(function (response) {
|
|
||||||
deferred.resolve(response);
|
|
||||||
}).catch(function (response) {
|
|
||||||
$state.go('404');
|
|
||||||
});
|
|
||||||
|
|
||||||
return deferred.promise;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Default fall back route
|
// Default fall back route
|
||||||
$urlRouterProvider.otherwise(function ($injector, $location) {
|
$urlRouterProvider.otherwise(function ($injector, $location) {
|
||||||
var state = $injector.get('$state');
|
var state = $injector.get('$state');
|
||||||
@@ -372,20 +336,20 @@ angular.module('app.frontend').controller('BaseCtrl', BaseCtrl);
|
|||||||
this.editUrlPressed = function () {
|
this.editUrlPressed = function () {
|
||||||
this.showMenu = false;
|
this.showMenu = false;
|
||||||
var url = this.publicUrlForNote(this.note);
|
var url = this.publicUrlForNote(this.note);
|
||||||
url = url.replace(this.note.presentation.root_path, "");
|
url = url.replace(this.note.presentation_name, "");
|
||||||
this.url = { base: url, token: this.note.presentation.root_path };
|
this.url = { base: url, token: this.note.presentation_name };
|
||||||
this.editingUrl = true;
|
this.editingUrl = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.saveUrl = function ($event) {
|
this.saveUrl = function ($event) {
|
||||||
$event.target.blur();
|
$event.target.blur();
|
||||||
|
|
||||||
var original = this.note.presentation.relative_path;
|
var original = this.note.presentation_name;
|
||||||
this.note.presentation.relative_path = this.url.token;
|
this.note.presentation_name = this.url.token;
|
||||||
|
|
||||||
apiController.updatePresentation(this.note, this.note.presentation, function (response) {
|
apiController.saveItems([this.note], function (response) {
|
||||||
if (!response) {
|
if (!response) {
|
||||||
this.note.presentation.relative_path = original;
|
this.note.presentation_name = original;
|
||||||
this.url.token = original;
|
this.url.token = original;
|
||||||
alert("This URL is not available.");
|
alert("This URL is not available.");
|
||||||
} else {
|
} else {
|
||||||
@@ -403,14 +367,14 @@ angular.module('app.frontend').controller('BaseCtrl', BaseCtrl);
|
|||||||
a.click();
|
a.click();
|
||||||
}
|
}
|
||||||
|
|
||||||
apiController.shareItem(this.user, this.note, function (note) {
|
apiController.shareItem(this.note, function (note) {
|
||||||
openInNewTab(this.publicUrlForNote(note));
|
openInNewTab(this.publicUrlForNote(note));
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
this.showMenu = false;
|
this.showMenu = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.unshareNote = function () {
|
this.unshareNote = function () {
|
||||||
apiController.unshareItem(this.user, this.note, function (note) {});
|
apiController.unshareItem(this.note, function (note) {});
|
||||||
this.showMenu = false;
|
this.showMenu = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -767,7 +731,7 @@ angular.module('app.frontend').controller('BaseCtrl', BaseCtrl);
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}).controller('NotesCtrl', function (apiController, $timeout, ngDialog, $rootScope) {
|
}).controller('NotesCtrl', function (apiController, $timeout, $rootScope) {
|
||||||
|
|
||||||
$rootScope.$on("editorFocused", function () {
|
$rootScope.$on("editorFocused", function () {
|
||||||
this.showMenu = false;
|
this.showMenu = false;
|
||||||
@@ -823,37 +787,12 @@ angular.module('app.frontend').controller('BaseCtrl', BaseCtrl);
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var _callback = function (username) {
|
apiController.shareItem(this.tag, function (response) {});
|
||||||
apiController.shareItem(this.user, this.tag, function (response) {});
|
|
||||||
}.bind(this);
|
|
||||||
|
|
||||||
if (!this.user.username) {
|
|
||||||
ngDialog.open({
|
|
||||||
template: 'frontend/modals/username.html',
|
|
||||||
controller: 'UsernameModalCtrl',
|
|
||||||
resolve: {
|
|
||||||
user: function () {
|
|
||||||
return this.user;
|
|
||||||
}.bind(this),
|
|
||||||
callback: function callback() {
|
|
||||||
return _callback;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
className: 'ngdialog-theme-default',
|
|
||||||
disableAnimation: true
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
_callback(this.user.username);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
this.selectedTagUnshare = function () {
|
this.selectedTagUnshare = function () {
|
||||||
this.showMenu = false;
|
this.showMenu = false;
|
||||||
apiController.unshareItem(this.user, this.tag, function (response) {});
|
apiController.unshareItem(this.tag, function (response) {});
|
||||||
};
|
|
||||||
|
|
||||||
this.publicUrlForTag = function () {
|
|
||||||
return this.tag.presentation.url;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
this.selectFirstNote = function (createNew) {
|
this.selectFirstNote = function (createNew) {
|
||||||
@@ -1090,10 +1029,16 @@ var Item = function () {
|
|||||||
value: function updateReferencesLocalMapping() {
|
value: function updateReferencesLocalMapping() {
|
||||||
// should be overriden to manage local properties
|
// should be overriden to manage local properties
|
||||||
}
|
}
|
||||||
|
}, {
|
||||||
|
key: 'referencesAffectedBySharingChange',
|
||||||
|
value: function referencesAffectedBySharingChange() {
|
||||||
|
// should be overriden to determine which references should be decrypted/encrypted
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}, {
|
}, {
|
||||||
key: 'isPublic',
|
key: 'isPublic',
|
||||||
value: function isPublic() {
|
value: function isPublic() {
|
||||||
return this.presentation;
|
return this.presentation_name;
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
key: 'isEncrypted',
|
key: 'isEncrypted',
|
||||||
@@ -1108,7 +1053,7 @@ var Item = function () {
|
|||||||
}, {
|
}, {
|
||||||
key: 'presentationURL',
|
key: 'presentationURL',
|
||||||
value: function presentationURL() {
|
value: function presentationURL() {
|
||||||
return this.presentation.url;
|
return this.presentation_url;
|
||||||
}
|
}
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
@@ -1141,6 +1086,11 @@ var Note = function (_Item) {
|
|||||||
_get(Note.prototype.__proto__ || Object.getPrototypeOf(Note.prototype), 'updateReferencesLocalMapping', this).call(this);
|
_get(Note.prototype.__proto__ || Object.getPrototypeOf(Note.prototype), 'updateReferencesLocalMapping', this).call(this);
|
||||||
this.tags = this.referencesMatchingContentType("Tag");
|
this.tags = this.referencesMatchingContentType("Tag");
|
||||||
}
|
}
|
||||||
|
}, {
|
||||||
|
key: 'referencesAffectedBySharingChange',
|
||||||
|
value: function referencesAffectedBySharingChange() {
|
||||||
|
return _get(Note.prototype.__proto__ || Object.getPrototypeOf(Note.prototype), 'referencesAffectedBySharingChange', this).call(this);
|
||||||
|
}
|
||||||
}, {
|
}, {
|
||||||
key: 'toJSON',
|
key: 'toJSON',
|
||||||
value: function toJSON() {
|
value: function toJSON() {
|
||||||
@@ -1207,6 +1157,11 @@ var Tag = function (_Item2) {
|
|||||||
_get(Tag.prototype.__proto__ || Object.getPrototypeOf(Tag.prototype), 'updateReferencesLocalMapping', this).call(this);
|
_get(Tag.prototype.__proto__ || Object.getPrototypeOf(Tag.prototype), 'updateReferencesLocalMapping', this).call(this);
|
||||||
this.notes = this.referencesMatchingContentType("Note");
|
this.notes = this.referencesMatchingContentType("Note");
|
||||||
}
|
}
|
||||||
|
}, {
|
||||||
|
key: 'referencesAffectedBySharingChange',
|
||||||
|
value: function referencesAffectedBySharingChange() {
|
||||||
|
return this.referencesMatchingContentType("Note");
|
||||||
|
}
|
||||||
}, {
|
}, {
|
||||||
key: 'content_type',
|
key: 'content_type',
|
||||||
get: function get() {
|
get: function get() {
|
||||||
@@ -1244,11 +1199,11 @@ var User = function User(json_obj) {
|
|||||||
return url;
|
return url;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.$get = function (Restangular, modelManager) {
|
this.$get = function (Restangular, modelManager, ngDialog) {
|
||||||
return new ApiController(Restangular, modelManager);
|
return new ApiController(Restangular, modelManager, ngDialog);
|
||||||
};
|
};
|
||||||
|
|
||||||
function ApiController(Restangular, modelManager) {
|
function ApiController(Restangular, modelManager, ngDialog) {
|
||||||
|
|
||||||
this.setUser = function (user) {
|
this.setUser = function (user) {
|
||||||
this.user = user;
|
this.user = user;
|
||||||
@@ -1288,6 +1243,7 @@ var User = function User(json_obj) {
|
|||||||
Restangular.one("users/current").get().then(function (response) {
|
Restangular.one("users/current").get().then(function (response) {
|
||||||
var plain = response.plain();
|
var plain = response.plain();
|
||||||
var items = plain.items;
|
var items = plain.items;
|
||||||
|
console.log("retreived items", plain);
|
||||||
this.decryptItemsWithLocalKey(items);
|
this.decryptItemsWithLocalKey(items);
|
||||||
callback(plain);
|
callback(plain);
|
||||||
}.bind(this)).catch(function (error) {
|
}.bind(this)).catch(function (error) {
|
||||||
@@ -1364,9 +1320,9 @@ var User = function User(json_obj) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
this.setUsername = function (user, username, callback) {
|
this.setUsername = function (user, username, callback) {
|
||||||
var request = Restangular.one("users", user.uuid).one("set_username");
|
var request = Restangular.one("users", user.uuid);
|
||||||
request.username = username;
|
request.username = username;
|
||||||
request.post().then(function (response) {
|
request.patch().then(function (response) {
|
||||||
callback(response.plain());
|
callback(response.plain());
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -1424,9 +1380,6 @@ var User = function User(json_obj) {
|
|||||||
request.post().then(function (response) {
|
request.post().then(function (response) {
|
||||||
var savedItems = response.items;
|
var savedItems = response.items;
|
||||||
console.log("response items", savedItems);
|
console.log("response items", savedItems);
|
||||||
// items.forEach(function(item) {
|
|
||||||
// _.merge(item, _.find(savedItems, {uuid: item.uuid}));
|
|
||||||
// })
|
|
||||||
callback(response);
|
callback(response);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -1434,7 +1387,8 @@ var User = function User(json_obj) {
|
|||||||
this.createRequestParamsForItem = function (item) {
|
this.createRequestParamsForItem = function (item) {
|
||||||
var itemCopy = _.cloneDeep(item);
|
var itemCopy = _.cloneDeep(item);
|
||||||
|
|
||||||
var params = { uuid: item.uuid, content_type: item.content_type };
|
var params = { uuid: item.uuid, content_type: item.content_type, presentation_name: item.presentation_name };
|
||||||
|
|
||||||
itemCopy.content.references = _.map(itemCopy.content.references, function (reference) {
|
itemCopy.content.references = _.map(itemCopy.content.references, function (reference) {
|
||||||
return { uuid: reference.uuid, content_type: reference.content_type };
|
return { uuid: reference.uuid, content_type: reference.content_type };
|
||||||
});
|
});
|
||||||
@@ -1464,47 +1418,43 @@ var User = function User(json_obj) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
this.shareItem = function (item, callback) {
|
this.shareItem = function (item, callback) {
|
||||||
|
console.log("sharing item", item);
|
||||||
if (!this.user.uuid) {
|
if (!this.user.uuid) {
|
||||||
alert("You must be signed in to share.");
|
alert("You must be signed in to share.");
|
||||||
} else {
|
return;
|
||||||
Restangular.one("users", this.user.uuid).one("items", item.uuid).one("presentations").post().then(function (response) {
|
}
|
||||||
var presentation = response.plain();
|
|
||||||
_.merge(item, { presentation: presentation });
|
|
||||||
callback(item);
|
|
||||||
|
|
||||||
// decrypt references
|
var shareFn = function () {
|
||||||
if (item.references.length > 0) {
|
item.presentation_name = "_auto_";
|
||||||
this.saveBatchItems(item.references, function (success) {});
|
var needsUpdate = [item].concat(item.referencesAffectedBySharingChange() || []);
|
||||||
}
|
this.saveItems(needsUpdate, function (success) {});
|
||||||
|
}.bind(this);
|
||||||
|
|
||||||
|
if (!this.user.username) {
|
||||||
|
ngDialog.open({
|
||||||
|
template: 'frontend/modals/username.html',
|
||||||
|
controller: 'UsernameModalCtrl',
|
||||||
|
resolve: {
|
||||||
|
user: function () {
|
||||||
|
return this.user;
|
||||||
|
}.bind(this),
|
||||||
|
callback: function callback() {
|
||||||
|
return shareFn;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
className: 'ngdialog-theme-default',
|
||||||
|
disableAnimation: true
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
shareFn();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.unshareItem = function (item, callback) {
|
this.unshareItem = function (item, callback) {
|
||||||
var request = Restangular.one("users", this.user.uuid).one("items", item.uuid).one("presentations", item.presentation.uuid);
|
console.log("unsharing item", item);
|
||||||
request.remove().then(function (response) {
|
item.presentation_name = null;
|
||||||
item.presentation = null;
|
var needsUpdate = [item].concat(item.referencesAffectedBySharingChange() || []);
|
||||||
callback(null);
|
this.saveItems(needsUpdate, function (success) {});
|
||||||
|
|
||||||
// encrypt references
|
|
||||||
if (item.references.length > 0) {
|
|
||||||
this.saveBatchItems(item.references, function (success) {});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
Presentations
|
|
||||||
*/
|
|
||||||
|
|
||||||
this.updatePresentation = function (resource, presentation, callback) {
|
|
||||||
var request = Restangular.one("users", this.user.uuid).one("items", resource.uuid).one("presentations", resource.presentation.uuid);
|
|
||||||
_.merge(request, presentation);
|
|
||||||
request.patch().then(function (response) {
|
|
||||||
callback(response.plain());
|
|
||||||
}).catch(function (error) {
|
|
||||||
callback(nil);
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
2
vendor/assets/javascripts/transpiled.js.map
vendored
2
vendor/assets/javascripts/transpiled.js.map
vendored
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user