sum7/warehost-frontend
sum7
/
warehost-frontend
Archived
1
0
Fork 0

add blog post + bugfix

This commit is contained in:
Martin Geno 2017-03-21 18:16:32 +01:00
parent f07e4bece5
commit d8378c4073
No known key found for this signature in database
GPG Key ID: F0D39A37E925E941
10 changed files with 144 additions and 34 deletions

View File

@ -253,6 +253,14 @@ module.exports = function (grunt) {
'*.*' '*.*'
] ]
}, },
{
expand: true,
cwd: 'public/bower_components/font-awesome/fonts',
dest: 'build/fonts',
src: [
'*.*'
]
},
{ {
expand: true, expand: true,
cwd: '.tmp/img', cwd: '.tmp/img',

View File

@ -23,9 +23,33 @@
i (http(s)://DOMAIN/{{blog.url.path}}) i (http(s)://DOMAIN/{{blog.url.path}})
input.form-control(id="url",ng-model="blog.url.path") input.form-control(id="url",ng-model="blog.url.path")
.form-group .form-group
label(for="posturl") Post URL Schema label(for="posturl") Post url schema
.input-group
.input-group-addon http(s)://DOMAIN/{{blog.url.path}}
select.form-control(ng-model="blog.posturl",ng-options="item.key as item.label for item in posturlOptions")
.form-group .form-group
label(for="content") Content label(for="content") Content
div(id="content",text-angular,ta-text-editor-class="clearfix border-around" ta-html-editor-class="border-around",ng-model="blog.content") div(id="content",text-angular,ta-text-editor-class="clearfix border-around" ta-html-editor-class="border-around",ng-model="blog.content")
// .form-group
.checkbox
label
input(type="checkbox",ng-model="blog.preview_enable")
| Preview image
.form-group
.checkbox
label
input(type="checkbox",ng-model="blog.author_enable")
| Show author
.form-group
.checkbox
label
input(type="checkbox",ng-model="blog.createat_enable")
| Show create at
.form-group
.checkbox
label
input(type="checkbox",ng-model="blog.timerange_enable")
| Manage timerange in post
input.btn.btn-default(type="submit",value="Save") input.btn.btn-default(type="submit",value="Save")
input.btn.btn-danger(ng-if="blog.ID",value="Delete",ng-click="delete(blog)") input.btn.btn-danger(ng-if="blog.ID",value="Delete",ng-click="delete(blog)")

View File

@ -2,6 +2,10 @@
angular.module('warehost') angular.module('warehost')
.controller('BlogWebCtrl',function(session,config,alert,NgTableParams,$scope,$rootScope,$http,$stateParams){ .controller('BlogWebCtrl',function(session,config,alert,NgTableParams,$scope,$rootScope,$http,$stateParams){
$scope.posturlOptions = [
{key:0, label: '/title'},
{key:1, label: '/year/month/title'}
];
$scope.bloglist = []; $scope.bloglist = [];
alert.set({}); alert.set({});
$scope.blog = {}; $scope.blog = {};
@ -16,17 +20,21 @@ angular.module('warehost')
resetBlog(); resetBlog();
$scope.bloglist = res.data.data; $scope.bloglist = res.data.data;
var blog; var blog;
for(blog in $scope.bloglist){ for(var i in $scope.bloglist){
if(blog.ID === $stateParams.blogid) { blog = $scope.bloglist[i];
$scope.blog = blog; if(blog.ID === Number($stateParams.blogid)) {
$http.get(config.api+'/web/website/'+$stateParams.websiteid+'/blog/'+$stateParams.blogid).then(setBlog);
return; return;
} }
} }
if($scope.bloglist.length > 0 && $stateParams.blogid !== '-1'){ if($scope.bloglist.length > 0 && $stateParams.blogid !== '-1'){
$scope.blog = $scope.bloglist[0]; $http.get(config.api+'/web/website/'+$stateParams.websiteid+'/blog/'+$scope.bloglist[0].ID).then(setBlog);
} }
}); });
} }
function setBlog(res) {
$scope.blog = res.data.data;
}
function submitresult(res){ function submitresult(res){
session.set(res); session.set(res);
alert.set(res); alert.set(res);

View File

@ -1,31 +1,46 @@
h2 Posts h2 Posts
.row .row
.well.col-md-3 .col-md-3
.btn-toolbar .panel.panel-default
.btn-group .panel-heading All
a.btn.btn-default(ng-click="add()") a.pull-right.btn.btn-default.btn-xs(ng-click="add()")
span.glyphicon.glyphicon-plus span.glyphicon.glyphicon-plus
br table.table
.list-group tr(ng-repeat="item in blog.posts")
.list-group-item(ng-repeat="item in data") td {{item.title}}
.angular-ui-tree-handle {{item.title}} td
.pull-right.btn-group.btn-group-xs .pull-right.btn-group.btn-group-xs
a.btn.btn-default(ng-click="edit(item)") a.btn.btn-default(ng-click="edit(item)")
span.glyphicon.glyphicon-pencil span.glyphicon.glyphicon-pencil
a.btn.btn-default(ng-click="delete(item)") a.btn.btn-default(ng-click="delete(item)")
span.glyphicon.glyphicon-remove span.glyphicon.glyphicon-remove
form.col-md-9(ng-submit="save()") form.col-md-9(ng-submit="save()")
h3(ng-if="obj.ID") Edit h3(ng-if="post.ID") Edit
h3(ng-if="!obj.ID") New h3(ng-if="!post.ID") New
.form-group .form-group
label(for="title") Title label(for="title") Title
input.form-control(id="title",ng-model="obj.title") input.form-control(id="title",ng-model="post.title")
.form-group(ng-if="blog.author_enable")
label(for="author") Author
input.form-control(id="author",ng-model="post.author")
.form-group(ng-if="blog.createat_enable")
label(for="date") Create at
input.form-control(id="date",ng-model="post.createat")
.form-group(ng-if="blog.timerange_enable")
label(for="timerange") Timerange
.row
.col-md-6
.input-group
.input-group-addon start
input.form-control(id="timerange",ng-model="post.start")
.col-md-6
.input-group
.input-group-addon end
input.form-control(id="timerange",ng-model="post.end")
.form-group .form-group
label(for="url") URL label(for="summary") Summary
br div(id="summary",text-angular,ta-text-editor-class="clearfix border-around",ta-html-editor-class="border-around",ng-model="post.summary")
i (http(s)://DOMAIN/{{obj.url.path}})
input.form-control(id="url",ng-model="obj.url.path")
.form-group .form-group
label(for="content") Content label(for="content") Content
div(id="content",text-angular,ta-text-editor-class="clearfix border-around" ta-html-editor-class="border-around",ng-model="obj.content") div(id="content",text-angular,ta-text-editor-class="clearfix border-around",ta-html-editor-class="border-around",ng-model="post.content")
input.btn.btn-default(type="submit",value="Save") input.btn.btn-default(type="submit",value="Save")

View File

@ -0,0 +1,45 @@
'use strict';
angular.module('warehost')
.controller('BlogPostWebCtrl',function(session,config,alert,NgTableParams,$scope,$rootScope,$http,$stateParams){
alert.set({});
$scope.post = {};
$scope.websiteid = $stateParams.websiteid;
function reset(){
$scope.post = {};
}
function load(){
$http.get(config.api+'/web/website/'+$stateParams.websiteid+'/blog/'+$scope.blog.ID).then(function(res){
session.set(res);
reset();
$scope.blog = res.data.data;
});
}
function submitresult(res){
session.set(res);
alert.set(res);
if(res.data.data){
load();
}
}
reset();
$rootScope.$on('warehost.session',load);
$scope.edit = function(a){
$scope.post = a;
};
$scope.add = function(){
$scope.post = {};
};
$scope.save = function(){
if($scope.post.ID){
$http.patch(config.api+'/web/website/'+$stateParams.websiteid+'/blog/'+$scope.blog.ID+'/post/'+$scope.post.ID, $scope.post).then(submitresult);
}else{
$http.post(config.api+'/web/website/'+$stateParams.websiteid+'/blog/'+$scope.blog.ID+'/post', $scope.post).then(submitresult);
}
};
$scope.delete = function(a){
$http.delete(config.api+'/web/website/'+$stateParams.websiteid+'/blog/'+$scope.blog.ID+'/post/'+a.ID).then(submitresult);
};
});

View File

@ -64,7 +64,7 @@ angular.module('warehost')
views:{ views:{
'posts':{ 'posts':{
templateUrl: 'app/web/blogpost.html', templateUrl: 'app/web/blogpost.html',
controller:'BlogWebCtrl' controller:'BlogPostWebCtrl'
} }
} }
}) })

View File

@ -4,7 +4,7 @@
.row .row
.col-md-3 .col-md-3
.panel.panel-default .panel.panel-default
.panel-heading Pages .panel-heading All
a.pull-right.btn.btn-default.btn-xs(ng-click="add()") a.pull-right.btn.btn-default.btn-xs(ng-click="add()")
span.glyphicon.glyphicon-plus span.glyphicon.glyphicon-plus
table.table table.table

View File

@ -35,11 +35,20 @@ angular.module('warehost')
url.obj.url = null; url.obj.url = null;
$scope.urllist.push(url); $scope.urllist.push(url);
}); });
$http.get(config.api+'/web/website/'+$stateParams.websiteid+'/blog').then(function(res){
res.data.data.forEach(function (d) {
var url = d.url;
url.type = 'blog';
url.obj = d;
url.obj.url = null;
$scope.urllist.push(url);
});
$http.get(config.api+'/web/website/'+$stateParams.websiteid+'/menu').then(function(res){ $http.get(config.api+'/web/website/'+$stateParams.websiteid+'/menu').then(function(res){
session.set(res); session.set(res);
$scope.data = res.data.data; $scope.data = res.data.data;
}); });
}); });
});
} }
function submitresult(res){ function submitresult(res){
session.set(res); session.set(res);

View File

@ -2,7 +2,7 @@
angular.module('config', []) angular.module('config', [])
.factory('config', function() { .factory('config', function() {
return { return {
api: 'http://[::1]:8080', api: 'https://api.warehost.de',
table: { table: {
count: 25 count: 25
} }

View File

@ -7,7 +7,7 @@
<meta charset="utf-8"> <meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
<base href="/"> <base href="/">
<title>Warehost v2</title> <title>Warehost</title>
<meta name="description" content=""> <meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no"> <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon"> <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">
@ -22,7 +22,7 @@
<!-- endbower --> <!-- endbower -->
<link rel="stylesheet" href="bower_components/font-awesome/css/font-awesome.min.css" /> <link rel="stylesheet" href="bower_components/font-awesome/css/font-awesome.min.css" />
<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.min.css" /> <link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.min.css" />
<link rel="stylesheet" href="bower_components/bootswatch/united/bootstrap.min.css" /> <link rel="stylesheet" href="bower_components/bootswatch/paper/bootstrap.min.css" />
<!-- endbuild --> <!-- endbuild -->
<!-- build:css({.tmp,public}) app/app.css --> <!-- build:css({.tmp,public}) app/app.css -->
<link rel="stylesheet" href="app/app.css"> <link rel="stylesheet" href="app/app.css">
@ -77,6 +77,7 @@
<script src="app/setting.js"></script> <script src="app/setting.js"></script>
<script src="app/user.js"></script> <script src="app/user.js"></script>
<script src="app/web/blog.js"></script> <script src="app/web/blog.js"></script>
<script src="app/web/blogpost.js"></script>
<script src="app/web/domain.js"></script> <script src="app/web/domain.js"></script>
<script src="app/web/index.js"></script> <script src="app/web/index.js"></script>
<script src="app/web/list.js"></script> <script src="app/web/list.js"></script>