Open platform to collect and prioritize feedback
some ui changes
goenning20a543818818
diff --git a/app/router.go b/app/router.goindex edb3f1ce4..675e854d0 100644--- a/app/router.go+++ b/app/router.go@@ -77,7 +77,8 @@ func GetMainEngine(ctx *WechyServices) *echo.Echo {appGroup.Use(identity.JwtSetter())appGroup.Use(identity.MultiTenant(ctx.Tenant))- appGroup.GET("/", feedback.Index(ctx.Idea))+ appGroup.GET("/", feedback.Index(ctx.Idea).List())+ appGroup.POST("/api/ideas", feedback.Index(ctx.Idea).Post())appGroup.GET("/logout", identity.OAuth(ctx.OAuth, ctx.User).Logout())appGroup.GET("/status", Status(ctx.Health, ctx.Settings))}diff --git a/assets.json b/assets.jsondeleted file mode 100644index 1f0704c9d..000000000--- a/assets.json+++ /dev/null@@ -1 +0,0 @@-4390ad7f630f41e4b096\ No newline at end of filediff --git a/feedback/handler.go b/feedback/handler.goindex 78c35c81d..c4219c154 100644--- a/feedback/handler.go+++ b/feedback/handler.go@@ -5,16 +5,18 @@ import ("github.com/labstack/echo")-type indexHandlder struct {+// IndexHandlder contains multiple feedback HTTP handlers+type IndexHandlder struct {ideaService IdeaService}// Index handles initial page-func Index(ideaService IdeaService) echo.HandlerFunc {- return indexHandlder{ideaService}.get()+func Index(ideaService IdeaService) IndexHandlder {+ return IndexHandlder{ideaService}}-func (h indexHandlder) get() echo.HandlerFunc {+// List all tenant ideas+func (h IndexHandlder) List() echo.HandlerFunc {return func(c echo.Context) error {tenant := c.Get("Tenant").(*identity.Tenant)ideas, _ := h.ideaService.GetAll(tenant.ID)@@ -24,3 +26,21 @@ func (h indexHandlder) get() echo.HandlerFunc {})}}++type newIdea struct {+ Title string `json:"title"`+}++// Post creates a new idea on current tenant+func (h IndexHandlder) Post() echo.HandlerFunc {+ return func(c echo.Context) error {+ idea := new(newIdea)+ c.Bind(idea)++ return c.JSON(200, echo.Map{+ "tenant": c.Get("Tenant"),+ "claims": c.Get("Claims"),+ "idea": idea.Title,+ })+ }+}diff --git a/package.json b/package.jsonindex df2797bd7..d89f8c6d5 100644--- a/package.json+++ b/package.json@@ -11,15 +11,18 @@"heroku-postbuild": "npm run build"},"dependencies": {+ "axios": "^0.15.3","jquery": "^3.2.0","react": "^15.4.2","react-dom": "^15.4.2","semantic-ui-css": "^2.2.9"},"devDependencies": {+ "@types/axios": "^0.14.0","@types/jquery": "^2.0.41","@types/react": "^15.0.16","@types/react-dom": "^0.14.23",+ "clean-webpack-plugin": "^0.1.16","css-loader": "^0.27.3","file-loader": "^0.10.1","rimraf": "^2.6.1",@@ -27,7 +30,6 @@"ts-loader": "^2.0.1","tslint": "^4.5.1","typescript": "^2.2.1",- "webpack": "^2.2.1",- "webpack-auto-clean-build-plugin": "^1.0.3"+ "webpack": "^2.2.1"}}diff --git a/public/components/Header.tsx b/public/components/Header.tsxindex cb1037925..73fbf17cd 100644--- a/public/components/Header.tsx+++ b/public/components/Header.tsx@@ -43,10 +43,10 @@ export class Header extends React.Component<{}, {}> {return <div><div className="ui menu"><div className="ui container">- <div className="header item">- { tenant.name }- </div>- { profile }+ <div className="header item">+ { tenant.name }+ </div>+ { profile }</div></div>{ dropdown }diff --git a/public/components/IdeaInput.tsx b/public/components/IdeaInput.tsxindex c965cfd60..98e9e7b85 100644--- a/public/components/IdeaInput.tsx+++ b/public/components/IdeaInput.tsx@@ -1,3 +1,4 @@+import axios from "axios";import * as React from "react";import { SocialSignInButton } from "./SocialSignInButton";@@ -14,9 +15,15 @@ export class IdeaInput extends React.Component<{}, IdeaInputState> {this.state = { idea: "" };}+ public async submit() {+ const response = await axios.post("/api/ideas", {+ title: this.state.idea+ });+ }+public render() {const details = claims ?- <button className="ui positive button">+ <button className="ui positive button" onClick={async () => { await this.submit(); } }>Submit Idea</button> :<div>@@ -35,13 +42,13 @@ export class IdeaInput extends React.Component<{}, IdeaInputState> {<div className="ui fluid input"><input id="new-idea-input"type="text"- onKeyUp={(e) => {this.setState({ idea: e.currentTarget.value }); }}+ onKeyUp={(e) => { this.setState({ idea: e.currentTarget.value }); }}placeholder="Enter your idea, new feature or suggestion here ..." /></div><div id="new-idea-submit" className="ui grid"><div className="four wide column">- { this.state.idea.length > 0 ? details : <div /> }+ { this.state.idea.length > 0 && details }</div></div></div>;diff --git a/tsconfig.json b/tsconfig.jsonindex 379cdd562..b27d40285 100755--- a/tsconfig.json+++ b/tsconfig.json@@ -1,7 +1,7 @@{"compilerOptions": {"module": "commonjs",- "target": "es5",+ "target": "es6","noImplicitAny": true,"strictNullChecks": true,"sourceMap": true,diff --git a/views/base.html b/views/base.htmlindex 0ff6fa9e9..7b02a6944 100644--- a/views/base.html+++ b/views/base.html@@ -17,6 +17,7 @@</script><div id="root"></div>+{{template "content" .}}<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.0/jquery.min.js" integrity="sha256-JAW99MJVpJBGcbzEuXk4Az05s/XyDdBomFqNlM3ic+I=" crossorigin="anonymous"></script>diff --git a/webpack.config.js b/webpack.config.jsindex c47704077..528aff7eb 100755--- a/webpack.config.js+++ b/webpack.config.js@@ -1,5 +1,5 @@const path = require('path');-const AutoCleanBuildPlugin = require('webpack-auto-clean-build-plugin');+const CleanWebpackPlugin = require('clean-webpack-plugin');module.exports = {entry: "./public/index.ts",@@ -27,7 +27,12 @@ module.exports = {]},plugins: [- new AutoCleanBuildPlugin()+ new CleanWebpackPlugin(['dist'], {+ root: __dirname,+ verbose: true,+ dry: false,+ watch: true+ })],externals: {'react': 'React',