add available terms added

This commit is contained in:
PawelJa 2018-12-02 19:22:59 +01:00
parent ef2047bb98
commit e45dc87655
47 changed files with 12086 additions and 58 deletions

View File

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
<mapping directory="$PROJECT_DIR$/src/github.com/gorilla/mux" vcs="Git" />
</component>
</project>

View File

@ -1,7 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="baac0fea-ba77-4412-8e4a-c4ee1e16e324" name="Default Changelist" comment="" />
<list default="true" id="baac0fea-ba77-4412-8e4a-c4ee1e16e324" name="Default Changelist" comment="">
<change afterPath="$PROJECT_DIR$/calendar/controller.go" afterDir="false" />
<change afterPath="$PROJECT_DIR$/dbConfig/config.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/vcs.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/vcs.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/main.go" beforeDir="false" afterPath="$PROJECT_DIR$/main.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/router/routes.go" beforeDir="false" afterPath="$PROJECT_DIR$/router/routes.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/test/controller.go" beforeDir="false" afterPath="$PROJECT_DIR$/test/controller.go" afterDir="false" />
</list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -39,9 +47,74 @@
</counts>
</usages-collector>
</session>
<session id="2110107836">
<usages-collector id="statistics.lifecycle.project">
<counts>
<entry key="project.closed" value="4" />
<entry key="project.open.time.1" value="1" />
<entry key="project.open.time.10" value="1" />
<entry key="project.open.time.13" value="1" />
<entry key="project.open.time.14" value="1" />
<entry key="project.opened" value="4" />
</counts>
</usages-collector>
<usages-collector id="statistics.file.extensions.edit">
<counts>
<entry key="go" value="4248" />
</counts>
</usages-collector>
<usages-collector id="statistics.file.types.edit">
<counts>
<entry key="Go" value="4248" />
</counts>
</usages-collector>
<usages-collector id="statistics.file.extensions.open">
<counts>
<entry key="go" value="11" />
</counts>
</usages-collector>
<usages-collector id="statistics.file.types.open">
<counts>
<entry key="Go" value="11" />
</counts>
</usages-collector>
<usages-collector id="statistics.go.postfix.template.usages.trigger">
<counts>
<entry key=".len" value="1" />
</counts>
</usages-collector>
</session>
</component>
<component name="FileEditorManager">
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300" />
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/main.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="24">
<caret line="173" column="81" selection-start-line="173" selection-start-column="81" selection-end-line="173" selection-end-column="81" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/dbConfig/config.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="153">
<caret line="15" column="23" selection-start-line="15" selection-start-column="23" selection-end-line="15" selection-end-column="23" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/test/controller.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="187">
<caret line="14" column="1" selection-start-line="14" selection-start-column="1" selection-end-line="14" selection-end-column="1" />
</state>
</provider>
</entry>
</file>
</leaf>
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
@ -52,7 +125,7 @@
</component>
<component name="GOROOT" path="C:\Go" />
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/src/github.com/gorilla/mux" />
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="IdeDocumentHistory">
<option name="CHANGED_PATHS">
@ -62,6 +135,10 @@
<option value="$PROJECT_DIR$/router.go" />
<option value="$PROJECT_DIR$/routes.go" />
<option value="$PROJECT_DIR$/router/router.go" />
<option value="$PROJECT_DIR$/router/routes.go" />
<option value="$PROJECT_DIR$/calendar/controller.go" />
<option value="$PROJECT_DIR$/test/controller.go" />
<option value="$PROJECT_DIR$/dbConfig/config.go" />
<option value="$PROJECT_DIR$/main.go" />
</list>
</option>
@ -72,6 +149,14 @@
<detection-done>true</detection-done>
<sorting>DEFINITION_ORDER</sorting>
</component>
<component name="NodeModulesDirectoryManager">
<handled-path value="$PROJECT_DIR$/szt-visio-app/node_modules" />
</component>
<component name="NodePackageJsonFileManager">
<packageJsonPaths>
<path value="$PROJECT_DIR$/szt-visio-app/package.json" />
</packageJsonPaths>
</component>
<component name="ProjectFrameBounds" extendedState="6">
<option name="x" value="327" />
<option name="y" value="84" />
@ -89,7 +174,22 @@
<expand>
<path>
<item name="szt_visio" type="b2602c69:ProjectViewProjectNode" />
<item name="simpleREST" type="462c0819:PsiDirectoryNode" />
<item name="szt_visio" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="szt_visio" type="b2602c69:ProjectViewProjectNode" />
<item name="szt_visio" type="462c0819:PsiDirectoryNode" />
<item name="dbConfig" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="szt_visio" type="b2602c69:ProjectViewProjectNode" />
<item name="szt_visio" type="462c0819:PsiDirectoryNode" />
<item name="router" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="szt_visio" type="b2602c69:ProjectViewProjectNode" />
<item name="szt_visio" type="462c0819:PsiDirectoryNode" />
<item name="test" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="szt_visio" type="b2602c69:ProjectViewProjectNode" />
@ -104,6 +204,7 @@
</component>
<component name="PropertiesComponent">
<property name="DefaultGoTemplateProperty" value="Go File" />
<property name="SearchEverywhereHistoryKey" value="format cod&#9;ACTION&#9;ReformatCode" />
<property name="configurable.Global.GOPATH.is.expanded" value="true" />
<property name="configurable.Module.GOPATH.is.expanded" value="false" />
<property name="configurable.Project.GOPATH.is.expanded" value="true" />
@ -134,15 +235,6 @@
</option>
</component>
<component name="RunManager">
<configuration default="true" type="GoApplicationRunConfiguration" factoryName="Go Application">
<module name="szt_visio" />
<working_directory value="$PROJECT_DIR$/" />
<go_parameters value="-i" />
<kind value="FILE" />
<filePath value="$PROJECT_DIR$/" />
<directory value="$PROJECT_DIR$/" />
<method v="2" />
</configuration>
<configuration name="go build main.go" type="GoApplicationRunConfiguration" factoryName="Go Application" temporary="true" nameIsGenerated="true">
<module name="szt_visio" />
<working_directory value="$PROJECT_DIR$/" />
@ -151,16 +243,6 @@
<directory value="$PROJECT_DIR$/" />
<method v="2" />
</configuration>
<configuration default="true" type="GoTestRunConfiguration" factoryName="Go Test">
<module name="szt_visio" />
<working_directory value="$PROJECT_DIR$/" />
<go_parameters value="-i" />
<framework value="gotest" />
<kind value="DIRECTORY" />
<directory value="$PROJECT_DIR$/" />
<filePath value="$PROJECT_DIR$/" />
<method v="2" />
</configuration>
<recent_temporary>
<list>
<item itemvalue="Go Build.go build main.go" />
@ -170,7 +252,7 @@
<component name="ToolWindowManager">
<frame x="-8" y="-8" width="1936" height="1066" extended-state="6" />
<layout>
<window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.25799572" />
<window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.26865673" />
<window_info id="Structure" order="1" side_tool="true" weight="0.25" />
<window_info id="Favorites" order="2" side_tool="true" />
<window_info anchor="bottom" id="Message" order="0" />
@ -201,46 +283,48 @@
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="119">
<caret line="7" lean-forward="true" selection-start-line="7" selection-end-line="7" />
<folding>
<element signature="e#14#51#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/test/controller.go">
<entry file="file://$PROJECT_DIR$/calendar/controller.go">
<provider selected="true" editor-type-id="text-editor">
<state>
<caret column="12" selection-start-column="12" selection-end-column="12" />
<folding>
<element signature="e#14#43#0" expanded="true" />
</folding>
<state relative-caret-position="85">
<caret line="5" selection-start-line="5" selection-end-line="5" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/router/routes.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="51">
<caret line="3" column="10" selection-start-line="3" selection-start-column="10" selection-end-line="3" selection-end-column="10" />
<state relative-caret-position="255">
<caret line="15" column="19" selection-start-line="15" selection-start-column="19" selection-end-line="15" selection-end-column="19" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/router/router.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="204">
<caret line="12" lean-forward="true" selection-start-line="12" selection-end-line="12" />
<folding>
<element signature="e#16#64#0" expanded="true" />
</folding>
<state relative-caret-position="34">
<caret line="2" selection-start-line="2" selection-end-line="2" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/main.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="221">
<caret line="13" selection-start-line="13" selection-end-line="13" />
<folding>
<element signature="e#14#43#0" expanded="true" />
</folding>
<state relative-caret-position="24">
<caret line="173" column="81" selection-start-line="173" selection-start-column="81" selection-end-line="173" selection-end-column="81" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/dbConfig/config.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="153">
<caret line="15" column="23" selection-start-line="15" selection-start-column="23" selection-end-line="15" selection-end-column="23" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/test/controller.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="187">
<caret line="14" column="1" selection-start-line="14" selection-start-column="1" selection-end-line="14" selection-end-column="1" />
</state>
</provider>
</entry>

23
calendar/controller.go Normal file
View File

@ -0,0 +1,23 @@
package calendar
import (
"fmt"
"net/http"
)
func AddCalendar(w http.ResponseWriter, r *http.Request) {
keys, ok := r.URL.Query()["key"]
if !ok || len(keys[0]) < 1 {
fmt.Println("Url Param 'key' is missing")
return
}
key := keys[0]
fmt.Fprint(w, "Url Param 'key' is: " + string (key))
}
//func Calendar(w http.ResponseWriter, r *http.Request) {
// fmt.Fprint(w, "Welcome!\n")
//}

118
dbConfig/config.go Normal file
View File

@ -0,0 +1,118 @@
package dbConfig
import (
"database/sql"
"encoding/json"
"fmt"
"net/http"
"os"
)
var db *sql.DB
const (
dbhost = "DBHOST"
dbport = "5432"
dbuser = "postgres"
dbpass = "admin"
dbname = "mydb"
)
func initDb() {
//config := dbConfig()
var err error
//psqlInfo := fmt.Sprintf("host=localhost port=%s user=%s password=%s dbname=%s sslmode=disable",
// config[dbport], config[dbuser], config[dbpass], config[dbname])
db, err = sql.Open("postgres", "port=5432 password=admin user=postgres dbname=mydb sslmode=disable")
if err != nil {
panic(err)
}
err = db.Ping()
if err != nil {
panic(err)
}
fmt.Println("Successfullu connected!")
}
func dbConfig() map[string]string {
conf := make(map[string]string)
host, ok := os.LookupEnv(dbhost)
if !ok {
panic("DBHOST environment variable required but not set")
}
port, ok := os.LookupEnv(dbport)
if !ok {
panic("DBPORT environment variable required but not set")
}
user, ok := os.LookupEnv(dbuser)
if !ok {
panic("DBUSER environment variable required but not set")
}
password, ok := os.LookupEnv(dbpass)
if !ok {
panic("DBPASS environment variable required but not set")
}
name, ok := os.LookupEnv(dbname)
if !ok {
panic("DBNAME environment variable required but not set")
}
conf[dbhost] = host
conf[dbport] = port
conf[dbuser] = user
conf[dbpass] = password
conf[dbname] = name
return conf
}
func testFunc(w http.ResponseWriter, r *http.Request) {
fmt.Println("weszlo")
repos := repositories{}
err := queryRepos(&repos)
if err != nil {
http.Error(w, err.Error(), 500)
return
}
out, err := json.Marshal(repos)
if err != nil {
http.Error(w, err.Error(), 500)
return
}
fmt.Fprint(w, repos)
fmt.Fprintf(w, string(out))
}
func queryRepos(repos *repositories) error {
rows, err := db.Query(`SELECT * FROM friends.test;`)
if err != nil {
return err
}
defer rows.Close()
for rows.Next() {
repo := repositorySummary{}
err = rows.Scan(
&repo.firstname,
&repo.lastname, )
if err != nil {
return err
}
fmt.Println("mam", repo)
repos.Repositories = append(repos.Repositories, repo)
}
err = rows.Err()
if err != nil {
return err
}
return nil
}
type repositorySummary struct {
firstname string
lastname string
}
type repositories struct {
Repositories []repositorySummary
}

227
main.go
View File

@ -1,14 +1,235 @@
package main
import (
"database/sql"
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/http"
"./router"
"os"
"strconv"
"time"
)
import _"github.com/lib/pq"
func main() {
router := router.NewRouter()
initDb()
defer db.Close()
log.Fatal(http.ListenAndServe(":8080", router))
//router := router.NewRouter()
http.HandleFunc("/test", test)
http.HandleFunc("/test2", createTerms2)
http.HandleFunc("/date", createTerms)
log.Fatal(http.ListenAndServe(":8080", nil))
}
var db *sql.DB
const (
dbhost="DBHOST"
dbport="5432"
dbuser="postgres"
dbpass="admin"
dbname="mydb"
)
func initDb() {
//config := dbConfig()
var err error
//psqlInfo := fmt.Sprintf("host=localhost port=%s user=%s password=%s dbname=%s sslmode=disable",
// config[dbport], config[dbuser], config[dbpass], config[dbname])
db, err = sql.Open("postgres", "port=5432 password=admin user=postgres dbname=mydb sslmode=disable")
if err != nil {
panic(err)
}
err = db.Ping()
if err != nil {
panic(err)
}
fmt.Println("Successfullu connected!")
}
func dbConfig() map[string]string {
conf := make(map[string]string)
host, ok := os.LookupEnv(dbhost)
if !ok {
panic("DBHOST environment variable required but not set")
}
port, ok := os.LookupEnv(dbport)
if !ok {
panic("DBPORT environment variable required but not set")
}
user, ok := os.LookupEnv(dbuser)
if !ok {
panic("DBUSER environment variable required but not set")
}
password, ok := os.LookupEnv(dbpass)
if !ok {
panic("DBPASS environment variable required but not set")
}
name, ok := os.LookupEnv(dbname)
if !ok {
panic("DBNAME environment variable required but not set")
}
conf[dbhost] = host
conf[dbport] = port
conf[dbuser] = user
conf[dbpass] = password
conf[dbname] = name
return conf
}
func testFunc(w http.ResponseWriter, r *http.Request) {
fmt.Println("weszlo")
repos := repositories{}
err := queryRepos(&repos)
if err != nil {
http.Error(w, err.Error(), 500)
return
}
out, err := json.Marshal(repos)
if err != nil {
http.Error(w, err.Error(), 500)
return
}
fmt.Fprint(w, repos)
fmt.Fprintf(w, string(out))
}
func test(rw http.ResponseWriter, req *http.Request) {
//body, err := ioutil.ReadAll(req.Body)
//if err != nil {
// panic(err)
//}
//fmt.Println(string(body))
//var t test_struct
//err = json.Unmarshal(body, &t)
//if err != nil {
// panic(err)
//}
//fmt.Println(t.Test1)
//fmt.Println(t.aaa)
//addRow("2018-02-04")
}
func createTerms2(rw http.ResponseWriter, req *http.Request) {
decoder := json.NewDecoder(req.Body)
var t2 test_struct2
err := decoder.Decode(&t2)
if err != nil {
panic(err)
}
fmt.Println(t2.Test)
fmt.Println(t2.SomeKey)
}
type test_struct2 struct {
Test []int `json:"months"`
SomeKey int `json:"year"`
}
type test_struct struct {
Test1 int
aaa string
}
func createTerms(w http.ResponseWriter, req *http.Request) {
//year, ok :=r.URL.Query()["year"]
//daysIn(11,2018)
//daysIn(12,2018)
body, err := ioutil.ReadAll(req.Body)
if err != nil {
panic(err)
}
log.Println(string(body))
var term term_struct
err = json.Unmarshal(body, &term)
if err != nil {
panic(err)
}
//fmt.Println(term.Year)
//fmt.Println(term.Months)
for i:=0; i< len(term.Months); i++ {
daysIn(term.Months[i], term.Year)
// //fmt.Println(daysIn(newTerm.months[i], newTerm.year))
}
}
type term_struct struct {
Months []int `json:"months"`
Year int `json:"year"`
}
func daysIn(m int, year int) {
var data string
dni := time.Date(year, time.Month(m+1),0,0,0,0,0,time.UTC)
for i := 1; i <= dni.Day(); i++ {
data = strconv.Itoa(year) + "-" + strconv.Itoa(int(m)) + "-" + strconv.Itoa(i)
fmt.Println("data: ", data)
addRow(data)
}
}
func addRow(data string) {
tx, err := db.Begin()
if err != nil {
log.Fatal(err)
}
defer tx.Rollback()
stmt, err := tx.Prepare("INSERT INTO calendar (date, status, contractNo) VALUES ( $1, 'available', '');")
if err != nil {
log.Fatal(err)
}
defer stmt.Close() // danger!
for i := 0; i < 1; i++ {
_, err = stmt.Exec(data)
if err != nil {
log.Fatal(err)
}
}
err = tx.Commit()
if err != nil {
log.Fatal(err)
}
}
func queryRepos(repos *repositories) error {
rows, err := db.Query(`SELECT * FROM friends.test;`)
if err != nil {
return err
}
defer rows.Close()
for rows.Next() {
repo := repositorySummary{}
err = rows.Scan(
&repo.firstname,
&repo.lastname,)
if err != nil {
return err
}
fmt.Println("mam", repo)
repos.Repositories = append(repos.Repositories, repo)
}
err = rows.Err()
if err != nil {
return err
}
return nil
}
type repositorySummary struct {
firstname string
lastname string
}
type repositories struct {
Repositories []repositorySummary
}

View File

@ -1,7 +1,10 @@
package router
import "net/http"
import "../test"
import (
"net/http"
"../test"
"../calendar"
)
type Route struct {
Name string
@ -13,10 +16,6 @@ type Route struct {
type Routes []Route
var routes = Routes{
Route{
"Index",
"GET",
"/",
test.Index,
},
Route{"Index", "GET", "/", test.Index,},
Route{"AddCalendar", "POST", "/calendar", calendar.AddCalendar},
}

View File

@ -0,0 +1,13 @@
# Editor configuration, see https://editorconfig.org
root = true
[*]
charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true
[*.md]
max_line_length = off
trim_trailing_whitespace = false

39
szt-visio-app/.gitignore vendored Normal file
View File

@ -0,0 +1,39 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.
# compiled output
/dist
/tmp
/out-tsc
# dependencies
/node_modules
# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace
# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
# misc
/.sass-cache
/connect.lock
/coverage
/libpeerconnection.log
npm-debug.log
yarn-error.log
testem.log
/typings
# System Files
.DS_Store
Thumbs.db

27
szt-visio-app/README.md Normal file
View File

@ -0,0 +1,27 @@
# SztVisioApp
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 7.0.6.
## Development server
Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.
## Code scaffolding
Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`.
## Build
Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `--prod` flag for a production build.
## Running unit tests
Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).
## Running end-to-end tests
Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/).
## Further help
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md).

135
szt-visio-app/angular.json Normal file
View File

@ -0,0 +1,135 @@
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"szt-visio-app": {
"root": "",
"sourceRoot": "src",
"projectType": "application",
"prefix": "app",
"schematics": {},
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/szt-visio-app",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.app.json",
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"src/styles.css"
],
"scripts": []
},
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
}
]
}
}
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "szt-visio-app:build"
},
"configurations": {
"production": {
"browserTarget": "szt-visio-app:build:production"
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "szt-visio-app:build"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "src/test.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.spec.json",
"karmaConfig": "src/karma.conf.js",
"styles": [
"src/styles.css"
],
"scripts": [],
"assets": [
"src/favicon.ico",
"src/assets"
]
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"src/tsconfig.app.json",
"src/tsconfig.spec.json"
],
"exclude": [
"**/node_modules/**"
]
}
}
}
},
"szt-visio-app-e2e": {
"root": "e2e/",
"projectType": "application",
"prefix": "",
"architect": {
"e2e": {
"builder": "@angular-devkit/build-angular:protractor",
"options": {
"protractorConfig": "e2e/protractor.conf.js",
"devServerTarget": "szt-visio-app:serve"
},
"configurations": {
"production": {
"devServerTarget": "szt-visio-app:serve:production"
}
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": "e2e/tsconfig.e2e.json",
"exclude": [
"**/node_modules/**"
]
}
}
}
}
},
"defaultProject": "szt-visio-app"
}

View File

@ -0,0 +1,28 @@
// Protractor configuration file, see link for more information
// https://github.com/angular/protractor/blob/master/lib/config.ts
const { SpecReporter } = require('jasmine-spec-reporter');
exports.config = {
allScriptsTimeout: 11000,
specs: [
'./src/**/*.e2e-spec.ts'
],
capabilities: {
'browserName': 'chrome'
},
directConnect: true,
baseUrl: 'http://localhost:4200/',
framework: 'jasmine',
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000,
print: function() {}
},
onPrepare() {
require('ts-node').register({
project: require('path').join(__dirname, './tsconfig.e2e.json')
});
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
}
};

View File

@ -0,0 +1,14 @@
import { AppPage } from './app.po';
describe('workspace-project App', () => {
let page: AppPage;
beforeEach(() => {
page = new AppPage();
});
it('should display welcome message', () => {
page.navigateTo();
expect(page.getTitleText()).toEqual('Welcome to szt-visio-app!');
});
});

View File

@ -0,0 +1,11 @@
import { browser, by, element } from 'protractor';
export class AppPage {
navigateTo() {
return browser.get('/');
}
getTitleText() {
return element(by.css('app-root h1')).getText();
}
}

View File

@ -0,0 +1,13 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/app",
"module": "commonjs",
"target": "es5",
"types": [
"jasmine",
"jasminewd2",
"node"
]
}
}

10546
szt-visio-app/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,51 @@
{
"name": "szt-visio-app",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "^7.0.4",
"@angular/cdk": "^7.1.0",
"@angular/common": "~7.0.0",
"@angular/compiler": "~7.0.0",
"@angular/core": "~7.0.0",
"@angular/forms": "~7.0.0",
"@angular/http": "~7.0.0",
"@angular/material": "^7.1.0",
"@angular/platform-browser": "~7.0.0",
"@angular/platform-browser-dynamic": "~7.0.0",
"@angular/router": "~7.0.0",
"core-js": "^2.5.4",
"hammerjs": "^2.0.8",
"rxjs": "~6.3.3",
"zone.js": "~0.8.26"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.10.0",
"@angular/cli": "~7.0.6",
"@angular/compiler-cli": "~7.0.0",
"@angular/language-service": "~7.0.0",
"@types/node": "~8.9.4",
"@types/jasmine": "~2.8.8",
"@types/jasminewd2": "~2.0.3",
"codelyzer": "~4.5.0",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~3.0.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~1.1.2",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.4.0",
"ts-node": "~7.0.0",
"tslint": "~5.11.0",
"typescript": "~3.1.6"
}
}

View File

View File

@ -0,0 +1 @@
<router-outlet></router-outlet>

View File

@ -0,0 +1,31 @@
import { TestBed, async } from '@angular/core/testing';
import { AppComponent } from './app.component';
describe('AppComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [
AppComponent
],
}).compileComponents();
}));
it('should create the app', () => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
expect(app).toBeTruthy();
});
it(`should have as title 'szt-visio-app'`, () => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
expect(app.title).toEqual('szt-visio-app');
});
it('should render title in a h1 tag', () => {
const fixture = TestBed.createComponent(AppComponent);
fixture.detectChanges();
const compiled = fixture.debugElement.nativeElement;
expect(compiled.querySelector('h1').textContent).toContain('Welcome to szt-visio-app!');
});
});

View File

@ -0,0 +1,11 @@
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'szt-visio-app';
}

View File

@ -0,0 +1,27 @@
import { BrowserModule } from '@angular/platform-browser';
import {CUSTOM_ELEMENTS_SCHEMA, NgModule} from '@angular/core';
import { AppComponent } from './app.component';
import { AddTermsComponent } from './components/add-terms/add-terms.component';
import {RouterModule} from '@angular/router';
import {appRoutes} from './app.router.module';
import {MaterialModule} from './material.module';
@NgModule({
declarations: [
AppComponent,
AddTermsComponent
],
imports: [
BrowserModule,
MaterialModule,
RouterModule.forRoot(
appRoutes,
// { enableTracking: true }
)
],
providers: [],
bootstrap: [AppComponent],
schemas: [ CUSTOM_ELEMENTS_SCHEMA ]
})
export class AppModule { }

View File

@ -0,0 +1,9 @@
import {AddTermsComponent} from './components/add-terms/add-terms.component';
import {Routes} from '@angular/router';
export const appRoutes: Routes = [
{
path: 'add-term',
component: AddTermsComponent
}
]

View File

@ -0,0 +1,25 @@
<!--<form [formGroup]="form">-->
<!--<mat-form-field>-->
<!--<mat-select placeholder="Rok" [formControl]="year" required>-->
<!--<mat-option>&#45;&#45;</mat-option>-->
<!--<mat-option *ngFor="let year of yearItems" [value]="year">-->
<!--{{year}}-->
<!--</mat-option>-->
<!--</mat-select>-->
<!--<mat-error *ngIf="year.hasError('required')">Wybierz rok</mat-error>-->
<!--</mat-form-field>-->
<!--</form>-->
<form class="example-form">
<mat-form-field class="example-full-width">
<input matInput placeholder="Email" [formControl]="emailFormControl"
[errorStateMatcher]="matcher">
<mat-hint>Errors appear instantly!</mat-hint>
<mat-error *ngIf="emailFormControl.hasError('email') && !emailFormControl.hasError('required')">
Please enter a valid email address
</mat-error>
<mat-error *ngIf="emailFormControl.hasError('required')">
Email is <strong>required</strong>
</mat-error>
</mat-form-field>
</form>

View File

@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { AddTermsComponent } from './add-terms.component';
describe('AddTermsComponent', () => {
let component: AddTermsComponent;
let fixture: ComponentFixture<AddTermsComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ AddTermsComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(AddTermsComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,59 @@
import { Component, OnInit } from '@angular/core';
import {FormControl, FormGroup, FormGroupDirective, NgForm, Validators} from '@angular/forms';
import {ErrorStateMatcher} from '@angular/material';
@Component({
selector: 'app-add-terms',
templateUrl: './add-terms.component.html',
styleUrls: ['./add-terms.component.css']
})
export class AddTermsComponent implements OnInit {
form: FormGroup;
emailFormControl: FormControl;
matcher = new MyErrorStateMatcher();
yearItems = [ 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025, 2026, 2027, 2028, 2029, 2030 ];
constructor() { }
ngOnInit() {
this.createForm();
this.emailFormControl = new FormControl('', [
Validators.required,
Validators.email,
]);
}
createForm() {
this.form = new FormGroup({
year: new FormControl(null, Validators.required),
months: new FormControl(false, Validators.requiredTrue),
month1: new FormControl(false),
month2: new FormControl(false),
month3: new FormControl(false),
month4: new FormControl(false),
month5: new FormControl(false),
month6: new FormControl(false),
month7: new FormControl(false),
month8: new FormControl(false),
month9: new FormControl(false),
month10: new FormControl(false),
month11: new FormControl(false),
month12: new FormControl(false)
});
}
}
export class MyErrorStateMatcher implements ErrorStateMatcher {
isErrorState(control: FormControl | null, form: FormGroupDirective | NgForm | null): boolean {
const isSubmitted = form && form.submitted;
return !!(control && control.invalid && (control.dirty || control.touched || isSubmitted));
}
}

View File

@ -0,0 +1,76 @@
import {
MatAutocompleteModule,
MatBadgeModule,
MatBottomSheetModule,
MatButtonModule,
MatButtonToggleModule,
MatCardModule,
MatCheckboxModule,
MatChipsModule,
MatDatepickerModule,
MatDialogModule,
MatDividerModule,
MatExpansionModule,
MatGridListModule,
MatIconModule,
MatInputModule,
MatListModule,
MatMenuModule,
MatNativeDateModule,
MatPaginatorModule,
MatProgressBarModule,
MatProgressSpinnerModule,
MatRadioModule,
MatRippleModule,
MatSelectModule,
MatSidenavModule,
MatSliderModule,
MatSlideToggleModule,
MatSnackBarModule,
MatSortModule,
MatStepperModule,
MatTableModule,
MatTabsModule,
MatToolbarModule,
MatTooltipModule,
MatTreeModule,
} from '@angular/material';
import {NgModule} from '@angular/core';
@NgModule({
exports: [
MatAutocompleteModule,
MatButtonModule,
MatButtonToggleModule,
MatCardModule,
MatCheckboxModule,
MatChipsModule,
MatStepperModule,
MatDatepickerModule,
MatDialogModule,
MatDividerModule,
MatExpansionModule,
MatGridListModule,
MatIconModule,
MatInputModule,
MatListModule,
MatMenuModule,
MatNativeDateModule,
MatPaginatorModule,
MatProgressBarModule,
MatProgressSpinnerModule,
MatRadioModule,
MatRippleModule,
MatSelectModule,
MatSidenavModule,
MatSliderModule,
MatSlideToggleModule,
MatSnackBarModule,
MatSortModule,
MatTableModule,
MatTabsModule,
MatToolbarModule,
MatTooltipModule,
]
})
export class MaterialModule {}

View File

@ -0,0 +1,12 @@
import { TestBed } from '@angular/core/testing';
import { TermService } from './term.service';
describe('TermService', () => {
beforeEach(() => TestBed.configureTestingModule({}));
it('should be created', () => {
const service: TermService = TestBed.get(TermService);
expect(service).toBeTruthy();
});
});

View File

@ -0,0 +1,9 @@
import { Injectable } from '@angular/core';
@Injectable({
providedIn: 'root'
})
export class TermService {
constructor() { }
}

View File

View File

@ -0,0 +1,11 @@
# This file is currently used by autoprefixer to adjust CSS to support the below specified browsers
# For additional information regarding the format and rule options, please see:
# https://github.com/browserslist/browserslist#queries
#
# For IE 9-11 support, please remove 'not' from the last line of the file and adjust as needed
> 0.5%
last 2 versions
Firefox ESR
not dead
not IE 9-11

View File

@ -0,0 +1,3 @@
export const environment = {
production: true
};

View File

@ -0,0 +1,16 @@
// This file can be replaced during build by using the `fileReplacements` array.
// `ng build --prod` replaces `environment.ts` with `environment.prod.ts`.
// The list of file replacements can be found in `angular.json`.
export const environment = {
production: false
};
/*
* For easier debugging in development mode, you can import the following file
* to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`.
*
* This import should be commented out in production mode because it will have a negative impact
* on performance if an error is thrown.
*/
// import 'zone.js/dist/zone-error'; // Included with Angular CLI.

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

View File

@ -0,0 +1,14 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>SztVisioApp</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body>
<app-root></app-root>
</body>
</html>

View File

@ -0,0 +1,31 @@
// Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('@angular-devkit/build-angular/plugins/karma')
],
client: {
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
coverageIstanbulReporter: {
dir: require('path').join(__dirname, '../coverage'),
reports: ['html', 'lcovonly'],
fixWebpackSourcePaths: true
},
reporters: ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false
});
};

13
szt-visio-app/src/main.ts Normal file
View File

@ -0,0 +1,13 @@
import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import 'hammerjs';
import { AppModule } from './app/app.module';
import { environment } from './environments/environment';
if (environment.production) {
enableProdMode();
}
platformBrowserDynamic().bootstrapModule(AppModule)
.catch(err => console.error(err));

View File

@ -0,0 +1,80 @@
/**
* This file includes polyfills needed by Angular and is loaded before the app.
* You can add your own extra polyfills to this file.
*
* This file is divided into 2 sections:
* 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers.
* 2. Application imports. Files imported after ZoneJS that should be loaded before your main
* file.
*
* The current setup is for so-called "evergreen" browsers; the last versions of browsers that
* automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera),
* Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile.
*
* Learn more in https://angular.io/guide/browser-support
*/
/***************************************************************************************************
* BROWSER POLYFILLS
*/
/** IE9, IE10 and IE11 requires all of the following polyfills. **/
// import 'core-js/es6/symbol';
// import 'core-js/es6/object';
// import 'core-js/es6/function';
// import 'core-js/es6/parse-int';
// import 'core-js/es6/parse-float';
// import 'core-js/es6/number';
// import 'core-js/es6/math';
// import 'core-js/es6/string';
// import 'core-js/es6/date';
// import 'core-js/es6/array';
// import 'core-js/es6/regexp';
// import 'core-js/es6/map';
// import 'core-js/es6/weak-map';
// import 'core-js/es6/set';
/**
* If the application will be indexed by Google Search, the following is required.
* Googlebot uses a renderer based on Chrome 41.
* https://developers.google.com/search/docs/guides/rendering
**/
// import 'core-js/es6/array';
/** IE10 and IE11 requires the following for NgClass support on SVG elements */
// import 'classlist.js'; // Run `npm install --save classlist.js`.
/** IE10 and IE11 requires the following for the Reflect API. */
// import 'core-js/es6/reflect';
/**
* Web Animations `@angular/platform-browser/animations`
* Only required if AnimationBuilder is used within the application and using IE/Edge or Safari.
* Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0).
**/
// import 'web-animations-js'; // Run `npm install --save web-animations-js`.
/**
* By default, zone.js will patch all possible macroTask and DomEvents
* user can disable parts of macroTask/DomEvents patch by setting following flags
*/
// (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame
// (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick
// (window as any).__zone_symbol__BLACK_LISTED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames
/*
* in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js
* with the following flag, it will bypass `zone.js` patch for IE/Edge
*/
// (window as any).__Zone_enable_cross_context_check = true;
/***************************************************************************************************
* Zone JS is required by default for Angular itself.
*/
import 'zone.js/dist/zone'; // Included with Angular CLI.
/***************************************************************************************************
* APPLICATION IMPORTS
*/

View File

@ -0,0 +1,2 @@
/* You can add global styles to this file, and also import other style files */
@import "~@angular/material/prebuilt-themes/indigo-pink.css";

20
szt-visio-app/src/test.ts Normal file
View File

@ -0,0 +1,20 @@
// This file is required by karma.conf.js and loads recursively all the .spec and framework files
import 'zone.js/dist/zone-testing';
import { getTestBed } from '@angular/core/testing';
import {
BrowserDynamicTestingModule,
platformBrowserDynamicTesting
} from '@angular/platform-browser-dynamic/testing';
declare const require: any;
// First, initialize the Angular testing environment.
getTestBed().initTestEnvironment(
BrowserDynamicTestingModule,
platformBrowserDynamicTesting()
);
// Then we find all the tests.
const context = require.context('./', true, /\.spec\.ts$/);
// And load the modules.
context.keys().map(context);

View File

@ -0,0 +1,11 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/app",
"types": []
},
"exclude": [
"test.ts",
"**/*.spec.ts"
]
}

View File

@ -0,0 +1,18 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/spec",
"types": [
"jasmine",
"node"
]
},
"files": [
"test.ts",
"polyfills.ts"
],
"include": [
"**/*.spec.ts",
"**/*.d.ts"
]
}

View File

@ -0,0 +1,17 @@
{
"extends": "../tslint.json",
"rules": {
"directive-selector": [
true,
"attribute",
"app",
"camelCase"
],
"component-selector": [
true,
"element",
"app",
"kebab-case"
]
}
}

View File

@ -0,0 +1,21 @@
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"module": "es2015",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2018",
"dom"
]
}
}

131
szt-visio-app/tslint.json Normal file
View File

@ -0,0 +1,131 @@
{
"rulesDirectory": [
"node_modules/codelyzer"
],
"rules": {
"arrow-return-shorthand": true,
"callable-types": true,
"class-name": true,
"comment-format": [
true,
"check-space"
],
"curly": true,
"deprecation": {
"severity": "warn"
},
"eofline": true,
"forin": true,
"import-blacklist": [
true,
"rxjs/Rx"
],
"import-spacing": true,
"indent": [
true,
"spaces"
],
"interface-over-type-literal": true,
"label-position": true,
"max-line-length": [
true,
140
],
"member-access": false,
"member-ordering": [
true,
{
"order": [
"static-field",
"instance-field",
"static-method",
"instance-method"
]
}
],
"no-arg": true,
"no-bitwise": true,
"no-console": [
true,
"debug",
"info",
"time",
"timeEnd",
"trace"
],
"no-construct": true,
"no-debugger": true,
"no-duplicate-super": true,
"no-empty": false,
"no-empty-interface": true,
"no-eval": true,
"no-inferrable-types": [
true,
"ignore-params"
],
"no-misused-new": true,
"no-non-null-assertion": true,
"no-redundant-jsdoc": true,
"no-shadowed-variable": true,
"no-string-literal": false,
"no-string-throw": true,
"no-switch-case-fall-through": true,
"no-trailing-whitespace": true,
"no-unnecessary-initializer": true,
"no-unused-expression": true,
"no-use-before-declare": true,
"no-var-keyword": true,
"object-literal-sort-keys": false,
"one-line": [
true,
"check-open-brace",
"check-catch",
"check-else",
"check-whitespace"
],
"prefer-const": true,
"quotemark": [
true,
"single"
],
"radix": true,
"semicolon": [
true,
"always"
],
"triple-equals": [
true,
"allow-null-check"
],
"typedef-whitespace": [
true,
{
"call-signature": "nospace",
"index-signature": "nospace",
"parameter": "nospace",
"property-declaration": "nospace",
"variable-declaration": "nospace"
}
],
"unified-signatures": true,
"variable-name": false,
"whitespace": [
true,
"check-branch",
"check-decl",
"check-operator",
"check-separator",
"check-type"
],
"no-output-on-prefix": true,
"use-input-property-decorator": true,
"use-output-property-decorator": true,
"use-host-property-decorator": true,
"no-input-rename": true,
"no-output-rename": true,
"use-life-cycle-interface": true,
"use-pipe-transform-interface": true,
"component-class-suffix": true,
"directive-class-suffix": true
}
}

BIN
szt_visio.exe Normal file

Binary file not shown.

View File

@ -5,6 +5,38 @@ import (
"net/http"
)
type repositorySummary struct {
firstname string
lastname string
}
type repositories struct {
Repositories []repositorySummary
}
func Index(w http.ResponseWriter, r *http.Request) {
fmt.Fprint(w, "Welcome!\n")
}
fmt.Fprintf(w, "Welcome!")
}
//
//func queryRepos(repos *repositories) error {
// rows, err := dbCdb.Query(`SELECT * FROM friends.test`)
// if err != nil {
// return err
// }
// defer rows.Close()
// for rows.Next() {
// repo := repositorySummary{}
// err = rows.Scan(
// &repo.firstname,
// &repo.lastname,)
// if err != nil {
// return err
// }
// repos.Repositories = append(repos.Repositories, repo)
// }
// err = rows.Err()
// if err != nil {
// return err
// }
// return nil
//}