mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-16 11:15:12 +00:00
add list/show routes
This commit is contained in:
@@ -14,12 +14,12 @@ angular.module('codexen')
|
|||||||
callSign: vm.snippet.callSign,
|
callSign: vm.snippet.callSign,
|
||||||
mode: vm.snippet.mode == null ? null : vm.snippet.mode.toLowerCase(),
|
mode: vm.snippet.mode == null ? null : vm.snippet.mode.toLowerCase(),
|
||||||
content: vm.snippet.content,
|
content: vm.snippet.content,
|
||||||
tags: angular.isArray(vm.snippet.tags) ? vm.snippet.tags.map(function (tag) { return {_id: tag._id, name: tag.name} }) : []
|
tags: angular.isArray(vm.snippet.tags) ? vm.snippet.tags.map(function (tag) { return tag.name }) : []
|
||||||
}
|
}
|
||||||
|
|
||||||
Snippet.update(vm.snippet._id, params)
|
Snippet.update(vm.snippet._id, params)
|
||||||
.success(function (data) {
|
.success(function (data) {
|
||||||
$modalInstance.close(data.snippet)
|
$modalInstance.close(data)
|
||||||
console.log('snippet created!', data)
|
console.log('snippet created!', data)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,12 +11,12 @@ angular.module('codexen')
|
|||||||
callSign: vm.callSign,
|
callSign: vm.callSign,
|
||||||
mode: vm.mode == null ? null : vm.mode.toLowerCase(),
|
mode: vm.mode == null ? null : vm.mode.toLowerCase(),
|
||||||
content: vm.content,
|
content: vm.content,
|
||||||
tags: angular.isArray(vm.tags) ? vm.tags.map(function (tag) { return {_id: tag._id, name: tag.name} }) : []
|
tags: angular.isArray(vm.tags) ? vm.tags.map(function (tag) { return tag.name }) : []
|
||||||
}
|
}
|
||||||
|
|
||||||
Snippet.create(params)
|
Snippet.create(params)
|
||||||
.success(function (data) {
|
.success(function (data) {
|
||||||
$modalInstance.close(data.snippet)
|
$modalInstance.close(data)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,14 +7,16 @@ angular.module('codexen')
|
|||||||
|
|
||||||
var snippetId = $state.params.id
|
var snippetId = $state.params.id
|
||||||
|
|
||||||
Snippet.show(snippetId)
|
Snippet.show(snippetId, {
|
||||||
|
'include': ['Tag']
|
||||||
|
})
|
||||||
.success(function (data) {
|
.success(function (data) {
|
||||||
vm.snippet = data.snippet
|
vm.snippet = data
|
||||||
vm.isLoaded = true
|
vm.isLoaded = true
|
||||||
})
|
})
|
||||||
|
|
||||||
vm.delete = function () {
|
vm.delete = function () {
|
||||||
Snippet.delete(vm.snippet._id)
|
Snippet.delete(vm.snippet.id)
|
||||||
.success(function () {
|
.success(function () {
|
||||||
$rootScope.$broadcast('snippetDeleted')
|
$rootScope.$broadcast('snippetDeleted')
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -7,13 +7,13 @@ angular.module('codexen')
|
|||||||
|
|
||||||
var loadSnippets = function () {
|
var loadSnippets = function () {
|
||||||
if ($auth.isAuthenticated) {
|
if ($auth.isAuthenticated) {
|
||||||
console.log($auth.getPayload())
|
Snippet.findMine({
|
||||||
var userId = $auth.getPayload().sub
|
'include': ['Tag']
|
||||||
Snippet.findByUser(userId)
|
})
|
||||||
.success(function (data) {
|
.success(function (data) {
|
||||||
console.log('snippets fetched', data.snippets)
|
console.log('snippets fetched', data)
|
||||||
vm.isLoaded = true
|
vm.isLoaded = true
|
||||||
vm.snippets = data.snippets
|
vm.snippets = data
|
||||||
vm.isGuest = false
|
vm.isGuest = false
|
||||||
})
|
})
|
||||||
}else {
|
}else {
|
||||||
|
|||||||
@@ -11,16 +11,22 @@ angular.module('codexen')
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var findMine = function (params) {
|
||||||
|
var url = apiUrl + 'snippets/my'
|
||||||
|
|
||||||
|
return $http.get(url, {params: params})
|
||||||
|
}
|
||||||
|
|
||||||
var create = function (params) {
|
var create = function (params) {
|
||||||
var url = apiUrl + 'snippets/create'
|
var url = apiUrl + 'snippets/create'
|
||||||
|
|
||||||
return $http.post(url, params)
|
return $http.post(url, params)
|
||||||
}
|
}
|
||||||
|
|
||||||
var show = function (id) {
|
var show = function (id, params) {
|
||||||
var url = apiUrl + 'snippets/id/' + id
|
var url = apiUrl + 'snippets/id/' + id
|
||||||
|
|
||||||
return $http.get(url)
|
return $http.get(url, {params: params})
|
||||||
}
|
}
|
||||||
|
|
||||||
var update = function (id, params) {
|
var update = function (id, params) {
|
||||||
@@ -37,6 +43,7 @@ angular.module('codexen')
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
findByUser: findByUser,
|
findByUser: findByUser,
|
||||||
|
findMine: findMine,
|
||||||
create: create,
|
create: create,
|
||||||
show: show,
|
show: show,
|
||||||
delete: destroy,
|
delete: destroy,
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ textarea
|
|||||||
left: 0
|
left: 0
|
||||||
width: 200px
|
width: 200px
|
||||||
background-color: $baseBackgroundColor
|
background-color: $baseBackgroundColor
|
||||||
border-right solid 1px $baseBorderColor
|
border-right solid 2px $backgroundColorSelected
|
||||||
box-sizing: border-box
|
box-sizing: border-box
|
||||||
padding: 10px 0 10px 10px
|
padding: 10px 0 10px 10px
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
.nav-control-group
|
.nav-control-group
|
||||||
margin 0 5px
|
margin 0 5px
|
||||||
ul.nav.nav-pills
|
ul.nav.nav-pills
|
||||||
|
margin-top 10px
|
||||||
li hr
|
li hr
|
||||||
margin: 5px 0
|
margin: 5px 0
|
||||||
border-top none
|
border-top none
|
||||||
|
|||||||
@@ -3,8 +3,8 @@
|
|||||||
<img width="30" class="img-circle" ng-src="http://www.gravatar.com/avatar/{{ vm.currentUser.email | gravatar }}">
|
<img width="30" class="img-circle" ng-src="http://www.gravatar.com/avatar/{{ vm.currentUser.email | gravatar }}">
|
||||||
<a href ng-bind="vm.currentUser.name"></a>
|
<a href ng-bind="vm.currentUser.name"></a>
|
||||||
<span class="nav-control-group pull-right">
|
<span class="nav-control-group pull-right">
|
||||||
<a href class="btn btn-sm btn-primary"><i class="fa fa-gears"></i></a>
|
<a href class="btn btn-sm btn-default"><i class="fa fa-gears"></i></a>
|
||||||
<a href class="btn btn-sm btn-primary" ng-click="vm.signOut()"><i class="fa fa-sign-out"></i></a>
|
<a href class="btn btn-sm btn-default" ng-click="vm.signOut()"><i class="fa fa-sign-out"></i></a>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -22,7 +22,8 @@
|
|||||||
<div
|
<div
|
||||||
ui-ace="{
|
ui-ace="{
|
||||||
mode: vm.snippet.mode.toLowerCase(),
|
mode: vm.snippet.mode.toLowerCase(),
|
||||||
theme:'solarized_dark'
|
theme:'solarized_dark',
|
||||||
|
useWrapMode : true
|
||||||
|
|
||||||
}"
|
}"
|
||||||
ng-model="vm.snippet.content"
|
ng-model="vm.snippet.content"
|
||||||
@@ -30,7 +31,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<ui-select multiple tagging="vm.transform" tagging-tokens="SPACE|,|/" ng-model="vm.snippet.tags" theme="bootstrap">
|
<ui-select multiple tagging="vm.transform" tagging-tokens="SPACE|,|/" ng-model="vm.snippet.Tags" theme="bootstrap">
|
||||||
<ui-select-match placeholder="Write Tags">{{$item.name}}</ui-select-match>
|
<ui-select-match placeholder="Write Tags">{{$item.name}}</ui-select-match>
|
||||||
<ui-select-choices repeat="tag in vm.tagCandidates" refresh="vm.refreshTagCandidates($select.search)"
|
<ui-select-choices repeat="tag in vm.tagCandidates" refresh="vm.refreshTagCandidates($select.search)"
|
||||||
refresh-delay="200">
|
refresh-delay="200">
|
||||||
|
|||||||
@@ -22,7 +22,8 @@
|
|||||||
<div
|
<div
|
||||||
ui-ace="{
|
ui-ace="{
|
||||||
mode: vm.mode.toLowerCase(),
|
mode: vm.mode.toLowerCase(),
|
||||||
theme:'solarized_dark'
|
theme:'solarized_dark',
|
||||||
|
useWrapMode : true
|
||||||
|
|
||||||
}"
|
}"
|
||||||
ng-model="vm.content"
|
ng-model="vm.content"
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<div class="detail-header">
|
<div class="detail-header">
|
||||||
<span class="detail-header-title">
|
<span class="detail-header-title">
|
||||||
<span ng-bind="vm.snippet.callSign"></span>
|
<span ng-bind="vm.snippet.callSign"></span>
|
||||||
<small><span ng-bind="snippet.updatedAt|fromNow"></span> <i class="fa fa-clock-o"></i></small>
|
<small><span ng-bind="vm.snippet.updatedAt|fromNow"></span> <i class="fa fa-clock-o"></i></small>
|
||||||
</span>
|
</span>
|
||||||
<span class="detail-header-control pull-right">
|
<span class="detail-header-control pull-right">
|
||||||
<button type="button" name="button" class="btn btn-default"><i class="fa fa-share"></i></button>
|
<button type="button" name="button" class="btn btn-default"><i class="fa fa-share"></i></button>
|
||||||
@@ -20,12 +20,13 @@
|
|||||||
|
|
||||||
<div ng-if="vm.isLoaded" class="">
|
<div ng-if="vm.isLoaded" class="">
|
||||||
<p ng-bind="vm.snippet.description"></p>
|
<p ng-bind="vm.snippet.description"></p>
|
||||||
<div tags="vm.snippet.tags"></div>
|
<div tags="vm.snippet.Tags"></div>
|
||||||
<div ui-ace="{
|
<div ui-ace="{
|
||||||
showGutter: false,
|
showGutter: false,
|
||||||
useWrapMode : true,
|
useWrapMode : true,
|
||||||
mode:vm.snippet.mode.toLowerCase(),
|
mode:vm.snippet.mode.toLowerCase(),
|
||||||
maxLines: -1,
|
maxLines: -1,
|
||||||
|
theme:'solarized_dark',
|
||||||
rendererOptions: {
|
rendererOptions: {
|
||||||
maxLinks: Infinity
|
maxLinks: Infinity
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
<a ui-sref="auth.signin" class="btn btn-default"><i class="fa fa-signin"></i> Sign In</a>
|
<a ui-sref="auth.signin" class="btn btn-default"><i class="fa fa-signin"></i> Sign In</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<li ng-repeat="snippet in vm.snippets | filter:vm.search" ui-sref="snippets.detail({id:snippet._id})" ui-sref-active="active">
|
<li ng-repeat="snippet in vm.snippets | filter:vm.search" ui-sref="snippets.detail({id:snippet.id})" ui-sref-active="active">
|
||||||
<div class="media">
|
<div class="media">
|
||||||
<div class="media-left">
|
<div class="media-left">
|
||||||
<img width="25" height="25" src="http://www.gravatar.com/avatar/ea0b6ad1c11700120d1af08810caa19d" alt="" />
|
<img width="25" height="25" src="http://www.gravatar.com/avatar/ea0b6ad1c11700120d1af08810caa19d" alt="" />
|
||||||
@@ -41,7 +41,7 @@
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div tags="snippet.tags"></div>
|
<div tags="snippet.Tags"></div>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user