Number571 před 5 roky
rodič
revize
8e27c41f46

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 27 - 7
html/index.html


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

@@ -1,3 +1,7 @@
+<<<<<<< HEAD
+<<<<<<< HEAD
+=======
+>>>>>>> b5fe990a18b258e28401117b0be0a70e1a10db12
 addClassroom = () =>{
 	let number = document.querySelector('.numberCab').value
 	let	placeQuantity = document.querySelector('.placeQuantity').value
@@ -6,6 +10,7 @@ addClassroom = () =>{
 	for(let i=0; i<building.length; i++ ){
 		if (building[i].checked) {
 			radioValue = building[i].value
+<<<<<<< HEAD
 
 		}
 	}
@@ -30,3 +35,44 @@ addClassroom = () =>{
 	
 	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: ['${', '}'],
         data: {
             classrooms:[], 
+<<<<<<< HEAD
+<<<<<<< HEAD
             buildings: []
+=======
+            buildings: [],
+            selectedRow: {
+                "Code": "",
+                "Name": "",
+                "IDDuration": 0,
+                "ID": ""
+            },
+>>>>>>> master
+=======
+            buildings: []
+>>>>>>> b5fe990a18b258e28401117b0be0a70e1a10db12
          },
         methods: {
             showClassrooms() {
                 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(){
         		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);
 return await res.json();
 };
+<<<<<<< HEAD
+<<<<<<< HEAD
 var app = new Vue({
+=======
+
+var vueapp = new Vue({
+>>>>>>> master
+=======
+var app = new Vue({
+>>>>>>> b5fe990a18b258e28401117b0be0a70e1a10db12
         el: '#app',
         delimiters: ['${', '}'],
         data: {
             groups:[],
             teachers:[],
+<<<<<<< HEAD
+<<<<<<< HEAD
+            selected:null
+         },
+=======
+            specialties:[],
+        },
+>>>>>>> master
+=======
             selected:null
          },
+>>>>>>> b5fe990a18b258e28401117b0be0a70e1a10db12
         methods: {
             showGroups() {
                 console.log(this.groups)
@@ -44,10 +63,31 @@ var app = new Vue({
                     Vue.set(this.teachers, i, teachers[i]);
                 }
             },
+<<<<<<< HEAD
+<<<<<<< HEAD
             async mountFunc(){
                 await this.getTeachers()
                 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() {
             await this.mountFunc()
@@ -58,6 +98,10 @@ var app = new Vue({
 
 
 
+<<<<<<< HEAD
+<<<<<<< HEAD
+=======
+>>>>>>> b5fe990a18b258e28401117b0be0a70e1a10db12
 // const requestFunc = async(url, method = "GET", data = null, token = null) => {
 //     apihost = 'http://schedule.tomtit.tomsk.ru/api'
 //     method = method.toLocaleUpperCase()
@@ -69,6 +113,55 @@ var app = new Vue({
 //     "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) {
 //     case "PUT":
@@ -80,6 +173,9 @@ var app = new Vue({
 //     break;
 // }
 
+<<<<<<< HEAD
+>>>>>>> master
+=======
 // const res = await fetch(fullurl, options);
 // return await res.json();
 // };
@@ -113,4 +209,5 @@ var app = new Vue({
 //             await this.mountFunc()
 //             console.log(this.teachers)
 //         }
-//     });
+//     });
+>>>>>>> b5fe990a18b258e28401117b0be0a70e1a10db12

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

@@ -0,0 +1,39 @@
+// <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.");
+        }
+    };
+// </script>

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

@@ -23,11 +23,21 @@ switch(method) {
 const res = await fetch(fullurl, options);
 return await res.json();
 };
+<<<<<<< HEAD
+<<<<<<< HEAD
 var app = new Vue({
+=======
+var vueApp = new Vue({
+>>>>>>> master
+=======
+var app = new Vue({
+>>>>>>> b5fe990a18b258e28401117b0be0a70e1a10db12
         el: '#app',
         delimiters: ['${', '}'],
         data: {
             specialties:[], 
+<<<<<<< HEAD
+<<<<<<< HEAD
          },
         methods: {
             showSpecialties() {
@@ -37,8 +47,91 @@ var app = new Vue({
         		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() {
         	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();
 };
 
+<<<<<<< HEAD
+<<<<<<< HEAD
+=======
+>>>>>>> b5fe990a18b258e28401117b0be0a70e1a10db12
 // addTeacher() =>{
 //     let surname = document.querySelector('.surname').value
 //     let name = document.querySelector('.name').value
@@ -35,6 +39,11 @@ return await res.json();
 
 
 
+<<<<<<< HEAD
+=======
+>>>>>>> master
+=======
+>>>>>>> b5fe990a18b258e28401117b0be0a70e1a10db12
 var vueApp = new Vue({
         el: '#app',
         delimiters: ['${', '}'],
@@ -54,9 +63,18 @@ var vueApp = new Vue({
             async getClassrooms(){
                 classrooms = await requestFunc("/classroom", "GET")
                 for(let i =0; i < classrooms.length; i++) {
+<<<<<<< HEAD
+<<<<<<< HEAD
 
                     //this.classrooms.push(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]);
                 }
             },