Browse Source

bunch of fixes

Антон Викторович Боровик 5 years ago
parent
commit
7ee59c9a1e

+ 1 - 1
.env

@@ -1 +1 @@
-WEB_PORT=8083
+WEB_PORT=80

+ 3 - 0
.gitignore

@@ -3,6 +3,9 @@
 *.o
 *.o
 *.a
 *.a
 *.so
 *.so
+*.log
+*.xlsx
+*.xls
 
 
 # Folders
 # Folders
 _obj
 _obj

+ 8 - 0
.idea/ScheduleAPI.iml

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="WEB_MODULE" version="4">
+  <component name="NewModuleRootManager">
+    <content url="file://$MODULE_DIR$" />
+    <orderEntry type="inheritedJdk" />
+    <orderEntry type="sourceFolder" forTests="false" />
+  </component>
+</module>

+ 6 - 0
.idea/misc.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="JavaScriptSettings">
+    <option name="languageLevel" value="ES6" />
+  </component>
+</project>

+ 8 - 0
.idea/modules.xml

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="ProjectModuleManager">
+    <modules>
+      <module fileurl="file://$PROJECT_DIR$/.idea/ScheduleAPI.iml" filepath="$PROJECT_DIR$/.idea/ScheduleAPI.iml" />
+    </modules>
+  </component>
+</project>

+ 6 - 0
.idea/vcs.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="VcsDirectoryMappings">
+    <mapping directory="$PROJECT_DIR$/ScheduleGenerator" vcs="Git" />
+  </component>
+</project>

+ 11 - 3
.idea/workspace.xml

@@ -2,7 +2,16 @@
 <project version="4">
 <project version="4">
   <component name="ChangeListManager">
   <component name="ChangeListManager">
     <list default="true" id="b8a967e5-9651-44eb-87a6-16760f979b45" name="Default Changelist" comment="">
     <list default="true" id="b8a967e5-9651-44eb-87a6-16760f979b45" name="Default Changelist" comment="">
-      <change beforePath="$PROJECT_DIR$/html/api.html" beforeDir="false" afterPath="$PROJECT_DIR$/html/api.html" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/ScheduleGenerator/LICENSE" beforeDir="false" afterPath="$PROJECT_DIR$/ScheduleGenerator/LICENSE" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/ScheduleGenerator/README.md" beforeDir="false" afterPath="$PROJECT_DIR$/ScheduleGenerator/README.md" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/ScheduleGenerator/input/groups.json" beforeDir="false" afterPath="$PROJECT_DIR$/ScheduleGenerator/input/groups.json" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/ScheduleGenerator/input/teachers.json" beforeDir="false" afterPath="$PROJECT_DIR$/ScheduleGenerator/input/teachers.json" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/ScheduleGenerator/main.go" beforeDir="false" afterPath="$PROJECT_DIR$/ScheduleGenerator/main.go" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/ScheduleGenerator/output/schedule.xlsx" beforeDir="false" afterPath="$PROJECT_DIR$/ScheduleGenerator/output/schedule.xlsx" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/ScheduleGenerator/schedule/generator.go" beforeDir="false" afterPath="$PROJECT_DIR$/ScheduleGenerator/schedule/generator.go" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/ScheduleGenerator/schedule/localdata.go" beforeDir="false" afterPath="$PROJECT_DIR$/ScheduleGenerator/schedule/localdata.go" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/ScheduleGenerator/schedule/models.go" beforeDir="false" afterPath="$PROJECT_DIR$/ScheduleGenerator/schedule/models.go" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/ScheduleGenerator/schedule/settings.go" beforeDir="false" afterPath="$PROJECT_DIR$/ScheduleGenerator/schedule/settings.go" afterDir="false" />
     </list>
     </list>
     <option name="SHOW_DIALOG" value="false" />
     <option name="SHOW_DIALOG" value="false" />
     <option name="HIGHLIGHT_CONFLICTS" value="true" />
     <option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -18,13 +27,12 @@
   </component>
   </component>
   <component name="GOROOT" path="/usr/lib/go-1.12" />
   <component name="GOROOT" path="/usr/lib/go-1.12" />
   <component name="Git.Settings">
   <component name="Git.Settings">
-    <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
+    <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/ScheduleGenerator" />
   </component>
   </component>
   <component name="GoLibraries">
   <component name="GoLibraries">
     <option name="indexEntireGoPath" value="false" />
     <option name="indexEntireGoPath" value="false" />
   </component>
   </component>
   <component name="ProjectId" id="1YHJ2vSULrwvl6h5lxSsZ9HGGXG" />
   <component name="ProjectId" id="1YHJ2vSULrwvl6h5lxSsZ9HGGXG" />
-  <component name="ProjectLevelVcsManager" settingsEditedManually="true" />
   <component name="ProjectViewState">
   <component name="ProjectViewState">
     <option name="hideEmptyMiddlePackages" value="true" />
     <option name="hideEmptyMiddlePackages" value="true" />
     <option name="showExcludedFiles" value="true" />
     <option name="showExcludedFiles" value="true" />

+ 1 - 4
Dockerfile

@@ -1,10 +1,7 @@
 FROM golang:latest 
 FROM golang:latest 
-RUN go get github.com/jinzhu/gorm
-RUN go get github.com/go-sql-driver/mysql
-RUN go get github.com/tealeg/xlsx
 RUN rm /app -rf
 RUN rm /app -rf
 RUN mkdir /app 
 RUN mkdir /app 
 ADD . /app/ 
 ADD . /app/ 
 WORKDIR /app 
 WORKDIR /app 
-CMD ["/app/main"]
+CMD ["/app/main", "8888"]
 
 

+ 6 - 29
Jenkins/jenkinsfile

@@ -1,29 +1,7 @@
 #!groovy
 #!groovy
-def GetLog(build_url) {
-    withCredentials([string(credentialsId: 'JenkinsAPI', variable: 'token')]){
-		def creds = 'admin:' + token
-		def auth = creds.bytes.encodeBase64().toString()
-
-    	responce = httpRequest(httpMode: 'GET',
-		url: build_url + 'consoleText',
-		customHeaders:[[name:'Authorization', value:"Basic ${auth}"]],
-		contentType: 'TEXT_PLAIN')
-		def test = responce.status
-
-	}
-	return test
+node {
+	checkout scm
 }
 }
-
-def sendMessage(message){
-	def encode = URLEncoder.encode(message,"UTF-8")
-	withCredentials([string(credentialsId: 'TGBot', variable: 'SECRET')]) {
-	responce = httpRequest(contentType: 'APPLICATION_JSON',
-		httpMode: 'GET',
-		url: "https://api.telegram.org/bot$SECRET/sendMessage?text=$encode&chat_id=-1001282104904&disable_web_page_preview=true")
-		
-	}
-}
-
 pipeline {
 pipeline {
     agent {
     agent {
        label 'master'
        label 'master'
@@ -32,20 +10,20 @@ pipeline {
     stages {
     stages {
       stage("build project") {
       stage("build project") {
         steps {
         steps {
-          echo 'go build main.go webPage.go'
+          sh 'go build main.go webPage.go'
         }
         }
       }
       }
       stage("deploy docker") {
       stage("deploy docker") {
         steps{
         steps{
-          echo 'docker-compose stop schedule'
-          echo 'docker-compose up --build -d'
+          sh 'docker-compose stop schedule'
+          sh 'docker-compose up --build -d'
         }
         }
       } 
       } 
     }
     }
     post {
     post {
       success {
       success {
         echo 'I succeeeded!'
         echo 'I succeeeded!'
-        echo GetLog("${BUILD_URL}")
+        
 
 
       }
       }
       unstable {
       unstable {
@@ -53,7 +31,6 @@ pipeline {
       }
       }
       failure {
       failure {
         echo 'I failed :((('
         echo 'I failed :((('
-        echo GetLog("${BUILD_URL}")
       }
       }
       changed {
       changed {
         echo 'things were different before...'
         echo 'things were different before...'

+ 60 - 21
api/authorization.go

@@ -1,26 +1,65 @@
 package api
 package api
 
 
-// import(
-// 	"github.com/jtblin/go-ldap-client"
-// )
+import(
+	"gopkg.in/korylprince/go-ad-auth.v2"
+	"net/http"
+	"encoding/json"
+)
 
 
-// func GetUser(login string, password string) bool{
+type User struct{
+	Login string `json:"login"`
+	Password string `json:"password"`
+}
 
 
-// 	ok, user, err := clientLDAP.Authenticate(login, password)
-// 	if err != nil {
-// 		printError(err)
-// 		return false
-// 	}
-// 	if !ok {
-// 		return false
-// 	}
-// 	return true
-// }
+/*func (u User) SetCookie(w http.ResponseWriter, r *http.Request){
+	cookie := http.Cookie{
+		Name: u.Login,
+		Value: "logged in",
+		Domain: r.Host,
+		Path: "/",
+		MaxAge: 60*60,
+		HttpOnly: true,
+	}
+	http.SetCookie(rw, &cookie)
+}*/
 
 
-// func GetGroupOfUser(login string) []string{
-// 	groups, err := client.GetGroupsOfUser(login)
-// 	if err != nil {
-// 		printError(err)
-// 	}
-// 	return groups
-// }
+func LoginRoute(w http.ResponseWriter, r *http.Request){
+	showAPIRequest(r)
+	var userGroups []string
+	Groups := []string{"Студенты", "Персонал", "Бухгалтерия", "Преподаватели", "Админы"}
+	if r.Method == "POST"{
+		config := &auth.Config{
+		Server:   "192.168.10.121",
+        Port:     389,
+        BaseDN:   "DC=ttit,DC=local",
+        Security: auth.SecurityNone,
+		}
+
+		var user User
+		error := json.NewDecoder(r.Body).Decode(&user)
+		if error != nil{
+			json.NewEncoder(w).Encode(struct{ Error string }{Error: "an error has occured during decoding"})
+			showError(r, error)
+			return
+		}
+		status, /*entry*/_, groups, err := auth.AuthenticateExtended(config, user.Login, user.Password, []string{"cn"}, Groups)
+		if err != nil {
+	   	 	json.NewEncoder(w).Encode(struct{ Error string }{Error: "an error has occured"})
+	   	 	showError(r, err)
+	   	 	return
+		} else if !status {
+    		json.NewEncoder(w).Encode(struct{ Error string }{Error: "no user found"})
+    		return
+		} 
+		for _, group := range groups{
+			for _, constGroup := range Groups{
+				if group == constGroup{
+					userGroups = append(userGroups, group)
+				}
+			}
+		}
+		//user.SetCookie(w, r)
+		json.NewEncoder(w).Encode(userGroups)
+		return
+	}
+}

+ 23 - 5
api/models.go

@@ -1,9 +1,5 @@
 package api
 package api
 
 
-
-
-
-
 type Professionalmodule struct {
 type Professionalmodule struct {
 	ID        uint
 	ID        uint
 	Name      string
 	Name      string
@@ -54,6 +50,8 @@ type Group struct {
 	IDTeacher   uint
 	IDTeacher   uint
 	Groupnumber string 
 	Groupnumber string 
 	Studentsquantity uint
 	Studentsquantity uint
+	Isbudget bool
+	IDPlan uint
 }
 }
 
 
 type Semester struct {
 type Semester struct {
@@ -61,6 +59,12 @@ type Semester struct {
 	Weeksquantity uint
 	Weeksquantity uint
 }
 }
 
 
+
+type Exampleprogram struct {
+	ID            uint
+	IDSpecialty   uint
+}
+
 type Teacher struct {
 type Teacher struct {
 	ID          uint
 	ID          uint
 	Name        string
 	Name        string
@@ -123,7 +127,7 @@ type Subjectofplan struct {
 	IDPlan		  uint
 	IDPlan		  uint
 	IDSubject	  uint
 	IDSubject	  uint
 	Hoursquantitytotal uint
 	Hoursquantitytotal uint
-	idepentwork	  uint
+	independentwork	  uint
 	consulthours  uint
 	consulthours  uint
 }
 }
 
 
@@ -131,4 +135,18 @@ type Subjectofplan struct {
 type Studyplan struct {
 type Studyplan struct {
 	ID            uint
 	ID            uint
 	IDSpecialty   uint
 	IDSpecialty   uint
+	IDGroup       uint
+	Isarchive 	  bool
+}
+
+
+type Subjectofexample struct {
+	ID            uint
+	IDSubject     uint
+	IDExampleprogram     uint
+	Totalhours uint
+	Prefferedcourse string
+	Labhours uint
+	Practicehours uint
+
 }
 }

+ 8 - 8
api/scheduletemplate.go

@@ -88,18 +88,18 @@ func GetDataGroups(w http.ResponseWriter, r *http.Request){
 			tmpsubject.Teacher2 = tmpsubject.Teacher // TODO
 			tmpsubject.Teacher2 = tmpsubject.Teacher // TODO
 			if tsubject.IDStype == 1{
 			if tsubject.IDStype == 1{
 				tmpsubject.IsComputer = false
 				tmpsubject.IsComputer = false
-				tmpsubject.Theory = 0
-				tmpsubject.Practice.A = subject.Hoursquantity/2
-				tmpsubject.Practice.B = subject.Hoursquantity/2
+				// tmpsubject.Theory = 0
+				// tmpsubject.Practice.A = subject.Hoursquantity/2
+				// tmpsubject.Practice.B = subject.Hoursquantity/2
 			} else if tsubject.IDStype == 0{
 			} else if tsubject.IDStype == 0{
 				tmpsubject.IsComputer = true
 				tmpsubject.IsComputer = true
-				tmpsubject.Theory = subject.Hoursquantity/2
-				tmpsubject.Practice.A = 0
-				tmpsubject.Practice.B = 0
+				// tmpsubject.Theory = subject.Hoursquantity/2
+				// tmpsubject.Practice.A = 0
+				// tmpsubject.Practice.B = 0
 			}
 			}
 			fmt.Println(semester)
 			fmt.Println(semester)
-			tmpsubject.WeekLessons.A = (subject.Hoursquantity/semester.Weeksquantity)/2
-			tmpsubject.WeekLessons.B = (subject.Hoursquantity/semester.Weeksquantity)/2
+			// tmpsubject.WeekLessons.A = (subject.Hoursquantity/semester.Weeksquantity)/2
+			// tmpsubject.WeekLessons.B = (subject.Hoursquantity/semester.Weeksquantity)/2
 			tmpsubjects = append(tmpsubjects, tmpsubject)
 			tmpsubjects = append(tmpsubjects, tmpsubject)
 		}
 		}
 	}
 	}

+ 65 - 0
api/studyPlanImport.go

@@ -0,0 +1,65 @@
+package api
+
+import(
+	"net/http"
+	"encoding/json"
+	"os"
+	"mime/multipart"
+	"crypto/rand"
+	xls "../schedule"
+)
+
+func ImportPlanRoute(w http.ResponseWriter, r *http.Request){
+	input, _, err := r.FormFile("uploadfile")
+	if err != nil {
+		json.NewEncoder(w).Encode(struct{Error string}{Error: "Error read upload file"})
+		return
+	}
+	tempname := readFile(input)
+	result := xls.ImportXLSX(tempname)
+	json.NewEncoder(w).Encode(result)
+}
+
+func readFile(input multipart.File) string {
+	var (
+		size   = uint64(0)
+		buffer = make([]byte, 2 << 20) // 1MiB
+	)
+
+	tempname := GenerateRandomString(16) + ".xlsx"
+
+	output, err := os.OpenFile(
+		tempname,
+		os.O_WRONLY|os.O_CREATE,
+		0666,
+	)
+	if err != nil {
+		printError(err)
+		return "error"
+	}
+
+	for {
+		length, err := input.Read(buffer)
+		if err != nil {
+			printError(err)
+			break
+		}
+		size += uint64(length)
+		output.Write(buffer[:length])
+	}
+
+	input.Close()
+	output.Close()
+	return tempname
+}
+
+func GenerateRandomString(max int) string {
+    var slice []byte = make([]byte, max)
+    _, err := rand.Read(slice)
+    if err != nil {
+    	printError(err)
+        return ""
+    }
+
+    return string(slice)
+}

+ 3 - 3
go.mod

@@ -3,8 +3,8 @@ module github.com/Fistim/Schedule
 go 1.14
 go 1.14
 
 
 require (
 require (
-	github.com/jinzhu/gorm
-	github.com/jtblin/go-ldap-client
-	github.com/tealeg/xlsx
+	github.com/jinzhu/gorm v1.9.12
+	github.com/jtblin/go-ldap-client 0.0.3
+	github.com/tealeg/xlsx v2.0.0
 	github.com/jinzhu/gorm/dialects/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs=
 	github.com/jinzhu/gorm/dialects/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs=
 )
 )

+ 0 - 10
go.modWIP

@@ -1,10 +0,0 @@
-module github.com/Fistim/Schedule
-
-go 1.14
-
-require (
-	github.com/jinzhu/gorm
-	github.com/jtblin/go-ldap-client
-	github.com/tealeg/xlsx
-	github.com/jinzhu/gorm/dialects/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs=
-)

+ 29 - 0
go.sum

@@ -0,0 +1,29 @@
+github.com/denisenkom/go-mssqldb v0.0.0-20191124224453-732737034ffd/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU=
+github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5/go.mod h1:a2zkGnVExMxdzMo3M0Hi/3sEU+cWnZpSni0O6/Yb/P0=
+github.com/go-sql-driver/mysql v1.4.1 h1:g24URVg0OFbNUTx9qqY1IRZ9D9z3iPyi5zKhQZpNwpA=
+github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
+github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0=
+github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
+github.com/jinzhu/gorm v1.9.12 h1:Drgk1clyWT9t9ERbzHza6Mj/8FY/CqMyVzOiHviMo6Q=
+github.com/jinzhu/gorm v1.9.12/go.mod h1:vhTjlKSJUTWNtcbQtrMBFCxy7eXTzeCAzfL5fBZT/Qs=
+github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
+github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
+github.com/jinzhu/now v1.0.1/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
+github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
+github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
+github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
+github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
+github.com/mattn/go-sqlite3 v2.0.1+incompatible/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
+github.com/tealeg/xlsx v1.0.5 h1:+f8oFmvY8Gw1iUXzPk+kz+4GpbDZPK1FhPiQRd+ypgE=
+github.com/tealeg/xlsx v1.0.5/go.mod h1:btRS8dz54TDnvKNosuAqxrM1QgN1udgk9O34bDCnORM=
+golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
+golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
+golang.org/x/crypto v0.0.0-20191205180655-e7c4368fe9dd/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
+golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
+golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
+google.golang.org/appengine v1.4.0 h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO508=
+google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
+gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=

+ 8 - 0
go1.mod

@@ -0,0 +1,8 @@
+module web
+
+go 1.14
+
+require (
+	github.com/jinzhu/gorm v1.9.12 // indirect
+	github.com/tealeg/xlsx v1.0.5 // indirect
+)

+ 29 - 34
html/group.html

@@ -57,15 +57,6 @@
                                         </div>
                                         </div>
                                     </div>
                                     </div>
                                 </div>
                                 </div>
-                                <div class="col-md-4 col-ms-4 grid-element filter-business">
-                                    <div class="tile-basic">
-                                        <a href="#" class="preview-delete" data-preview-size="modal-lg">
-                                            <div class="tile-content tile-content-condensed-bottom text-center">
-                                                <button type="button" class="btn btn-danger btn-lg">Удалить</button>
-                                            </div>
-                                        </a>
-                                    </div>
-                                </div>
                                 <div class="block-content">
                                 <div class="block-content">
                             <table class="table table-striped table-bordered">
                             <table class="table table-striped table-bordered">
                                 <h1>Группы</h1>
                                 <h1>Группы</h1>
@@ -105,39 +96,43 @@
                                 <div class="modal-content">
                                 <div class="modal-content">
                                     <div class="block">
                                     <div class="block">
                                         <div class="row">
                                         <div class="row">
-                                    <div class="col-md-12">
-                                        <label>Номер группы</label>
-                                        <div class="input-group">
+                                    <div class="form-group">
+                                        <label class="col-md-3 control-label">Номер группы</label>
+                                        <div class="col-md-9">
                                             <input type="text" class="form-control" placeholder="362">
                                             <input type="text" class="form-control" placeholder="362">
                                         </div>
                                         </div>
                                     </div>
                                     </div>
-                                    <div class="col-md-12">
-                                        <label>Специальность</label>
-                                        <select class="bs-select">
-                                            <option>00.00.00 Программирование</option>
-                                            <option>11.11.11 Администрирование</option>
-                                            <option>22.22.22 Монтажники</option>
-                                            <option>33.33.33 Пример</option>
-                                            <option>44.44.44 Пример</option>
-                                        </select>
+                                    <div class="form-group">
+                                        <label class="col-md-3 control-label">Специальность</label>
+                                        <div class="col-md-9">
+	                                        <select class="">
+	                                            <option>00.00.00 Программирование</option>
+	                                            <option>11.11.11 Администрирование</option>
+	                                            <option>22.22.22 Монтажники</option>
+	                                            <option>33.33.33 Пример</option>
+	                                            <option>44.44.44 Пример</option>
+	                                        </select>
+	                                    </div>
                                     </div>
                                     </div>
-                                    <div class="col-md-12">
-                                        <label>Куратор</label>
-                                        <select>
-                                            <option v-for="t in teachers" v-bind:value="t.Surname">${t.Surname}</option>
-                                        </select>
+                                    <div class="form-group">
+                                        <label class="col-md-3 control-label">Куратор</label>
+                                        <div class="col-md-9">
+                                        	<select>
+                                            	<option v-for="t in teachers" v-bind:value="t.Surname">${t.Surname}</option>
+                                        	</select>
+                                        </div>
                                     </div>
                                     </div>
-                                    <div class="col-md-12">
-                                        <label class="col-md-3">Год приема</label>
-                                        <div class="input-group col-md-9">
+                                    <div class="form-group">
+                                        <label class="col-md-3 control-label">Год приема</label>
+                                        <div class="col-md-9">
                                             <input type="text" class="form-control" placeholder="2020">
                                             <input type="text" class="form-control" placeholder="2020">
                                         </div>
                                         </div>
                                     </div>
                                     </div>
-                                    <div class="col-md-12">
-                                        <label>Год выпуска</label>
-                                        <div class="input-group">
-                                            <input type="text" class="form-control" placeholder="2024">
-                                        </div>
+                                    <div class="form-group">
+                                        <label class="col-md-3 control-label">Год выпуска</label>
+                                        <div class="col-md-9">
+											<input type="text" class="form-control" placeholder="2024">
+	                                    </div>
                                     </div>
                                     </div>
                                         <div class="col-md-12">
                                         <div class="col-md-12">
                                             <br>
                                             <br>

+ 0 - 3
html/groupcard.html

@@ -52,9 +52,6 @@
                                             <button type="button" class="btn btn-success btn-lg" data-toggle="modal" data-target="#modal-default">Добавить</button>
                                             <button type="button" class="btn btn-success btn-lg" data-toggle="modal" data-target="#modal-default">Добавить</button>
                                         </div>
                                         </div>
                                         <div class="col-md-3">
                                         <div class="col-md-3">
-                                            <button type="button" class="btn btn-danger btn-lg">Удалить</button>
-                                        </div>
-                                        <div class="col-md-3">
                                             <button type="button" class="btn btn-warning btn-lg">Редактировать</button>
                                             <button type="button" class="btn btn-warning btn-lg">Редактировать</button>
                                         </div>
                                         </div>
                                         <div class="col-md-3">
                                         <div class="col-md-3">

File diff suppressed because it is too large
+ 44 - 79
html/index.html


+ 5 - 5
html/login.html

@@ -16,7 +16,7 @@
                         <div class="title">Авторизуйтесь</div>               
                         <div class="title">Авторизуйтесь</div>               
                     </div>
                     </div>
                     <div class="app-login-box-container">
                     <div class="app-login-box-container">
-                        <form action="index.html" method="post">
+                        <form method="post">
                             <div class="form-group">
                             <div class="form-group">
                                 <input type="text" class="form-control" name="login" placeholder="Логин">
                                 <input type="text" class="form-control" name="login" placeholder="Логин">
                             </div>
                             </div>
@@ -32,15 +32,15 @@
                                         </div>
                                         </div>
                                     </div>
                                     </div>
                                     <div class="col-md-6 col-xs-6">
                                     <div class="col-md-6 col-xs-6">
-                                        <input type="submit" name="" class="btn btn-success btn-block">Войти</div>>
+                                        <button class="btn btn-success btn-block">Войти</button></div>
                                     </div>
                                     </div>
                                 </div>
                                 </div>
                                 
                                 
                             </div>
                             </div>
                         </form>
                         </form>
-                    </div>
-                    <div class="app-login-box-footer">
-                        &copy; Томский Техникум Информационных Технологий 2020
+                        <div class="app-login-box-footer">
+                            &copy; Томский Техникум Информационных Технологий 2021
+                        </div>
                     </div>
                     </div>
                 </div>
                 </div>
                                 
                                 

+ 7 - 15
html/specialty.html

@@ -51,15 +51,7 @@
                                 </div>
                                 </div>
                             </div>
                             </div>
                         </div>
                         </div>
-                        <div class="col-md-4 col-ms-4 grid-element filter-business">
-                            <div class="tile-basic">
-                                <a href="#" class="preview-delete" data-preview-size="modal-lg">
-                                    <div class="tile-content tile-content-condensed-bottom text-center">
-                                        <button type="button" class="btn btn-danger btn-lg">Удалить</button>
-                                    </div>
-                                </a>
-                            </div>
-                        </div>
+                        
                         <!-- модальные окна -->
                         <!-- модальные окна -->
                         <div class="modal fade" id="preview-delete" tabindex="1" role="dialog">
                         <div class="modal fade" id="preview-delete" tabindex="1" role="dialog">
                             <div class="modal-dialog">
                             <div class="modal-dialog">
@@ -75,15 +67,15 @@
                                 <div class="modal-content">
                                 <div class="modal-content">
                                     <div class="block">
                                     <div class="block">
                                         <h1>Специальности</h1>
                                         <h1>Специальности</h1>
-                                        <div class="col-md-12">
-                                            <label>Код специальности</label>
-                                            <div class="input-group">
+                                        <div class="form-group">
+                                            <label class="col-md-3 control-label">Код специальности</label>
+                                            <div class="col-ms-9">
                                                 <input type="text" class="form-control code" placeholder="09.02.04">
                                                 <input type="text" class="form-control code" placeholder="09.02.04">
                                             </div>
                                             </div>
                                         </div>
                                         </div>
-                                        <div class="col-md-12">
-                                            <label>Название специальности</label>
-                                            <div class="input-group">
+                                        <div class="form-group">
+                                            <label class="col-md-3 control-label">Название специальности</label>
+                                            <div class="col-ms-9">
                                                 <input type="text" class="form-control name" placeholder="Программирование в компьютерных системах">
                                                 <input type="text" class="form-control name" placeholder="Программирование в компьютерных системах">
                                                 <div class="app-radio">
                                                 <div class="app-radio">
                                                     <label><input type="radio" name="app-radio-1" class="duration-radio" value="1"> 2 года 10 месяцев</label>
                                                     <label><input type="radio" name="app-radio-1" class="duration-radio" value="1"> 2 года 10 месяцев</label>

+ 1 - 3
html/teacher.html

@@ -87,9 +87,7 @@
                                             <h4 class="modal-title" id="modal-default-header">Добавление кабинета</h4>    
                                             <h4 class="modal-title" id="modal-default-header">Добавление кабинета</h4>    
                                         </div>
                                         </div>
                                         <div class="form-group">
                                         <div class="form-group">
-                                            <div class="col-md-3">
-                                                <label>Фамилия</label>
-                                            </div>
+                                            <label class="control-label col-md-3">Фамилия</label>
                                             <div class="col-md-9">
                                             <div class="col-md-9">
                                                 <input type="text" class="form-control surname">
                                                 <input type="text" class="form-control surname">
                                             </div>
                                             </div>

BIN
main


+ 8 - 5
main.go

@@ -103,11 +103,14 @@ func main() {
 	http.HandleFunc("/wekan", wekanRedirect)
 	http.HandleFunc("/wekan", wekanRedirect)
 	http.HandleFunc("/test/", testPage) // testing token
 	http.HandleFunc("/test/", testPage) // testing token
 	// HTTP pages handling end
 	// HTTP pages handling end
-	port := os.Args[1]
-	api.PrintConsole("Server is listening")
-	fmt.Println(port)
-
-	http.ListenAndServe(":" + port, nil)
+	api.PrintConsole("Server is starting...")
+	err = nil
+	err = http.ListenAndServe(":" + os.Args[1], nil)
+	if err!=nil{
+		t := time.Now()
+		s := "[" + t.Format(settings.TimeLayout) + "] " + "Error:" + err.Error()
+		fmt.Println(s)
+	}
 }
 }
 
 
 func wekanRedirect(w http.ResponseWriter, r *http.Request){
 func wekanRedirect(w http.ResponseWriter, r *http.Request){

+ 26 - 183
schedule/generator.go

@@ -2,9 +2,7 @@ package schedule
 
 
 import (
 import (
     "fmt"
     "fmt"
-    "strconv"
     "encoding/json"
     "encoding/json"
-    "github.com/tealeg/xlsx"
 )
 )
 
 
 func NewGenerator(data *Generator) *Generator {
 func NewGenerator(data *Generator) *Generator {
@@ -13,7 +11,8 @@ func NewGenerator(data *Generator) *Generator {
         Debug: data.Debug,
         Debug: data.Debug,
         Groups: data.Groups,
         Groups: data.Groups,
         Teachers: data.Teachers,
         Teachers: data.Teachers,
-        Blocked: make(map[string]bool),
+        Cabinets: data.Cabinets,
+        // Blocked: make(map[string]bool),
         Reserved: Reserved{
         Reserved: Reserved{
             Teachers: make(map[string][]bool),
             Teachers: make(map[string][]bool),
             Cabinets: make(map[string][]bool),
             Cabinets: make(map[string][]bool),
@@ -55,14 +54,16 @@ func ReadGroups(filename string) map[string]*Group {
                 Teacher: sb.Teacher,
                 Teacher: sb.Teacher,
                 IsComputer: sb.IsComputer,
                 IsComputer: sb.IsComputer,
                 SaveWeek: sb.Lessons.Week,
                 SaveWeek: sb.Lessons.Week,
-                Theory: sb.Lessons.Theory,
-                Practice: Subgroup{
-                    A: sb.Lessons.Practice,
-                    B: sb.Lessons.Practice,
-                },
-                WeekLessons: Subgroup{
-                    A: sb.Lessons.Week,
-                    B: sb.Lessons.Week,
+                Lessons: Lessons{
+                    Theory: sb.Lessons.Theory,
+                    Practice: Subgroup{
+                        A: sb.Lessons.Practice,
+                        B: sb.Lessons.Practice,
+                    },
+                    Week: Subgroup{
+                        A: sb.Lessons.Week,
+                        B: sb.Lessons.Week,
+                    },
                 },
                 },
             }
             }
         }
         }
@@ -89,32 +90,23 @@ func ReadTeachers(filename string) map[string]*Teacher {
     return teachers
     return teachers
 }
 }
 
 
-const (
-    OUTDATA = "output/"
-)
-func (gen *Generator) Template() [][]*Schedule {
+func ReadCabinets(filename string) map[string]*Cabinet {
     var (
     var (
-        weekLessons = make([][]*Schedule, 7)
-        generator = new(Generator)
-        file *xlsx.File
-        name string
+        cabinets = make(map[string]*Cabinet)
+        cabinetsList []Cabinet
     )
     )
-    unpackJSON(packJSON(gen), generator)
-    if gen.Debug {
-        file, name = CreateXLSX(OUTDATA + "template.xlsx")
+    data := readFile(filename)
+    err := json.Unmarshal([]byte(data), &cabinetsList)
+    if err != nil {
+        return nil
     }
     }
-    for i := generator.Day; i < generator.Day+7; i++ {
-        weekLessons[i % 7] = generator.Generate(nil)
-        if gen.Debug {
-            generator.WriteXLSX(
-                file,
-                name,
-                weekLessons[i],
-                int(i),
-            )
+    for _, cb := range cabinetsList {
+        cabinets[cb.Name] = &Cabinet{
+            Name: cb.Name,
+            IsComputer: cb.IsComputer,
         }
         }
     }
     }
-    return weekLessons
+    return cabinets
 }
 }
 
 
 func (gen *Generator) Generate(template [][]*Schedule) []*Schedule {
 func (gen *Generator) Generate(template [][]*Schedule) []*Schedule {
@@ -138,8 +130,8 @@ func (gen *Generator) Generate(template [][]*Schedule) []*Schedule {
             list = append(list, schedule)
             list = append(list, schedule)
             for _, subject := range subjects {
             for _, subject := range subjects {
                 saved := gen.Groups[group.Name].Subjects[subject.Name].SaveWeek
                 saved := gen.Groups[group.Name].Subjects[subject.Name].SaveWeek
-                gen.Groups[group.Name].Subjects[subject.Name].WeekLessons.A = saved
-                gen.Groups[group.Name].Subjects[subject.Name].WeekLessons.B = saved
+                gen.Groups[group.Name].Subjects[subject.Name].Lessons.Week.A = saved
+                gen.Groups[group.Name].Subjects[subject.Name].Lessons.Week.B = saved
             }
             }
             continue
             continue
         }
         }
@@ -185,155 +177,6 @@ func (gen *Generator) Generate(template [][]*Schedule) []*Schedule {
     return sortSchedule(list)
     return sortSchedule(list)
 }
 }
 
 
-func CreateXLSX(filename string) (*xlsx.File, string) {
-    file := xlsx.NewFile()
-    _, err := file.AddSheet("Init")
-    if err != nil {
-        return nil, ""
-    }
-    err = file.Save(filename)
-    if err != nil {
-        return nil, ""
-    }
-    return file, filename
-}
-
-func (gen *Generator) WriteXLSX(file *xlsx.File, filename string, schedule []*Schedule, iter int) error {
-    const (
-        colWidth = 30
-        rowHeight = 30
-    )
-
-    var (
-        MAXCOL = uint(3)
-    )
-
-    rowsNext := uint(len(schedule)) / MAXCOL
-    if rowsNext == 0 || uint(len(schedule)) % MAXCOL != 0 {
-        rowsNext += 1
-    }
-
-    var (
-        
-        colNum = uint(NUM_TABLES + 2)
-        
-        row = make([]*xlsx.Row, colNum * rowsNext) //  * (rowsNext + 1)
-        cell *xlsx.Cell
-        dayN = gen.Day
-        day = ""
-    )
-
-    if dayN == SUNDAY {
-        dayN = SATURDAY
-    } else {
-        dayN -= 1
-    }
-
-    switch dayN {
-    case SUNDAY: day = "Sunday"
-    case MONDAY: day = "Monday"
-    case TUESDAY: day = "Tuesday"
-    case WEDNESDAY: day = "Wednesday"
-    case THURSDAY: day = "Thursday"
-    case FRIDAY: day = "Friday"
-    case SATURDAY: day = "Saturday"
-    }
-
-    sheet, err := file.AddSheet(day + "-" + strconv.Itoa(iter))
-    if err != nil {
-        return err
-    }
-
-    sheet.SetColWidth(2, int(MAXCOL)*3+1, COL_W)
-
-    for r := uint(0); r < rowsNext; r++ {
-        for i := uint(0); i < colNum; i++ {
-            row[(r*colNum)+i] = sheet.AddRow() // (r*rowsNext)+
-            row[(r*colNum)+i].SetHeight(ROW_H)
-            cell = row[(r*colNum)+i].AddCell()
-            if i == 0 {
-                cell.Value = "Пара"
-                continue
-            }
-            cell.Value = strconv.Itoa(int(i-1))
-        }
-    }
-
-    index := uint(0)
-    exit: for r := uint(0); r < rowsNext; r++ {
-        for i := uint(0); i < MAXCOL; i++ {
-            if uint(len(schedule)) <= index {
-                break exit
-            }
-
-            savedCell := row[(r*colNum)+0].AddCell()
-            savedCell.Value = "Группа " + schedule[index].Group
-
-            cell = row[(r*colNum)+0].AddCell()
-            cell = row[(r*colNum)+0].AddCell()
-
-            savedCell.Merge(2, 0)
-
-            cell = row[(r*colNum)+1].AddCell()
-            cell.Value = "Предмет"
-
-            cell = row[(r*colNum)+1].AddCell()
-            cell.Value = "Преподаватель"
-
-            cell = row[(r*colNum)+1].AddCell()
-            cell.Value = "Кабинет"
-
-            for j, trow := range schedule[index].Table {
-                cell = row[(r*colNum)+uint(j)+2].AddCell()
-                if trow.Subject[A] == trow.Subject[B] {
-                    cell.Value = trow.Subject[A]
-                } else {
-                    if trow.Subject[A] != "" {
-                        cell.Value = trow.Subject[A] + " (A)"
-                    }
-                    if trow.Subject[B] != "" {
-                        cell.Value += "\n" + trow.Subject[B] + " (B)"
-                    }
-                }
-
-                cell = row[(r*colNum)+uint(j)+2].AddCell()
-                if trow.Teacher[A] == trow.Teacher[B] {
-                    cell.Value = trow.Teacher[A]
-                } else {
-                    if trow.Teacher[A] != "" {
-                        cell.Value = trow.Teacher[A]
-                    }
-                    if trow.Teacher[B] != "" {
-                        cell.Value += "\n" + trow.Teacher[B]
-                    }
-                }
-
-                sheet.SetColWidth(colWidthForCabinets(int(j)))
-                cell = row[(r*colNum)+uint(j)+2].AddCell()
-                if trow.Cabinet[A] == trow.Cabinet[B] {
-                    cell.Value = trow.Cabinet[A]
-                } else {
-                    if trow.Cabinet[A] != "" {
-                        cell.Value = trow.Cabinet[A]
-                    }
-                    if trow.Cabinet[B] != "" {
-                        cell.Value += "\n" + trow.Cabinet[B]
-                    }
-                }
-            }
-
-            index++
-        }
-    }
-
-    err = file.Save(filename)
-    if err != nil {
-        return err
-    }
-
-    return nil
-}
-
 func RandSubgroup() SubgroupType {
 func RandSubgroup() SubgroupType {
     return SubgroupType(random(0, 1))
     return SubgroupType(random(0, 1))
 }
 }

+ 84 - 58
schedule/localdata.go

@@ -4,7 +4,7 @@ import (
     "os"
     "os"
     "sort"
     "sort"
     "time"
     "time"
-    "errors"
+    // "errors"
     "math/rand"
     "math/rand"
     "encoding/json"
     "encoding/json"
 )
 )
@@ -22,7 +22,20 @@ func (gen *Generator) tryGenerate(
     countl *Subgroup, 
     countl *Subgroup, 
     template []*Schedule,
     template []*Schedule,
 ) {
 ) {
-    flag := false
+    var (
+        indexGroup = -1
+        flag       = false
+    )
+    if template != nil {
+        for i, sch := range template {
+            if sch.Group == group.Name {
+                indexGroup = i
+            }
+        }
+        if indexGroup == -1 {
+            return
+        }
+    }
 startAgain:
 startAgain:
     nextLesson: for lesson := uint(0); lesson < NUM_TABLES; lesson++ {
     nextLesson: for lesson := uint(0); lesson < NUM_TABLES; lesson++ {
         // Если лимит пар на день окончен, тогда прекратить ставить пары группе.
         // Если лимит пар на день окончен, тогда прекратить ставить пары группе.
@@ -42,7 +55,7 @@ startAgain:
 
 
         // Если учитель заблокирован (не может присутствовать на занятиях) или
         // Если учитель заблокирован (не может присутствовать на занятиях) или
         // лимит пар на текущую неделю для предмета завершён, тогда пропустить этот предмет.
         // лимит пар на текущую неделю для предмета завершён, тогда пропустить этот предмет.
-        if gen.inBlocked(subject.Teacher) || gen.notHaveWeekLessons(subgroup, subject) {
+        if gen.notHaveWeekLessons(subgroup, subject) { // gen.inBlocked(subject.Teacher) || 
             break nextLesson
             break nextLesson
         }
         }
 
 
@@ -167,22 +180,16 @@ tryAfter:
         }
         }
 
 
         // Если существует шаблон расписания, тогда придерживаться его структуры.
         // Если существует шаблон расписания, тогда придерживаться его структуры.
-        if template != nil {
-            for _, sch := range template {
-                if sch.Group == group.Name {
-                    if sch.Table[lesson].Subject[A] == "" && sch.Table[lesson].Subject[B] == "" {
-                        if  (gen.cellIsReserved(A, schedule, lesson) && !gen.cellIsReserved(B, schedule, lesson)) ||
-                            (gen.cellIsReserved(B, schedule, lesson) && !gen.cellIsReserved(A, schedule, lesson)) {
-                                break
-                        }
-                        lesson = savedLesson
-                        continue nextLesson
-                    }
-                    break
-                }
+        if template != nil && template[indexGroup].Table[lesson].Subject[A] == "" && template[indexGroup].Table[lesson].Subject[B] == "" {
+            if  (gen.cellIsReserved(A, schedule, lesson) && !gen.cellIsReserved(B, schedule, lesson)) ||
+                (gen.cellIsReserved(B, schedule, lesson) && !gen.cellIsReserved(A, schedule, lesson)) {
+                    goto passTemplate
             }
             }
+            lesson = savedLesson
+            continue nextLesson
         }
         }
 
 
+passTemplate:
         // Полный день - максимум 7 пар.
         // Полный день - максимум 7 пар.
         // lesson начинается с нуля!
         // lesson начинается с нуля!
         if (gen.Day != WEDNESDAY && gen.Day != SATURDAY) && lesson >= 7 {
         if (gen.Day != WEDNESDAY && gen.Day != SATURDAY) && lesson >= 7 {
@@ -213,7 +220,7 @@ tryAfter:
             // в это же время, тогда пропустить проверку пустых окон.
             // в это же время, тогда пропустить проверку пустых окон.
             if  gen.cellIsReserved(A, schedule, lesson) && A != subgroup || 
             if  gen.cellIsReserved(A, schedule, lesson) && A != subgroup || 
                 gen.cellIsReserved(B, schedule, lesson) && B != subgroup {
                 gen.cellIsReserved(B, schedule, lesson) && B != subgroup {
-                    goto passcheck
+                    goto passCheck
             }
             }
             // Если стоит полная пара, а за ней идёт подгруппа неравная проверяемой, тогда
             // Если стоит полная пара, а за ней идёт подгруппа неравная проверяемой, тогда
             // прекратить ставить пары у проверяемой подгруппы.
             // прекратить ставить пары у проверяемой подгруппы.
@@ -230,7 +237,7 @@ tryAfter:
             }
             }
         }
         }
 
 
-passcheck:
+passCheck:
         // [ III ] Третья проверка.
         // [ III ] Третья проверка.
         // Если нет возможности добавить новые пары без создания окон, тогда не ставить пары.
         // Если нет возможности добавить новые пары без создания окон, тогда не ставить пары.
         if lesson > 1 {
         if lesson > 1 {
@@ -256,24 +263,24 @@ passcheck:
 
 
         switch subgroup {
         switch subgroup {
         case A:
         case A:
-            gen.Groups[group.Name].Subjects[subject.Name].WeekLessons.A -= 1
-            gen.Groups[group.Name].Subjects[subject.Name].Practice.A -= 1
+            gen.Groups[group.Name].Subjects[subject.Name].Lessons.Week.A -= 1
+            gen.Groups[group.Name].Subjects[subject.Name].Lessons.Practice.A -= 1
             countl.A += 1
             countl.A += 1
         case B:
         case B:
-            gen.Groups[group.Name].Subjects[subject.Name].WeekLessons.B -= 1
-            gen.Groups[group.Name].Subjects[subject.Name].Practice.B -= 1
+            gen.Groups[group.Name].Subjects[subject.Name].Lessons.Week.B -= 1
+            gen.Groups[group.Name].Subjects[subject.Name].Lessons.Practice.B -= 1
             countl.B += 1
             countl.B += 1
         case ALL:
         case ALL:
-            gen.Groups[group.Name].Subjects[subject.Name].WeekLessons.A -= 1
-            gen.Groups[group.Name].Subjects[subject.Name].WeekLessons.B -= 1
+            gen.Groups[group.Name].Subjects[subject.Name].Lessons.Week.A -= 1
+            gen.Groups[group.Name].Subjects[subject.Name].Lessons.Week.B -= 1
             countl.A += 1
             countl.A += 1
             countl.B += 1
             countl.B += 1
             switch subjtype {
             switch subjtype {
             case THEORETICAL:
             case THEORETICAL:
-                gen.Groups[group.Name].Subjects[subject.Name].Theory -= 1
+                gen.Groups[group.Name].Subjects[subject.Name].Lessons.Theory -= 1
             case PRACTICAL:
             case PRACTICAL:
-                gen.Groups[group.Name].Subjects[subject.Name].Practice.A -= 1
-                gen.Groups[group.Name].Subjects[subject.Name].Practice.B -= 1
+                gen.Groups[group.Name].Subjects[subject.Name].Lessons.Practice.A -= 1
+                gen.Groups[group.Name].Subjects[subject.Name].Lessons.Practice.B -= 1
             }
             }
         }
         }
 
 
@@ -338,20 +345,20 @@ func (gen *Generator) withSubgroups(group string) bool {
     return false
     return false
 }
 }
 
 
-func (gen *Generator) blockTeacher(teacher string) error {
-    if !gen.inTeachers(teacher) {
-        return errors.New("teacher undefined")
-    }
-    gen.Blocked[teacher] = true
-    return nil
-}
-
-func (gen *Generator) inBlocked(teacher string) bool {
-    if _, ok := gen.Blocked[teacher]; !ok {
-        return false
-    }
-    return true
-}
+// func (gen *Generator) blockTeacher(teacher string) error {
+//     if !gen.inTeachers(teacher) {
+//         return errors.New("teacher undefined")
+//     }
+//     gen.Blocked[teacher] = true
+//     return nil
+// }
+
+// func (gen *Generator) inBlocked(teacher string) bool {
+//     if _, ok := gen.Blocked[teacher]; !ok {
+//         return false
+//     }
+//     return true
+// }
 
 
 func (gen *Generator) inGroups(group string) bool {
 func (gen *Generator) inGroups(group string) bool {
     if _, ok := gen.Groups[group]; !ok {
     if _, ok := gen.Groups[group]; !ok {
@@ -367,13 +374,13 @@ func (gen *Generator) inTeachers(teacher string) bool {
     return true
     return true
 }
 }
 
 
-func (gen *Generator) unblockTeacher(teacher string) error {
-    if !gen.inBlocked(teacher) {
-        return errors.New("teacher undefined")
-    }
-    delete(gen.Blocked, teacher)
-    return nil
-}
+// func (gen *Generator) unblockTeacher(teacher string) error {
+//     if !gen.inBlocked(teacher) {
+//         return errors.New("teacher undefined")
+//     }
+//     delete(gen.Blocked, teacher)
+//     return nil
+// }
 
 
 func packJSON(data interface{}) []byte {
 func packJSON(data interface{}) []byte {
     jsonData, err := json.MarshalIndent(data, "", "\t")
     jsonData, err := json.MarshalIndent(data, "", "\t")
@@ -457,10 +464,11 @@ func (gen *Generator) cellIsReserved(subgroup SubgroupType, schedule *Schedule,
 }
 }
 
 
 func (gen *Generator) cabinetIsReserved(subgroup SubgroupType, subject *Subject, teacher string, lesson uint, cabinet *string) bool {
 func (gen *Generator) cabinetIsReserved(subgroup SubgroupType, subject *Subject, teacher string, lesson uint, cabinet *string) bool {
-    var result = true
     if !gen.inTeachers(teacher) {
     if !gen.inTeachers(teacher) {
-        return result
+        return true
     }
     }
+
+    // Основные кабинеты преподавателя.
     for _, cab := range gen.Teachers[teacher].Cabinets {
     for _, cab := range gen.Teachers[teacher].Cabinets {
         gen.cabinetToReserved(cab.Name)
         gen.cabinetToReserved(cab.Name)
         // Если это не компьютерный кабинет, а предмет предполагает практику в компьютерных кабинетах и идёт время практики,
         // Если это не компьютерный кабинет, а предмет предполагает практику в компьютерных кабинетах и идёт время практики,
@@ -476,7 +484,25 @@ func (gen *Generator) cabinetIsReserved(subgroup SubgroupType, subject *Subject,
             return false
             return false
         }
         }
     }
     }
-    return result
+
+    // Все другие кабинеты. Могут быть использованы в случае, если все основные кабинеты преподавателя были заняты.
+    for _, cab := range gen.Cabinets {
+        gen.cabinetToReserved(cab.Name)
+        // Если это не компьютерный кабинет, а предмет предполагает практику в компьютерных кабинетах и идёт время практики,
+        // тогда посмотреть другой кабинет преподавателя.
+        if   subject.IsComputer && !cab.IsComputer &&
+             gen.havePracticalLessons(subgroup, subject) &&
+            !gen.haveTheoreticalLessons(subject) {
+                continue
+        }
+        // Если кабинет не зарезирвирован, тогда занять кабинет.
+        if _, ok := gen.Reserved.Cabinets[cab.Name]; ok && !gen.Reserved.Cabinets[cab.Name][lesson] {
+            *cabinet = cab.Name
+            return false
+        }
+    }
+
+    return true
 }
 }
 
 
 func (gen *Generator) teacherIsReserved(teacher string, lesson uint) bool {
 func (gen *Generator) teacherIsReserved(teacher string, lesson uint) bool {
@@ -504,15 +530,15 @@ func (gen *Generator) cabinetToReserved(cabnum string) {
 func (gen *Generator) notHaveWeekLessons(subgroup SubgroupType, subject *Subject) bool {
 func (gen *Generator) notHaveWeekLessons(subgroup SubgroupType, subject *Subject) bool {
     switch subgroup {
     switch subgroup {
     case A:
     case A:
-        if subject.WeekLessons.A == 0 {
+        if subject.Lessons.Week.A == 0 {
             return true
             return true
         }
         }
     case B:
     case B:
-        if subject.WeekLessons.B == 0 {
+        if subject.Lessons.Week.B == 0 {
             return true
             return true
         }
         }
     case ALL:
     case ALL:
-        if subject.WeekLessons.A == 0 && subject.WeekLessons.B == 0 {
+        if subject.Lessons.Week.A == 0 && subject.Lessons.Week.B == 0 {
             return true
             return true
         }
         }
     }
     }
@@ -520,7 +546,7 @@ func (gen *Generator) notHaveWeekLessons(subgroup SubgroupType, subject *Subject
 }
 }
 
 
 func (gen *Generator) haveTheoreticalLessons(subject *Subject) bool {
 func (gen *Generator) haveTheoreticalLessons(subject *Subject) bool {
-    if subject.Theory == 0 {
+    if subject.Lessons.Theory == 0 {
         return false
         return false
     }
     }
     return true
     return true
@@ -529,15 +555,15 @@ func (gen *Generator) haveTheoreticalLessons(subject *Subject) bool {
 func (gen *Generator) havePracticalLessons(subgroup SubgroupType, subject *Subject) bool {
 func (gen *Generator) havePracticalLessons(subgroup SubgroupType, subject *Subject) bool {
     switch subgroup {
     switch subgroup {
     case A:
     case A:
-        if subject.Practice.A == 0 {
+        if subject.Lessons.Practice.A == 0 {
             return false
             return false
         }
         }
     case B:
     case B:
-        if subject.Practice.B == 0 {
+        if subject.Lessons.Practice.B == 0 {
             return false
             return false
         }
         }
     case ALL:
     case ALL:
-        if subject.Practice.A == 0 && subject.Practice.B == 0 {
+        if subject.Lessons.Practice.A == 0 && subject.Lessons.Practice.B == 0 {
             return false
             return false
         }
         }
     }
     }

+ 61 - 21
schedule/models.go

@@ -1,5 +1,40 @@
 package schedule
 package schedule
 
 
+type TypeRow uint8
+const (
+	IsCycleTR = 0
+	IsStartTR = 1
+	IsPmTR    = 2
+	IsSubTR   = 3
+)
+
+type PlanXLSX struct {
+	ProgramCode   string     `json:"program_code"`
+	NameCode      string     `json:"name_code"`
+	PeriodOfStudy string     `json:"period_of_study"`
+	GroupNumber   string     `json:"group_number"`
+	Lines         []LineXLSX `json:"lines"`
+}
+
+type LineXLSX struct {
+	ID        string        `json:"id"`
+	Name      string        `json:"name"`
+	CertForm  string        `json:"cert_form"`
+	StudyLoad StudyLoadXLSX `json:"study_load"`
+	Course    [4][2]int     `json:"course"`
+	TypeRow   TypeRow       `json:"typerow"`
+}
+
+type StudyLoadXLSX struct {
+	Max          int `json:"max"`
+	SelfStudy    int `json:"self_study"`
+	AllStudy     int `json:"all_study"`
+	Lectures     int `json:"lectures"`
+	Labs         int `json:"labs"`
+	Projects     int `json:"projects"`
+	Consultation int `json:"consultation"`
+}
+
 type DayType uint8
 type DayType uint8
 const (
 const (
 	SUNDAY 		DayType = 0
 	SUNDAY 		DayType = 0
@@ -25,11 +60,12 @@ const (
 )
 )
 
 
 type Generator struct {
 type Generator struct {
-	Day DayType
-	Debug bool
-	Groups map[string]*Group
+	Day      DayType
+	Debug    bool
+	Groups   map[string]*Group
 	Teachers map[string]*Teacher
 	Teachers map[string]*Teacher
-	Blocked map[string]bool
+	Cabinets map[string]*Cabinet
+	// Blocked map[string]bool
 	Reserved Reserved
 	Reserved Reserved
 }
 }
 
 
@@ -39,7 +75,7 @@ type Reserved struct {
 }
 }
 
 
 type Schedule struct {
 type Schedule struct {
-	Day DayType
+	Day   DayType
 	Group string
 	Group string
 	Table []Row
 	Table []Row
 }
 }
@@ -51,30 +87,34 @@ type Row struct {
 }
 }
 
 
 type Teacher struct {
 type Teacher struct {
-	Name string `json:"name"`
+	Name     string    `json:"name"`
 	Cabinets []Cabinet `json:"cabinets"`
 	Cabinets []Cabinet `json:"cabinets"`
 }
 }
 
 
 type Cabinet struct {
 type Cabinet struct {
-	Name string `json:"name"`
-	IsComputer bool `json:"is_computer"`
+	Name       string `json:"name"`
+	IsComputer bool   `json:"is_computer"`
 }
 }
 
 
 type Group struct {
 type Group struct {
-	Name string
+	Name     string
 	Quantity uint // students count
 	Quantity uint // students count
 	Subjects map[string]*Subject
 	Subjects map[string]*Subject
 }
 }
 
 
 type Subject struct {
 type Subject struct {
-	Name string
-	Teacher string
-	Teacher2 string
+	Name       string
 	IsComputer bool
 	IsComputer bool
-	SaveWeek uint
-	Theory uint
+	Teacher    string
+	Teacher2   string
+	SaveWeek   uint
+	Lessons    Lessons
+}
+
+type Lessons struct {
+	Theory   uint
 	Practice Subgroup
 	Practice Subgroup
-	WeekLessons Subgroup
+	Week     Subgroup
 }
 }
 
 
 type Subgroup struct {
 type Subgroup struct {
@@ -83,20 +123,20 @@ type Subgroup struct {
 }
 }
 
 
 type GroupJSON struct {
 type GroupJSON struct {
-	Name string `json:"name"`
+	Name     string `json:"name"`
 	Quantity uint `json:"quantity"`
 	Quantity uint `json:"quantity"`
 	Subjects []SubjectJSON `json:"subjects"`
 	Subjects []SubjectJSON `json:"subjects"`
 }
 }
 
 
 type SubjectJSON struct {
 type SubjectJSON struct {
-	Name string `json:"name"`
-	Teacher string `json:"teacher"`
+	Name       string `json:"name"`
+	Teacher    string `json:"teacher"`
 	IsComputer bool `json:"is_computer"`
 	IsComputer bool `json:"is_computer"`
-	Lessons LessonsJSON `json:"lessons"`
+	Lessons    LessonsJSON `json:"lessons"`
 }
 }
 
 
 type LessonsJSON struct {
 type LessonsJSON struct {
-	Theory uint `json:"theory"`
+	Theory   uint `json:"theory"`
 	Practice uint `json:"practice"`
 	Practice uint `json:"practice"`
-	Week uint `json:"week"`
+	Week     uint `json:"week"`
 }
 }

+ 5 - 1
schedule/settings.go

@@ -7,7 +7,7 @@ const (
 const (
 const (
 	NUM_TABLES = 11
 	NUM_TABLES = 11
 	MAX_COUNT_LESSONS_IN_DAY = 3
 	MAX_COUNT_LESSONS_IN_DAY = 3
-	MAX_COUNT_WITHOUT_SUBGROUPS = 16
+	MAX_COUNT_WITHOUT_SUBGROUPS = 20
 )
 )
 
 
 // For XLSX.
 // For XLSX.
@@ -16,3 +16,7 @@ const (
 	COL_W = 30
 	COL_W = 30
 	COL_W_CAB = 10
 	COL_W_CAB = 10
 )
 )
+
+const (
+	OUTDATA = "output/"
+)

+ 82 - 15
schedule/xlsx.go

@@ -7,6 +7,32 @@ import (
     "github.com/tealeg/xlsx"
     "github.com/tealeg/xlsx"
 )
 )
 
 
+func (gen *Generator) Template() [][]*Schedule {
+    var (
+        weekLessons = make([][]*Schedule, 7)
+        generator = new(Generator)
+        file *xlsx.File
+        name string
+    )
+    unpackJSON(packJSON(gen), generator)
+    if gen.Debug {
+        file, name = CreateXLSX(OUTDATA + "template.xlsx")
+    }
+    day := generator.Day
+    for i := day; i < day+7; i++ {
+        weekLessons[i % 7] = generator.Generate(nil)
+        if gen.Debug {
+            generator.WriteXLSX(
+                file,
+                name,
+                weekLessons[i % 7],
+                int(i % 7),
+            )
+        }
+    }
+    return weekLessons
+}
+
 func ImportXLSX(filename string) []*PlanXLSX {
 func ImportXLSX(filename string) []*PlanXLSX {
     var (
     var (
         listOfPlans []*PlanXLSX
         listOfPlans []*PlanXLSX
@@ -17,19 +43,35 @@ func ImportXLSX(filename string) []*PlanXLSX {
     }
     }
     for _, sheet := range xlFile.Sheets {
     for _, sheet := range xlFile.Sheets {
         var plan = new(PlanXLSX)
         var plan = new(PlanXLSX)
+        
         plan.ProgramCode   = sheet.Rows[5].Cells[1].String()
         plan.ProgramCode   = sheet.Rows[5].Cells[1].String()
         plan.NameCode      = strings.Split(sheet.Rows[5].Cells[6].String(), " ")[0]
         plan.NameCode      = strings.Split(sheet.Rows[5].Cells[6].String(), " ")[0]
         plan.PeriodOfStudy = sheet.Rows[7].Cells[6].String()
         plan.PeriodOfStudy = sheet.Rows[7].Cells[6].String()
         splited := strings.Split(sheet.Rows[9].Cells[1].String(), " ")
         splited := strings.Split(sheet.Rows[9].Cells[1].String(), " ")
         plan.GroupNumber   = strings.Split(splited[len(splited)-1], "-")[0]
         plan.GroupNumber   = strings.Split(splited[len(splited)-1], "-")[0]
 
 
+        maxCells := 18
+        consultExist := false
+        if strings.HasPrefix(sheet.Rows[13].Cells[9].String(), "Консультации") {
+            maxCells = 19
+            consultExist = true
+        }
+
+        plusTable := 0
+        if sheet.Rows[11].Cells[10].String() == "" || sheet.Rows[11].Cells[11].String() == "" {
+            plusTable = 2
+        }
+
         for i, row := range sheet.Rows {
         for i, row := range sheet.Rows {
             if i < 20 {
             if i < 20 {
                 continue
                 continue
             }
             }
-            if len(row.Cells) < 20 {
+
+            if len(row.Cells) < maxCells {
+                // fmt.Println(len(row.Cells))
                 continue
                 continue
             }
             }
+            
             if row.Cells[2].String() == "" || row.Cells[2].String() == "ИТОГО" {
             if row.Cells[2].String() == "" || row.Cells[2].String() == "ИТОГО" {
                 continue
                 continue
             }
             }
@@ -53,20 +95,44 @@ func ImportXLSX(filename string) []*PlanXLSX {
                 typerow = IsPmTR
                 typerow = IsPmTR
             }
             }
 
 
-            max, _       := row.Cells[4].Int()
-            selfstudy, _ := row.Cells[5].Int()
-            allstudy, _  := row.Cells[6].Int()
-            lectures, _  := row.Cells[7].Int()
-            labs, _      := row.Cells[8].Int()
-            projects, _  := row.Cells[9].Int()
-            c1s1, _      := row.Cells[12].Int()
-            c1s2, _      := row.Cells[13].Int()
-            c2s1, _      := row.Cells[14].Int()
-            c2s2, _      := row.Cells[15].Int()
-            c3s1, _      := row.Cells[16].Int()
-            c3s2, _      := row.Cells[17].Int()
-            c4s1, _      := row.Cells[18].Int()
-            c4s2, _      := row.Cells[19].Int()
+            var (
+                max, selfstudy, allstudy, lectures, labs, consult, projects int
+                c1s1, c1s2, c2s1, c2s2, c3s1, c3s2, c4s1, c4s2 int
+            )
+
+            max, _       = row.Cells[4].Int()
+            selfstudy, _ = row.Cells[5].Int()
+            allstudy, _  = row.Cells[6].Int()
+            lectures, _  = row.Cells[7].Int()
+            labs, _      = row.Cells[8].Int()
+
+            if consultExist {
+                consult, _   = row.Cells[9].Int()
+                projects, _  = row.Cells[10].Int()
+                c1s1, _      = row.Cells[11+plusTable].Int()
+                c1s2, _      = row.Cells[12+plusTable].Int()
+                c2s1, _      = row.Cells[13+plusTable].Int()
+                c2s2, _      = row.Cells[14+plusTable].Int()
+                c3s1, _      = row.Cells[15+plusTable].Int()
+                c3s2, _      = row.Cells[16+plusTable].Int()
+                if plusTable == 0 {
+                    c4s1, _      = row.Cells[17+plusTable].Int()
+                    c4s2, _      = row.Cells[18+plusTable].Int()
+                }
+            } else {
+                consult      = -1
+                projects, _  = row.Cells[9].Int()
+                c1s1, _      = row.Cells[10+plusTable].Int()
+                c1s2, _      = row.Cells[11+plusTable].Int()
+                c2s1, _      = row.Cells[12+plusTable].Int()
+                c2s2, _      = row.Cells[13+plusTable].Int()
+                c3s1, _      = row.Cells[14+plusTable].Int()
+                c3s2, _      = row.Cells[15+plusTable].Int()
+                if plusTable == 0 {
+                    c4s1, _      = row.Cells[16+plusTable].Int()
+                    c4s2, _      = row.Cells[17+plusTable].Int()
+                }
+            }
 
 
             certform := ""
             certform := ""
             splited = strings.Split(row.Cells[3].String(), ",")
             splited = strings.Split(row.Cells[3].String(), ",")
@@ -87,6 +153,7 @@ func ImportXLSX(filename string) []*PlanXLSX {
                     AllStudy:  allstudy,
                     AllStudy:  allstudy,
                     Lectures:  lectures,
                     Lectures:  lectures,
                     Labs:      labs,
                     Labs:      labs,
+                    Consultation: consult,
                     Projects:  projects,
                     Projects:  projects,
                 },
                 },
                 Course: [4][2]int{
                 Course: [4][2]int{

+ 46 - 0
static/js/api/jsClassrooms.js

@@ -1,3 +1,7 @@
+<<<<<<< HEAD
+<<<<<<< HEAD
+=======
+>>>>>>> b5fe990a18b258e28401117b0be0a70e1a10db12
 addClassroom = () =>{
 addClassroom = () =>{
 	let number = document.querySelector('.numberCab').value
 	let number = document.querySelector('.numberCab').value
 	let	placeQuantity = document.querySelector('.placeQuantity').value
 	let	placeQuantity = document.querySelector('.placeQuantity').value
@@ -6,6 +10,7 @@ addClassroom = () =>{
 	for(let i=0; i<building.length; i++ ){
 	for(let i=0; i<building.length; i++ ){
 		if (building[i].checked) {
 		if (building[i].checked) {
 			radioValue = building[i].value
 			radioValue = building[i].value
+<<<<<<< HEAD
 
 
 		}
 		}
 	}
 	}
@@ -30,3 +35,44 @@ addClassroom = () =>{
 	
 	
 	alert("Добавлено")
 	alert("Добавлено")
 }
 }
+=======
+// addClassroom = () =>{
+// 	let number = document.querySelector('.numberCab').value
+// 	let	placeQuantity = document.querySelector('.placeQuantity').value
+// 	let	 building = document.querySelectorAll('.building-radio');
+// 	let radioValue
+// 	for(let i=0; i<building.length; i++ ){
+// 		if (building[i].checked) {
+// 			radioValue = building[i].value
+=======
+>>>>>>> b5fe990a18b258e28401117b0be0a70e1a10db12
+
+		}
+	}
+	let isComputer = document.querySelector('.computerclass').checked
+
+	var myHeaders = new Headers();
+	myHeaders.append("Content-Type", "application/json");
+
+	var raw = JSON.stringify({"PlaceQuantity":Number(placeQuantity),"IsComputer":isComputer,"IDBuilding":Number(radioValue),"Name": number});
+
+		var requestOptions = {
+		  method: 'POST',
+		  headers: myHeaders,
+		  body: raw,
+		  redirect: 'follow'
+		};
+	url = 'http://schedule.tomtit.tomsk.ru/api/classroom/'
+	fetch(url, requestOptions)
+	  .then(response => response.text())
+	  .then(result => console.log(result))
+	  .catch(error => console.log('error', error));
+	
+<<<<<<< HEAD
+// 	alert("Добавлено")
+// }
+>>>>>>> master
+=======
+	alert("Добавлено")
+}
+>>>>>>> b5fe990a18b258e28401117b0be0a70e1a10db12

+ 59 - 0
static/js/api/vueAuth.js

@@ -0,0 +1,59 @@
+const requestFunc = async(url, method = "GET", data = null, token = null) => {
+	apihost = 'http://schedule.tomtit.tomsk.ru/api'
+	method = method.toLocaleUpperCase()
+	let fullurl = `${apihost}${url}`;
+	let options = {
+	method: method,
+	headers: {
+	"Content-Type": "application/json",
+	"Authorization": `Bearer ${token}`,
+	},
+};
+
+switch(method) {
+	case "PUT":
+	delete options.headers["Content-Type"];
+	options.body = data;
+	break;
+	case "POST": case "PATCH": case "DELETE":
+	options.body = JSON.stringify(data);
+	break;
+}
+
+const res = await fetch(fullurl, options);
+return await res.json();
+};
+
+var vueApp = new Vue({
+	delimiters: ['${', '}'],
+    el: '#app',
+    data: {
+    	userdata: {
+    		Login: null,
+    		Password: null,
+    	}
+    },
+    methods: {
+    	async authButton() {
+    		let res = await requestFunc("/auth/", "POST", this.userdata);
+    		localStorage.setItem("Login", this.userdata.Login);
+    		localStorage.setItem("Password", this.userdata.Password);
+    		// console.log(Array.isArray(res))
+    		this.nulldata();
+    		if (Array.isArray(res)) {
+    			location.href = 'http://schedule.tomtit.tomsk.ru/plan/'
+    		}
+    		// return Array.isArray(res)
+    	},
+    	nulldata() {
+            this.userdata.Login = null;
+            this.userdata.Password = null;
+        }
+    },
+
+});
+// authButton = () =>{
+// 	let login = document.querySelector('.login').value
+// 	let password = document.querySelector('.password').value
+
+// }

+ 74 - 0
static/js/api/vueClassrooms.js

@@ -29,12 +29,60 @@ var app = new Vue({
         delimiters: ['${', '}'],
         delimiters: ['${', '}'],
         data: {
         data: {
             classrooms:[], 
             classrooms:[], 
+<<<<<<< HEAD
+<<<<<<< HEAD
             buildings: []
             buildings: []
+=======
+            buildings: [],
+            selectedRow: {
+                "Code": "",
+                "Name": "",
+                "IDDuration": 0,
+                "ID": ""
+            },
+>>>>>>> master
+=======
+            buildings: []
+>>>>>>> b5fe990a18b258e28401117b0be0a70e1a10db12
          },
          },
         methods: {
         methods: {
             showClassrooms() {
             showClassrooms() {
                 console.log(this.classrooms)
                 console.log(this.classrooms)
             },
             },
+<<<<<<< HEAD
+<<<<<<< HEAD
+=======
+            selectRow(row, index){
+                let rows = document.querySelectorAll('.clickHover')
+                console.log(index)
+                this.selectedRow = row;
+                
+                // for(let i = 0; i < row.length; i++) {
+                //     rows[i].style.backgroundColor = 'red'
+                // }
+                console.log(rows)
+                console.log(rows[index].style.backgroundColor)
+                // empty string
+                if(rows[index].style.backgroundColor != 'red'){
+                    rows[index].style.backgroundColor = 'red'
+                }
+                else{
+                    rows[index].style.backgroundColor = 'white'
+                    this.clearSelectedRow()
+                }   
+                
+                console.log(row)
+            },
+            clearSelectedRow(){
+                this.selectedRow =   {
+                "Code": "",
+                "Name": "",
+                "IDDuration": 0
+                }
+            },
+>>>>>>> master
+=======
+>>>>>>> b5fe990a18b258e28401117b0be0a70e1a10db12
         	async getClassrooms(){
         	async getClassrooms(){
         		this.classrooms = await requestFunc("/classroom", "GET")
         		this.classrooms = await requestFunc("/classroom", "GET")
         	}, 
         	}, 
@@ -53,3 +101,29 @@ var app = new Vue({
         }
         }
     });
     });
 
 
+<<<<<<< HEAD
+<<<<<<< HEAD
+=======
+addClassroom = () =>{
+    let number = document.querySelector('.numberCab').value
+    let placeQuantity = document.querySelector('.placeQuantity').value
+    let building = document.querySelectorAll('.building-radio');
+    let radioValue
+    for(let i=0; i<building.length; i++ ){
+        if (building[i].checked) {
+            radioValue = building[i].value
+
+        }
+    }
+    let isComputer = document.querySelector('.computerclass').checked
+
+    var myHeaders = new Headers();
+    myHeaders.append("Content-Type", "application/json");
+
+    var raw = {"PlaceQuantity":Number(placeQuantity),"IsComputer":isComputer,"IDBuilding":Number(radioValue),"Name": number};
+    requestFunc(url="/classroom/", method="POST", data=raw)
+    alert("Добавлено")
+}
+>>>>>>> master
+=======
+>>>>>>> b5fe990a18b258e28401117b0be0a70e1a10db12

+ 98 - 1
static/js/api/vueGroup.js

@@ -23,14 +23,33 @@ switch(method) {
 const res = await fetch(fullurl, options);
 const res = await fetch(fullurl, options);
 return await res.json();
 return await res.json();
 };
 };
+<<<<<<< HEAD
+<<<<<<< HEAD
 var app = new Vue({
 var app = new Vue({
+=======
+
+var vueapp = new Vue({
+>>>>>>> master
+=======
+var app = new Vue({
+>>>>>>> b5fe990a18b258e28401117b0be0a70e1a10db12
         el: '#app',
         el: '#app',
         delimiters: ['${', '}'],
         delimiters: ['${', '}'],
         data: {
         data: {
             groups:[],
             groups:[],
             teachers:[],
             teachers:[],
+<<<<<<< HEAD
+<<<<<<< HEAD
+            selected:null
+         },
+=======
+            specialties:[],
+        },
+>>>>>>> master
+=======
             selected:null
             selected:null
          },
          },
+>>>>>>> b5fe990a18b258e28401117b0be0a70e1a10db12
         methods: {
         methods: {
             showGroups() {
             showGroups() {
                 console.log(this.groups)
                 console.log(this.groups)
@@ -44,10 +63,31 @@ var app = new Vue({
                     Vue.set(this.teachers, i, teachers[i]);
                     Vue.set(this.teachers, i, teachers[i]);
                 }
                 }
             },
             },
+<<<<<<< HEAD
+<<<<<<< HEAD
             async mountFunc(){
             async mountFunc(){
                 await this.getTeachers()
                 await this.getTeachers()
                 await this.getGroups()
                 await this.getGroups()
             },
             },
+=======
+            async getSpecilties(){
+                specialties = await requestFunc("/specialty/", "GET")
+                for(let i =0; i < specialties.length; i++) {
+                    Vue.set(this.specialties, i, specialties[i]);
+                }
+            },
+            async mountFunc(){
+                await this.getTeachers()
+                await this.getGroups()
+                await this.getSpecilties()
+            }
+>>>>>>> master
+=======
+            async mountFunc(){
+                await this.getTeachers()
+                await this.getGroups()
+            },
+>>>>>>> b5fe990a18b258e28401117b0be0a70e1a10db12
         }, 
         }, 
         async mounted() {
         async mounted() {
             await this.mountFunc()
             await this.mountFunc()
@@ -58,6 +98,10 @@ var app = new Vue({
 
 
 
 
 
 
+<<<<<<< HEAD
+<<<<<<< HEAD
+=======
+>>>>>>> b5fe990a18b258e28401117b0be0a70e1a10db12
 // const requestFunc = async(url, method = "GET", data = null, token = null) => {
 // const requestFunc = async(url, method = "GET", data = null, token = null) => {
 //     apihost = 'http://schedule.tomtit.tomsk.ru/api'
 //     apihost = 'http://schedule.tomtit.tomsk.ru/api'
 //     method = method.toLocaleUpperCase()
 //     method = method.toLocaleUpperCase()
@@ -69,6 +113,55 @@ var app = new Vue({
 //     "Authorization": `Bearer ${token}`,
 //     "Authorization": `Bearer ${token}`,
 //     },
 //     },
 // };
 // };
+<<<<<<< HEAD
+
+// switch(method) {
+//     case "PUT":
+//     delete options.headers["Content-Type"];
+//     options.body = data;
+//     break;
+//     case "POST": case "PATCH": case "DELETE":
+//     options.body = JSON.stringify(data);
+//     break;
+// }
+
+// const res = await fetch(fullurl, options);
+// return await res.json();
+// };
+// var app = new Vue({
+//         el: '#app',
+//         delimiters: ['${', '}'],
+//         data: {
+//             groups:[],
+//             teachers:[],
+//             profmoduls:[],
+//          },
+//         methods: {
+//             showGroups() {
+//                 console.log(this.groups)
+//             },
+//             async getGroups(){
+//                 this.groups = await requestFunc("/group/", "GET")
+//             },
+//             async getTeachers(){
+//                 teachers = await requestFunc("/teacher/", "GET")
+//                 for(let i =0; i < teachers.length; i++) {
+//                         Vue.set(this.teachers, i, teachers[i]);
+//                     },
+//             },
+//             async mountFunc(){
+//                 await this.getTeachers()
+//                 await this.getGroups()
+//             },
+//         }, 
+//         async mounted() {
+//             await this.mountFunc()
+//             console.log(this.teachers)
+//         }
+//     });
+=======
+=======
+>>>>>>> b5fe990a18b258e28401117b0be0a70e1a10db12
 
 
 // switch(method) {
 // switch(method) {
 //     case "PUT":
 //     case "PUT":
@@ -80,6 +173,9 @@ var app = new Vue({
 //     break;
 //     break;
 // }
 // }
 
 
+<<<<<<< HEAD
+>>>>>>> master
+=======
 // const res = await fetch(fullurl, options);
 // const res = await fetch(fullurl, options);
 // return await res.json();
 // return await res.json();
 // };
 // };
@@ -113,4 +209,5 @@ var app = new Vue({
 //             await this.mountFunc()
 //             await this.mountFunc()
 //             console.log(this.teachers)
 //             console.log(this.teachers)
 //         }
 //         }
-//     });
+//     });
+>>>>>>> b5fe990a18b258e28401117b0be0a70e1a10db12

+ 144 - 0
static/js/api/vueIndex.js

@@ -0,0 +1,144 @@
+const requestFunc = async(url, method = "GET", data = null, token = null) => {
+    apihost = 'http://schedule.tomtit.tomsk.ru:8888/api'
+    method = method.toLocaleUpperCase()
+    let fullurl = `${apihost}${url}`;
+    let options = {
+    method: method,
+    headers: {
+    "Content-Type": "application/json",
+    "Authorization": `Bearer ${token}`,
+    },
+};
+
+switch(method) {
+    case "PUT":
+    delete options.headers["Content-Type"];
+    options.body = data;
+    break;
+    case "POST": case "PATCH": case "DELETE":
+    options.body = JSON.stringify(data);
+    break;
+}
+
+const res = await fetch(fullurl, options);
+return await res.json();
+};
+
+var selectedFile;
+document
+    .getElementById("fileUpload")
+    .addEventListener("click", function(event){
+        selectedFile = event.target.files[0];
+    });
+document
+    .getElementById("uploadExcel")
+    .addEventListener("click", function(){
+        if (selectedFile) {
+          console.log("hi");
+          var fileReader = new FileReader();
+          fileReader.onload = function(event) {
+            var data = event.target.result;
+
+            var workbook = XLSX.read(data, {
+              type: "binary"
+            });
+            workbook.SheetNames.forEach(sheet => {
+              let rowObject = XLSX.utils.sheet_to_row_object_array(
+                workbook.Sheets[sheet]
+              );
+              var myHeaders = new Headers();
+                myHeaders.append("Content-Type", "application/json");
+                var raw = JSON.stringify(rowObject);
+                requestFunc(url="/plan/", method="POST", data=raw)
+                console.log(jsonObject);
+              // let jsonObject = JSON.stringify(rowObject);
+              // document.getElementById("jsonData").innerHTML = jsonObject;
+              // console.log(jsonObject);
+            });
+          };
+          fileReader.readAsBinaryString(selectedFile);
+        }
+      });
+    
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+// // <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.13.5/xlsx.full.min.js"></script>
+
+
+
+// // <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.13.5/jszip.js"></script>
+// // <script type="text/javascript">
+//     function Upload() {
+//         //Reference the FileUpload element.
+//         var fileUpload = document.getElementById("fileUpload");
+ 
+//         //Validate whether File is valid Excel file.
+//         var regex = /^([a-zA-Z0-9\s_\\.\-:])+(.xls|.xlsx)$/;
+//         if (regex.test(fileUpload.value.toLowerCase())) {
+//             if (typeof (FileReader) != "undefined") {
+//                 var reader = new FileReader();
+ 
+//                 //For Browsers other than IE.
+//                 if (reader.readAsBinaryString) {
+//                     reader.onload = function (e) {
+//                         ProcessExcel(e.target.result);
+//                     };
+//                     reader.readAsBinaryString(fileUpload.files[0]);
+//                 } else {
+//                     //For IE Browser.
+//                     reader.onload = function (e) {
+//                         var data = "";
+//                         var bytes = new Uint8Array(e.target.result);
+//                         for (var i = 0; i < bytes.byteLength; i++) {
+//                             data += String.fromCharCode(bytes[i]);
+//                         }
+//                         ProcessExcel(data);
+//                     };
+//                     reader.readAsArrayBuffer(fileUpload.files[0]);
+//                 }
+//             } else {
+//                 alert("This browser does not support HTML5.");
+//             }
+//         } else {
+//             alert("Please upload a valid Excel file.");
+//         }
+//         alert("Загружено")
+//     };
+// // </script>

+ 94 - 1
static/js/api/vueSpecialty.js

@@ -23,11 +23,21 @@ switch(method) {
 const res = await fetch(fullurl, options);
 const res = await fetch(fullurl, options);
 return await res.json();
 return await res.json();
 };
 };
+<<<<<<< HEAD
+<<<<<<< HEAD
 var app = new Vue({
 var app = new Vue({
+=======
+var vueApp = new Vue({
+>>>>>>> master
+=======
+var app = new Vue({
+>>>>>>> b5fe990a18b258e28401117b0be0a70e1a10db12
         el: '#app',
         el: '#app',
         delimiters: ['${', '}'],
         delimiters: ['${', '}'],
         data: {
         data: {
             specialties:[], 
             specialties:[], 
+<<<<<<< HEAD
+<<<<<<< HEAD
          },
          },
         methods: {
         methods: {
             showSpecialties() {
             showSpecialties() {
@@ -37,8 +47,91 @@ var app = new Vue({
         		this.specialties = await requestFunc("/specialty", "GET")
         		this.specialties = await requestFunc("/specialty", "GET")
         	},
         	},
             
             
+=======
+            selectedRow: {
+                "Code": "",
+                "Name": "",
+                "IDDuration": 0,
+                "ID": ""
+            },
+            requestType: null
+=======
+>>>>>>> b5fe990a18b258e28401117b0be0a70e1a10db12
+         },
+        methods: {
+            showSpecialties() {
+                console.log(this.specialty)
+            },
+        	async getSpecialties(){
+        		this.specialties = await requestFunc("/specialty", "GET")
+        	},
+<<<<<<< HEAD
+            selectRow(row, index){
+                let rows = document.querySelectorAll('.clickHover')
+                this.selectedRow = row;
+                // empty string
+                if(rows[index].style.backgroundColor != 'red'){
+                    rows[index].style.backgroundColor = 'red'
+                }
+                else{
+                    rows[index].style.backgroundColor = 'white'
+                    this.clearSelectedRow()
+                }   
+            },
+            clearSelectedRow(){
+                this.selectedRow =   {
+                "Code": "",
+                "Name": "",
+                "IDDuration": 0
+                }
+            },
+            changeRequestType(requestType){
+                this.requestType = requestType 
+            },
+            modalClick(add, requestType) {
+                if(add==='yes') {
+                    this.clearSelectedRow();
+                }
+                this.changeRequestType(requestType);
+            }         
+>>>>>>> master
+=======
+            
+>>>>>>> b5fe990a18b258e28401117b0be0a70e1a10db12
         }, 
         }, 
         mounted() {
         mounted() {
         	this.getSpecialties()
         	this.getSpecialties()
         }
         }
-    });
+<<<<<<< HEAD
+<<<<<<< HEAD
+    });
+=======
+    });
+    addSpecialty = (requestType)=>{
+        let code = document.querySelector('.code').value
+        let name = document.querySelector('.name').value
+        let duration = document.querySelectorAll('.duration-radio');
+        let radioValue
+        for(let i=0; i<duration.length; i++ ){
+            if (duration[i].checked) {
+                radioValue = duration[i].value
+
+            }
+        }
+        var myHeaders = new Headers();
+        myHeaders.append("Content-Type", "application/json");
+
+        var raw = {"Code":code,"Name":name,"IDDuration":Number(radioValue)};
+        if (vueApp.requestType=== 'PATCH') {
+            let ID = document.querySelector('.ID').value
+            console.log(ID)
+            raw.ID= Number(ID)
+            
+        }
+        requestFunc(url="/specialty/", method=vueApp.requestType, data=raw)
+        alert("Добавлено")
+    }
+>>>>>>> master
+=======
+    });
+>>>>>>> b5fe990a18b258e28401117b0be0a70e1a10db12

+ 18 - 0
static/js/api/vueTeacher.js

@@ -24,6 +24,10 @@ const res = await fetch(fullurl, options);
 return await res.json();
 return await res.json();
 };
 };
 
 
+<<<<<<< HEAD
+<<<<<<< HEAD
+=======
+>>>>>>> b5fe990a18b258e28401117b0be0a70e1a10db12
 // addTeacher() =>{
 // addTeacher() =>{
 //     let surname = document.querySelector('.surname').value
 //     let surname = document.querySelector('.surname').value
 //     let name = document.querySelector('.name').value
 //     let name = document.querySelector('.name').value
@@ -35,6 +39,11 @@ return await res.json();
 
 
 
 
 
 
+<<<<<<< HEAD
+=======
+>>>>>>> master
+=======
+>>>>>>> b5fe990a18b258e28401117b0be0a70e1a10db12
 var vueApp = new Vue({
 var vueApp = new Vue({
         el: '#app',
         el: '#app',
         delimiters: ['${', '}'],
         delimiters: ['${', '}'],
@@ -54,9 +63,18 @@ var vueApp = new Vue({
             async getClassrooms(){
             async getClassrooms(){
                 classrooms = await requestFunc("/classroom", "GET")
                 classrooms = await requestFunc("/classroom", "GET")
                 for(let i =0; i < classrooms.length; i++) {
                 for(let i =0; i < classrooms.length; i++) {
+<<<<<<< HEAD
+<<<<<<< HEAD
 
 
                     //this.classrooms.push(classrooms[i])
                     //this.classrooms.push(classrooms[i])
                     //this.classrooms.$set(i,classrooms[i]);
                     //this.classrooms.$set(i,classrooms[i]);
+=======
+>>>>>>> master
+=======
+
+                    //this.classrooms.push(classrooms[i])
+                    //this.classrooms.$set(i,classrooms[i]);
+>>>>>>> b5fe990a18b258e28401117b0be0a70e1a10db12
                     Vue.set(this.classrooms, i, classrooms[i]);
                     Vue.set(this.classrooms, i, classrooms[i]);
                 }
                 }
             },
             },

+ 1 - 1
webPage.go

@@ -11,7 +11,7 @@ import (
 )
 )
 
 
 func indexPage(w http.ResponseWriter, r *http.Request) {
 func indexPage(w http.ResponseWriter, r *http.Request) {
-	http.Redirect(w, r, "/plan/", 302)
+	loginPage(w, r)
 }
 }
 
 
 func planPage(w http.ResponseWriter, r *http.Request) {
 func planPage(w http.ResponseWriter, r *http.Request) {